java.lang.Object
org.pcap4j.packet.AbstractPacket
org.pcap4j.packet.SimplePacket
- All Implemented Interfaces:
Serializable,Iterable<Packet>,Packet
- Direct Known Subclasses:
CompressedPacket,EncryptedPacket,FragmentedPacket,UnknownPacket
- Since:
- pcap4j 1.4.0
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.pcap4j.packet.AbstractPacket
AbstractPacket.AbstractBuilder, AbstractPacket.AbstractHeaderNested classes/interfaces inherited from interface org.pcap4j.packet.Packet
Packet.Header -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]private static final long -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSimplePacket(byte[] rawData, int offset, int length) protectedSimplePacket(SimplePacket.Builder builder) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringThis method builds the valuetoString()will return by concatenating the header's string representation and the payload's string representation.protected intThis method calculates the valuehashCode()will return using the header's hash code and the payload's hash code.booleanIndicates whether some other object is "equal to" this one.byte[]Returns this packet's raw data.intlength()Returns the packet length in bytes.protected abstract Stringmodifier()Methods inherited from class org.pcap4j.packet.AbstractPacket
buildHexString, buildRawData, calcLength, contains, get, getBuilder, getHeader, getOuterOf, getPayload, hashCode, iterator, toHexString, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
rawData
private final byte[] rawData
-
-
Constructor Details
-
SimplePacket
protected SimplePacket(byte[] rawData, int offset, int length) -
SimplePacket
-
-
Method Details
-
length
public int length()Description copied from class:AbstractPacketReturns the packet length in bytes. This method callscalcLength()and caches the return value when it is called for the first time, and then, this method returns the cached value from the second time.- Specified by:
lengthin interfacePacket- Overrides:
lengthin classAbstractPacket- Returns:
- the length of the byte stream of the packet represented by this object in bytes
-
getRawData
public byte[] getRawData()Description copied from class:AbstractPacketReturns this packet's raw data. This method callsbuildRawData()and caches the return value when it is called for the first time, and then, this method returns the cached value from the second time. More correctly, this method returns a copy of the cached value, so that the cache can't be changed.- Specified by:
getRawDatain interfacePacket- Overrides:
getRawDatain classAbstractPacket- Returns:
- this packet's raw data, namely the byte stream which is actually sent through real network
-
buildString
Description copied from class:AbstractPacketThis method builds the valuetoString()will return by concatenating the header's string representation and the payload's string representation. If you write this subclass which represents a packet with extra parts (e.g. a trailer), you need to override this method.- Overrides:
buildStringin classAbstractPacket- Returns:
- a string representation of this object
-
modifier
-
equals
Description copied from class:AbstractPacketIndicates whether some other object is "equal to" this one. This method firstly compares this packet's header using the header's equals(Object) method, then compares this packet's payload using the payload's equals(Object) method. If you write this subclass with fields which represent somethings other than header or payload, you need to override this method.- Overrides:
equalsin classAbstractPacket
-
calcHashCode
protected int calcHashCode()Description copied from class:AbstractPacketThis method calculates the valuehashCode()will return using the header's hash code and the payload's hash code. If you write this subclass which represents a packet with extra parts (e.g. a trailer), you need to override this method.- Overrides:
calcHashCodein classAbstractPacket- Returns:
- a calculated hash code value for the object
-