org.jnetpcap.packet
Class JHeader.State

java.lang.Object
  extended by org.jnetpcap.nio.JMemory
      extended by org.jnetpcap.nio.JStruct
          extended by org.jnetpcap.packet.JHeader.State
Enclosing class:
JHeader

public static class JHeader.State
extends JStruct

This class is peered state of a header a native state structure

 typedef struct header_t {
 uint8_t  hdr_id;         // header ID
 
 uint8_t  hdr_prefix;     // length of the prefix (preamble) before the header
 uint8_t  hdr_gap;        // length of the gap between header and payload
 uint16_t hdr_flags;      // flags for this header
 uint16_t hdr_postfix;    // length of the postfix (trailer) after the payload
 uint32_t hdr_offset;     // offset into the packet_t->data buffer
 uint32_t hdr_length;     // length of the header in packet_t->data buffer
 uint32_t hdr_payload;    // length of the payload
 
 jobject  hdr_analysis;   // Java JAnalysis based object if not null
 } header_t;
 
 
.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jnetpcap.nio.JMemory
JMemory.Type
 
Field Summary
static int FLAG_CRC_INVALID
          Flag set in the header_t structure, tells if the CRC, if performed, was valid or invalid.
static int FLAG_CRC_PERFORMED
          Flag set in the header_t structure, a protocol specific CRC had been performed on the frame, header or its payload.
static int FLAG_FIELDS_DISSECTED
          Flag set in the header_t structure, which indicates that the current header was dissected for optional fields.
static int FLAG_GAP_TRUNCATED
          Flag set in the header_t structure, which tells if the postifx is incomplete due to packet truncation at the time of the capture.
static int FLAG_HEADER_FRAGMENTED
          Flag set in the header_t structure, which indicates that the current header and/or payload are fragmented.
static int FLAG_HEADER_TRUNCATED
          Flag set in the header_t structure, which tells if the header is incomplete due to packet truncation at the time of the capture.
static int FLAG_HEURISTIC_BINDING
          Flag set in the header_t structure, which tells if this header was bound due to a heuristic binding.
static int FLAG_IGNORE_BOUNDS
          A flag that is set for headers that should not strictly enforce their header boundaries.
static int FLAG_PAYLOAD_TRUNCATED
          Flag set in the header_t structure, which tells if the payload is incomplete due to packet truncation at the time of the capture.
static int FLAG_POSTFIX_TRUNCATED
          Flag set in the header_t structure, which tells if the postifx is incomplete due to packet truncation at the time of the capture.
static int FLAG_PREFIX_TRUNCATED
          Flag set in the header_t structure, which tells if the prefix is incomplete due to packet truncation at the time of the capture.
static int FLAG_SUBHEADERS_DISSECTED
          Flag set in the header_t structure, which indicates that the current header was dissected for optional sub-headers.
static java.lang.String STRUCT_NAME
          Name of the native structure backing this peer class.
 
Fields inherited from class org.jnetpcap.nio.JMemory
JNETPCAP_LIBRARY_NAME, MAX_DIRECT_MEMORY_DEFAULT, POINTER
 
Constructor Summary
JHeader.State(JMemory.Type type)
          Create an uninitialized type.
 
Method Summary
 int getFlags()
          Every header "record" keeps int-bit-flags that describe certain additional information about the header.
 int getGap()
          Gets the length in bytes of a gap (padding) between the header and the protocol 'records' payload:
 int getId()
          Gets the numerical ID of the header this structure describes as defined by JRegistry.
 int getLength()
          Gets the length of the protocol's header in bytes within the protocol's 'record':
 int getOffset()
          Gets the offset into the packet buffer of the actual protocol header header in bytes of protocols 'record':
 int getPayload()
          Gets the length of the payload that follows a protocol header in bytes within the protocol's 'record':
 int getPostfix()
          Gets the length of the postfix that follows a protocol's payload in bytes within the protocol's 'record':
 int getPrefix()
          Gets the length of the prefix that precedes a protocol's header in bytes within the protocol's 'record':
 boolean isDirect()
          Checks if this state object is reading for native structures or has a java implementation backing it.
 int peer(JHeader.State peer)
          Peers this state object with the native structures of another.
 void setFlags(int flags)
          Sets the header flags to new values.
 java.lang.String toString()
          Creates a string containing light debug information about this state class and underlying header it belongs to.
 
Methods inherited from class org.jnetpcap.nio.JStruct
getStructName
 
Methods inherited from class org.jnetpcap.nio.JMemory
availableDirectMemory, check, cleanup, createReference, isInitialized, isJMemoryBasedOwner, isOwner, maxDirectMemory, peer, peer, peer, reservedDirectMemory, setSize, size, softDirectMemory, toDebugString, toHexdump, toHexdump, totalActiveAllocated, totalAllocateCalls, totalAllocated, totalAllocatedSegments0To255Bytes, totalAllocatedSegments256OrAbove, totalDeAllocateCalls, totalDeAllocated, transferFrom, transferFrom, transferFrom, transferFrom, transferFromDirect, transferOwnership, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo0
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FLAG_CRC_INVALID

public static final int FLAG_CRC_INVALID
Flag set in the header_t structure, tells if the CRC, if performed, was valid or invalid. Invalid CRC means that computed CRC did not match the protocol specific CRC stored within the header.

See Also:
Constant Field Values

FLAG_CRC_PERFORMED

public static final int FLAG_CRC_PERFORMED
Flag set in the header_t structure, a protocol specific CRC had been performed on the frame, header or its payload.

See Also:
Constant Field Values

FLAG_GAP_TRUNCATED

public static final int FLAG_GAP_TRUNCATED
Flag set in the header_t structure, which tells if the postifx is incomplete due to packet truncation at the time of the capture.

See Also:
Constant Field Values

FLAG_HEADER_TRUNCATED

public static final int FLAG_HEADER_TRUNCATED
Flag set in the header_t structure, which tells if the header is incomplete due to packet truncation at the time of the capture.

See Also:
Constant Field Values

FLAG_HEURISTIC_BINDING

public static final int FLAG_HEURISTIC_BINDING
Flag set in the header_t structure, which tells if this header was bound due to a heuristic binding. If set, this means that the header was found heuristically (guessed based on correctness of the field values within the header). It is always possible, that heuristic binding may be incorrect and this flag, provides a way to determine how trust worthy the binding is.

See Also:
Constant Field Values

FLAG_PAYLOAD_TRUNCATED

public static final int FLAG_PAYLOAD_TRUNCATED
Flag set in the header_t structure, which tells if the payload is incomplete due to packet truncation at the time of the capture. Only protocols with a payload buffer of static length would set this flag or if the payload buffer is at the end of the packet and a calculation can determine based on over-all packet trancation, if the payload was affected as well.

See Also:
Constant Field Values

FLAG_POSTFIX_TRUNCATED

public static final int FLAG_POSTFIX_TRUNCATED
Flag set in the header_t structure, which tells if the postifx is incomplete due to packet truncation at the time of the capture.

See Also:
Constant Field Values

FLAG_PREFIX_TRUNCATED

public static final int FLAG_PREFIX_TRUNCATED
Flag set in the header_t structure, which tells if the prefix is incomplete due to packet truncation at the time of the capture.

See Also:
Constant Field Values

FLAG_HEADER_FRAGMENTED

public static final int FLAG_HEADER_FRAGMENTED
Flag set in the header_t structure, which indicates that the current header and/or payload are fragmented. The header fragmentation could have been determined by the scanner of this protocol or the flag could have been inherited from encapsulating header.

See Also:
Constant Field Values

FLAG_FIELDS_DISSECTED

public static final int FLAG_FIELDS_DISSECTED
Flag set in the header_t structure, which indicates that the current header was dissected for optional fields. All optional fields were recorded.

See Also:
Constant Field Values

FLAG_SUBHEADERS_DISSECTED

public static final int FLAG_SUBHEADERS_DISSECTED
Flag set in the header_t structure, which indicates that the current header was dissected for optional sub-headers. All optional sub-headers were recorded.

See Also:
Constant Field Values

FLAG_IGNORE_BOUNDS

public static final int FLAG_IGNORE_BOUNDS
A flag that is set for headers that should not strictly enforce their header boundaries. This is used in cases such as encapsulated IP and ICMP header, where the original IP packet was truncated before encapsulating in ICMP, yet its header tot_length was not adjusted.

See Also:
Constant Field Values

STRUCT_NAME

public static final java.lang.String STRUCT_NAME
Name of the native structure backing this peer class.

See Also:
Constant Field Values
Constructor Detail

JHeader.State

public JHeader.State(JMemory.Type type)
Create an uninitialized type.

Parameters:
type - type of memory
Method Detail

getFlags

public int getFlags()
Every header "record" keeps int-bit-flags that describe certain additional information about the header. Most commonly use flags are

Returns:
unsigned integer contains bit-flags for this header FLAG_PAYLOAD_TRUNCATED and other like it.

getGap

public int getGap()
Gets the length in bytes of a gap (padding) between the header and the protocol 'records' payload:
 +------------------=====--------------------+
 | prefix | header | GAP | payload | postfix |
 +------------------=====--------------------+
 
.

Returns:
length in bytes of the gap or 0 if not set

getId

public int getId()
Gets the numerical ID of the header this structure describes as defined by JRegistry.

Returns:
numerical ID of this header
See Also:
JRegistry

getLength

public int getLength()
Gets the length of the protocol's header in bytes within the protocol's 'record':
 +---------========--------------------------+
 | prefix | HEADER | gap | payload | postfix |
 +---------========--------------------------+
 
.

Returns:
length in bytes of the header

getOffset

public int getOffset()
Gets the offset into the packet buffer of the actual protocol header header in bytes of protocols 'record':
 +---------========--------------------------+
 | prefix | HEADER | gap | payload | postfix |
 +---------========--------------------------+
 
.

Returns:
offset in bytes of the header

getPayload

public int getPayload()
Gets the length of the payload that follows a protocol header in bytes within the protocol's 'record':
 +------------------------=========----------+
 | prefix | header | gap | PAYLOAD | postfix |
 +------------------------=========----------+
 
.

Returns:
length in bytes of the payload or 0 if not set

getPostfix

public int getPostfix()
Gets the length of the postfix that follows a protocol's payload in bytes within the protocol's 'record':
 +----------------------------------=========+
 | prefix | header | gap | payload | POSTFIX |
 +----------------------------------=========+
 
.

Returns:
length in bytes of the postfix or 0 if not set

getPrefix

public int getPrefix()
Gets the length of the prefix that precedes a protocol's header in bytes within the protocol's 'record':
 +========-----------------------------------+
 | PREFIX | header | gap | payload | postfix |
 +========-----------------------------------+
 
.

Returns:
length in bytes of the postfix or 0 if not set

isDirect

public boolean isDirect()
Checks if this state object is reading for native structures or has a java implementation backing it.

Returns:
true if the implementation is native, otherwise false

peer

public int peer(JHeader.State peer)
Peers this state object with the native structures of another. No copies are done, only references are changed.

Parameters:
peer - destination object holding the native memory reference we need to peer to
Returns:
number of bytes that actually were part of the operation even though non were physically copied during the peering process

setFlags

public void setFlags(int flags)
Sets the header flags to new values.

Parameters:
flags - unsinged integer containing the bit-flags to set for this header

toString

public java.lang.String toString()
Creates a string containing light debug information about this state class and underlying header it belongs to.

Overrides:
toString in class JStruct
Returns:
light debug string for this object and header