Package org.pcap4j.packet
Interface Packet
-
- All Superinterfaces:
java.lang.Iterable<Packet>
,java.io.Serializable
- All Known Subinterfaces:
IllegalRawDataPacket
,IpPacket
,TransportPacket
- All Known Implementing Classes:
AbstractPacket
,ArpPacket
,BsdLoopbackPacket
,CompressedPacket
,DnsPacket
,Dot11ManagementPacket
,Dot11ProbeRequestPacket
,Dot11Selector
,Dot1qVlanTagPacket
,EncryptedPacket
,EthernetPacket
,FragmentedPacket
,GtpSelector
,GtpV1Packet
,HdlcPppPacket
,IcmpV4CommonPacket
,IcmpV4DestinationUnreachablePacket
,IcmpV4EchoPacket
,IcmpV4EchoReplyPacket
,IcmpV4InformationReplyPacket
,IcmpV4InformationRequestPacket
,IcmpV4ParameterProblemPacket
,IcmpV4RedirectPacket
,IcmpV4SourceQuenchPacket
,IcmpV4TimeExceededPacket
,IcmpV4TimestampPacket
,IcmpV4TimestampReplyPacket
,IcmpV6CommonPacket
,IcmpV6DestinationUnreachablePacket
,IcmpV6EchoReplyPacket
,IcmpV6EchoRequestPacket
,IcmpV6HomeAgentAddressDiscoveryReplyPacket
,IcmpV6HomeAgentAddressDiscoveryRequestPacket
,IcmpV6MobilePrefixAdvertisementPacket
,IcmpV6MobilePrefixSolicitationPacket
,IcmpV6NeighborAdvertisementPacket
,IcmpV6NeighborSolicitationPacket
,IcmpV6PacketTooBigPacket
,IcmpV6ParameterProblemPacket
,IcmpV6RedirectPacket
,IcmpV6RouterAdvertisementPacket
,IcmpV6RouterSolicitationPacket
,IcmpV6TimeExceededPacket
,IllegalPacket
,IpSelector
,IpV4Packet
,IpV6ExtDestinationOptionsPacket
,IpV6ExtFragmentPacket
,IpV6ExtHopByHopOptionsPacket
,IpV6ExtOptionsPacket
,IpV6ExtRoutingPacket
,IpV6ExtUnknownPacket
,IpV6Packet
,LinuxSllPacket
,LlcPacket
,PcapPacket
,PppPacket
,PppSelector
,RadiotapPacket
,SctpPacket
,SnapPacket
,Ssh2BinaryPacket
,Ssh2DebugPacket
,Ssh2DisconnectPacket
,Ssh2IgnorePacket
,Ssh2KexDhInitPacket
,Ssh2KexDhReplyPacket
,Ssh2KexInitPacket
,Ssh2NewKeysPacket
,Ssh2ServiceAcceptPacket
,Ssh2ServiceRequestPacket
,Ssh2UnimplementedPacket
,Ssh2VersionExchangePacket
,SshPacket
,TcpPacket
,UdpPacket
,UnknownPacket
public interface Packet extends java.lang.Iterable<Packet>, java.io.Serializable
The interface representing a packet which consists of a header and a payload. If you usePropertiesBasedPacketFactory
, classes which implement this interface must implement the following method:public static Packet newPacket(byte[] rawData, int offset, int length) throws IllegalRawDataException
- Since:
- pcap4j 0.9.1
- Author:
- Kaito Yamada
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Packet.Builder
This interface is designed to be implemented by builder classes for packet objects.static interface
Packet.Header
The interface representing a packet's header.
-
Method Summary
Modifier and Type Method Description default <T extends Packet>
booleancontains(java.lang.Class<T> clazz)
Returns true if this packet is or its payload includes an object of specified packet class; false otherwise.default <T extends Packet>
Tget(java.lang.Class<T> clazz)
Traverses this packet and its payload to find an object of the specified packet class and returns the object.Packet.Builder
getBuilder()
Returns a new Builder object populated with this object's fields' values.Packet.Header
getHeader()
Returns the Header object representing this packet's header.default Packet
getLowerLayerOf(java.lang.Class<? extends Packet> clazz)
Returns the outer packet object of a packet objectget(clazz)
returns.Packet
getPayload()
Returns the Packet object representing this packet's payload.byte[]
getRawData()
Returns this packet's raw data.default java.util.Iterator<Packet>
iterator()
int
length()
Returns the packet length in bytes.
-
-
-
Method Detail
-
getHeader
Packet.Header getHeader()
Returns the Header object representing this packet's header.- Returns:
- the Header object representing this packet's header. May be null if the header doesn't exist
-
getPayload
Packet getPayload()
Returns the Packet object representing this packet's payload.- Returns:
- the Packet object representing this packet's payload. May be null if the payload doesn't exist
-
length
int length()
Returns the packet length in bytes.- Returns:
- the length of the byte stream of the packet represented by this object in bytes
-
getRawData
byte[] getRawData()
Returns this packet's raw data.- Returns:
- this packet's raw data, namely the byte stream which is actually sent through real network
-
iterator
default java.util.Iterator<Packet> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<Packet>
-
get
default <T extends Packet> T get(java.lang.Class<T> clazz)
Traverses this packet and its payload to find an object of the specified packet class and returns the object. If there are more than one objects of the specified class in this object, this method returns the most outer one of them.- Type Parameters:
T
- packet- Parameters:
clazz
- the packet class of the object to get- Returns:
- a packet object if found; otherwise null
-
getLowerLayerOf
default Packet getLowerLayerOf(java.lang.Class<? extends Packet> clazz)
Returns the outer packet object of a packet objectget(clazz)
returns.- Parameters:
clazz
- the packet class of the object whose outer packet object is what you want to get- Returns:
- a packet object if found; otherwise null
-
contains
default <T extends Packet> boolean contains(java.lang.Class<T> clazz)
Returns true if this packet is or its payload includes an object of specified packet class; false otherwise.- Type Parameters:
T
- packet- Parameters:
clazz
- the packet class of the object to search for- Returns:
- true if this packet is or its payload includes an object of specified packet class; false otherwise
-
getBuilder
Packet.Builder getBuilder()
Returns a new Builder object populated with this object's fields' values.- Returns:
- a new Builder object populated with this object's fields values
-
-