- Tutorials
- API Examples
- User Guide
- Ch 1 - The Basics
- Ch 2 - libpcap
- 2.1 - The Main libpcap API Overview
- 2.2 - Getting a List of Interfaces
- 2.3 - Opening a Network Interface for Capture
- 2.4 - Opening offline capture
- 2.5 - Setting a packet filter
- 2.6 - Reading one packet at a time
- 2.7 - Reading multiple packets with dispatch loops
- 2.8 - Dumping captured packet to an offline file
- 2.9 - Transmitting packets
- 2.10 - Close Pcap and PcapDumper handles
- Ch 3 - Packet Decoding
- Ch 4 - Internals
- Ch 5 - Protocols
- Ch 6 - Native API
It is possible to work with packet's decoded state directly. You can use the method JPacket.getState() to retrieve direct access to packet's state. It is a separate object, that is peered to a native state structure. This structure maintains information about each header, its length and offset into the packet data buffer. It also maintains a bit based integer map of the headers that are present within the packet.
The JPacket.State class provides native accessors for accessing members of the native struct packet_state_t C structure. The information in the structure is surprisingly simple. It only maintains the start and the length of the header within the packet buffer. That information is used to peer specific header instances directly with the packet's buffer memory where the header is said reside. Then its upto the header, a java class, to actually read the information from that native memory using JBuffer accessors.
This is an advanced topic, that is very implementation specific, therefore it is best not to rely on this part of the API.
»
Printer-friendly- Login or register to post comments
Send via Email
PDF Convert