org.jnetpcap.packet
Interface JHeaderAccessor

All Known Implementing Classes:
JMemoryPacket, JPacket, PcapPacket

public interface JHeaderAccessor

Accessor to get a structured header from underlying buffer.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Method Summary
<T extends JHeader>
T
getHeader(T header)
          Peers the supplied header with the native header state structure and packet data buffer.
<T extends JHeader>
T
getHeader(T header, int instance)
          Peers the supplied header with the native header state structure and packet data buffer.
<T extends JHeader>
T
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.
 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
<T extends JHeader>
boolean
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.
<T extends JHeader>
boolean
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.
 

Method Detail

getHeader

<T extends JHeader> T getHeader(T header)
Peers the supplied header with the native header state structure and packet data buffer.

Type Parameters:
T - name of the header
Parameters:
header - instance of a header object
Returns:
the supplied instance of the header

getHeader

<T extends JHeader> T getHeader(T header,
                                int instance)
Peers the supplied header with the native header state structure and packet data buffer. This method allows retrieval of a specific instance of a header if more than one instance has been found.

Type Parameters:
T - name of the header
Parameters:
header - instance of a header object
instance - instance number of the header since more than one header of the same type can exist in the same packet buffer
Returns:
the supplied instance of the header

getHeaderByIndex

<T extends JHeader> T getHeaderByIndex(int index,
                                       T header)
Peers a header with specific index, not the numerical header ID assigned by JRegistry, of a header.

Type Parameters:
T - name of the header
Parameters:
header - instance of a header object
index - index into the header array the scanner has found
Returns:
the supplied header
Throws:
java.lang.IndexOutOfBoundsException

getHeaderCount

int getHeaderCount()
Gets number of headers found within the packet header. The last header may or may not be the builtin Payload header

Returns:
number of headers present

getHeaderIdByIndex

int getHeaderIdByIndex(int index)
Gets the numerical ID of the header at specified index into header array as found by the packet scanner

Parameters:
index - index into the header array
Returns:
numerical ID of the header found at the specific index

getHeaderInstanceCount

int getHeaderInstanceCount(int id)
Gets number of headers with the same numerical ID as assigned by JRegistry within the same packet. For example Ip4 in ip4 packet would contain 2 instances of Ip4 header.

Parameters:
id - numerical ID of the header to search for
Returns:
number of headers of the same type in the packet

hasHeader

boolean hasHeader(int id)
Checks if header with specified numerical ID exists within the decoded packet

Parameters:
id - protocol header ID as assigned by JRegistry
Returns:
true header exists, otherwise false

hasHeader

boolean hasHeader(int id,
                  int instance)
Check if requested instance of header with specified numerical ID exists within the decoded packet

Parameters:
id - protocol header ID as assigned by JRegistry
instance - instance number of the specific header within the packet
Returns:
true header exists, otherwise false

hasHeader

<T extends JHeader> boolean 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. This method executes as hasHeader followed by getHeader if found more efficiently.

Type Parameters:
T - name of the header type
Parameters:
header - protocol header object instance
Returns:
true header exists, otherwise false

hasHeader

<T extends JHeader> boolean 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. This method executes as hasHeader followed by getHeader if found more efficiently.

Type Parameters:
T - name of the header type
Parameters:
header - protocol header object instance
instance - instance number of the specific header within the packet
Returns:
true header exists, otherwise false