Interface PacketReceiver

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
AbstractPacketReceiver, PacketDissectorReceiver

public interface PacketReceiver extends AutoCloseable
PacketReceiver relies on preview features of the Java platform:
Programs can only use PacketReceiver when preview features are enabled.
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 Details

    • isNativePacketReceiverSupported

      static boolean isNativePacketReceiverSupported()
      Checks if is native packet dispatcher supported.
      Returns:
      true, if is native packet dispatcher supported
    • javaPacketReceiver

      static PacketReceiver javaPacketReceiver(PacketReceiverConfig config)
      Java packet dispatcher.
      Parameters:
      config - the config
      Returns:
      the packet dispatcher
    • nativePacketReceiver

      static PacketReceiver nativePacketReceiver(PacketReceiverConfig config)
      Native packet dispatcher.
      Parameters:
      config - the config
      Returns:
      the packet dispatcher
    • packetReceiver

      static PacketReceiver packetReceiver(PacketReceiverConfig config)
      Packet dispatcher.
      Parameters:
      config - the config
      Returns:
      the packet dispatcher
    • receivePacketWithDispatch

      <U> int receivePacketWithDispatch(int count, PcapProHandler.OfPacket<U> sink, U user)
      Dispatch packet.
      Type Parameters:
      U - the generic type
      Parameters:
      count - the count
      sink - the sink
      user - 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 count
      sink - the sink
      user - the user
      packetFactory - 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

      <U> int receivePacketWithLoop(int count, PcapProHandler.OfPacket<U> sink, U user)
      Loop packet.
      Type Parameters:
      U - the generic type
      Parameters:
      count - the count
      sink - the sink
      user - 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 hdr
      pktData - the pkt data
      session - 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 buffer
      mpacket - the mpacket
      caplen - the caplen
      wirelen - the wirelen
      timestamp - the timestamp
      Returns:
      the packet
    • onNativeCallbackException

      void onNativeCallbackException(Throwable e, int caplen, int wirelen)
      On native callback exception.
      Parameters:
      e - the e
      caplen - the caplen
      wirelen - the wirelen
    • getPacketWithNextExtended

      com.slytechs.jnet.protocol.Packet getPacketWithNextExtended() throws org.jnetpcap.PcapException, TimeoutException
      Next ex packet.
      Returns:
      the packet
      Throws:
      org.jnetpcap.PcapException - the pcap exception
      TimeoutException - the timeout exception
    • getPacketWithNext

      com.slytechs.jnet.protocol.Packet getPacketWithNext() throws org.jnetpcap.PcapException
      Next packet.
      Returns:
      the packet
      Throws:
      org.jnetpcap.PcapException - the pcap exception
    • close

      void close()
      Close.
      Specified by:
      close in interface AutoCloseable
      See Also:
    • activate

      void activate()
      Activate.