org.jnetpcap
Class PcapDumper

java.lang.Object
org.jnetpcap.PcapDumper

public class PcapDumper

extends java.lang.Object

Class peered with native pcap_dumper structure. A dumper that
allows a previously opened pcap session to be dumped to a "savefile" which is
a file containing captured packets in pcap file format. To get an object of
type PcapDumper, use method Pcap.dumpOpen.

dump

Outputs a packet to the "savefile" opened with dumpOpen.
Note that the calling arguments are suitable for use with dipstach() or
loop(). This a convenience method, which takes the parameters of PcapPkthdr
class directly.

Parameters:

seconds - timestamp in seconds

useconds - timestamp fraction in microseconds

caplen - how much was captured

len - actual packet length on wire

packet - packet buffer

ftell

public long ftell()

Returns the current file position for the "savefile", representing the
number of bytes written by Pcap.dumpOpen and
Pcap.dump.

Returns:

position within the file, or -1 on error

flush

public int flush()

Flushes the output buffer to the "savefile", so that any packets written
with Pcap.dump but not yet written to the "savefile" will be
written.

Returns:

0 on success, -1 on error

close

public void close()

Closes a savefile. The existing PcapDumper object on which close method was
invoked is no longer usable and needs to be discarded.