net.sourceforge.jpcap.client
Class CaptureTool

java.lang.Object
  |
  +--net.sourceforge.jpcap.client.CaptureTool
All Implemented Interfaces:
PacketListener, RawPacketListener

public class CaptureTool
extends java.lang.Object
implements RawPacketListener, PacketListener

Tool with text console for controlling packet capture.


Field Summary
protected static java.lang.String MODE_OBJECT
           
protected static java.lang.String MODE_RAW
           
protected static java.lang.String MODE_TERSE
           
protected static java.lang.String MODE_VERBOSE
           
 
Constructor Summary
CaptureTool()
          Create a new capture tool.
 
Method Summary
 boolean activateUi()
          Active the graphical packet view.
protected  boolean autoDetect()
          Attempt to detect and open a capture device.
 CaptureStatistics capture(int count)
          Capture packets.
 void clearHistory()
          Clear the capture history.
 int dumpHistory()
          Dump the capture history buffer contents.
 java.lang.String getDevice()
          Fetch the capture device name.
 java.lang.String getFilter()
          Fetch the filter expression.
 CaptureHistory getHistory()
          Fetch a reference to the history buffer.
 int getLinkLayerType()
          Fetch the link-layer type.
 java.lang.String getMode()
          Fetch the capture mode.
 int getNetmask()
          Fetch the netmask for the current device.
 int getNetwork()
          Fetch the network number for the current device.
 int getSnaplen()
          Fetch the snapshot length.
 int getTimeout()
          Fetch the capture timeout value.
protected  void initializeConsole()
          Initialize the tool's console.
protected  void initializeSystem()
          Initialize the packet capture system.
static boolean isModeValid(java.lang.String pmode)
          Check if a proposed mode is valid.
static void main(java.lang.String[] args)
          Packet capture.
 void packetArrived(Packet packet)
           
 void rawPacketArrived(RawPacket rawPacket)
           
 void setDevice(java.lang.String device)
          Set and open the capture device.
 void setFilter(java.lang.String filter)
          Set the packet filter expression.
 void setMaxHistorySize(int size)
          Clear the capture history.
 void setMode(java.lang.String mode)
          Set the capture mode.
 void setSnaplen(int snaplen)
          Set the snapshot length.
 void setTimeout(int timeout)
          Set the capture timeout value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_RAW

protected static java.lang.String MODE_RAW

MODE_OBJECT

protected static java.lang.String MODE_OBJECT

MODE_VERBOSE

protected static java.lang.String MODE_VERBOSE

MODE_TERSE

protected static java.lang.String MODE_TERSE
Constructor Detail

CaptureTool

public CaptureTool()
Create a new capture tool.
Method Detail

rawPacketArrived

public void rawPacketArrived(RawPacket rawPacket)
Specified by:
rawPacketArrived in interface RawPacketListener

packetArrived

public void packetArrived(Packet packet)
Specified by:
packetArrived in interface PacketListener

initializeSystem

protected void initializeSystem()
Initialize the packet capture system.

autoDetect

protected boolean autoDetect()
Attempt to detect and open a capture device.

initializeConsole

protected void initializeConsole()
Initialize the tool's console.

clearHistory

public void clearHistory()
Clear the capture history.

setMaxHistorySize

public void setMaxHistorySize(int size)
Clear the capture history.

dumpHistory

public int dumpHistory()
Dump the capture history buffer contents.

activateUi

public boolean activateUi()
Active the graphical packet view.

getNetwork

public int getNetwork()
               throws CaptureConfigurationException
Fetch the network number for the current device.

getNetmask

public int getNetmask()
               throws CaptureConfigurationException
Fetch the netmask for the current device.

getLinkLayerType

public int getLinkLayerType()
                     throws CaptureConfigurationException,
                            CaptureDeviceOpenException
Fetch the link-layer type.

setDevice

public void setDevice(java.lang.String device)
               throws CaptureDeviceOpenException
Set and open the capture device.

capture

public CaptureStatistics capture(int count)
                          throws CaptureDeviceOpenException,
                                 InvalidFilterException,
                                 CapturePacketException
Capture packets.

getDevice

public java.lang.String getDevice()
Fetch the capture device name.

setFilter

public void setFilter(java.lang.String filter)
               throws InvalidFilterException
Set the packet filter expression.

getFilter

public java.lang.String getFilter()
Fetch the filter expression.

setMode

public void setMode(java.lang.String mode)
Set the capture mode.

getMode

public java.lang.String getMode()
Fetch the capture mode.

isModeValid

public static boolean isModeValid(java.lang.String pmode)
Check if a proposed mode is valid.

setTimeout

public void setTimeout(int timeout)
Set the capture timeout value.

getTimeout

public int getTimeout()
Fetch the capture timeout value.

setSnaplen

public void setSnaplen(int snaplen)
Set the snapshot length.

getSnaplen

public int getSnaplen()
Fetch the snapshot length.

getHistory

public CaptureHistory getHistory()
Fetch a reference to the history buffer.

main

public static void main(java.lang.String[] args)
Packet capture.