|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjpcap.JpcapCaptor
public class JpcapCaptor
This class is used to capture packets or read packets from a captured file.
| Field Summary | |
|---|---|
int |
dropped_packets
Number of dropped packets |
int |
received_packets
Number of received packets |
| Method Summary | |
|---|---|
void |
breakLoop()
Set a flag that will force processPacket() and loopPacket() to return rather than looping. |
void |
close()
Closes the opened interface of dump file. |
int |
dispatchPacket(int count,
PacketReceiver handler)
Deprecated. |
static NetworkInterface[] |
getDeviceList()
Returns the interfaces that can be used for capturing. |
java.lang.String |
getErrorMessage()
Returns an error message |
JpcapSender |
getJpcapSenderInstance()
Obtains an instance of JpcapSender that uses the same interface to send packets. |
Packet |
getPacket()
Captures a single packet. |
int |
getPacketReadTimeout()
Returns the socket read timeout (SO_RCVTIMEO) for the socket used to read packets from the kernel. |
boolean |
isNonBlockinMode()
Checks if the current setting is in "non-blocking" mode or not. |
int |
loopPacket(int count,
PacketReceiver handler)
Captures the specified number of packets consecutively. |
static JpcapCaptor |
openDevice(NetworkInterface intrface,
int snaplen,
boolean promisc,
int to_ms)
Opens the specified network interface, and returns an instance of this class. |
static JpcapCaptor |
openFile(java.lang.String filename)
Opens a dump file created by tcpdump or Ethereal, and returns an instance of this class. |
int |
processPacket(int count,
PacketReceiver handler)
Captures the specified number of packets consecutively. Unlike loopPacket(), this method returns (althrough not guaranteed) when the timeout expires. |
void |
setFilter(java.lang.String condition,
boolean optimize)
Sets a filter. |
void |
setNonBlockingMode(boolean nonblocking)
Sets/unsets "non-blocking" mode |
boolean |
setPacketReadTimeout(int millis)
Sets the socket read timeout (SO_RCVTIMEO) for the socket used to read packets from the kernel. |
void |
updateStat()
Updates received_packets and
dropped_packets. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public int received_packets
updateStat()public int dropped_packets
updateStat()| Method Detail |
|---|
public static NetworkInterface[] getDeviceList()
public static JpcapCaptor openDevice(NetworkInterface intrface,
int snaplen,
boolean promisc,
int to_ms)
throws java.io.IOException
intrface - The network interface to capture packetssnaplen - Max number of bytes captured at oncepromisc - If true, the inferface becomes promiscuous modeto_ms - Timeout of
processPacket().
Not all platforms support a timeout; on platforms that don't,
the timeout is ignored.
On platforms that support a timeout, a zero value will cause Jpcap
to wait forever to allow enough packets to arrive, with no timeout.
java.io.IOException - Raised when the specified interface cannot be opened
public static JpcapCaptor openFile(java.lang.String filename)
throws java.io.IOException
filename - File name of the dump file
java.io.IOException - If the file cannot be openedpublic void close()
public Packet getPacket()
public int processPacket(int count,
PacketReceiver handler)
count - Number of packets to be capturedhandler - an instnace of JpcapHandler that analyzes the captured packets
public int loopPacket(int count,
PacketReceiver handler)
Unlike processPacket(), this method ignores the timeout. This method also does not support "non-blocking" mode.
count - Number of packets to be capturedhandler - an instnace of JpcapHandler that analyzes the captured packets
@Deprecated
public int dispatchPacket(int count,
PacketReceiver handler)
public void setNonBlockingMode(boolean nonblocking)
nonblocking - TRUE to set "non-blocking" mode. FALSE to set "blocking" modepublic boolean isNonBlockinMode()
public void breakLoop()
Note that processPacket() and loopPacket() will not return after this flag is set UNTIL a packet is received or a read timeout occurs. By default, there is no read timeout. See comments in setPacketReadTimeout().
public boolean setPacketReadTimeout(int millis)
This is currently only supported on UNIX.
millis - Timeout in milliseconds; 0 for no timeout.
public int getPacketReadTimeout()
This is currently only supported on UNIX.
public void setFilter(java.lang.String condition,
boolean optimize)
throws java.io.IOException
condition - a string representation of the filteroptimize - If true, the filter is optimized
java.io.IOException - Raised if the filter condition cannot be compiled or
installedpublic void updateStat()
received_packets and
dropped_packets.
public java.lang.String getErrorMessage()
public JpcapSender getJpcapSenderInstance()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||