Module org.jnetpcap

Class PcapSendQueue

java.lang.Object
org.jnetpcap.windows.PcapSendQueue
All Implemented Interfaces:
AutoCloseable

public class PcapSendQueue extends Object implements AutoCloseable
PcapSendQueue relies on preview features of the Java platform:
  • PcapSendQueue refers to one or more preview APIs: MemorySegment.
Programs can only use PcapSendQueue when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A queue of raw packets that will be sent to the network with transmit on Microsoft Windows platforms.
Author:
Sly Technologies Inc, repos@slytechs.com, mark
  • Constructor Details

    • PcapSendQueue

      public PcapSendQueue(int capacity)
      Instantiates a new pcap send queue.
      Parameters:
      capacity - Maximum size of the queue, in bytes
  • Method Details

    • close

      public void close()
      Close and destroy the send queue.
      Specified by:
      close in interface AutoCloseable
      See Also:
    • queue

      public int queue(MemorySegmentPREVIEW header, MemorySegmentPREVIEW packet)
      Add a packet to a send queue.

      pcap_sendqueue_queue() adds a packet at the end of the send queue pointed by the queue parameter. pkt_header points to a pcap_pkthdr structure with the timestamp and the length of the packet, pkt_data points to a buffer with the data of the packet.

      The pcap_pkthdr structure is the same used by WinPcap and libpcap to store the packets in a file, therefore sending a capture file is straightforward. 'Raw packet' means that the sending application will have to include the protocol headers, since every packet is sent to the network 'as is'. The CRC of the packets needs not to be calculated, because it will be transparently added by the network interface.

      Parameters:
      header - the header
      packet - the packet
      Returns:
      the int
    • queue

      public int queue(PcapHeader header, byte[] packet, int offset)
      Add a packet to a send queue.

      pcap_sendqueue_queue() adds a packet at the end of the send queue pointed by the queue parameter. pkt_header points to a pcap_pkthdr structure with the timestamp and the length of the packet, pkt_data points to a buffer with the data of the packet.

      The pcap_pkthdr structure is the same used by WinPcap and libpcap to store the packets in a file, therefore sending a capture file is straightforward. 'Raw packet' means that the sending application will have to include the protocol headers, since every packet is sent to the network 'as is'. The CRC of the packets needs not to be calculated, because it will be transparently added by the network interface.

      Parameters:
      header - the header
      packet - the packet
      offset - the offset
      Returns:
      the int
    • maxlen

      public int maxlen()
      The value of the {code pcap_sendqueue_t.maxlen} structure field.
      Returns:
      the maxlen or capacity, in bytes, of this send queue
    • len

      public int len()
      The value of the {code pcap_sendqueue_t.len} structure field.
      Returns:
      the length or current size, in bytes, of this send queue