java.lang.Object
java.lang.Record
org.jnetpcap.util.PcapPacketRef
- Record Components:
abi
- platform specific ABI (Abstract Binary Interface)header
- raw pcap header in a memory segmentdata
- raw packet data in a memory segment
A utility class which holds references to native pcap header and native pcap
packet data. The scope of these addresses is libpcap packet scope and should
be used with great care or VM crashes can occur.
- Author:
- Sly Technologies Inc, repos@slytechs.com
-
Constructor Summary
ConstructorDescriptionPcapPacketRef
(Object abi, MemorySegment header, MemorySegment data) Creates an instance of aPcapPacketRef
record class. -
Method Summary
Modifier and TypeMethodDescriptionabi()
Returns the value of theabi
record component.int
Capture length of the packet.data()
Returns the value of thedata
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.header()
Returns the value of theheader
record component.byte[]
toArray()
Returns byte[] representation of the entire packet.byte[]
toArray
(int offset, int length) Returns an array containing only the packet bytes starting atoffset
andoffset + length
.final String
toString()
Returns a string representation of this record class.long
tvSec()
The timestamp in seconds in epoch time.long
tvUsec()
The timestamp fraction of a second.int
Wire length of the packet.
-
Constructor Details
-
Method Details
-
toArray
public byte[] toArray()Returns byte[] representation of the entire packet.- Returns:
- the byte[] containing packet bytes
-
captureLength
public int captureLength()Capture length of the packet.- Returns:
- the capture length pcap header field value
-
wireLength
public int wireLength()Wire length of the packet.- Returns:
- the wire length pcap header field value
-
tvSec
public long tvSec()The timestamp in seconds in epoch time.- Returns:
- the epoch seconds since Jan 1st, 1970.
-
tvUsec
public long tvUsec()The timestamp fraction of a second.- Returns:
- fraction of a second in micros or nanos.
-
toArray
public byte[] toArray(int offset, int length) Returns an array containing only the packet bytes starting atoffset
andoffset + length
.- Parameters:
offset
- the offset offset into the packetlength
- number of bytes starting at the offset- Returns:
- the byte[] containing the selected bytes
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
abi
-
header
-
data
-