net.clackrouter.protocol
Class VNSProtocolManager

java.lang.Object
  extended by java.lang.Thread
      extended by net.clackrouter.protocol.VNSProtocolManager
All Implemented Interfaces:
java.lang.Runnable

public class VNSProtocolManager
extends java.lang.Thread

Establishes a connection with VNS server, receives packets and propagates them to the Clack Client. Also receives packets from the Clack Client and sends them to the VNS server.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
VNSProtocolManager(java.lang.String server, int port)
           
 
Method Summary
 VNSClose checkForVNSCloseCommand()
          Performs a test to see if the VNS server is sending us a CLOSE command.
 void connect(java.lang.String server, int port)
          Establish a connection to the VNS server for this protocol manager
 void disconnectFromVNS()
          Signals the protocol manager to exit
 void doAuth(java.lang.String username, java.lang.String auth_key)
           
 VNSData getData()
          Supplies the next data chunk from the VNS server
 VNSHWInfo getHardwareInfo()
          Loops until it receives the hardware information from the VNS server about this ProtocolManager's host.
 java.lang.String getHostName()
           
 int getPort()
           
 java.lang.String getServer()
           
 int getTopology()
           
 boolean isConnected()
          Tests that the protocol manager is still connected to the VNS server
 void run()
          Main processing loop for the ProtocolManager thread This is simply a loop in which the ProtocolManager checks if it has been told to stop, then sleeps, then both tries to read a single command from the server and send one command from its outgoing queue.
 void sendData(VNSData data)
          Send data to the VNS server (currently supports only Packet data)
 void sendOpenCommand(short topologyID, java.lang.String virtualRouterID, java.lang.String username)
          Sends an OPEN command to the VNS server to initiate a session
 void setRouter(Router r)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VNSProtocolManager

public VNSProtocolManager(java.lang.String server,
                          int port)
                   throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

connect

public void connect(java.lang.String server,
                    int port)
             throws java.lang.Exception
Establish a connection to the VNS server for this protocol manager

Parameters:
server - server to connect to
port - port to connect to
Throws:
java.lang.Exception

run

public void run()
Main processing loop for the ProtocolManager thread This is simply a loop in which the ProtocolManager checks if it has been told to stop, then sleeps, then both tries to read a single command from the server and send one command from its outgoing queue. Note that both incoming and outgoing queues are accessed asynchronously by the Router.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

isConnected

public boolean isConnected()
Tests that the protocol manager is still connected to the VNS server


disconnectFromVNS

public void disconnectFromVNS()
Signals the protocol manager to exit


getHardwareInfo

public VNSHWInfo getHardwareInfo()
                          throws java.lang.Exception
Loops until it receives the hardware information from the VNS server about this ProtocolManager's host.

Throws:
java.lang.Exception

doAuth

public void doAuth(java.lang.String username,
                   java.lang.String auth_key)
            throws java.lang.Exception
Throws:
java.lang.Exception

sendOpenCommand

public void sendOpenCommand(short topologyID,
                            java.lang.String virtualRouterID,
                            java.lang.String username)
                     throws java.lang.Exception
Sends an OPEN command to the VNS server to initiate a session

Throws:
java.lang.Exception

getData

public VNSData getData()
                throws java.lang.Exception
Supplies the next data chunk from the VNS server

Throws:
java.lang.Exception

checkForVNSCloseCommand

public VNSClose checkForVNSCloseCommand()
                                 throws java.lang.Exception
Performs a test to see if the VNS server is sending us a CLOSE command.

Throws:
java.lang.Exception

sendData

public void sendData(VNSData data)
              throws java.lang.Exception
Send data to the VNS server (currently supports only Packet data)

Throws:
java.lang.Exception

setRouter

public void setRouter(Router r)

getTopology

public int getTopology()

getHostName

public java.lang.String getHostName()

getPort

public int getPort()

getServer

public java.lang.String getServer()