public class SMBSrvPacket
extends java.lang.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_EXTENDEDSECURITY |
static int |
FLG2_LONGERRORCODE |
static int |
FLG2_LONGFILENAMES |
static int |
FLG2_READIFEXE |
static int |
FLG2_SECURITYSIGS |
static int |
FLG2_UNICODE |
static int |
HeaderLength |
protected int |
m_endpos |
protected int |
m_pos |
static int |
MID |
static int |
MIN_RXLEN |
static int |
NO_ANDX_CMD |
static int |
PARAMWORDS |
static int |
PID |
static int |
PIDHIGH |
static int |
PROTOCOL_NETBIOS |
static int |
PROTOCOL_TCPIP |
static int |
PROTOCOL_WIN32NETBIOS |
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 |
---|
SMBSrvPacket()
Default constructor
|
SMBSrvPacket(byte[] buf)
Construct an SMB packet using the specified packet buffer.
|
SMBSrvPacket(int siz)
Construct an SMB packet of the specified size.
|
SMBSrvPacket(SMBSrvPacket pkt)
Copy constructor.
|
SMBSrvPacket(SMBSrvPacket pkt,
int len)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
alignBytePointer()
Align the byte area pointer on an int (32bit) boundary
|
static int |
calculateHeaderLength(int numParams)
Calculate the header length for the specified number of parameters
|
boolean |
checkAndXPacketIsValid(int off,
int reqWords,
int reqBytes)
Check the SMB AndX command for the required minimum parameter count and byte count.
|
boolean |
checkPacketIsValid(int reqWords,
int reqBytes)
Check the SMB packet for a valid SMB signature, and the required minimum parameter count and
byte count.
|
boolean |
checkPacketSignature()
Check the SMB packet has a valid SMB signature.
|
void |
clearAssociatedPacket()
Clear the associated packet
|
void |
clearBytes()
Clear the data byte count
|
void |
clearHeader()
Clear the packet header
|
void |
clearLeaseTime()
Clear the lease time
|
void |
DumpPacket()
Dump the SMB packet to the debug stream
|
void |
DumpPacket(boolean dumpAll)
Dump the SMB packet to the debug stream
|
int |
getAndXByteCount(int off)
Get the data byte count for the SMB AndX command.
|
int |
getAndXByteOffset(int off)
Get the AndX data byte area offset within the SMB packet
|
int |
getAndXCommand()
Get the secondary command code
|
int |
getAndXParameter(int off,
int idx)
Get an AndX parameter word from the SMB packet.
|
int |
getAndXParameterCount(int off)
Get the AndX command parameter count.
|
int |
getAndXParameterLong(int off,
int idx)
Get an AndX parameter integer from the SMB packet.
|
SMBSrvPacket |
getAssociatedPacket()
Return the associated packet
|
int |
getAvailableLength()
Return the available buffer space for data bytes
|
int |
getAvailableLength(int len)
Return the available buffer space for data bytes for the specified buffer length
|
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 |
getDeferredCount()
Return the deferred processing count for this packet
|
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 |
getHeaderFlags()
Return the NetBIOS header flags value.
|
int |
getHeaderLength()
Return the NetBIOS header data length value.
|
int |
getHeaderType()
Return the NetBIOS header message type.
|
long |
getLeaseTime()
Return the packet lease time
|
int |
getLength()
Calculate the total used packet length.
|
int |
getLongErrorCode()
Get the long SMB error code
|
int |
getMultiplexId()
Get the multiplex identifier.
|
int |
getPacketLength()
Calculate the total packet length, including header
|
java.lang.String |
getPacketTypeString()
Dump the packet type
|
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 identifier (PID)
|
int |
getProcessIdFull()
Return the 32bit process id value
|
int |
getProcessIdHigh()
Get the process identifier (PID) high bytes, or zero if not used
|
int |
getReceivedLength()
Get the actual received data length.
|
int |
getSID()
Get the session identifier (SID)
|
int |
getTreeId()
Get the tree identifier (TID)
|
int |
getUserId()
Get the user identifier (UID)
|
boolean |
hasAndXCommand()
Determine if there is a secondary command in this packet.
|
boolean |
hasAssociatedPacket()
Check if there is an associated packet
|
boolean |
hasLeaseTime()
Check if the packet has a lease
|
boolean |
hasMoreData()
Check if there is more data in the byte area
|
void |
incrementDeferredCount()
Increment the deferred processing count for this packet
|
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 |
isQueuedForAsyncIO()
Determine if the packet is queued for sending via asynchronous I/O
|
boolean |
isRequestPacket()
Check if this is a request packet
|
boolean |
isResponse()
Determine if this packet is an SMB response, or command packet
|
boolean |
isSMB2()
Check if the packet is an SMB2 request/response
|
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 an integer (32 bit) value into the byte area
|
void |
packLong(long val)
Pack a long integer (64 bit) value into the byte area
|
void |
packString(java.lang.String str,
boolean uni)
Pack a string using either ASCII or Unicode into the byte area
|
void |
packString(java.lang.String str,
boolean uni,
boolean nul)
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 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 |
SendResponseSMB(java.io.DataOutputStream out,
int proto)
Send the SMB response packet.
|
void |
SendResponseSMB(java.io.DataOutputStream out,
int proto,
int len)
Send the SMB response packet.
|
void |
SendSuccessSMB(java.io.DataOutputStream out,
int proto)
Send a success SMB response packet.
|
void |
setAndXByteCount(int off,
int cnt)
Set the AndX data byte count for this SMB packet.
|
void |
setAndXBytes(int off,
byte[] byts)
Set the AndX data byte area in the SMB packet
|
void |
setAndXCommand(int cmd)
Set the secondary SMB command
|
void |
setAndXCommand(int off,
int cmd)
Set the AndX command for an AndX command block.
|
void |
setAndXParameter(int off,
int idx,
int val)
Set the specified AndX parameter word.
|
void |
setAndXParameterCount(int off,
int cnt)
Set the AndX parameter count
|
void |
setAssociatedPacket(SMBSrvPacket smbPkt)
Set the associated packet
|
void |
setBuffer(byte[] buf)
Set the data buffer
|
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 |
setError(boolean longError,
int ntErr,
int errCode,
int errClass)
Set the error class/code.
|
void |
setError(int errCode,
int errClass)
Set the error class and code.
|
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 |
setHeaderFlags(int flg)
Set the NetBIOS packet header flags value.
|
void |
setHeaderLength(int len)
Set the NetBIOS packet data length in the packet header.
|
void |
setHeaderType(int typ)
Set the NetBIOS packet type in the packet header.
|
void |
setLeaseTime(long tmo)
Set the packet lease time
|
void |
setLongErrorCode(int err)
Set the long SMB error code
|
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 |
setPosition(int pos)
Set the pack/unpack position
|
void |
setProcessId(int pid)
Set the process identifier value (PID).
|
void |
setQueuedForAsyncIO(boolean asyncIO)
Set/clear the asynchronous I/O flag
|
void |
setReceivedLength(int len)
Set the actual received data length.
|
void |
setRequestPacket(boolean reqPkt)
Set/clear the request packet flag
|
void |
setSeqNo(int seq)
Set the packet sequence number, for connectionless commands.
|
void |
setSID(int sid)
Set the session id.
|
void |
setSuccessStatus()
Set a success status code
|
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
|
java.lang.String |
toString()
Return the SMB packet details as a string
|
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 area
|
long |
unpackLong()
Unpack a long integer (64 bit) value from the byte area
|
java.lang.String |
unpackString(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 PROTOCOL_NETBIOS
public static final int PROTOCOL_TCPIP
public static final int PROTOCOL_WIN32NETBIOS
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 HeaderLength
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_EXTENDEDSECURITY
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
public static final int NO_ANDX_CMD
protected int m_pos
protected int m_endpos
public SMBSrvPacket()
public SMBSrvPacket(byte[] buf)
buf
- SMB packet buffer.public SMBSrvPacket(int siz)
siz
- Size of SMB packet buffer to allocate.public SMBSrvPacket(SMBSrvPacket pkt)
pkt
- SMB packet buffer.public SMBSrvPacket(SMBSrvPacket pkt, int len)
pkt
- SMB packet buffer.len
- Length of packet to be copiedpublic final boolean checkAndXPacketIsValid(int off, int reqWords, int reqBytes)
off
- Offset to the AndX command within the SMB packet.reqWords
- Minimum number of parameter words expected.reqBytes
- Minimum number of bytes expected.public final boolean checkPacketIsValid(int reqWords, int reqBytes)
reqWords
- Minimum number of parameter words expected.reqBytes
- Minimum number of bytes expected.public final boolean checkPacketSignature()
public final boolean isSMB2()
public final void clearBytes()
public final void DumpPacket()
public final void DumpPacket(boolean dumpAll)
dumpAll
- booleanpublic final int getAndXByteCount(int off)
off
- Offset to the AndX command.public final int getAndXByteOffset(int off)
off
- Offset to the AndX command.public final int getAndXCommand()
public final int getAndXParameter(int off, int idx) throws java.lang.IndexOutOfBoundsException
off
- Offset to the AndX command.idx
- Parameter index (zero based).java.lang.IndexOutOfBoundsException
- If the parameter index is out of range.public final int getAndXParameterLong(int off, int idx) throws java.lang.IndexOutOfBoundsException
off
- Offset to the AndX command.idx
- Parameter index (zero based).java.lang.IndexOutOfBoundsException
- If the parameter index is out of range.public final int getAndXParameterCount(int off)
off
- Offset to the AndX command.public final byte[] getBuffer()
public final int getBufferLength()
public final int getByteCount()
public final int getByteOffset()
public final int getCommand()
public final int getErrorClass()
public final int getErrorCode()
public final int getFlags()
public final int getFlags2()
public final int getHeaderFlags()
public final int getHeaderLength()
public final int getHeaderType()
public final int getLength()
public final int getPacketLength()
public final int getAvailableLength()
public final int getAvailableLength(int len)
len
- intpublic final int getLongErrorCode()
public final int getMultiplexId()
public final java.lang.String getPacketTypeString()
public final int getParameter(int idx) throws java.lang.IndexOutOfBoundsException
idx
- Parameter index (zero based).java.lang.IndexOutOfBoundsException
- If the parameter index is out of range.public final int getParameterCount()
public final int getParameterLong(int idx)
idx
- Parameter index (zero based).public final int getProcessId()
public final int getProcessIdHigh()
public final int getProcessIdFull()
public final int getReceivedLength()
public final int getSID()
public final int getTreeId()
public final int getUserId()
public final boolean hasAndXCommand()
public final boolean isResponse()
public final boolean isValidResponse()
public final boolean isUnicode()
public final boolean isCaseless()
public final boolean isLongFileNames()
public final boolean isLongErrorCode()
public final boolean isRequestPacket()
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(java.lang.String str, boolean uni)
str
- Stringuni
- booleanpublic final void packString(java.lang.String str, boolean uni, boolean nul)
str
- Stringuni
- booleannul
- 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 java.lang.String unpackString(boolean uni)
uni
- booleanpublic final boolean hasMoreData()
public final void SendResponseSMB(java.io.DataOutputStream out, int proto) throws java.io.IOException
out
- Output stream associated with the session socket.proto
- Protocol type, either PROTOCOL_NETBIOS or PROTOCOL_TCPIPjava.io.IOException
- If an I/O error occurs.public final void SendResponseSMB(java.io.DataOutputStream out, int proto, int len) throws java.io.IOException
out
- Output stream associated with the session socket.proto
- Protocol type, either PROTOCOL_NETBIOS or PROTOCOL_TCPIPlen
- Packet lengthjava.io.IOException
- If an I/O error occurs.public final void SendSuccessSMB(java.io.DataOutputStream out, int proto) throws java.io.IOException
out
- Output stream associated with the session socket.proto
- Protocol type, either PROTOCOL_NETBIOS or PROTOCOL_TCPIPjava.io.IOException
- If an I/O error occurs.public final void setAndXByteCount(int off, int cnt)
off
- AndX command offset.cnt
- Data byte count.public final void setAndXBytes(int off, byte[] byts)
off
- Offset to the AndX command.byts
- Byte array containing the data to be copied to the SMB packet.public final void setAndXCommand(int cmd)
cmd
- Secondary SMB command code.public final void setAndXCommand(int off, int cmd)
off
- Offset to the current AndX command.cmd
- Secondary SMB command code.public final void setAndXParameter(int off, int idx, int val)
off
- Offset to the AndX command.idx
- Parameter index (zero based).val
- Parameter value.public final void setAndXParameterCount(int off, int cnt)
off
- Offset to the AndX command.cnt
- Parameter word count.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 setError(int errCode, int errClass)
errCode
- interrClass
- intpublic final void setError(boolean longError, int ntErr, int errCode, int errClass)
longError
- booleanntErr
- interrCode
- interrClass
- intpublic final void setErrorClass(int cl)
cl
- SMB error class.public final void setErrorCode(int sts)
sts
- SMB error code.public final void setLongErrorCode(int err)
err
- Long SMB error code.public final void setSuccessStatus()
public final void setFlags(int flg)
flg
- SMB flags value.public final void setFlags2(int flg)
flg
- SMB flags2 value.public final void setHeaderFlags(int flg)
flg
- intpublic final void setHeaderLength(int len)
len
- intpublic final void setHeaderType(int typ)
typ
- intpublic 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 setParameterCount(int cnt)
cnt
- Parameter word count.public final void setParameterLong(int idx, int val)
idx
- Parameter index (zero based).val
- Parameter value.public final void setPosition(int pos)
pos
- intpublic final void setProcessId(int pid)
pid
- Process identifier value.public final void setReceivedLength(int len)
len
- intpublic 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 resetBytePointer()
public final void setBytePointer(int off, int len)
off
- intlen
- intpublic final void alignBytePointer()
public final void resetBytePointerAlign()
public final void skipBytes(int cnt)
cnt
- intpublic final void setBuffer(byte[] buf)
buf
- byte[]public final boolean hasAssociatedPacket()
public final SMBSrvPacket getAssociatedPacket()
public final void setAssociatedPacket(SMBSrvPacket smbPkt)
smbPkt
- SMBSrvPacketpublic final void clearAssociatedPacket()
public static final int calculateHeaderLength(int numParams)
numParams
- intpublic final boolean isQueuedForAsyncIO()
public final void setQueuedForAsyncIO(boolean asyncIO)
asyncIO
- booleanpublic final void clearHeader()
public final int getDeferredCount()
public final void incrementDeferredCount()
public final void setRequestPacket(boolean reqPkt)
reqPkt
- booleanpublic final boolean hasLeaseTime()
public final long getLeaseTime()
public final void clearLeaseTime()
public final void setLeaseTime(long tmo)
tmo
- longpublic java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.