Module com.slytechs.jnet.jnetpcap
Interface PacketReceiver
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractPacketReceiver,PacketDissectorReceiver
PacketReceiver relies on preview features of the Java platform:
PacketReceiverrefers to one or more preview APIs:Arena,MemorySegment.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Packet dispatcher with protocol level support.
- Author:
- Sly Technologies Inc, repos@slytechs.com
-
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Activate.voidclose()Close.Gets the capture statistics.com.slytechs.jnet.protocol.core.constants.PacketDescriptorTypeGets the descriptor type.com.slytechs.jnet.protocol.descriptor.PacketDissectorGets the dissector.com.slytechs.jnet.protocol.PacketNext packet.com.slytechs.jnet.protocol.PacketNext ex packet.static booleanChecks if is native packet dispatcher supported.static PacketReceiverJava packet dispatcher.static PacketReceiverNative packet dispatcher.voidonNativeCallbackException(Throwable e, int caplen, int wirelen) On native callback exception.static PacketReceiverpacketReceiver(PacketReceiverConfig config) Packet dispatcher.<U> com.slytechs.jnet.protocol.PacketprocessPacket(MemorySegmentPREVIEW pcapHdr, MemorySegmentPREVIEW pktData, ArenaPREVIEW session) Process packet.<U> com.slytechs.jnet.protocol.PacketprocessPacket(ByteBuffer buffer, MemorySegmentPREVIEW mpacket, int caplen, int wirelen, long timestamp) Process packet.<U> intreceivePacketWithDispatch(int count, PcapProHandler.OfPacket<U> sink, U user) Dispatch packet.<U> intreceivePacketWithDispatch(int count, PcapProHandler.OfPacket<U> sink, U user, Supplier<com.slytechs.jnet.protocol.Packet> packetFactory) Receive packet with dispatch.<U> intreceivePacketWithLoop(int count, PcapProHandler.OfPacket<U> sink, U user) Loop packet.
-
Method Details
-
isNativePacketReceiverSupported
static boolean isNativePacketReceiverSupported()Checks if is native packet dispatcher supported.- Returns:
- true, if is native packet dispatcher supported
-
javaPacketReceiver
Java packet dispatcher.- Parameters:
config- the config- Returns:
- the packet dispatcher
-
nativePacketReceiver
Native packet dispatcher.- Parameters:
config- the config- Returns:
- the packet dispatcher
-
packetReceiver
Packet dispatcher.- Parameters:
config- the config- Returns:
- the packet dispatcher
-
receivePacketWithDispatch
Dispatch packet.- Type Parameters:
U- the generic type- Parameters:
count- the countsink- the sinkuser- the user- Returns:
- the int
-
receivePacketWithDispatch
<U> int receivePacketWithDispatch(int count, PcapProHandler.OfPacket<U> sink, U user, Supplier<com.slytechs.jnet.protocol.Packet> packetFactory) Receive packet with dispatch.- Type Parameters:
U- the generic type- Parameters:
count- the countsink- the sinkuser- the userpacketFactory- the packet factory- Returns:
- the int
-
getDissector
com.slytechs.jnet.protocol.descriptor.PacketDissector getDissector()Gets the dissector.- Returns:
- the dissector
-
getDescriptorType
com.slytechs.jnet.protocol.core.constants.PacketDescriptorType getDescriptorType()Gets the descriptor type.- Returns:
- the descriptor type
-
receivePacketWithLoop
Loop packet.- Type Parameters:
U- the generic type- Parameters:
count- the countsink- the sinkuser- the user- Returns:
- the int
-
getCaptureStatistics
CaptureStatistics getCaptureStatistics()Gets the capture statistics.- Returns:
- the capture statistics
-
processPacket
<U> com.slytechs.jnet.protocol.Packet processPacket(MemorySegmentPREVIEW pcapHdr, MemorySegmentPREVIEW pktData, ArenaPREVIEW session) Process packet.- Type Parameters:
U- the generic type- Parameters:
pcapHdr- the pcap hdrpktData- the pkt datasession- the session- Returns:
- the packet
-
processPacket
<U> com.slytechs.jnet.protocol.Packet processPacket(ByteBuffer buffer, MemorySegmentPREVIEW mpacket, int caplen, int wirelen, long timestamp) Process packet.- Type Parameters:
U- the generic type- Parameters:
buffer- the buffermpacket- the mpacketcaplen- the caplenwirelen- the wirelentimestamp- the timestamp- Returns:
- the packet
-
onNativeCallbackException
On native callback exception.- Parameters:
e- the ecaplen- the caplenwirelen- the wirelen
-
getPacketWithNextExtended
com.slytechs.jnet.protocol.Packet getPacketWithNextExtended() throws org.jnetpcap.PcapException, TimeoutExceptionNext ex packet.- Returns:
- the packet
- Throws:
org.jnetpcap.PcapException- the pcap exceptionTimeoutException- the timeout exception
-
getPacketWithNext
com.slytechs.jnet.protocol.Packet getPacketWithNext() throws org.jnetpcap.PcapExceptionNext packet.- Returns:
- the packet
- Throws:
org.jnetpcap.PcapException- the pcap exception
-
close
void close()Close.- Specified by:
closein interfaceAutoCloseable- See Also:
-
activate
void activate()Activate.
-
PacketReceiverwhen preview features are enabled.