java.lang.Object
org.codelibs.jcifs.smb.internal.smb1.ServerMessageBlock
- All Implemented Interfaces:
CommonServerMessageBlock,CommonServerMessageBlockRequest,CommonServerMessageBlockResponse,RequestWithPath,Message,Request,Response
- Direct Known Subclasses:
AndXServerMessageBlock,SmbComBlankResponse,SmbComClose,SmbComCreateDirectory,SmbComDelete,SmbComDeleteDirectory,SmbComFindClose2,SmbComNegotiate,SmbComNegotiateResponse,SmbComNtCancel,SmbComQueryInformation,SmbComQueryInformationResponse,SmbComRename,SmbComSeek,SmbComSeekResponse,SmbComSetInformation,SmbComSetInformationResponse,SmbComTransaction,SmbComTransactionResponse,SmbComTreeDisconnect,SmbComWrite,SmbComWriteResponse
public abstract class ServerMessageBlock
extends Object
implements CommonServerMessageBlockRequest, CommonServerMessageBlockResponse, RequestWithPath
Base class for all SMB1/CIFS protocol message blocks.
This abstract class provides the fundamental structure and common functionality for SMB1 request
and response messages, including header fields, message encoding/decoding, and wire format handling.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intBatch level for batched requests.protected intCount of data bytes in the SMB message.protected SMB1SigningDigestMessage signing digest for SMB1 security.protected intError code returned by the server.protected intAdditional flags for the SMB message.protected intStarting position of the SMB header in the buffer.protected intTotal length of the SMB message.protected intMultiplex identifier for correlating requests and responses.protected StringPath associated with this SMB message.protected intProcess identifier.static final byteSMB command to check if a directory exists.static final byteSMB command to close a file handle.static final byteSMB command to create a directory.static final byteSMB command to delete a file.static final byteSMB command to delete a directory.static final byteSMB command for echo/ping operations.static final byteSMB command to close a find operation.static final byteSMB command for file locking operations.static final byteSMB command to logoff from a session with extended attributes.static final byteSMB command to move a file.static final byteSMB command to negotiate protocol dialect.static final byteSMB command to cancel an NT operation.static final byteSMB command to create or open a file with NT extended attributes.static final byteSMB command for NT transaction operations.static final byteSMB command for secondary NT transaction operations.static final byteSMB command to open a file with extended attributes.static final byteSMB command to query file information.static final byteSMB command to read from a file with extended attributes.static final byteSMB command to rename a file.static final byteSMB command to seek within a file.static final byteSMB command to setup a session with extended attributes.static final byteSMB command to set file information.static final byteSMB command for transaction operations.static final byteSMB command for secondary transaction operations.static final byteSMB command for extended transaction operations.static final byteSMB command to connect to a tree share with extended attributes.static final byteSMB command to disconnect from a tree share.static final byteSMB command to write data to a file.static final byteSMB command to write to a file with extended attributes.protected intTree identifier for the connected share.protected intUser identifier for the authenticated session.protected intCount of parameter words in the SMB message. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedServerMessageBlock(Configuration config) Creates a new SMB message with default command.protectedServerMessageBlock(Configuration config, byte command) Creates a new SMB message with the specified command.protectedServerMessageBlock(Configuration config, byte command, String path) Creates a new SMB message with the specified command and path. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddFlags2(int fl) Adds flags to the flags2 field using bitwise ORbooleanChecks if chaining is allowed with the next request.final voidUnset received statusCreates a cancel request for this request.intdecode(byte[] buffer, int bufferIndex) Decode message data from the given byte arrayintencode(byte[] dst, int dstIndex) Encodes this message into a byte array.booleanvoiderror()Set error statusvoidSets an exception for this response.final intGets the byte count of this message blockfinal intGets the SMB command.protected final ConfigurationGets the configuration object for this message blockintGets the number of credits this request requires.final SMB1SigningDigestGets the signing digest for this message.Gets the domain name.final intGets the error status code.Gets the exception associated with this response.Gets the expiration time for this response.final bytegetFlags()Gets the SMB message flagsfinal intGets the SMB message flags2 fieldGets the full UNC path.intGets the number of credits granted by the server.final intGets the total length of this message blockfinal longgetMid()Gets the message ID.getNext()Gets the next request in the chain.Gets the next response in the chain.final IntegerGets the custom response timeout for this request.final StringgetPath()Gets the path to the resource.final intgetPid()Gets the process identifierbyte[]Gets the raw payload of the message.Gets the response associated with this message.Gets the server name.intGets the signature sequence numberfinal intgetTid()Gets the tree connection identifierfinal intgetUid()Gets the user identifierinthashCode()Returns a message block that ignores disconnectionbooleanisAsync()Checks if this is an asynchronous response.booleanisCancel()Checks if this is a cancel request.booleanisError()Checks if the response indicates an error.booleanChecks if extended security is enabled for this messagebooleanChecks if Unicode encoding is forced for this messagefinal booleanChecks if the response has been received.booleanChecks if this request should be resolved in DFS.protected booleanChecks if this message is a response.booleanChecks if the request will be handled asynchronously.booleanDetermines whether to retain the message payload.final booleanChecks if Unicode encoding is enabled for this messagebooleanChecks if signature verification failed.voidPrepares this response for the next request.protected abstract intreadBytesWireFormat(byte[] buffer, int bufferIndex) Reads the data bytes portion of the SMB message from the wire format.protected intreadHeaderWireFormat(byte[] buffer, int bufferIndex) Reads the SMB header from the wire format.protected abstract intreadParameterWordsWireFormat(byte[] buffer, int bufferIndex) Reads the parameter words portion of the SMB message from the wire format.readString(byte[] src, int srcIndex) Reads a null-terminated string from the bufferreadString(byte[] src, int srcIndex, int maxLen, boolean unicode) Reads a null-terminated string from the buffer with specified encodingreadString(byte[] src, int srcIndex, int srcEnd, int maxLen, boolean unicode) Reads a null-terminated string from the buffer with bounds checkingprotected intreadStringLength(byte[] src, int srcIndex, int max) Calculates the length of a null-terminated string in the buffer.voidreceived()Set received statusfinal voidremFlags2(int fl) Removes flags from the flags2 field using bitwise AND NOTvoidreset()Resets this message to its initial state.voidIndicate that this message should retain it's raw payloadfinal voidsetCommand(int command) Sets the SMB command.final voidsetDigest(SMBSigningDigest digest) Sets the signing digest for this message.final voidsetErrorCode(int errorCode) Sets the error code for this message blockvoidsetExpiration(Long exp) Sets the expiration time for this response.voidsetExtendedSecurity(boolean extendedSecurity) Sets whether extended security is enabled.final voidsetFlags(byte flags) Sets the SMB message flagsfinal voidsetFlags2(int fl) Sets the SMB message flags2 fieldvoidsetFullUNCPath(String domain, String server, String fullPath) Sets the full UNC path components.final voidsetMid(long mid) Sets the message ID.final voidsetOverrideTimeout(Integer overrideTimeout) Sets the timeout override for this message blockfinal voidSets the path to the resource.final voidsetPid(int pid) Sets the process identifiervoidsetRawPayload(byte[] rawPayload) Sets the raw payload of the message.voidsetRequestCredits(int credits) Sets the number of request credits.voidsetResolveInDfs(boolean resolve) Sets whether to resolve this request path in DFS.final voidsetResponse(CommonServerMessageBlockResponse response) Sets the response for this message.final voidsetSessionId(long sessionId) Sets the session ID.final voidsetSignSeq(int signSeq) Sets the signature sequence numberfinal voidsetTid(int tid) Sets the tree ID.final voidsetUid(int uid) Sets the user ID.final voidsetUseUnicode(boolean useUnicode) Sets whether to use Unicode encoding for this messageintsize()Gets the size of this message.split()Splits this request for processing.intstringWireLength(String str, int offset) Calculates the wire format length of a stringtoString()booleanverifySignature(byte[] buffer, int i, int size) Verifies the signature of this response.protected abstract intwriteBytesWireFormat(byte[] dst, int dstIndex) Writes the data bytes portion of the SMB message to the wire format.protected intwriteHeaderWireFormat(byte[] dst, int dstIndex) Writes the SMB header to the wire format.protected abstract intwriteParameterWordsWireFormat(byte[] dst, int dstIndex) Writes the parameter words portion of the SMB message to the wire format.protected intwriteString(String str, byte[] dst, int dstIndex) Writes a string to the destination buffer using the current encoding.protected intwriteString(String str, byte[] dst, int dstIndex, boolean unicode) Writes a string to the destination buffer with specified encoding.
-
Field Details
-
SMB_COM_CREATE_DIRECTORY
public static final byte SMB_COM_CREATE_DIRECTORYSMB command to create a directory.- See Also:
-
SMB_COM_DELETE_DIRECTORY
public static final byte SMB_COM_DELETE_DIRECTORYSMB command to delete a directory.- See Also:
-
SMB_COM_CLOSE
public static final byte SMB_COM_CLOSESMB command to close a file handle.- See Also:
-
SMB_COM_DELETE
public static final byte SMB_COM_DELETESMB command to delete a file.- See Also:
-
SMB_COM_RENAME
public static final byte SMB_COM_RENAMESMB command to rename a file.- See Also:
-
SMB_COM_QUERY_INFORMATION
public static final byte SMB_COM_QUERY_INFORMATIONSMB command to query file information.- See Also:
-
SMB_COM_SET_INFORMATION
public static final byte SMB_COM_SET_INFORMATIONSMB command to set file information.- See Also:
-
SMB_COM_WRITE
public static final byte SMB_COM_WRITESMB command to write data to a file.- See Also:
-
SMB_COM_CHECK_DIRECTORY
public static final byte SMB_COM_CHECK_DIRECTORYSMB command to check if a directory exists.- See Also:
-
SMB_COM_SEEK
public static final byte SMB_COM_SEEKSMB command to seek within a file.- See Also:
-
SMB_COM_LOCKING_ANDX
public static final byte SMB_COM_LOCKING_ANDXSMB command for file locking operations.- See Also:
-
SMB_COM_TRANSACTION
public static final byte SMB_COM_TRANSACTIONSMB command for transaction operations.- See Also:
-
SMB_COM_TRANSACTION_SECONDARY
public static final byte SMB_COM_TRANSACTION_SECONDARYSMB command for secondary transaction operations.- See Also:
-
SMB_COM_MOVE
public static final byte SMB_COM_MOVESMB command to move a file.- See Also:
-
SMB_COM_ECHO
public static final byte SMB_COM_ECHOSMB command for echo/ping operations.- See Also:
-
SMB_COM_OPEN_ANDX
public static final byte SMB_COM_OPEN_ANDXSMB command to open a file with extended attributes.- See Also:
-
SMB_COM_READ_ANDX
public static final byte SMB_COM_READ_ANDXSMB command to read from a file with extended attributes.- See Also:
-
SMB_COM_WRITE_ANDX
public static final byte SMB_COM_WRITE_ANDXSMB command to write to a file with extended attributes.- See Also:
-
SMB_COM_TRANSACTION2
public static final byte SMB_COM_TRANSACTION2SMB command for extended transaction operations.- See Also:
-
SMB_COM_FIND_CLOSE2
public static final byte SMB_COM_FIND_CLOSE2SMB command to close a find operation.- See Also:
-
SMB_COM_TREE_DISCONNECT
public static final byte SMB_COM_TREE_DISCONNECTSMB command to disconnect from a tree share.- See Also:
-
SMB_COM_NEGOTIATE
public static final byte SMB_COM_NEGOTIATESMB command to negotiate protocol dialect.- See Also:
-
SMB_COM_SESSION_SETUP_ANDX
public static final byte SMB_COM_SESSION_SETUP_ANDXSMB command to setup a session with extended attributes.- See Also:
-
SMB_COM_LOGOFF_ANDX
public static final byte SMB_COM_LOGOFF_ANDXSMB command to logoff from a session with extended attributes.- See Also:
-
SMB_COM_TREE_CONNECT_ANDX
public static final byte SMB_COM_TREE_CONNECT_ANDXSMB command to connect to a tree share with extended attributes.- See Also:
-
SMB_COM_NT_TRANSACT
public static final byte SMB_COM_NT_TRANSACTSMB command for NT transaction operations.- See Also:
-
SMB_COM_NT_CANCEL
public static final byte SMB_COM_NT_CANCELSMB command to cancel an NT operation.- See Also:
-
SMB_COM_NT_TRANSACT_SECONDARY
public static final byte SMB_COM_NT_TRANSACT_SECONDARYSMB command for secondary NT transaction operations.- See Also:
-
SMB_COM_NT_CREATE_ANDX
public static final byte SMB_COM_NT_CREATE_ANDXSMB command to create or open a file with NT extended attributes.- See Also:
-
headerStart
protected int headerStartStarting position of the SMB header in the buffer. -
length
protected int lengthTotal length of the SMB message. -
batchLevel
protected int batchLevelBatch level for batched requests. -
errorCode
protected int errorCodeError code returned by the server. -
flags2
protected int flags2Additional flags for the SMB message. -
pid
protected int pidProcess identifier. -
uid
protected int uidUser identifier for the authenticated session. -
mid
protected int midMultiplex identifier for correlating requests and responses. -
wordCount
protected int wordCountCount of parameter words in the SMB message. -
byteCount
protected int byteCountCount of data bytes in the SMB message. -
tid
protected int tidTree identifier for the connected share. -
path
Path associated with this SMB message. -
digest
Message signing digest for SMB1 security.
-
-
Constructor Details
-
ServerMessageBlock
Creates a new SMB message with default command.- Parameters:
config- the configuration to use
-
ServerMessageBlock
Creates a new SMB message with the specified command.- Parameters:
config- the configuration to usecommand- the SMB command code
-
ServerMessageBlock
Creates a new SMB message with the specified command and path.- Parameters:
config- the configuration to usecommand- the SMB command codepath- the path for this SMB operation
-
-
Method Details
-
size
public int size()Gets the size of this message.- Specified by:
sizein interfaceCommonServerMessageBlockRequest- Returns:
- the size of this message
- See Also:
-
isAsync
public boolean isAsync()Checks if this is an asynchronous response.- Specified by:
isAsyncin interfaceCommonServerMessageBlockResponse- Returns:
- is an async response
- See Also:
-
isResponseAsync
public boolean isResponseAsync()Checks if the request will be handled asynchronously.- Specified by:
isResponseAsyncin interfaceCommonServerMessageBlockRequest- Returns:
- request was handled asynchronously
- See Also:
-
getOverrideTimeout
Gets the custom response timeout for this request.- Specified by:
getOverrideTimeoutin interfaceCommonServerMessageBlockRequest- Returns:
- custom response timeout for this request
- See Also:
-
setOverrideTimeout
Sets the timeout override for this message block- Parameters:
overrideTimeout- the overrideTimeout to set
-
getNext
Gets the next request in the chain.- Specified by:
getNextin interfaceCommonServerMessageBlockRequest- Specified by:
getNextin interfaceRequest- Returns:
- next chained message
- See Also:
-
allowChain
Checks if chaining is allowed with the next request.- Specified by:
allowChainin interfaceCommonServerMessageBlockRequest- Parameters:
next- the next request in the chain- Returns:
- whether to allow chaining
- See Also:
-
split
Splits this request for processing.- Specified by:
splitin interfaceCommonServerMessageBlockRequest- Returns:
- the following message
- See Also:
-
createCancel
Creates a cancel request for this request.- Specified by:
createCancelin interfaceCommonServerMessageBlockRequest- Returns:
- create cancel request
- See Also:
-
getNextResponse
Gets the next response in the chain.- Specified by:
getNextResponsein interfaceCommonServerMessageBlockResponse- Specified by:
getNextResponsein interfaceResponse- Returns:
- the next response
- See Also:
-
prepare
Prepares this response for the next request.- Specified by:
preparein interfaceCommonServerMessageBlockResponse- Parameters:
next- the next request to prepare for- See Also:
-
getCreditCost
public int getCreditCost()Gets the number of credits this request requires.- Specified by:
getCreditCostin interfaceRequest- Returns:
- number of credits this request requires
- See Also:
-
getGrantedCredits
public int getGrantedCredits()Gets the number of credits granted by the server.- Specified by:
getGrantedCreditsin interfaceResponse- Returns:
- number of credits granted by the server
- See Also:
-
setRequestCredits
public void setRequestCredits(int credits) Sets the number of request credits.- Specified by:
setRequestCreditsin interfaceRequest- Parameters:
credits- the number of credits to set- See Also:
-
getCommand
public final int getCommand()Description copied from interface:CommonServerMessageBlockGets the SMB command.- Specified by:
getCommandin interfaceCommonServerMessageBlock- Returns:
- the command
-
setCommand
public final void setCommand(int command) Description copied from interface:CommonServerMessageBlockSets the SMB command.- Specified by:
setCommandin interfaceCommonServerMessageBlock- Parameters:
command- the command to set
-
getByteCount
public final int getByteCount()Gets the byte count of this message block- Returns:
- the byteCount
-
getLength
public final int getLength()Gets the total length of this message block- Returns:
- the length
-
isForceUnicode
public boolean isForceUnicode()Checks if Unicode encoding is forced for this message- Returns:
- the forceUnicode
-
getFlags
public final byte getFlags()Gets the SMB message flags- Returns:
- the flags
-
setFlags
public final void setFlags(byte flags) Sets the SMB message flags- Parameters:
flags- the flags to set
-
getFlags2
public final int getFlags2()Gets the SMB message flags2 field- Returns:
- the flags2
-
setFlags2
public final void setFlags2(int fl) Sets the SMB message flags2 field- Parameters:
fl- the flags2 to set
-
addFlags2
public final void addFlags2(int fl) Adds flags to the flags2 field using bitwise OR- Parameters:
fl- flags to add
-
remFlags2
public final void remFlags2(int fl) Removes flags from the flags2 field using bitwise AND NOT- Parameters:
fl- flags to remove
-
setResolveInDfs
public void setResolveInDfs(boolean resolve) Sets whether to resolve this request path in DFS.- Specified by:
setResolveInDfsin interfaceRequestWithPath- Parameters:
resolve- true to enable DFS resolution- See Also:
-
isResolveInDfs
public boolean isResolveInDfs()Checks if this request should be resolved in DFS.- Specified by:
isResolveInDfsin interfaceRequestWithPath- Returns:
- whether to resolve the request path in DFS
- See Also:
-
getErrorCode
public final int getErrorCode()Description copied from interface:ResponseGets the error status code.- Specified by:
getErrorCodein interfaceResponse- Returns:
- the errorCode
-
setErrorCode
public final void setErrorCode(int errorCode) Sets the error code for this message block- Parameters:
errorCode- the errorCode to set
-
getPath
Description copied from interface:RequestWithPathGets the path to the resource.- Specified by:
getPathin interfaceRequestWithPath- Returns:
- the path
-
getFullUNCPath
Gets the full UNC path.- Specified by:
getFullUNCPathin interfaceRequestWithPath- Returns:
- the full UNC path
- See Also:
-
getDomain
Gets the domain name.- Specified by:
getDomainin interfaceRequestWithPath- Returns:
- the domain name
- See Also:
-
getServer
Gets the server name.- Specified by:
getServerin interfaceRequestWithPath- Returns:
- the server name
- See Also:
-
setFullUNCPath
Sets the full UNC path components.- Specified by:
setFullUNCPathin interfaceRequestWithPath- Parameters:
domain- the domain nameserver- the server namefullPath- the full UNC path- See Also:
-
setPath
Description copied from interface:RequestWithPathSets the path to the resource.- Specified by:
setPathin interfaceRequestWithPath- Parameters:
path- the path to set
-
getDigest
Description copied from interface:CommonServerMessageBlockGets the signing digest for this message.- Specified by:
getDigestin interfaceCommonServerMessageBlock- Returns:
- the digest
-
setDigest
Description copied from interface:CommonServerMessageBlockSets the signing digest for this message.- Specified by:
setDigestin interfaceCommonServerMessageBlock- Parameters:
digest- the digest to set
-
isExtendedSecurity
public boolean isExtendedSecurity()Checks if extended security is enabled for this message- Returns:
- the extendedSecurity
-
setSessionId
public final void setSessionId(long sessionId) Description copied from interface:CommonServerMessageBlockSets the session ID.- Specified by:
setSessionIdin interfaceCommonServerMessageBlock- Parameters:
sessionId- the session ID to set
-
setExtendedSecurity
public void setExtendedSecurity(boolean extendedSecurity) Description copied from interface:CommonServerMessageBlockSets whether extended security is enabled.- Specified by:
setExtendedSecurityin interfaceCommonServerMessageBlock- Parameters:
extendedSecurity- the extendedSecurity to set
-
isUseUnicode
public final boolean isUseUnicode()Checks if Unicode encoding is enabled for this message- Returns:
- the useUnicode
-
setUseUnicode
public final void setUseUnicode(boolean useUnicode) Sets whether to use Unicode encoding for this message- Parameters:
useUnicode- the useUnicode to set
-
isReceived
public final boolean isReceived()Description copied from interface:ResponseChecks if the response has been received.- Specified by:
isReceivedin interfaceResponse- Returns:
- the received
-
clearReceived
public final void clearReceived()Description copied from interface:ResponseUnset received status- Specified by:
clearReceivedin interfaceResponse
-
received
public void received()Set received status -
exception
Sets an exception for this response. -
error
public void error()Set error status -
getResponse
Description copied from interface:CommonServerMessageBlockGets the response associated with this message.- Specified by:
getResponsein interfaceCommonServerMessageBlock- Specified by:
getResponsein interfaceRequest- Returns:
- the response
-
ignoreDisconnect
Returns a message block that ignores disconnection- Returns:
- null
-
setResponse
Description copied from interface:CommonServerMessageBlockSets the response for this message.- Specified by:
setResponsein interfaceCommonServerMessageBlock- Parameters:
response- the response to set
-
isCancel
public boolean isCancel()Checks if this is a cancel request. -
getMid
public final long getMid()Description copied from interface:CommonServerMessageBlockGets the message ID.- Specified by:
getMidin interfaceCommonServerMessageBlock- Specified by:
getMidin interfaceResponse- Returns:
- the mid
-
setMid
public final void setMid(long mid) Description copied from interface:CommonServerMessageBlockSets the message ID.- Specified by:
setMidin interfaceCommonServerMessageBlock- Specified by:
setMidin interfaceResponse- Parameters:
mid- the mid to set
-
getTid
public final int getTid()Gets the tree connection identifier- Returns:
- the tid
-
setTid
public final void setTid(int tid) Description copied from interface:CommonServerMessageBlockRequestSets the tree ID.- Specified by:
setTidin interfaceCommonServerMessageBlockRequest- Parameters:
tid- the tid to set
-
getPid
public final int getPid()Gets the process identifier- Returns:
- the pid
-
setPid
public final void setPid(int pid) Sets the process identifier- Parameters:
pid- the pid to set
-
getUid
public final int getUid()Gets the user identifier- Returns:
- the uid
-
setUid
public final void setUid(int uid) Description copied from interface:CommonServerMessageBlockSets the user ID.- Specified by:
setUidin interfaceCommonServerMessageBlock- Parameters:
uid- the uid to set
-
getSignSeq
public int getSignSeq()Gets the signature sequence number- Returns:
- the signSeq
-
setSignSeq
public final void setSignSeq(int signSeq) Sets the signature sequence number- Parameters:
signSeq- the signSeq to set
-
isVerifyFailed
public boolean isVerifyFailed()Description copied from interface:ResponseChecks if signature verification failed.- Specified by:
isVerifyFailedin interfaceResponse- Returns:
- the verifyFailed
-
getException
Gets the exception associated with this response.- Specified by:
getExceptionin interfaceResponse- Returns:
- an exception linked to an error
- See Also:
-
isError
public boolean isError()Checks if the response indicates an error. -
getRawPayload
public byte[] getRawPayload()Gets the raw payload of the message.- Specified by:
getRawPayloadin interfaceMessage- Returns:
- the raw response message
- See Also:
-
setRawPayload
public void setRawPayload(byte[] rawPayload) Sets the raw payload of the message.- Specified by:
setRawPayloadin interfaceMessage- Parameters:
rawPayload- the raw message payload to set- See Also:
-
isRetainPayload
public boolean isRetainPayload()Determines whether to retain the message payload.- Specified by:
isRetainPayloadin interfaceMessage- Returns:
- whether to retain the message payload
- See Also:
-
retainPayload
public void retainPayload()Indicate that this message should retain it's raw payload- Specified by:
retainPayloadin interfaceMessage- See Also:
-
getExpiration
Gets the expiration time for this response.- Specified by:
getExpirationin interfaceResponse- Returns:
- the message timeout
- See Also:
-
setExpiration
Sets the expiration time for this response.- Specified by:
setExpirationin interfaceResponse- Parameters:
exp- the message timeout to set- See Also:
-
getConfig
Gets the configuration object for this message block- Returns:
- the config
-
reset
public void reset()Description copied from interface:CommonServerMessageBlockResets this message to its initial state.- Specified by:
resetin interfaceCommonServerMessageBlock- Specified by:
resetin interfaceResponse
-
verifySignature
public boolean verifySignature(byte[] buffer, int i, int size) Verifies the signature of this response.- Specified by:
verifySignaturein interfaceResponse- Parameters:
buffer- the buffer containing the signature datai- the starting index in the buffersize- the size of the signature data- Returns:
- whether signature verification is successful
- See Also:
-
writeString
Writes a string to the destination buffer using the current encoding.- Parameters:
str- the string to writedst- the destination bufferdstIndex- the starting offset in the buffer- Returns:
- the number of bytes written
-
writeString
Writes a string to the destination buffer with specified encoding.- Parameters:
str- the string to writedst- the destination bufferdstIndex- the starting offset in the bufferunicode- true to use Unicode encoding, false for OEM encoding- Returns:
- the number of bytes written
-
readString
Reads a null-terminated string from the buffer- Parameters:
src- source buffersrcIndex- starting index in the buffer- Returns:
- read string
-
readString
Reads a null-terminated string from the buffer with specified encoding- Parameters:
src- source buffersrcIndex- starting index in the buffermaxLen- maximum length to readunicode- whether to use Unicode encoding- Returns:
- read string
-
readString
Reads a null-terminated string from the buffer with bounds checking- Parameters:
src- source buffersrcIndex- starting index in the buffersrcEnd- ending index boundarymaxLen- maximum length to readunicode- whether to use Unicode encoding- Returns:
- read string
-
stringWireLength
Calculates the wire format length of a string- Parameters:
str- string to measureoffset- current buffer offset for alignment calculation- Returns:
- string length
-
readStringLength
protected int readStringLength(byte[] src, int srcIndex, int max) Calculates the length of a null-terminated string in the buffer.- Parameters:
src- the source buffersrcIndex- the starting offset in the buffermax- the maximum number of bytes to scan- Returns:
- the length of the string in bytes
-
encode
public int encode(byte[] dst, int dstIndex) Description copied from interface:CommonServerMessageBlockEncodes this message into a byte array.- Specified by:
encodein interfaceCommonServerMessageBlock- Parameters:
dst- the destination byte arraydstIndex- the starting index in the destination array- Returns:
- message length
-
decode
Description copied from interface:CommonServerMessageBlockDecode message data from the given byte array- Specified by:
decodein interfaceCommonServerMessageBlock- Parameters:
buffer- the byte array containing the message databufferIndex- the starting index in the buffer- Returns:
- message length
- Throws:
SMBProtocolDecodingException- if decoding fails
-
writeHeaderWireFormat
protected int writeHeaderWireFormat(byte[] dst, int dstIndex) Writes the SMB header to the wire format.- Parameters:
dst- the destination bufferdstIndex- the starting offset in the buffer- Returns:
- the number of bytes written
-
readHeaderWireFormat
protected int readHeaderWireFormat(byte[] buffer, int bufferIndex) Reads the SMB header from the wire format.- Parameters:
buffer- the buffer containing the message databufferIndex- the starting offset in the buffer- Returns:
- the number of bytes read
-
isResponse
protected boolean isResponse()Checks if this message is a response.- Returns:
- true if this is a response message, false if it's a request
-
writeParameterWordsWireFormat
protected abstract int writeParameterWordsWireFormat(byte[] dst, int dstIndex) Writes the parameter words portion of the SMB message to the wire format.- Parameters:
dst- the destination bufferdstIndex- the starting offset in the buffer- Returns:
- the number of bytes written
-
writeBytesWireFormat
protected abstract int writeBytesWireFormat(byte[] dst, int dstIndex) Writes the data bytes portion of the SMB message to the wire format.- Parameters:
dst- the destination bufferdstIndex- the starting offset in the buffer- Returns:
- the number of bytes written
-
readParameterWordsWireFormat
protected abstract int readParameterWordsWireFormat(byte[] buffer, int bufferIndex) Reads the parameter words portion of the SMB message from the wire format.- Parameters:
buffer- the buffer containing the message databufferIndex- the starting offset in the buffer- Returns:
- the number of bytes read
-
readBytesWireFormat
protected abstract int readBytesWireFormat(byte[] buffer, int bufferIndex) throws SMBProtocolDecodingException Reads the data bytes portion of the SMB message from the wire format.- Parameters:
buffer- the buffer containing the message databufferIndex- the starting offset in the buffer- Returns:
- the number of bytes read
- Throws:
SMBProtocolDecodingException- if the data cannot be decoded
-
hashCode
public int hashCode() -
equals
-
toString
-