-
- All Superinterfaces:
java.lang.Iterable<Packet>,java.io.Serializable
- All Known Subinterfaces:
IpPacket,TransportPacket
- All Known Implementing Classes:
AbstractPacket,AbstractPppPacket,ArpPacket,BsdLoopbackPacket,CompressedPacket,DnsPacket,Dot11ManagementPacket,Dot11ProbeRequestPacket,Dot11Selector,Dot1qVlanTagPacket,EncryptedPacket,EthernetPacket,FragmentedPacket,GtpSelector,GtpV1Packet,HdlcPppPacket,IcmpIdentifiablePacket,IcmpV4CommonPacket,IcmpV4DestinationUnreachablePacket,IcmpV4EchoPacket,IcmpV4EchoReplyPacket,IcmpV4InformationReplyPacket,IcmpV4InformationRequestPacket,IcmpV4InvokingPacketPacket,IcmpV4ParameterProblemPacket,IcmpV4RedirectPacket,IcmpV4SourceQuenchPacket,IcmpV4TimeExceededPacket,IcmpV4TimestampPacket,IcmpV4TimestampReplyPacket,IcmpV6CommonPacket,IcmpV6DestinationUnreachablePacket,IcmpV6EchoReplyPacket,IcmpV6EchoRequestPacket,IcmpV6HomeAgentAddressDiscoveryReplyPacket,IcmpV6HomeAgentAddressDiscoveryRequestPacket,IcmpV6InvokingPacketPacket,IcmpV6MobilePrefixAdvertisementPacket,IcmpV6MobilePrefixSolicitationPacket,IcmpV6NeighborAdvertisementPacket,IcmpV6NeighborSolicitationPacket,IcmpV6PacketTooBigPacket,IcmpV6ParameterProblemPacket,IcmpV6RedirectPacket,IcmpV6RouterAdvertisementPacket,IcmpV6RouterSolicitationPacket,IcmpV6TimeExceededPacket,IllegalPacket,IpSelector,IpV4Packet,IpV6ExtDestinationOptionsPacket,IpV6ExtFragmentPacket,IpV6ExtHopByHopOptionsPacket,IpV6ExtOptionsPacket,IpV6ExtRoutingPacket,IpV6ExtUnknownPacket,IpV6Packet,LinuxSllPacket,LlcPacket,PppPacket,PppSelector,RadiotapPacket,SctpPacket,SimplePacket,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
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfacePacket.BuilderThis interface is designed to be implemented by builder classes for packet objects.static interfacePacket.HeaderThe interface representing a packet's header.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <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.<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.BuildergetBuilder()Returns a new Builder object populated with this object's fields' values.Packet.HeadergetHeader()Returns the Header object representing this packet's header.PacketgetOuterOf(java.lang.Class<? extends Packet> clazz)Returns the outer packet object of a packet objectget(clazz)returns.PacketgetPayload()Returns the Packet object representing this packet's payload.byte[]getRawData()Returns this packet's raw data.intlength()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
-
get
<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
-
getOuterOf
Packet getOuterOf(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
<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
-
-