org.jnetpcap
Class PcapDumper

java.lang.Object
  extended by 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.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Constructor Summary
PcapDumper()
           
 
Method Summary
 void close()
          Closes a savefile.
 void dump(long seconds, int useconds, int caplen, int len, java.nio.ByteBuffer packet)
          Outputs a packet to the "savefile" opened with dumpOpen.
 void dump(PcapPktHdr hdr, java.nio.ByteBuffer packet)
          Outputs a packet to the "savefile" opened with dumpOpen.
 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.
 long ftell()
          Returns the current file position for the "savefile", representing the number of bytes written by Pcap.dumpOpen and Pcap.dump.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PcapDumper

public PcapDumper()
Method Detail

dump

public void dump(PcapPktHdr hdr,
                 java.nio.ByteBuffer packet)
Outputs a packet to the "savefile" opened with dumpOpen. Note that the calling arguments are suitable for use with dipstach() or loop().

Parameters:
hdr -
packet -

dump

public void dump(long seconds,
                 int useconds,
                 int caplen,
                 int len,
                 java.nio.ByteBuffer packet)
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.