|
|||||||||
| 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.JPacket
public abstract class JPacket
A native packet buffer object. This class references both packet data buffer and decoded native packet structure. JPacket class is a subclass of a more general JBuffer providing full access to raw packet buffer data. It also has a reference to JPacket.State object which is peered, associated with, a native packet state structure generated by the packet scanner, the JScanner.
The packet interface provides numerous methods for accessing the decoded
information. To check if any particular header is found within the packet's
data buffer at the time the packet was scanned, the user can use
hasHeader(int) methods. The method returns true if a particular header is
found within the packet data buffer, otherwise false. A convenience method
hasHeader(JHeader) exists that performs both an existance check and
initializes the header instace supplied to point at the header within the
packet.
There are also numerous peer and deep copy methods. The peering methods do not copy any buffers but simply re-orient the pointers to point at the source peer structures to destination peer. The deep copy methods do copy physical data out of buffers and entire structures using native copy functions, not in java space.
| Nested Class Summary | |
|---|---|
static class |
JPacket.State
Class maintains the decoded packet state. |
| Nested classes/interfaces inherited from class org.jnetpcap.nio.JMemory |
|---|
JMemory.Type |
| Field Summary | |
|---|---|
static int |
DEFAULT_STATE_HEADER_COUNT
Default number of headers used when calculating memory requirements for an empty packet state structure. |
protected JBuffer |
memory
The allocated memory buffer. |
protected static JMemoryPool |
pool
Packet's default memory pool out of which allocates memory for deep copies |
protected static JScanner |
scanner
Default scanner used to scan a packet per user request |
protected JPacket.State |
state
Packet's state structure |
| Fields inherited from class org.jnetpcap.nio.JMemory |
|---|
JNETPCAP_LIBRARY_NAME |
| Constructor Summary | |
|---|---|
JPacket(int size,
int state)
Allocates a memory block and peers both the state and data buffer with it. |
|
JPacket(JMemory.Type type)
A JPacket pointer. |
|
| Method Summary | ||
|---|---|---|
|
addAnalysis(T analysis)
|
|
void |
allocate(int size)
Creates a new memory buffer of given size for internal usage |
|
int |
getAllocatedMemorySize()
Gets the size of the current internal memory buffer |
|
|
getAnalysis(java.lang.Class<? extends JHeader> c,
T analysis)
|
|
|
getAnalysis(int id,
int instance,
T analysis)
|
|
|
getAnalysis(int id,
T analysis)
|
|
|
getAnalysis(T analysis)
|
|
abstract JCaptureHeader |
getCaptureHeader()
Gets the capture header as generated by the native capture library. |
|
static JFormatter |
getFormatter()
Gets the current internal packet formatter used in the toString()
method. |
|
long |
getFrameNumber()
Returns the frame number as assigned by either the packet scanner or analyzers. |
|
|
getHeader(T header)
Peers the supplied header with the native header state structure and packet data buffer. |
|
|
getHeader(T header,
int instance)
Peers the supplied header with the native header state structure and packet data buffer. |
|
|
getHeaderByIndex(int index,
T header)
Peers a header with specific index, not the numerical header ID assigned by JRegistry, of a header. |
|
int |
getHeaderCount()
Gets number of headers found within the packet header. |
|
int |
getHeaderIdByIndex(int index)
Gets the numerical ID of the header at specified index into header array as found by the packet scanner |
|
int |
getHeaderInstanceCount(int id)
Gets number of headers with the same numerical ID as assigned by JRegistry within the same packet. |
|
protected JBuffer |
getMemoryBuffer(byte[] buffer)
Gets the memory buffer with the supplied byte array data copied into it. |
|
protected JBuffer |
getMemoryBuffer(java.nio.ByteBuffer buffer)
Gets the memory buffer with the supplied ByteBuffer data copied into it. |
|
protected JBuffer |
getMemoryBuffer(int minSize)
Retrieves a memory buffer, allocated if neccessary, at least minSize in bytes. |
|
protected JBuffer |
getMemoryBuffer(JBuffer buffer)
Gets the memory buffer with the supplied JBuffer data copied into it. |
|
static JMemoryPool |
getMemoryPool()
Gets the current memory allocation memory pool. |
|
JPacket.State |
getState()
Gets the peered packet state object |
|
abstract int |
getTotalSize()
Gets the total size of this packet. |
|
int |
getType()
|
|
boolean |
hasAnalysis(java.lang.Class<? extends JAnalysis> analysis)
|
|
boolean |
hasAnalysis(int type)
|
|
|
hasAnalysis(T analysis)
|
|
boolean |
hasHeader(int id)
Checks if header with specified numerical ID exists within the decoded packet |
|
boolean |
hasHeader(int id,
int instance)
Check if requested instance of header with specified numerical ID exists within the decoded packet |
|
|
hasHeader(T header)
Check if requested instance of header with specified numerical ID exists within the decoded packet and if found peers the supplied header with the located header within the decoded packet. |
|
|
hasHeader(T header,
int instance)
Check if requested instance of header with specified numerical ID exists within the decoded packet and if found peers the supplied header with the located header within the decoded packet. |
|
int |
remaining(int offset)
Calculates the number of bytes remaining within the packet given a specific offset |
|
int |
remaining(int offset,
int length)
Calculates the remaining number of bytes within the packet buffer taking into account offset and length of a header supplied. |
|
void |
scan(int id)
Scan and decode the packet using current scanner. |
|
static void |
setFormatter(JFormatter out)
Replaced the default formatter for formatting output in the toString() method. |
|
static void |
setMemoryPool(JMemoryPool pool)
Replaces the default memory allocation mechanism with user supplied one. |
|
java.lang.String |
toString()
Generates text formatted output using the default builtin formatter. |
|
| 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, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.jnetpcap.nio.JByteBuffer |
|---|
size |
| Field Detail |
|---|
public static final int DEFAULT_STATE_HEADER_COUNT
protected static JMemoryPool pool
protected static JScanner scanner
protected final JBuffer memory
protected final JPacket.State state
| Constructor Detail |
|---|
public JPacket(int size,
int state)
size - amount of memory to allocate for packet datastate - size of the statepublic JPacket(JMemory.Type type)
JPacket constists of 2 peers. The first and the main memory peering is with the packet_state_t structure which stores information about the decoded state of the packet, another words the result of the scanned packet data buffer. The second peer is to the actual packet data buffer which is a seperate pointer.
transferStateAndDataTo which will copy the packet state
and/or data buffer into another memory area, such as a direct ByteBuffer or
JBuffer.
| Method Detail |
|---|
public static JFormatter getFormatter()
toString()
method.
public static JMemoryPool getMemoryPool()
public static void setFormatter(JFormatter out)
toString() method. The new formatter will be used by default for all
packets. The formatter should internally build a string that will be
returned with out.toString() method call to get meaningfull output.
out - new formatterpublic static void setMemoryPool(JMemoryPool pool)
pool - new memory pool to use.public <T extends JAnalysis> void addAnalysis(T analysis)
sequence - public void allocate(int size)
size - size in bytespublic int getAllocatedMemorySize()
public <T extends JAnalysis> T getAnalysis(T analysis)
public <T extends JAnalysis> T getAnalysis(int id,
T analysis)
public <T extends JAnalysis> T getAnalysis(int id,
int instance,
T analysis)
public <T extends JAnalysis> T getAnalysis(java.lang.Class<? extends JHeader> c,
T analysis)
public abstract JCaptureHeader getCaptureHeader()
public <T extends JHeader> T getHeader(T header)
T - name of the headerheader - instance of a header object
public <T extends JHeader> T getHeader(T header,
int instance)
T - name of the headerheader - instance of a header objectinstance - instance number of the header since more than one header of the
same type can exist in the same packet buffer
public <T extends JHeader> T getHeaderByIndex(int index,
T header)
throws java.lang.IndexOutOfBoundsException
T - name of the headerheader - instance of a header objectindex - index into the header array the scanner has found
java.lang.IndexOutOfBoundsExceptionpublic int getHeaderCount()
public int getHeaderIdByIndex(int index)
index - index into the header array
public int getHeaderInstanceCount(int id)
id - numerical ID of the header to search for
protected JBuffer getMemoryBuffer(byte[] buffer)
buffer - source array buffer to copy data out of
protected JBuffer getMemoryBuffer(java.nio.ByteBuffer buffer)
throws PeeringException
buffer - source array buffer to copy data out of
PeeringExceptionprotected JBuffer getMemoryBuffer(int minSize)
minSize - minimum number of bytes required for the buffer
protected JBuffer getMemoryBuffer(JBuffer buffer)
buffer - source array buffer to copy data out of
public JPacket.State getState()
public abstract int getTotalSize()
public int getType()
public boolean hasAnalysis(int type)
public boolean hasAnalysis(java.lang.Class<? extends JAnalysis> analysis)
public <T extends JAnalysis> boolean hasAnalysis(T analysis)
public boolean hasHeader(int id)
id - protocol header ID as assigned by JRegistry
public boolean hasHeader(int id,
int instance)
id - protocol header ID as assigned by JRegistryinstance - instance number of the specific header within the packet
public <T extends JHeader> boolean hasHeader(T header)
T - name of the header typeheader - protocol header object instance
public <T extends JHeader> boolean hasHeader(T header,
int instance)
T - name of the header typeheader - protocol header object instanceinstance - instance number of the specific header within the packet
public int remaining(int offset)
offset - offset into the packet in bytes
public int remaining(int offset,
int length)
offset - offset of the header to take into accountlength - length of the header
public void scan(int id)
id - numerical ID as assigned by JRegistry of the first protocol header
to be found in the packet, the DLTpublic java.lang.String toString()
toString in class java.lang.Objectpublic long getFrameNumber()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||