Package nl.sidnlabs.pcap.decoder
Class IPDecoder
- java.lang.Object
-
- nl.sidnlabs.pcap.decoder.IPDecoder
-
public class IPDecoder extends Object
Decode the IP header
-
-
Field Summary
Fields Modifier and Type Field Description static intIP_FLAGSstatic intIP_FRAGMENT_OFFSETstatic intIP_PROTOCOL_VERSION_4static intIP_PROTOCOL_VERSION_6static intIP_TOTAL_LEN_OFFSET
-
Constructor Summary
Constructors Constructor Description IPDecoder(Decoder tcpReader, Decoder udpReader, ICMPDecoder icmpDecoder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearCache(int ipFragmentTTL)Clear expired cache entries in order to avoid memory problemsPacketcreatePacket(byte[] packetData, int ipStart)Packetdecode(byte[] packetData, int ipStart, long packetTimestampSecs, long packetTimestampMicros)com.google.common.collect.Multimap<Datagram,DatagramPayload>getDatagrams()voidprintStats()byte[]reassemble(Packet packet, byte[] packetData)Reassemble the IP packet is it is fragmented.voidsetDatagrams(com.google.common.collect.Multimap<Datagram,DatagramPayload> datagrams)
-
-
-
Field Detail
-
IP_PROTOCOL_VERSION_4
public static final int IP_PROTOCOL_VERSION_4
- See Also:
- Constant Field Values
-
IP_PROTOCOL_VERSION_6
public static final int IP_PROTOCOL_VERSION_6
- See Also:
- Constant Field Values
-
IP_TOTAL_LEN_OFFSET
public static final int IP_TOTAL_LEN_OFFSET
- See Also:
- Constant Field Values
-
IP_FLAGS
public static final int IP_FLAGS
- See Also:
- Constant Field Values
-
IP_FRAGMENT_OFFSET
public static final int IP_FRAGMENT_OFFSET
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IPDecoder
public IPDecoder(Decoder tcpReader, Decoder udpReader, ICMPDecoder icmpDecoder)
-
-
Method Detail
-
printStats
public void printStats()
-
decode
public Packet decode(byte[] packetData, int ipStart, long packetTimestampSecs, long packetTimestampMicros)
-
createPacket
public Packet createPacket(byte[] packetData, int ipStart)
-
reassemble
public byte[] reassemble(Packet packet, byte[] packetData)
Reassemble the IP packet is it is fragmented. If it is not fragmented then the packetData bytes are returned as result. If the packet is fragmented and this packet is the final fragment then all the bytes from the fragments are concatenated and returned. if fragmented and current fragment is not yet the final fragment then an empty byte array is returned. the- Parameters:
packet- the current packetpacketData- the payload of the current packet- Returns:
- input, reassembled or no bytes
-
getDatagrams
public com.google.common.collect.Multimap<Datagram,DatagramPayload> getDatagrams()
-
setDatagrams
public void setDatagrams(com.google.common.collect.Multimap<Datagram,DatagramPayload> datagrams)
-
clearCache
public void clearCache(int ipFragmentTTL)
Clear expired cache entries in order to avoid memory problems- Parameters:
ipFragmentTTL- timeout for IP fragments
-
-