|
|||||||||
| 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.JFunction
org.jnetpcap.packet.JHeaderScanner
public class JHeaderScanner
A header scanner, there is one per header, that is able to scan raw memory
buffer and determine the length of the header and the next header ID after
examining the current header's structure. The header scanner is bound to the
native direct scanner provided by the jNetPcap native implementation. The
header scanner can be overriden with a java implementation by simply
subclassing it and overriding the getHeaderLength and
getNextHeader methods. If either of the 2 types of methods are
overriden, then the user should also overriden the isDirect() method
and return false to indicate that this is not a native direct scanner.
The header scanner is natively peered directly with the appropriate function that performs the scan and determines the next protocol in chain of headers found in the data buffer. Another words this class is peered using a function pointer and dispatched appropriately when invoked to scan for length or next header id.
Here is a typedef definition and the function pointer signature.
typedef void (*native_protocol_func_t)(scan_t *scan);Note that scan_t structure is implemented by java class JScan which is peered with that structure.
JScan| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.jnetpcap.nio.JMemory |
|---|
JMemory.Type |
| Field Summary |
|---|
| Fields inherited from class org.jnetpcap.nio.JMemory |
|---|
JNETPCAP_LIBRARY_NAME, MAX_DIRECT_MEMORY_DEFAULT, POINTER |
| Constructor Summary | |
|---|---|
JHeaderScanner(java.lang.Class<? extends JHeader> c)
Instantiates a new j header scanner. |
|
JHeaderScanner(JProtocol protocol)
A java scanner for headers out of a native packet buffer. |
|
| Method Summary | |
|---|---|
boolean |
addBindings(JBinding... bindings)
Adds the bindings. |
void |
clearBindings()
Clear bindings. |
JBinding[] |
getBindings()
Gets the bindings. |
int |
getGapLength(JPacket packet,
int offset)
Gets the gap length. |
int |
getHeaderLength(JPacket packet,
int offset)
Returns the length of the header this scanner is registered for. |
int |
getId()
Gets the protocol header's numerical ID as assigned by JRegistry |
int |
getPayloadLength(JPacket packet,
int offset)
Gets the payload length. |
int |
getPostfixLength(JPacket packet,
int offset)
Gets the postfix length. |
int |
getPrefixLength(JPacket packet,
int offset)
Gets the prefix length. |
boolean |
hasBindings()
Checks for bindings. |
boolean |
hasScanMethod()
Checks for scan method. |
boolean |
isDirect()
Checks if the scanner at the given ID is a direct or java scanner. |
boolean |
removeBindings(JBinding... bindings)
Removes the bindings. |
int |
scanAllBindings(JPacket packet,
int offset)
Calculates the next header in sequence of headers within the packet buffer. |
protected void |
scanHeader(JScan scan)
The main method that this header scanner is called on by the packet scanner, typically from native user space. |
void |
setScannerMethod(AnnotatedScannerMethod method)
Sets the scanner method. |
java.lang.String |
toString()
To string. |
| Methods inherited from class org.jnetpcap.nio.JFunction |
|---|
getName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JHeaderScanner(java.lang.Class<? extends JHeader> c)
c - the cpublic JHeaderScanner(JProtocol protocol)
protocol - core protocol constant for which to override its default native
header scanner| Method Detail |
|---|
public boolean addBindings(JBinding... bindings)
bindings - the bindings
public void clearBindings()
public boolean hasBindings()
public JBinding[] getBindings()
public int getHeaderLength(JPacket packet,
int offset)
packet - the packet object this header is bound tooffset - offset into the packet buffer in bytes of the start of this header
public int getPrefixLength(JPacket packet,
int offset)
packet - the packetoffset - the offset
public int getGapLength(JPacket packet,
int offset)
packet - the packetoffset - the offset
public int getPayloadLength(JPacket packet,
int offset)
packet - the packetoffset - the offset
public int getPostfixLength(JPacket packet,
int offset)
packet - the packetoffset - the offset
public final int getId()
public boolean isDirect()
public boolean removeBindings(JBinding... bindings)
bindings - the bindings
public int scanAllBindings(JPacket packet,
int offset)
packet - the packet object this header is bound tooffset - offset into the packet buffer in bytes of the start of this header
protected void scanHeader(JScan scan)
scan - scan state structure that is used to pass around state both in
java and native user spacepublic void setScannerMethod(AnnotatedScannerMethod method)
method - the new scanner methodpublic java.lang.String toString()
toString in class java.lang.ObjectObject.toString()public boolean hasScanMethod()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||