net.sourceforge.jpcap.capture
Class PacketCaptureBase
java.lang.Object
net.sourceforge.jpcap.capture.PacketDispatcher
net.sourceforge.jpcap.capture.PacketCaptureBase
- All Implemented Interfaces:
- PacketDispatchCapable
- Direct Known Subclasses:
- PacketCapture
public abstract class PacketCaptureBase
- extends PacketDispatcher
This class contains base functionality shared by
both the simulator and the actual packet capture system.
Regardless of whether 'real' packets are being captured off a network
or 'fake' packets are being generated by the simulator,
the packet dispatch logic is the same.
This class is abstract because it is useless standalone. The
packet capture system which inherits from this class must provide a
way of feeding data to handlePacket() where it is then dispatched to
listeners.
- Version:
- $Revision: 1.1 $
- Author:
- Patrick Charles and Jonas Lehmann, Esmond Pitt
- Last modified by:
- $Author: esmondpitt $
- Last modified at:
- $Date: 2008/08/21 02:57:57 $
Field Summary |
protected int |
linkType
The link-type code for the currently open network device. |
Method Summary |
protected void |
handlePacket(int length,
int caplen,
int seconds,
int useconds,
ByteBuffer dbb)
Handle arriving packets. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
linkType
protected int linkType
- The link-type code for the currently open network device.
The type is queried and set in open() and then utilized when
packets are received by handlePacket().
PacketCaptureBase
public PacketCaptureBase()
handlePacket
protected void handlePacket(int length,
int caplen,
int seconds,
int useconds,
ByteBuffer dbb)
- Handle arriving packets.
Arriving packets are dispatched to registered packet listeners.
If caplen is smaller than length, then the packet was truncated
because the amount of data on the wire exceeded the snapshot length
specified when open() was called.
In the simulator case, fake packets are generated and this method
called with the fabricated data. In the case of the capture system,
the native library libjpcap calls the method back.
- Parameters:
length
- the length of the packet off of the wire.caplen
- the number of bytes actually captured.seconds
- the seconds component of the timestamp.useconds
- the microseconds component of the timestamp.dbb
- the contents of the captured packet in a direct ByteBuffer:
note that the direct content must be copied out immediately,
because it is only valid for the duration of this callback.