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
public record PcapPacketRef(Object abi, MemorySegmentPREVIEW header, MemorySegmentPREVIEW data)
extends Record
PcapPacketRef
relies on preview features of the Java platform:
PcapPacketRef
refers to one or more preview APIs:MemorySegment
.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
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, MemorySegmentPREVIEW header, MemorySegmentPREVIEW 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
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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
Returns the value of theabi
record component.- Returns:
- the value of the
abi
record component
-
header
Returns the value of theheader
record component.- Returns:
- the value of the
header
record component
-
data
Returns the value of thedata
record component.- Returns:
- the value of the
data
record component
-
PcapPacketRef
when preview features are enabled.