org.jnetpcap.protocol.tcpip
Class Tcp

java.lang.Object
  extended by org.jnetpcap.nio.JMemory
      extended by org.jnetpcap.nio.JBuffer
          extended by org.jnetpcap.packet.JHeader
              extended by org.jnetpcap.protocol.tcpip.Tcp
All Implemented Interfaces:
JByteBuffer, JPayloadAccessor

@Header
public class Tcp
extends JHeader

Tcp/Ip header definition

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
static class Tcp.Flag
          Constants for each TCP flag
 
Nested classes/interfaces inherited from class org.jnetpcap.packet.JHeader
JHeader.State
 
Nested classes/interfaces inherited from class org.jnetpcap.nio.JMemory
JMemory.Type
 
Field Summary
static int ID
           
 
Fields inherited from class org.jnetpcap.packet.JHeader
annotatedHeader, EMPTY_HEADER_ARRAY, isSubHeader, packet, state
 
Fields inherited from class org.jnetpcap.nio.JMemory
JNETPCAP_LIBRARY_NAME
 
Constructor Summary
Tcp()
           
 
Method Summary
 long ack()
           
 void ack(long ack)
           
 int checksum()
           
 void checksum(int crc)
           
protected  void decodeHeader()
          Allows a header to decode its complex fields
 int destination()
           
 void destination(int dst)
           
 boolean flags_ACK()
           
 void flags_ACK(boolean flag)
           
 boolean flags_CWR()
           
 void flags_CWR(boolean flag)
           
 boolean flags_ECE()
           
 void flags_ECE(boolean flag)
           
 boolean flags_FIN()
           
 void flags_FIN(boolean flag)
           
 boolean flags_PSH()
           
 void flags_PSH(boolean flag)
           
 boolean flags_RST()
           
 void flags_RST(boolean flag)
           
 boolean flags_SYN()
           
 void flags_SYN(boolean flag)
           
 boolean flags_URG()
           
 void flags_URG(boolean flag)
           
 int flags()
           
 void flags(int flags)
           
 java.lang.String flagsCompactString()
           
 java.util.Set<Tcp.Flag> flagsEnum()
           
 int getPayloadLength()
          Calculates the length of the TCP payload.
 int hashCode()
          Returns a bi-directional hashcode for this header.
static int headerLength(JBuffer buffer, int offset)
           
 int hlen()
           
 void hlen(int length)
           
 int reserved()
           
 long seq()
           
 void seq(long seq)
           
 int source()
           
 void source(int src)
           
 int uniHashCode()
          Uni-directional hashcode.
 int urgent()
           
 void urgent(int urg)
           
 int window()
           
 void window(int win)
           
 int windowScaled()
           
 
Methods inherited from class org.jnetpcap.packet.JHeader
addAnalysis, decode, getAnalysis, getAnalysisIterable, getAnnotatedHeader, getDescription, getFields, getId, getLength, getName, getNicname, getOffset, getPacket, getParent, getPayload, getState, getSubHeaders, getType, hasAnalysis, hasAnalysis, hasAnalysis, hasDescription, hasSubHeaders, peer, peer, peerPayloadTo, setPacket, setSubHeaders, sizeof, toString, transferPayloadTo, transferPayloadTo, transferPayloadTo, validateHeader
 
Methods inherited from class org.jnetpcap.nio.JBuffer
findUTF8String, getByte, getByteArray, getByteArray, getDouble, getFloat, getInt, getLong, getShort, getUByte, getUInt, getUShort, getUTF8Char, getUTF8String, getUTF8String, getUTF8String, getUTF8String, isReadonly, order, order, peer, peer, peer, peer, setByte, setByteArray, setByteBuffer, setDouble, setFloat, setInt, setLong, setShort, setUByte, setUInt, setUShort, transferFrom, transferFrom, transferFrom, transferTo, transferTo, transferTo
 
Methods inherited from class org.jnetpcap.nio.JMemory
check, cleanup, finalize, isInitialized, isJMemoryBasedOwner, isOwner, peer, setSize, size, toDebugString, toHexdump, toHexdump, totalActiveAllocated, totalAllocateCalls, totalAllocated, totalAllocatedSegments0To255Bytes, totalAllocatedSegments256OrAbove, totalDeAllocateCalls, totalDeAllocated, transferFrom, transferFrom, transferFromDirect, transferOwnership, transferTo, transferTo, transferTo, transferTo, transferTo
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jnetpcap.nio.JByteBuffer
size
 

Field Detail

ID

public static final int ID
See Also:
Constant Field Values
Constructor Detail

Tcp

public Tcp()
Method Detail

headerLength

@HeaderLength
public static int headerLength(JBuffer buffer,
                                            int offset)

ack

@Field(offset=64,
       length=16,
       format="%x")
public long ack()

ack

public void ack(long ack)
Parameters:
ack -

checksum

@Field(offset=128,
       length=16,
       format="%x")
public int checksum()

checksum

public void checksum(int crc)
Parameters:
crc -

decodeHeader

protected void decodeHeader()
Description copied from class: JHeader
Allows a header to decode its complex fields

Overrides:
decodeHeader in class JHeader

destination

@Field(offset=16,
       length=16)
@FlowKey(index=2,
         reversable=true)
public int destination()

destination

public void destination(int dst)

flags

@Field(offset=104,
       length=8,
       format="%x")
public int flags()

flags

public void flags(int flags)

flags_ACK

@Field(parent="flags",
       offset=4,
       length=1,
       format="%b",
       display="ack",
       description="acknowledgment")
public boolean flags_ACK()
Returns:

flags_ACK

public void flags_ACK(boolean flag)
Parameters:
flag -

flags_CWR

@Field(parent="flags",
       offset=7,
       length=1,
       format="%b",
       display="cwr",
       description="reduced (cwr)")
public boolean flags_CWR()

flags_CWR

public void flags_CWR(boolean flag)

flags_ECE

@Field(parent="flags",
       offset=6,
       length=1,
       format="%b",
       display="ece",
       description="ECN echo flag")
public boolean flags_ECE()

flags_ECE

public void flags_ECE(boolean flag)

flags_FIN

@Field(parent="flags",
       offset=0,
       length=1,
       format="%b",
       display="fin",
       description="closing down connection")
public boolean flags_FIN()

flags_FIN

public void flags_FIN(boolean flag)

flags_PSH

@Field(parent="flags",
       offset=3,
       length=1,
       format="%b",
       display="ack",
       description="push current segment of data")
public boolean flags_PSH()

flags_PSH

public void flags_PSH(boolean flag)

flags_RST

@Field(parent="flags",
       offset=2,
       length=1,
       format="%b",
       display="ack",
       description="reset connection")
public boolean flags_RST()

flags_RST

public void flags_RST(boolean flag)

flags_SYN

@Field(parent="flags",
       offset=1,
       length=1,
       format="%b",
       display="ack",
       description="synchronize connection, startup")
public boolean flags_SYN()

flags_SYN

public void flags_SYN(boolean flag)

flags_URG

@Field(parent="flags",
       offset=5,
       length=1,
       format="%b",
       display="ack",
       description="urgent, out-of-band data")
public boolean flags_URG()

flags_URG

public void flags_URG(boolean flag)
Parameters:
b -

flagsCompactString

public java.lang.String flagsCompactString()

flagsEnum

public java.util.Set<Tcp.Flag> flagsEnum()
Returns:

getPayloadLength

public int getPayloadLength()
Calculates the length of the TCP payload.

Returns:
length of tcp segment data in bytes

hashCode

public int hashCode()
Returns a bi-directional hashcode for this header. The hashcode is made up of IP source, IP destination, Tcp source and destination port numbers. It is created in a such a way that packet's source and destination fields are interchangable and will generate the same hashcode.

Overrides:
hashCode in class java.lang.Object
Returns:
bi-directional hashcode for this TCP/IP header combination
See Also:
uniHashCode()

hlen

@Field(offset=96,
       length=4)
public int hlen()

hlen

public void hlen(int length)
Parameters:
length - in 4 byte words

reserved

@Field(offset=100,
       length=4)
public int reserved()

seq

@Field(offset=32,
       length=16,
       format="%x")
public long seq()

seq

public void seq(long seq)
Parameters:
seq -

source

@Field(offset=0,
       length=16)
@FlowKey(index=2,
         reversable=true)
public int source()

source

public void source(int src)

uniHashCode

public int uniHashCode()
Uni-directional hashcode. A hashcode that is computed based on IP destination and TCP destination port. This make the hashcode uni-direction in the direction from source to destination.

Returns:
a hashcode that is uni-directional

urgent

@Field(offset=144,
       length=16)
public int urgent()

urgent

public void urgent(int urg)
Parameters:
urg -

window

@Field(offset=112,
       length=16)
public int window()

window

public void window(int win)

windowScaled

public int windowScaled()