|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jnetpcap.nio.JMemory
org.jnetpcap.nio.JBuffer
org.jnetpcap.packet.JHeader
public abstract class JHeader
A base class for all protocol header definitions.
| Nested Class Summary | |
|---|---|
static class |
JHeader.State
This class is peered state of a header a native state structure |
| Nested classes/interfaces inherited from class org.jnetpcap.nio.JMemory |
|---|
JMemory.Type |
| Field Summary | |
|---|---|
protected AnnotatedHeader |
annotatedHeader
The annotated header. |
static int |
BYTE
A constant that defines how many bits there are in a byte. |
protected static JHeader[] |
EMPTY_HEADER_ARRAY
The Constant EMPTY_HEADER_ARRAY. |
protected boolean |
isSubHeader
The is sub header. |
protected JPacket |
packet
A reference to the packet that this header is part of. |
protected JHeader.State |
state
Reference to header's native state structure. |
| Fields inherited from class org.jnetpcap.nio.JMemory |
|---|
JNETPCAP_LIBRARY_NAME, MAX_DIRECT_MEMORY_DEFAULT, POINTER |
| Constructor Summary | |
|---|---|
JHeader()
Calls on the header defintion's static annotated \@HeaderLength method to get header's length. |
|
JHeader(int id,
JField[] fields,
java.lang.String name)
Constructs a header and initializes its static fields. |
|
JHeader(int id,
JField[] fields,
java.lang.String name,
java.lang.String nicname)
Constructs a header and initializes its static fields. |
|
JHeader(int id,
java.lang.String name)
Constructs a header. |
|
JHeader(int id,
java.lang.String name,
java.lang.String nicname)
Constructs a header. |
|
JHeader(JHeader.State state,
JField[] fields,
java.lang.String name,
java.lang.String nicname)
Constructs a header and initializes its static fields. |
|
JHeader(JProtocol protocol)
Constructs a header for a CORE protocol. |
|
| Method Summary | |
|---|---|
void |
decode()
Method that gets called everytime a header is successfully peered with new buffer and/or state structure. |
protected void |
decodeHeader()
Allows a header to decode its complex fields. |
AnnotatedHeader |
getAnnotatedHeader()
Retrieves the cached annotation of the header definition file. |
java.lang.String |
getDescription()
Retrives the description property for this header as defined in the source definition. |
JField[] |
getFields()
Retrieves the fields at runtime, that this header has so that they may be used by a formatter. |
byte[] |
getGap()
Reads the contents of the protocol's 'record' gap property as a byte array. |
int |
getGapLength()
Reads the length of the gap between the header and payload: * |
int |
getGapOffset()
Gets the offset into the packet, not the header, where the gap starts. |
byte[] |
getHeader()
Convenience method that retrieves the contents of the header as a byte are |
int |
getHeaderLength()
Length of the header in bytes. |
int |
getHeaderOffset()
Gets the offset in bytes into the packet, of the start of the header. |
int |
getId()
Gets the numerical ID of this protocol header at runtime as assigned by the JRegistry. |
int |
getIndex()
Gets the header's index into the packet state structure. |
int |
getLength()
Length of this header within the buffer. |
java.lang.String |
getName()
Gets the comprehensive name for this header. |
int |
getNextHeaderId()
Gets the next header id. |
int |
getNextHeaderOffset()
Gets the next header offset. |
java.lang.String |
getNicname()
Gets the short name for this header. |
int |
getOffset()
Offset into the packet buffer. |
JPacket |
getPacket()
Gets the packet that this header is associated with |
JHeader |
getParent()
If this is a sub-header of another header, gets the reference to the parent header. |
byte[] |
getPayload()
Retrieves the playload data portion of the packet right after the current header. |
int |
getPayloadLength()
Gets the length in bytes of the payload that follows the header and the gap. |
int |
getPayloadOffset()
Gets the offset of the payload into the packet buffer. |
byte[] |
getPostfix()
Gets the contents of the postfix as a byte array. |
int |
getPostfixLength()
Gets the length of the postfix. |
int |
getPostfixOffset()
Gets the offset in bytes into the packet buffer of the start of the postfix, even if not set or zero length. |
byte[] |
getPrefix()
Gets the contents of the prefix in a byte array. |
int |
getPrefixLength()
The length in bytes of the prefix within the packet buffer. |
int |
getPrefixOffset()
The offset in bytes into the packet buffer where the prefix starts, even if prefix is not set or zero in length. |
int |
getPreviousHeaderId()
Gets the previous header id. |
int |
getPreviousHeaderOffset()
Gets the previous header offset. |
JHeader.State |
getState()
Gets the reference to the current header's native state structure |
JHeader[] |
getSubHeaders()
Gets an array of currently defined sub headers. |
boolean |
hasDescription()
Checks if description header property has been set that provides a short description of this header. |
boolean |
hasGap()
Checks if gap has been set. |
boolean |
hasNextHeader()
Checks for next header. |
boolean |
hasPayload()
Checks if payload has been set. |
boolean |
hasPostfix()
Checks if postfix has been set. |
boolean |
hasPrefix()
Checks if prefix has been set. |
boolean |
hasPreviousHeader()
Checks for previous header. |
boolean |
hasSubHeaders()
Checks if header has any sub-headers. |
boolean |
isFragmented()
Checks if this entire header "record" which includes prefix, header, gap, payload and post is fragmented. |
boolean |
isGapTruncated()
Checks if gap has been truncated due to truncation at the time of the capture. |
boolean |
isHeaderTruncated()
Checks if header has been truncated due to truncation at the time of the capture. |
boolean |
isPayloadTruncated()
Checks if payload has been truncated due to truncation at the time of the capture. |
boolean |
isPostfixTruncated()
Checks if postifx has been truncated due to truncation at the time of the capture. |
boolean |
isPrefixTruncated()
Checks if prefix has been truncated due to truncation at the time of the capture. |
int |
peer(JBuffer buffer,
int offset)
Peers this state object with the buffer at specified offset. |
int |
peer(JHeader header)
Peers, associates a native packet buffer and scanner structure with this header. |
JBuffer |
peerPayloadTo(JBuffer buffer)
Peers, without copy, the user supplied buffer with payload data portion of the packet right after the current header. |
void |
setPacket(JPacket packet)
Sets the packet that this header should be associated with |
void |
setSubHeaders(JHeader[] headers)
Allows sub-headers to be set. |
static int |
sizeof()
Gets the size of the native header_t structure on this particular platform. |
java.lang.String |
toString()
Gets a string with summary information about the header. |
byte[] |
transferPayloadTo(byte[] buffer)
Copies the payload data portion of the packet right after the current header to user supplied buffer. |
java.nio.ByteBuffer |
transferPayloadTo(java.nio.ByteBuffer buffer)
Copies into the user supplied buffer, the payload data portion of the packet right after the current header. |
JBuffer |
transferPayloadTo(JBuffer buffer)
Copies into the user supplied buffer, the payload data portion of the packet right after the current header. |
protected void |
validateHeader()
Allows a header to validate its values. |
| Methods inherited from class org.jnetpcap.nio.JBuffer |
|---|
findUTF8String, getByte, getByteArray, 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, setShort0, setUByte, setUInt, setUShort, transferFrom, transferFrom, transferFrom, transferTo, transferTo, transferTo |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int BYTE
protected static final JHeader[] EMPTY_HEADER_ARRAY
protected AnnotatedHeader annotatedHeader
protected boolean isSubHeader
protected JPacket packet
protected final JHeader.State state
| Constructor Detail |
|---|
public JHeader()
public JHeader(int id,
JField[] fields,
java.lang.String name)
id - numerical ID of the protocolfields - fields usd by the formatter to reformat the packet for outputname - comprehensive name of the protocol
public JHeader(int id,
JField[] fields,
java.lang.String name,
java.lang.String nicname)
id - numerical ID of the protocolfields - fields usd by the formatter to reformat the packet for outputname - comprehensive name of the protocolnicname - a short name for the protocol
public JHeader(int id,
java.lang.String name)
id - numerical ID of the protocolname - comprehensive name of the protocol
public JHeader(int id,
java.lang.String name,
java.lang.String nicname)
id - numerical ID of the protocolname - comprehensive name of the protocolnicname - a short name for the protocolpublic JHeader(JProtocol protocol)
protocol - the CORE protocol constant
public JHeader(JHeader.State state,
JField[] fields,
java.lang.String name,
java.lang.String nicname)
state - the default header state object being referencedfields - fields usd by the formatter to reformat the packet for outputname - comprehensive name of the protocolnicname - a short name for the protocol| Method Detail |
|---|
public static int sizeof()
public final void decode()
protected void decodeHeader()
public AnnotatedHeader getAnnotatedHeader()
public java.lang.String getDescription()
public JField[] getFields()
public byte[] getGap()
+------------------=====--------------------+ | prefix | header | GAP | payload | postfix | +------------------=====--------------------+
public int getGapLength()
+------------------=====--------------------+ | prefix | header | GAP | payload | postfix | +------------------=====--------------------+.
public int getGapOffset()
+------------------=====--------------------+ | prefix | header | GAP | payload | postfix | +------------------=====--------------------+
public byte[] getHeader()
+---------========--------------------------+ | prefix | HEADER | gap | payload | postfix | +---------========--------------------------+.
public int getHeaderLength()
+---------========--------------------------+ | prefix | HEADER | gap | payload | postfix | +---------========--------------------------+
public int getHeaderOffset()
+---------========--------------------------+ | prefix | HEADER | gap | payload | postfix | +---------========--------------------------+
public final int getId()
public int getLength()
public final java.lang.String getName()
public final java.lang.String getNicname()
public int getOffset()
public final JPacket getPacket()
public JHeader getParent()
public byte[] getPayload()
+------------------------=========----------+ | prefix | header | gap | PAYLOAD | postfix | +------------------------=========----------+
getPayload in interface JPayloadAccessorpublic int getPayloadLength()
+------------------------=========----------+ | prefix | header | gap | PAYLOAD | postfix | +------------------------=========----------+
public int getPayloadOffset()
+------------------------=========----------+ | prefix | header | gap | PAYLOAD | postfix | +------------------------=========----------+
public byte[] getPostfix()
public int getPostfixLength()
+----------------------------------=========+ | prefix | header | gap | payload | POSTFIX | +----------------------------------=========+
public int getPostfixOffset()
public byte[] getPrefix()
+========-----------------------------------+ | PREFIX | header | gap | payload | postfix | +========-----------------------------------+
public int getPrefixLength()
public int getPrefixOffset()
public JHeader.State getState()
public JHeader[] getSubHeaders()
public boolean hasDescription()
public boolean hasGap()
public boolean hasPayload()
public boolean hasPostfix()
public boolean hasPrefix()
public boolean hasSubHeaders()
public boolean isGapTruncated()
public boolean isHeaderTruncated()
public boolean isPayloadTruncated()
public boolean isPostfixTruncated()
public boolean isPrefixTruncated()
public int peer(JBuffer buffer,
int offset)
buffer - buffer to peer tooffset - offset into the buffer
public int peer(JHeader header)
header - the header to peer with this header
public JBuffer peerPayloadTo(JBuffer buffer)
peerPayloadTo in interface JPayloadAccessorbuffer - buffer to peer the data with
public final void setPacket(JPacket packet)
packet - packet to associate with this headerpublic void setSubHeaders(JHeader[] headers)
headers - array of sub headerpublic java.lang.String toString()
toString in class java.lang.Objectpublic byte[] transferPayloadTo(byte[] buffer)
transferPayloadTo in interface JPayloadAccessorbuffer - buffer where the data will be written to
public java.nio.ByteBuffer transferPayloadTo(java.nio.ByteBuffer buffer)
transferPayloadTo in interface JPayloadAccessorbuffer - buffer to copy the data to
public JBuffer transferPayloadTo(JBuffer buffer)
transferPayloadTo in interface JPayloadAccessorbuffer - buffer to copy the data to
public int getIndex()
protected void validateHeader()
public boolean hasNextHeader()
public int getNextHeaderId()
public int getNextHeaderOffset()
public boolean hasPreviousHeader()
public int getPreviousHeaderId()
public int getPreviousHeaderOffset()
public boolean isFragmented()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||