Module org.jnetpcap
Package org.jnetpcap

Class PcapDumper

java.lang.Object
org.jnetpcap.PcapDumper
All Implemented Interfaces:
Flushable, AutoCloseable

public class PcapDumper extends Object implements AutoCloseable, Flushable
PcapDumper relies on preview features of the Java platform:
Programs can only use PcapDumper when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Dump packets to a capture file.
Author:
Sly Technologies Inc, repos@slytechs.com, mark
  • Method Details

    • close

      public void close()
      Close a savefile being written to.

      Closes the ``savefile.''

      Specified by:
      close in interface AutoCloseable
      Since:
      libpcap 0.4
      See Also:
    • dump

      public void dump(MemorySegmentPREVIEW header, MemorySegmentPREVIEW packet) throws IOException
      Write a packet to a capture file.

      pcap_dump() outputs a packet to the ``savefile'' opened with pcap_dump_open(3PCAP). Note that its calling arguments are suitable for use with pcap_dispatch(3PCAP) or pcap_loop(3PCAP). If called directly, the user parameter is of type pcap_dumper_t as returned by pcap_dump_open().

      Parameters:
      header - the header
      packet - the packet
      Throws:
      IOException - Signals that an I/O exception has occurred.
      Since:
      libpcap 0.4
    • dumpFile

      public MemorySegmentPREVIEW dumpFile()
      Get the OS standard I/O stream for a savefile being written.
      Returns:
      address to OS's stream I/O handle
      Since:
      libpcap 0.8
      See Also:
    • flush

      public void flush() throws IOException
      Flush to a savefile packets dumped.

      pcap_dump_flush() flushes the output buffer to the ``savefile,'' so that any packets written with pcap_dump(3PCAP) but not yet written to the ``savefile'' will be written.

      Specified by:
      flush in interface Flushable
      Throws:
      IOException - Signals that an I/O exception has occurred.
      Since:
      libpcap 0.8
      See Also:
    • toString

      public String toString()
      Information about this pcap dumper.
      Overrides:
      toString in class Object
      Returns:
      the formatted string