public class SMBPacket extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ANDXCOMMAND |
static int |
ANDXRESERVED |
static int |
COMMAND |
static int |
DEFAULT_BUFSIZE |
static int |
ERROR |
static int |
ERRORCLASS |
static int |
ERRORCODE |
static int |
FLAGS |
static int |
FLAGS2 |
static int |
FLG_CANONICAL |
static int |
FLG_CASELESS |
static int |
FLG_NOTIFY |
static int |
FLG_OPLOCK |
static int |
FLG_RESPONSE |
static int |
FLG_SUBDIALECT |
static int |
FLG2_DFSRESOLVE |
static int |
FLG2_EXTENDEDATTRIB |
static int |
FLG2_EXTENDNEGOTIATE |
static int |
FLG2_LONGERRORCODE |
static int |
FLG2_LONGFILENAMES |
static int |
FLG2_LONGNAMESUSED |
static int |
FLG2_READIFEXE |
static int |
FLG2_SECURITYSIGS |
static int |
FLG2_UNICODE |
protected int |
m_endpos |
protected int |
m_pos |
static int |
MID |
static int |
MIN_RXLEN |
static int |
PARAMWORDS |
static int |
PID |
static int |
PIDHIGH |
static int |
RAW_READ |
static int |
RAW_WRITE |
static int |
SEC_ENCRYPT |
static int |
SEC_USER |
static int |
SEQNO |
static int |
SID |
static int |
SIGNATURE |
static int |
TID |
static int |
TRANS_HEADERLEN |
static int |
UID |
static int |
WORDCNT |
Constructor and Description |
---|
SMBPacket()
Default constructor
|
SMBPacket(byte[] buf)
Construct an SMB packet using the specified packet buffer.
|
SMBPacket(int siz)
Construct an SMB packet of the specified size.
|
SMBPacket(SMBPacket pkt)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
void |
alignBytePointer()
Align the byte area pointer on an int (32bit) boundary
|
void |
clearBytes()
Clear the data byte count
|
void |
DumpPacket()
Dump the SMB packet to the debug stream
|
boolean |
equalsError(int errClass,
int errCode)
Check if the error class/code match the specified error/class
|
int |
getAndXCommand()
Get the secondary command code
|
byte[] |
getBuffer()
Return the byte array used for the SMB packet
|
int |
getBufferLength()
Return the total buffer size available to the SMB request
|
int |
getByteCount()
Get the data byte count for the SMB packet
|
int |
getByteOffset()
Get the data byte area offset within the SMB packet
|
int |
getCommand()
Get the SMB command
|
int |
getErrorClass()
Get the SMB error class
|
int |
getErrorCode()
Get the SMB error code
|
int |
getFlags()
Get the SMB flags value.
|
int |
getFlags2()
Get the SMB flags2 value.
|
int |
getLength()
Calculate the total used packet length.
|
int |
getLongErrorCode()
Get the long SMB error code
|
int |
getMultiplexId()
Get the multiplex identifier.
|
int |
getParameter(int idx)
Get a parameter word from the SMB packet.
|
int |
getParameterCount()
Get the parameter count
|
int |
getParameterLong(int idx)
Get the specified parameter words, as an int value.
|
int |
getPosition()
Return the current byte area buffer position
|
int |
getProcessId()
Get the process indentifier (PID)
|
int |
getTreeId()
Get the tree identifier (TID)
|
int |
getUserId()
Get the user identifier (UID)
|
boolean |
hasLongErrorCode()
Determine if normal or long error codes have been returned
|
boolean |
hasMoreData()
Check if there is more data in the byte area
|
boolean |
isCaseless()
Check if the packet is using caseless filenames
|
boolean |
isLongErrorCode()
Check if long error codes are being used
|
boolean |
isLongFileNames()
Check if long file names are being used
|
boolean |
isResponse()
Determine if this packet is an SMB response, or command packet
|
boolean |
isUnicode()
Check if the packet contains ASCII or Unicode strings
|
boolean |
isValidResponse()
Check if the response packet is valid, ie.
|
void |
packByte(byte val)
Pack a byte (8 bit) value into the byte area
|
void |
packByte(int val)
Pack a byte (8 bit) value into the byte area
|
void |
packBytes(byte[] byts,
int len)
Pack the specified bytes into the byte area
|
void |
packInt(int val)
Pack a 32 bit integer value into the byte area
|
void |
packLong(long val)
Pack a long integer (64 bit) value into the byte area
|
void |
packString(String str,
boolean uni)
Pack a string using either ASCII or Unicode into the byte area
|
void |
packWord(int val)
Pack a word (16 bit) value into the byte area
|
void |
resetBytePointer()
Reset the byte/parameter pointer area for packing/unpacking data items from the packet
|
void |
resetBytePointerAlign()
Reset the byte/parameter pointer area for packing/unpacking data items from the packet, and
align the buffer on an int (32bit) boundary
|
void |
resetParameterPointer()
Reset the byte/parameter pointer area for packing/unpacking paramaters from the packet
|
void |
setAndXCommand(int cmd)
Set the secondary SMB command
|
void |
setByteCount()
Set the data byte count for this SMB packet
|
void |
setByteCount(int cnt)
Set the data byte count for this SMB packet
|
void |
setBytePointer(int off,
int len)
Set the unpack pointer to the specified offset, for AndX processing
|
void |
setBytes(byte[] byts)
Set the data byte area in the SMB packet
|
void |
setCommand(int cmd)
Set the SMB command
|
void |
setErrorClass(int cl)
Set the SMB error class.
|
void |
setErrorCode(int sts)
Set the SMB error code
|
void |
setFlags(int flg)
Set the SMB flags value.
|
void |
setFlags2(int flg)
Set the SMB flags2 value.
|
void |
setMultiplexId(int mid)
Set the multiplex identifier.
|
void |
setParameter(int idx,
int val)
Set the specified parameter word.
|
void |
setParameterCount(int cnt)
Set the parameter count
|
void |
setParameterLong(int idx,
int val)
Set the specified parameter words.
|
void |
setProcessId(int pid)
Set the process identifier value (PID).
|
void |
setSeqNo(int seq)
Set the packet sequence number, for connectionless commands.
|
void |
setSID(int sid)
Set the session id.
|
void |
setTreeId(int tid)
Set the tree identifier (TID)
|
void |
setUserId(int uid)
Set the user identifier (UID)
|
void |
skipBytes(int cnt)
Skip a number of bytes in the parameter/byte area
|
int |
unpackByte()
Unpack a byte value from the byte area
|
byte[] |
unpackBytes(int len)
Unpack a block of bytes from the byte area
|
int |
unpackInt()
Unpack an integer (32 bit) value from the byte/parameter area
|
long |
unpackLong()
Unpack a long integer (64 bit) value from the byte area
|
String |
unpackString(boolean uni)
Unpack a string from the byte area
|
String |
unpackString(int len,
boolean uni)
Unpack a string from the byte area
|
int |
unpackWord()
Unpack a word (16 bit) value from the byte area
|
public static final int SIGNATURE
public static final int COMMAND
public static final int ERRORCODE
public static final int ERRORCLASS
public static final int ERROR
public static final int FLAGS
public static final int FLAGS2
public static final int PIDHIGH
public static final int SID
public static final int SEQNO
public static final int TID
public static final int PID
public static final int UID
public static final int MID
public static final int WORDCNT
public static final int ANDXCOMMAND
public static final int ANDXRESERVED
public static final int PARAMWORDS
public static final int TRANS_HEADERLEN
public static final int MIN_RXLEN
public static final int DEFAULT_BUFSIZE
public static final int FLG_SUBDIALECT
public static final int FLG_CASELESS
public static final int FLG_CANONICAL
public static final int FLG_OPLOCK
public static final int FLG_NOTIFY
public static final int FLG_RESPONSE
public static final int FLG2_LONGFILENAMES
public static final int FLG2_EXTENDEDATTRIB
public static final int FLG2_SECURITYSIGS
public static final int FLG2_LONGNAMESUSED
public static final int FLG2_EXTENDNEGOTIATE
public static final int FLG2_DFSRESOLVE
public static final int FLG2_READIFEXE
public static final int FLG2_LONGERRORCODE
public static final int FLG2_UNICODE
public static final int SEC_USER
public static final int SEC_ENCRYPT
public static final int RAW_READ
public static final int RAW_WRITE
protected int m_pos
protected int m_endpos
public SMBPacket()
public SMBPacket(byte[] buf)
buf
- SMB packet buffer.public SMBPacket(int siz)
siz
- Size of SMB packet buffer to allocate.public SMBPacket(SMBPacket pkt)
pkt
- SMBPacketpublic final void clearBytes()
public final void DumpPacket()
public final boolean equalsError(int errClass, int errCode)
errClass
- interrCode
- intpublic final int getAndXCommand()
public final byte[] getBuffer()
public final int getBufferLength()
public final int getByteCount()
public final int getByteOffset()
public final int getCommand()
public final boolean hasLongErrorCode()
public final boolean isUnicode()
public final boolean isCaseless()
public final boolean isLongFileNames()
public final boolean isLongErrorCode()
public final int getErrorClass()
public final int getErrorCode()
public final int getFlags()
public final int getFlags2()
public final int getLength()
public final int getLongErrorCode()
public final int getMultiplexId()
public final int getParameter(int idx) throws IndexOutOfBoundsException
idx
- Parameter index (zero based).IndexOutOfBoundsException
- If the parameter index is out of range.public final int getParameterLong(int idx)
idx
- Parameter index (zero based).public final int getParameterCount()
public final int getProcessId()
public final int getTreeId()
public final int getUserId()
public final boolean isResponse()
public final boolean isValidResponse()
public final void packByte(byte val)
val
- bytepublic final void packByte(int val)
val
- intpublic final void packBytes(byte[] byts, int len)
byts
- byte[]len
- intpublic final void packString(String str, boolean uni)
str
- Stringuni
- booleanpublic final void packWord(int val)
val
- intpublic final void packInt(int val)
val
- intpublic final void packLong(long val)
val
- longpublic final int getPosition()
public final int unpackByte()
public final byte[] unpackBytes(int len)
len
- intpublic final int unpackWord()
public final int unpackInt()
public final long unpackLong()
public final String unpackString(boolean uni)
uni
- booleanpublic final String unpackString(int len, boolean uni)
len
- intuni
- booleanpublic final boolean hasMoreData()
public final void setAndXCommand(int cmd)
cmd
- Secondary SMB command code.public final void setByteCount(int cnt)
cnt
- Data byte count.public final void setByteCount()
public final void setBytes(byte[] byts)
byts
- Byte array containing the data to be copied to the SMB packet.public final void setCommand(int cmd)
cmd
- SMB command codepublic final void setErrorClass(int cl)
cl
- SMB error class.public final void setErrorCode(int sts)
sts
- SMB error code.public final void setFlags(int flg)
flg
- SMB flags value.public final void setFlags2(int flg)
flg
- SMB flags2 value.public final void setMultiplexId(int mid)
mid
- Multiplex identifierpublic final void setParameter(int idx, int val)
idx
- Parameter index (zero based).val
- Parameter value.public final void setParameterLong(int idx, int val)
idx
- Parameter index (zero based).val
- Parameter value.public final void setParameterCount(int cnt)
cnt
- Parameter word count.public final void setProcessId(int pid)
pid
- Process identifier value.public final void setSeqNo(int seq)
seq
- Sequence number.public final void setSID(int sid)
sid
- Session id.public final void setTreeId(int tid)
tid
- Tree identifier value.public final void setUserId(int uid)
uid
- User identifier value.public final void alignBytePointer()
public final void resetBytePointer()
public final void resetBytePointerAlign()
public final void resetParameterPointer()
public final void setBytePointer(int off, int len)
off
- intlen
- intpublic final void skipBytes(int cnt)
cnt
- intCopyright © 2005–2018 Alfresco Software. All rights reserved.