|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.savarese.vserv.tcpip.IPPacket org.savarese.vserv.tcpip.TCPPacket
TCPPacket extends IPPacket
to handle TCP packets. The TCP
packet structure is described in
RFC 761.
Field Summary | |
static byte |
KIND_EOL
A byte value for TCP options indicating end of option list. |
static byte |
KIND_NOP
A byte value for TCP options indicating no operation. |
static byte |
KIND_SACK
A byte value for TCP options identifying a selective acknowledgement option. |
static int |
MASK_ACK
A mask for extracting the ACK bit from the control header. |
static int |
MASK_FIN
A mask for extracting the FIN bit from the control header. |
static int |
MASK_PSH
A mask for extracting the push bit from the control header. |
static int |
MASK_RST
A mask for extracting the reset bit from the control header. |
static int |
MASK_SYN
A mask for extracting the SYN bit from the control header. |
static int |
MASK_URG
A mask for extracting the urgent bit from the control header. |
static int |
OFFSET_ACK
Offset into the TCP packet of the acknowledgement number header value. |
static int |
OFFSET_CONTROL
Offset into the TCP packet of the control header. |
static int |
OFFSET_DESTINATION_PORT
Offset into the TCP packet of the destination port header value. |
static int |
OFFSET_HEADER_LENGTH
Offset into the TCP packet of the TCP header length. |
static int |
OFFSET_SEQUENCE
Offset into the TCP packet of the sequence number header value. |
static int |
OFFSET_SOURCE_PORT
Offset into the TCP packet of the source port header value. |
static int |
OFFSET_TCP_CHECKSUM
Offset into the TCP packet of the TCP checksum. |
static int |
OFFSET_URG_POINTER
Offset into the TCP packet of the URG pointer. |
static int |
OFFSET_WINDOW_SIZE
Offset into the TCP packet of the window size. |
Fields inherited from class org.savarese.vserv.tcpip.IPPacket |
_data_, LENGTH_DESTINATION_ADDRESS, LENGTH_SOURCE_ADDRESS, OFFSET_DESTINATION_ADDRESS, OFFSET_FLAGS, OFFSET_IDENTIFICATION, OFFSET_IP_CHECKSUM, OFFSET_PROTOCOL, OFFSET_SOURCE_ADDRESS, OFFSET_TOTAL_LENGTH, OFFSET_TTL, OFFSET_TYPE_OF_SERVICE, PROTOCOL_ICMP, PROTOCOL_IP, PROTOCOL_TCP, PROTOCOL_UDP |
Constructor Summary | |
TCPPacket(int size)
Creates a new TCP packet of a given size. |
|
TCPPacket(TCPPacket packet)
Creates a new TCP packet that is a copy of a given packet. |
Method Summary | |
void |
addControlFlags(int mask)
Sets the specified control bits without altering any other bits in the control header. |
void |
clearSACK()
Clears all selective acknowledgement options. |
int |
computeTCPChecksum()
Same as computeTCPChecksum(true); |
int |
computeTCPChecksum(boolean update)
Computes the TCP checksum, optionally updating the TCP checksum header. |
void |
copyData(TCPPacket packet)
Copies the contents of a TCPPacket. |
long |
getAckNumber()
|
int |
getCombinedHeaderByteLength()
|
int |
getDestinationPort()
|
long |
getSequenceNumber()
|
int |
getSourcePort()
|
int |
getTCPChecksum()
|
int |
getTCPDataByteLength()
|
int |
getTCPHeaderByteLength()
|
int |
getTCPHeaderLength()
|
int |
getTCPPacketByteLength()
|
int |
getUrgentPointer()
|
int |
getWindowSize()
|
boolean |
isSet(int mask)
|
boolean |
isSetAny(int mask)
|
boolean |
isSetOnly(int mask)
|
void |
removeControlFlags(int mask)
Unsets the specified control bits. |
void |
setAckNumber(long seq)
Sets the acknowledgement number. |
void |
setControlFlags(int mask)
Sets the control header to the sepecified value. |
void |
setData(byte[] data)
Sets the raw packet byte array. |
void |
setDestinationPort(int port)
Sets the destination port. |
void |
setIPHeaderLength(int length)
Sets the IP header length field. |
void |
setSequenceNumber(long seq)
Sets the sequence number. |
void |
setSourcePort(int port)
Sets the source port. |
void |
setTCPDataByteLength(int length)
Sets the length of the TCP data payload. |
void |
setTCPHeaderLength(int length)
Sets te TCP header length (i.e., the data offset field) in 32-bit words. |
void |
setUrgentPointer(int pointer)
Sets the urgent pointer. |
void |
setWindowSize(int window)
Sets the TCP window size. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int OFFSET_SOURCE_PORT
public static final int OFFSET_DESTINATION_PORT
public static final int OFFSET_SEQUENCE
public static final int OFFSET_ACK
public static final int OFFSET_HEADER_LENGTH
public static final int OFFSET_CONTROL
public static final int OFFSET_WINDOW_SIZE
public static final int OFFSET_TCP_CHECKSUM
public static final int OFFSET_URG_POINTER
public static final int MASK_FIN
public static final int MASK_SYN
public static final int MASK_RST
public static final int MASK_PSH
public static final int MASK_ACK
public static final int MASK_URG
public static final byte KIND_EOL
public static final byte KIND_NOP
public static final byte KIND_SACK
Constructor Detail |
public TCPPacket(int size)
size
- The number of bytes in the packet.public TCPPacket(TCPPacket packet)
packet
- The packet to replicate.Method Detail |
public void clearSACK()
public final void copyData(TCPPacket packet)
packet
- The TCPPacket to copy.public boolean isSet(int mask)
mask
- The bit mask to check.
public boolean isSetAny(int mask)
mask
- The bit mask to check.
public boolean isSetOnly(int mask)
mask
- The bit mask to check.
public void addControlFlags(int mask)
mask
- The bits to set.public void removeControlFlags(int mask)
mask
- The bits to unset.public void setControlFlags(int mask)
mask
- The new control header bit mask.public void setData(byte[] data)
IPPacket
setData
in class IPPacket
data
- The raw packet byte array to wrap.public final void setSourcePort(int port)
port
- The new source port.public final void setDestinationPort(int port)
port
- The new destination port.public final int getSourcePort()
public final int getDestinationPort()
public final void setSequenceNumber(long seq)
seq
- The new sequence number.public final long getSequenceNumber()
public final void setAckNumber(long seq)
seq
- The new acknowledgement number.public final long getAckNumber()
public void setIPHeaderLength(int length)
IPPacket
setIPHeaderLength
in class IPPacket
length
- The length of the IP header in 32-bit words.public final void setTCPHeaderLength(int length)
length
- The TCP header length in 32-bit words.public final int getTCPHeaderLength()
public final int getTCPHeaderByteLength()
public final void setWindowSize(int window)
window
- The TCP window size.public final int getWindowSize()
public final void setUrgentPointer(int pointer)
pointer
- The urgent pointer value.public final int getUrgentPointer()
public final int getTCPChecksum()
public final int getTCPPacketByteLength()
public final int getCombinedHeaderByteLength()
public final void setTCPDataByteLength(int length)
length
- The length of the TCP data payload in bytes.public final int getTCPDataByteLength()
public final int computeTCPChecksum(boolean update)
update
- Specifies whether or not to update the TCP checksum
header after computing the checksum. A value of true indicates
the header should be updated, a value of false indicates it
should not be updated.
public final int computeTCPChecksum()
computeTCPChecksum(true);
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |