Module jcifs

Class SmbComTransaction

java.lang.Object
org.codelibs.jcifs.smb.internal.smb1.ServerMessageBlock
org.codelibs.jcifs.smb.internal.smb1.trans.SmbComTransaction
All Implemented Interfaces:
Enumeration<SmbComTransaction>, CommonServerMessageBlock, CommonServerMessageBlockRequest, CommonServerMessageBlockResponse, RequestWithPath, Message, Request, Response
Direct Known Subclasses:
NetServerEnum2, NetShareEnum, SmbComNtTransaction, Trans2FindFirst2, Trans2FindNext2, Trans2GetDfsReferral, Trans2QueryFSInformation, Trans2QueryPathInformation, Trans2SetFileInformation, TransCallNamedPipe, TransPeekNamedPipe, TransTransactNamedPipe, TransWaitNamedPipe

public abstract class SmbComTransaction extends ServerMessageBlock implements Enumeration<SmbComTransaction>
Base class for SMB1 transaction request messages. This abstract class provides the foundation for all SMB1 transaction commands, handling parameter and data buffer encoding, multi-part transactions, and setup word management.
  • Field Details

    • TRANS2_FIND_FIRST2

      public static final byte TRANS2_FIND_FIRST2
      SMB TRANS2 subcommand for finding first matching files
      See Also:
    • TRANS2_FIND_NEXT2

      public static final byte TRANS2_FIND_NEXT2
      SMB TRANS2 subcommand for finding next matching files
      See Also:
    • TRANS2_QUERY_FS_INFORMATION

      public static final byte TRANS2_QUERY_FS_INFORMATION
      SMB TRANS2 subcommand for querying file system information
      See Also:
    • TRANS2_QUERY_PATH_INFORMATION

      public static final byte TRANS2_QUERY_PATH_INFORMATION
      SMB TRANS2 subcommand for querying path information
      See Also:
    • TRANS2_GET_DFS_REFERRAL

      public static final byte TRANS2_GET_DFS_REFERRAL
      SMB TRANS2 subcommand for getting DFS referrals
      See Also:
    • TRANS2_QUERY_FILE_INFORMATION

      public static final byte TRANS2_QUERY_FILE_INFORMATION
      SMB TRANS2 subcommand for querying file information
      See Also:
    • TRANS2_SET_FILE_INFORMATION

      public static final byte TRANS2_SET_FILE_INFORMATION
      SMB TRANS2 subcommand for setting file information
      See Also:
    • NET_SHARE_ENUM

      public static final byte NET_SHARE_ENUM
      Network share enumeration subcommand
      See Also:
    • NET_SERVER_ENUM2

      public static final byte NET_SERVER_ENUM2
      Network server enumeration subcommand version 2
      See Also:
    • NET_SERVER_ENUM3

      public static final byte NET_SERVER_ENUM3
      Network server enumeration subcommand version 3
      See Also:
    • TRANS_PEEK_NAMED_PIPE

      public static final byte TRANS_PEEK_NAMED_PIPE
      Transaction subcommand for peeking data from a named pipe
      See Also:
    • TRANS_WAIT_NAMED_PIPE

      public static final byte TRANS_WAIT_NAMED_PIPE
      Transaction subcommand for waiting on a named pipe
      See Also:
    • TRANS_CALL_NAMED_PIPE

      public static final byte TRANS_CALL_NAMED_PIPE
      Transaction subcommand for calling a named pipe
      See Also:
    • TRANS_TRANSACT_NAMED_PIPE

      public static final byte TRANS_TRANSACT_NAMED_PIPE
      Transaction subcommand for transacting with a named pipe
      See Also:
    • primarySetupOffset

      protected int primarySetupOffset
      Offset to the setup words in the primary request
    • secondaryParameterOffset

      protected int secondaryParameterOffset
      Offset to the parameters in secondary requests
    • parameterCount

      protected int parameterCount
      Number of parameter bytes being sent in this request
    • parameterOffset

      protected int parameterOffset
      Offset from the start of the SMB header to the parameter bytes
    • parameterDisplacement

      protected int parameterDisplacement
      Displacement of these parameter bytes from the start of the total parameter block
    • dataCount

      protected int dataCount
      Number of data bytes being sent in this request
    • dataOffset

      protected int dataOffset
      Offset from the start of the SMB header to the data bytes
    • dataDisplacement

      protected int dataDisplacement
      Displacement of these data bytes from the start of the total data block
    • totalParameterCount

      protected int totalParameterCount
      Total number of parameter bytes to be sent
    • totalDataCount

      protected int totalDataCount
      Total number of data bytes to be sent
    • maxParameterCount

      protected int maxParameterCount
      Maximum number of parameter bytes the server should return
    • maxDataCount

      protected int maxDataCount
      Maximum number of data bytes the server should return
    • maxSetupCount

      protected byte maxSetupCount
      Maximum number of setup words the server should return
    • timeout

      protected int timeout
      Timeout in milliseconds to wait for the transaction to complete
    • setupCount

      protected int setupCount
      Number of setup words in this request
    • name

      protected String name
      The transaction name for named pipe transactions
    • maxBufferSize

      protected int maxBufferSize
      Maximum buffer size set in SmbTransport.sendTransaction() before nextElement called
  • Constructor Details

    • SmbComTransaction

      protected SmbComTransaction(Configuration config, byte command, byte subCommand)
      Constructs a transaction request.
      Parameters:
      config - the configuration to use
      command - the SMB command code
      subCommand - the transaction subcommand code
  • Method Details

    • setMaxBufferSize

      public final void setMaxBufferSize(int maxBufferSize)
      Sets the maximum buffer size for this transaction
      Parameters:
      maxBufferSize - the maxBufferSize to set
    • setMaxDataCount

      public final void setMaxDataCount(int maxDataCount)
      Sets the maximum data count for this transaction
      Parameters:
      maxDataCount - the maxDataCount to set
    • setBuffer

      public void setBuffer(byte[] buffer)
      Sets the transaction buffer
      Parameters:
      buffer - the transaction buffer to use
    • releaseBuffer

      public byte[] releaseBuffer()
      Releases and returns the transaction buffer
      Returns:
      the txn_buf
    • getSubCommand

      public final byte getSubCommand()
      Gets the transaction subcommand
      Returns:
      the subCommand
    • setSubCommand

      public final void setSubCommand(byte subCommand)
      Sets the transaction subcommand
      Parameters:
      subCommand - the subCommand to set
    • reset

      public void reset()
      Description copied from interface: CommonServerMessageBlock
      Resets this message to its initial state.
      Specified by:
      reset in interface CommonServerMessageBlock
      Specified by:
      reset in interface Response
      Overrides:
      reset in class ServerMessageBlock
    • reset

      protected void reset(int key, String lastName)
      Resets the transaction state with key and last name
      Parameters:
      key - the key to use for reset
      lastName - the last name for the transaction
    • hasMoreElements

      public boolean hasMoreElements()
      Specified by:
      hasMoreElements in interface Enumeration<SmbComTransaction>
    • nextElement

      public SmbComTransaction nextElement()
      Specified by:
      nextElement in interface Enumeration<SmbComTransaction>
    • pad

      protected int pad(int offset)
      Calculates padding needed for the given offset
      Parameters:
      offset - the current offset
      Returns:
      padding size in bytes
    • getPadding

      public int getPadding()
      Gets the padding size for alignment
      Returns:
      padding size
    • writeParameterWordsWireFormat

      protected int writeParameterWordsWireFormat(byte[] dst, int dstIndex)
      Description copied from class: ServerMessageBlock
      Writes the parameter words portion of the SMB message to the wire format.
      Specified by:
      writeParameterWordsWireFormat in class ServerMessageBlock
      Parameters:
      dst - the destination buffer
      dstIndex - the starting offset in the buffer
      Returns:
      the number of bytes written
    • writeBytesWireFormat

      protected int writeBytesWireFormat(byte[] dst, int dstIndex)
      Description copied from class: ServerMessageBlock
      Writes the data bytes portion of the SMB message to the wire format.
      Specified by:
      writeBytesWireFormat in class ServerMessageBlock
      Parameters:
      dst - the destination buffer
      dstIndex - the starting offset in the buffer
      Returns:
      the number of bytes written
    • readParameterWordsWireFormat

      protected int readParameterWordsWireFormat(byte[] buffer, int bufferIndex)
      Description copied from class: ServerMessageBlock
      Reads the parameter words portion of the SMB message from the wire format.
      Specified by:
      readParameterWordsWireFormat in class ServerMessageBlock
      Parameters:
      buffer - the buffer containing the message data
      bufferIndex - the starting offset in the buffer
      Returns:
      the number of bytes read
    • readBytesWireFormat

      protected int readBytesWireFormat(byte[] buffer, int bufferIndex)
      Description copied from class: ServerMessageBlock
      Reads the data bytes portion of the SMB message from the wire format.
      Specified by:
      readBytesWireFormat in class ServerMessageBlock
      Parameters:
      buffer - the buffer containing the message data
      bufferIndex - the starting offset in the buffer
      Returns:
      the number of bytes read
    • writeSetupWireFormat

      protected abstract int writeSetupWireFormat(byte[] dst, int dstIndex)
      Writes setup data in wire format
      Parameters:
      dst - destination buffer
      dstIndex - starting index in destination buffer
      Returns:
      number of bytes written
    • writeParametersWireFormat

      protected abstract int writeParametersWireFormat(byte[] dst, int dstIndex)
      Writes parameters in wire format
      Parameters:
      dst - destination buffer
      dstIndex - starting index in destination buffer
      Returns:
      number of bytes written
    • writeDataWireFormat

      protected abstract int writeDataWireFormat(byte[] dst, int dstIndex)
      Writes data in wire format
      Parameters:
      dst - destination buffer
      dstIndex - starting index in destination buffer
      Returns:
      number of bytes written
    • readSetupWireFormat

      protected abstract int readSetupWireFormat(byte[] buffer, int bufferIndex, int len)
      Reads setup data from wire format
      Parameters:
      buffer - source buffer
      bufferIndex - starting index in source buffer
      len - length of data to read
      Returns:
      number of bytes read
    • readParametersWireFormat

      protected abstract int readParametersWireFormat(byte[] buffer, int bufferIndex, int len)
      Reads parameters from wire format
      Parameters:
      buffer - source buffer
      bufferIndex - starting index in source buffer
      len - length of data to read
      Returns:
      number of bytes read
    • readDataWireFormat

      protected abstract int readDataWireFormat(byte[] buffer, int bufferIndex, int len)
      Reads data from wire format
      Parameters:
      buffer - source buffer
      bufferIndex - starting index in source buffer
      len - length of data to read
      Returns:
      number of bytes read
    • toString

      public String toString()
      Overrides:
      toString in class ServerMessageBlock