FileDocCategorySizeDatePackage
SmbComTransaction.javaAPI DocJCIFS 1.3.17 API10988Tue Oct 18 15:26:24 BST 2011jcifs.smb

SmbComTransaction

public abstract class SmbComTransaction extends ServerMessageBlock implements Enumeration

Fields Summary
private static final int
DEFAULT_MAX_DATA_COUNT
private static final int
PRIMARY_SETUP_OFFSET
private static final int
SECONDARY_PARAMETER_OFFSET
private static final int
DISCONNECT_TID
private static final int
ONE_WAY_TRANSACTION
private static final int
PADDING_SIZE
private int
flags
private int
fid
private int
pad
private int
pad1
private boolean
hasMore
private boolean
isPrimary
private int
bufParameterOffset
private int
bufDataOffset
static final int
TRANSACTION_BUF_SIZE
static final byte
TRANS2_FIND_FIRST2
static final byte
TRANS2_FIND_NEXT2
static final byte
TRANS2_QUERY_FS_INFORMATION
static final byte
TRANS2_QUERY_PATH_INFORMATION
static final byte
TRANS2_GET_DFS_REFERRAL
static final byte
TRANS2_SET_FILE_INFORMATION
static final int
NET_SHARE_ENUM
static final int
NET_SERVER_ENUM2
static final int
NET_SERVER_ENUM3
static final byte
TRANS_PEEK_NAMED_PIPE
static final byte
TRANS_WAIT_NAMED_PIPE
static final byte
TRANS_CALL_NAMED_PIPE
static final byte
TRANS_TRANSACT_NAMED_PIPE
protected int
primarySetupOffset
protected int
secondaryParameterOffset
protected int
parameterCount
protected int
parameterOffset
protected int
parameterDisplacement
protected int
dataCount
protected int
dataOffset
protected int
dataDisplacement
int
totalParameterCount
int
totalDataCount
int
maxParameterCount
int
maxDataCount
byte
maxSetupCount
int
timeout
int
setupCount
byte
subCommand
String
name
int
maxBufferSize
byte[]
txn_buf
Constructors Summary
SmbComTransaction()


     
        maxParameterCount = 1024;
        primarySetupOffset = PRIMARY_SETUP_OFFSET;
        secondaryParameterOffset = SECONDARY_PARAMETER_OFFSET;
    
Methods Summary
public booleanhasMoreElements()

        return hasMore;
    
public java.lang.ObjectnextElement()

        if( isPrimary ) {
            isPrimary = false;

            parameterOffset = primarySetupOffset + ( setupCount * 2 ) + 2;
            if (command != SMB_COM_NT_TRANSACT) {
                if( command == SMB_COM_TRANSACTION && isResponse() == false ) {
                    parameterOffset += stringWireLength( name, parameterOffset );
                }
            } else if (command == SMB_COM_NT_TRANSACT) {
                parameterOffset += 2;
            }
            pad = parameterOffset % PADDING_SIZE;
            pad = pad == 0 ? 0 : PADDING_SIZE - pad;
            parameterOffset += pad;

            totalParameterCount = writeParametersWireFormat( txn_buf, bufParameterOffset );
            bufDataOffset = totalParameterCount; // data comes right after data

            int available = maxBufferSize - parameterOffset;
            parameterCount = Math.min( totalParameterCount, available );
            available -= parameterCount;

            dataOffset = parameterOffset + parameterCount;
            pad1 = dataOffset % PADDING_SIZE;
            pad1 = pad1 == 0 ? 0 : PADDING_SIZE - pad1;
            dataOffset += pad1;

            totalDataCount = writeDataWireFormat( txn_buf, bufDataOffset );

            dataCount = Math.min( totalDataCount, available );
        } else {
            if (command != SMB_COM_NT_TRANSACT) {
                command = SMB_COM_TRANSACTION_SECONDARY;
            } else {
                command = SMB_COM_NT_TRANSACT_SECONDARY;
            }
            // totalParameterCount and totalDataCount are set ok from primary

            parameterOffset = SECONDARY_PARAMETER_OFFSET;
            if(( totalParameterCount - parameterDisplacement ) > 0 ) {
                pad = parameterOffset % PADDING_SIZE;
                pad = pad == 0 ? 0 : PADDING_SIZE - pad;
                parameterOffset += pad;
            }

            // caclulate parameterDisplacement before calculating new parameterCount
            parameterDisplacement += parameterCount;

            int available = maxBufferSize - parameterOffset - pad;
            parameterCount = Math.min( totalParameterCount - parameterDisplacement, available);
            available -= parameterCount;

            dataOffset = parameterOffset + parameterCount;
            pad1 = dataOffset % PADDING_SIZE;
            pad1 = pad1 == 0 ? 0 : PADDING_SIZE - pad1;
            dataOffset += pad1;

            dataDisplacement += dataCount;

            available -= pad1;
            dataCount = Math.min( totalDataCount - dataDisplacement, available );
        }
        if(( parameterDisplacement + parameterCount ) >= totalParameterCount &&
                    ( dataDisplacement + dataCount ) >= totalDataCount ) {
            hasMore = false;
        }
        return this;
    
intreadBytesWireFormat(byte[] buffer, int bufferIndex)

        return 0;
    
abstract intreadDataWireFormat(byte[] buffer, int bufferIndex, int len)

intreadParameterWordsWireFormat(byte[] buffer, int bufferIndex)

        return 0;
    
abstract intreadParametersWireFormat(byte[] buffer, int bufferIndex, int len)

abstract intreadSetupWireFormat(byte[] buffer, int bufferIndex, int len)

voidreset()

        super.reset();
        isPrimary = hasMore = true; 
    
voidreset(int key, java.lang.String lastName)

        reset();
    
public java.lang.StringtoString()

        return new String( super.toString() +
            ",totalParameterCount=" + totalParameterCount +
            ",totalDataCount=" + totalDataCount +
            ",maxParameterCount=" + maxParameterCount +
            ",maxDataCount=" + maxDataCount +
            ",maxSetupCount=" + (int)maxSetupCount +
            ",flags=0x" + Hexdump.toHexString( flags, 2 ) +
            ",timeout=" + timeout +
            ",parameterCount=" + parameterCount +
            ",parameterOffset=" + parameterOffset +
            ",parameterDisplacement=" + parameterDisplacement +
            ",dataCount=" + dataCount +
            ",dataOffset=" + dataOffset +
            ",dataDisplacement=" + dataDisplacement +
            ",setupCount=" + setupCount +
            ",pad=" + pad +
            ",pad1=" + pad1 );
    
intwriteBytesWireFormat(byte[] dst, int dstIndex)

        int start = dstIndex;
        int p = pad;

        if( command == SMB_COM_TRANSACTION && isResponse() == false ) {
            dstIndex += writeString( name, dst, dstIndex );
        }

        if( parameterCount > 0 ) {
            while( p-- > 0 ) {
                dst[dstIndex++] = (byte)0x00;       // Pad
            }

            System.arraycopy( txn_buf, bufParameterOffset, dst, dstIndex, parameterCount );
            dstIndex += parameterCount;
        }

        if( dataCount > 0 ) {
            p = pad1;
            while( p-- > 0 ) {
                dst[dstIndex++] = (byte)0x00;       // Pad1
            }
            System.arraycopy( txn_buf, bufDataOffset, dst, dstIndex, dataCount );
            bufDataOffset += dataCount;
            dstIndex += dataCount;
        }

        return dstIndex - start;
    
abstract intwriteDataWireFormat(byte[] dst, int dstIndex)

intwriteParameterWordsWireFormat(byte[] dst, int dstIndex)

        int start = dstIndex;

        writeInt2( totalParameterCount, dst, dstIndex );
        dstIndex += 2;
        writeInt2( totalDataCount, dst, dstIndex );
        dstIndex += 2;
        if( command != SMB_COM_TRANSACTION_SECONDARY ) {
            writeInt2( maxParameterCount, dst, dstIndex );
            dstIndex += 2;
            writeInt2( maxDataCount, dst, dstIndex );
            dstIndex += 2;
            dst[dstIndex++] = maxSetupCount;
            dst[dstIndex++] = (byte)0x00;           // Reserved1
            writeInt2( flags, dst, dstIndex );
            dstIndex += 2;
            writeInt4( timeout, dst, dstIndex );
            dstIndex += 4;
            dst[dstIndex++] = (byte)0x00;           // Reserved2
            dst[dstIndex++] = (byte)0x00;
        }
        writeInt2( parameterCount, dst, dstIndex );
        dstIndex += 2;
//        writeInt2(( parameterCount == 0 ? 0 : parameterOffset ), dst, dstIndex );
        writeInt2(parameterOffset, dst, dstIndex );
        dstIndex += 2;
        if( command == SMB_COM_TRANSACTION_SECONDARY ) {
            writeInt2( parameterDisplacement, dst, dstIndex );
            dstIndex += 2;
        }
        writeInt2( dataCount, dst, dstIndex );
        dstIndex += 2;
        writeInt2(( dataCount == 0 ? 0 : dataOffset ), dst, dstIndex );
        dstIndex += 2;
        if( command == SMB_COM_TRANSACTION_SECONDARY ) {
            writeInt2( dataDisplacement, dst, dstIndex );
            dstIndex += 2;
        } else {
            dst[dstIndex++] = (byte)setupCount;
            dst[dstIndex++] = (byte)0x00;           // Reserved3
            dstIndex += writeSetupWireFormat( dst, dstIndex );
        }

        return dstIndex - start;
    
abstract intwriteParametersWireFormat(byte[] dst, int dstIndex)

abstract intwriteSetupWireFormat(byte[] dst, int dstIndex)