|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This is the packet capture interface. It is implemented by both the packet capture system (PacketCapture) and the simulator (PacketCaptureSimulator).
The interface has two major components: methods that a client uses to register for packet events and methods that a client calls in order to setup and initiate packet capture.
Field Summary | |
static int |
DEFAULT_SNAPLEN
Snapshot length. |
static int |
DEFAULT_TIMEOUT
Default capture timeout in milliseconds. |
Method Summary | |
void |
addPacketListener(PacketListener objListener)
Register a packet object listener with this capture system. |
void |
addRawPacketListener(RawPacketListener rawListener)
Register a raw packet listener with this capture system. |
void |
capture(int count)
Capture packets. |
void |
close()
Close the capture device. |
java.lang.String |
findDevice()
Detect a network device suitable for packet capture. |
int |
getLinkLayerType()
Fetch the link layer type for the specified device. |
int |
getNetmask(java.lang.String device)
Fetch the network mask for the specified device. |
int |
getNetwork(java.lang.String device)
Fetch the network number for the specified device. |
int |
getSnapshotLength()
Get the snapshot length given that network device is open. |
CaptureStatistics |
getStatistics()
Fetch statistics on captured packets. |
void |
open(java.lang.String device,
boolean promiscuous)
Open a network device for data capture. |
void |
open(java.lang.String device,
int snaplen,
boolean promiscuous,
int timeout)
Open a network device for data capture. |
void |
openOffline(java.lang.String fileName)
Open a tcpdump-formatted savefile. |
void |
removePacketListener(PacketListener objListener)
Deregister a packet object listener from this capture system. |
void |
removeRawPacketListener(RawPacketListener rawListener)
Deregister a raw packet listener from this capture system. |
void |
setFilter(java.lang.String filterExpression,
boolean optimize)
Create, compile and activate a filter from a filter expression. |
Field Detail |
public static final int DEFAULT_SNAPLEN
public static final int DEFAULT_TIMEOUT
Method Detail |
public void open(java.lang.String device, boolean promiscuous) throws CaptureDeviceOpenException
device
- the name of the network device.
Examples of valid network devices on linux are 'eth0' and 'ppp0'.promiscuous
- whether or not the device should be opened in
promiscuous mode.
CaptureDeviceOpenException
public void open(java.lang.String device, int snaplen, boolean promiscuous, int timeout) throws CaptureDeviceOpenException
device
- the name of the network device.
Examples of valid network devices on linux are 'eth0' and 'ppp0'.snaplen
- the 'snapshot' length. Defines the maximum number of
bytes to save from each captured packet.promiscuous
- whether or not the device should be opened in
promiscuous mode.timeout
- the packet capture timeout in milliseconds.
CaptureDeviceOpenException
public void openOffline(java.lang.String fileName) throws CaptureFileOpenException
fileName
- the name of the savefile.
CaptureFileOpenException
public void setFilter(java.lang.String filterExpression, boolean optimize) throws InvalidFilterException
filterExpression
- the filter expression. For example,
the expression "host techno" would filter only packets sent or
arriving at the host named techno.optimize
- whether or not the resulting bpf code is optimized
internally by libpcap.
InvalidFilterException
public void capture(int count) throws CapturePacketException
count
- the number of packets to capture.
If count is negative, capture will block forever, unless an exception
is thrown.
CapturePacketException
public CaptureStatistics getStatistics()
public void close()
public java.lang.String findDevice() throws CaptureDeviceNotFoundException
CaptureDeviceNotFoundException
public int getNetwork(java.lang.String device) throws CaptureConfigurationException
device
- the name of the network device.
CaptureConfigurationException
public int getNetmask(java.lang.String device) throws CaptureConfigurationException
device
- the name of the network device.
CaptureConfigurationException
public int getLinkLayerType() throws CaptureConfigurationException
CaptureConfigurationException
public int getSnapshotLength()
public void addRawPacketListener(RawPacketListener rawListener)
rawListener
- the raw packet listener to add to the notification
list.public void removeRawPacketListener(RawPacketListener rawListener)
rawListener
- the raw packet listener to remove from the
notification list.public void addPacketListener(PacketListener objListener)
objListener
- the packet listener to add to the notification list.public void removePacketListener(PacketListener objListener)
objListener
- the packet listener to remove from the
notification list.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |