net.sourceforge.jpcap.net
Class IPEncoding
java.lang.Object
|
+--net.sourceforge.jpcap.net.IPEncoding
- public class IPEncoding
- extends java.lang.Object
IP protocol encoding information.
Field Summary |
static int |
CODE_POS
Position of the IP protocol code within a packet. |
static int |
DST_POS
Position of the destination IP address within a packet. |
static int |
HEADER_LEN
Length in bytes of an IP header. |
static int |
SRC_POS
Position of the source IP address within a packet. |
Method Summary |
static IPPacket |
create(int lLen,
byte[] bytes)
IPPacket factory. |
static java.lang.String |
extractAddress(boolean sourceFlag,
int lLen,
byte[] packetBytes)
Extract an IP address from an IP packet. |
static int |
extractProtocol(int lLen,
byte[] packetBytes)
Extract the protocol code from packet data. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CODE_POS
public static final int CODE_POS
- Position of the IP protocol code within a packet.
SRC_POS
public static final int SRC_POS
- Position of the source IP address within a packet.
DST_POS
public static final int DST_POS
- Position of the destination IP address within a packet.
HEADER_LEN
public static final int HEADER_LEN
- Length in bytes of an IP header.
IPEncoding
public IPEncoding()
create
public static IPPacket create(int lLen,
byte[] bytes)
- IPPacket factory.
extractProtocol
public static int extractProtocol(int lLen,
byte[] packetBytes)
- Extract the protocol code from packet data. The packet data
must contain an IP datagram.
The protocol code specifies what kind of information is contained in the
data block of the ip datagram.
- Parameters:
llen
- the length of the link-level header.packetBytes
- packet bytes, including the link-layer header.- Returns:
- the IP protocol code. i.e. 0x06 signifies TCP protocol.
extractAddress
public static java.lang.String extractAddress(boolean sourceFlag,
int lLen,
byte[] packetBytes)
- Extract an IP address from an IP packet.
- Parameters:
offset
- the offset of the address data from the start of the
packet.packetBytes
- packet bytes, including the link-layer header.