com.gremwell.jnetbridge
Class PcapPort

java.lang.Object
  extended by com.gremwell.jnetbridge.Port
      extended by com.gremwell.jnetbridge.PcapPort

public class PcapPort
extends Port

This class implements a port receiving and sending network packets with libpcap, through jnetpcap library. Upon instantiation PCAP handle gets initialized, but the packet pumping thread does not get started until start(). The clients of this class can invoke start()/stop() several times. The PCAP handle gets closed upon invocation of close() method. After that it does not get reopened by start().


Field Summary
 
Fields inherited from class com.gremwell.jnetbridge.Port
listener, name, received, sent
 
Constructor Summary
PcapPort(java.lang.String name)
          Prepare the interface to receive and send packets.
 
Method Summary
 void close()
          The clients have to invoke this method to release resources allocated for this port, if any.
 java.lang.String getStat()
           
 void send(org.jnetpcap.nio.JBuffer packet)
          Invoked by the clients.
 void start()
          Start packet pumping thread.
 void stop()
          Stop packet pumping thread.
 
Methods inherited from class com.gremwell.jnetbridge.Port
getName, setListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PcapPort

public PcapPort(java.lang.String name)
         throws PcapException
Prepare the interface to receive and send packets. May throw an exception if an error occurs.

Parameters:
name - Name of the interface to open
Throws:
PcapException
Method Detail

send

public void send(org.jnetpcap.nio.JBuffer packet)
Description copied from class: Port
Invoked by the clients. The subclasses of Port have to send the packet immediately or enqueue it.

Specified by:
send in class Port

start

public void start()
Start packet pumping thread. The thread will run until stop() or close().


stop

public void stop()
Stop packet pumping thread. Invoked by close().


close

public void close()
Description copied from class: Port
The clients have to invoke this method to release resources allocated for this port, if any.

Specified by:
close in class Port

getStat

public java.lang.String getStat()
Overrides:
getStat in class Port
Returns:
A string containing current packet and error counters.
See Also:
Port.getStat()