Module com.slytechs.jnet.jnetpcap
Class PacketDissectorReceiver
java.lang.Object
com.slytechs.jnet.jnetpcap.internal.PacketDissectorReceiver
- All Implemented Interfaces:
PacketReceiver,AutoCloseable
PacketDissectorReceiver relies on preview features of the Java platform:
PacketDissectorReceiverrefers 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.
A packet dissector and dispatcher.
- Author:
- Sly Technologies Inc, repos@slytechs.com, Mark Bednarczyk
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a new packet dispatcher. -
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 current dissector.longGets the dropped caplen count.longGets the dropped packet count.longGets the dropped wirelen count.com.slytechs.jnet.protocol.PacketGets the packet with next.com.slytechs.jnet.protocol.PacketGets the packet with next extended.longGets the received caplen count.longGets the received packet count.longGets the received wirelen count.voidonNativeCallbackException(Throwable e, int caplen, int wirelen) On native callback exception.<U> com.slytechs.jnet.protocol.PacketprocessPacket(MemorySegmentPREVIEW pcapHdr, MemorySegmentPREVIEW pktData, ArenaPREVIEW arena) 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.voidsetPcapDispatcher(org.jnetpcap.internal.PcapDispatcher pcapDispatcher) Sets the pcap dispatcher.
-
Constructor Details
-
PacketDissectorReceiver
Instantiates a new packet dispatcher.- Parameters:
config- the config
-
-
Method Details
-
activate
public void activate()Activate.- Specified by:
activatein interfacePacketReceiver- See Also:
-
close
public void close()Close.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacePacketReceiver- See Also:
-
getCaptureStatistics
Gets the capture statistics.- Specified by:
getCaptureStatisticsin interfacePacketReceiver- Returns:
- the capture statistics
-
getDescriptorType
public com.slytechs.jnet.protocol.core.constants.PacketDescriptorType getDescriptorType()Gets the descriptor type.- Specified by:
getDescriptorTypein interfacePacketReceiver- Returns:
- the descriptorType
-
getDissector
public com.slytechs.jnet.protocol.descriptor.PacketDissector getDissector()Gets the current dissector.- Specified by:
getDissectorin interfacePacketReceiver- Returns:
- the dissector
-
getDroppedCaplenCount
public long getDroppedCaplenCount()Gets the dropped caplen count.- Returns:
- the dropped caplen count
- See Also:
-
getDroppedPacketCount
public long getDroppedPacketCount()Gets the dropped packet count.- Returns:
- the dropped packet count
- See Also:
-
getDroppedWirelenCount
public long getDroppedWirelenCount()Gets the dropped wirelen count.- Returns:
- the dropped wirelen count
- See Also:
-
getPacketWithNext
public com.slytechs.jnet.protocol.Packet getPacketWithNext() throws org.jnetpcap.PcapExceptionGets the packet with next.- Specified by:
getPacketWithNextin interfacePacketReceiver- Returns:
- the packet with next
- Throws:
org.jnetpcap.PcapException- the pcap exception- See Also:
-
getPacketWithNextExtended
public com.slytechs.jnet.protocol.Packet getPacketWithNextExtended() throws org.jnetpcap.PcapException, TimeoutExceptionGets the packet with next extended.- Specified by:
getPacketWithNextExtendedin interfacePacketReceiver- Returns:
- the packet with next extended
- Throws:
org.jnetpcap.PcapException- the pcap exceptionTimeoutException- the timeout exception- See Also:
-
getReceivedCaplenCount
public long getReceivedCaplenCount()Gets the received caplen count.- Returns:
- the received caplen count
- See Also:
-
getReceivedPacketCount
public long getReceivedPacketCount()Gets the received packet count.- Returns:
- the received packet count
- See Also:
-
getReceivedWirelenCount
public long getReceivedWirelenCount()Gets the received wirelen count.- Returns:
- the received wirelen count
- See Also:
-
onNativeCallbackException
Description copied from interface:PacketReceiverOn native callback exception.- Specified by:
onNativeCallbackExceptionin interfacePacketReceiver- Parameters:
e- the ecaplen- the caplenwirelen- the wirelen- See Also:
-
processPacket
public <U> com.slytechs.jnet.protocol.Packet processPacket(ByteBuffer buffer, MemorySegmentPREVIEW mpacket, int caplen, int wirelen, long timestamp) Description copied from interface:PacketReceiverProcess packet.- Specified by:
processPacketin interfacePacketReceiver- Type Parameters:
U- the generic type- Parameters:
buffer- the buffermpacket- the mpacketcaplen- the caplenwirelen- the wirelentimestamp- the timestamp- Returns:
- the packet
- See Also:
-
processPacket
public <U> com.slytechs.jnet.protocol.Packet processPacket(MemorySegmentPREVIEW pcapHdr, MemorySegmentPREVIEW pktData, ArenaPREVIEW arena) Process packet.- Specified by:
processPacketin interfacePacketReceiver- Type Parameters:
U- the generic type- Parameters:
pcapHdr- the pcap hdrpktData- the pkt dataarena- the arena- Returns:
- the packet
- See Also:
-
receivePacketWithDispatch
public <U> int receivePacketWithDispatch(int count, PcapProHandler.OfPacket<U> sink, U user, Supplier<com.slytechs.jnet.protocol.Packet> packetFactory) Receive packet with dispatch.- Specified by:
receivePacketWithDispatchin interfacePacketReceiver- Type Parameters:
U- the generic type- Parameters:
count- the countsink- the sinkuser- the userpacketFactory- the packet factory- Returns:
- the int
- See Also:
-
receivePacketWithDispatch
Dispatch packet.- Specified by:
receivePacketWithDispatchin interfacePacketReceiver- Type Parameters:
U- the generic type- Parameters:
count- the countsink- the sinkuser- the user- Returns:
- the int
-
receivePacketWithLoop
Loop packet.- Specified by:
receivePacketWithLoopin interfacePacketReceiver- Type Parameters:
U- the generic type- Parameters:
count- the countsink- the sinkuser- the user- Returns:
- the int
-
setPcapDispatcher
public void setPcapDispatcher(org.jnetpcap.internal.PcapDispatcher pcapDispatcher) Sets the pcap dispatcher.- Parameters:
pcapDispatcher- the new pcap dispatcher
-
PacketDissectorReceiverwhen preview features are enabled.