com.gremwell.jnetbridge
Class Port

java.lang.Object
  extended by com.gremwell.jnetbridge.Port
Direct Known Subclasses:
PcapPort

public abstract class Port
extends java.lang.Object

This class represents an abstract port. Subclasses are expected to do the necessary to obtain received packets and to pass it to ingress() method, which will pass them to the listener. Subclasses have to override send() method and make necessary arrangements to send given packet. Subclasses are expected to increment corresponding counters to provide information about port activity.


Field Summary
protected  PortListener listener
           
protected  java.lang.String name
           
protected  int received
           
protected  int sent
           
 
Method Summary
abstract  void close()
          The clients have to invoke this method to release resources allocated for this port, if any.
 java.lang.String getName()
           
 java.lang.String getStat()
           
abstract  void send(org.jnetpcap.nio.JBuffer packet)
          Invoked by the clients.
 void setListener(PortListener listener)
          Set a PortListener the port has to pass ingress packets to.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected final java.lang.String name

listener

protected PortListener listener

received

protected int received

sent

protected int sent
Method Detail

setListener

public void setListener(PortListener listener)
Set a PortListener the port has to pass ingress packets to.

Parameters:
listener -

close

public abstract void close()
The clients have to invoke this method to release resources allocated for this port, if any.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getName

public java.lang.String getName()

getStat

public java.lang.String getStat()
Returns:
A string containing current packet and error counters.

send

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