#include <ServiceTable.h>
Inheritance diagram for ServiceTable::
Public Methods | |
ServiceTable () | |
Create the ServiceTable. More... | |
virtual | ~ServiceTable () |
Destroy the ServiceTable. More... | |
int | listenService () |
Listens for connections from remote nodes and keeps the connection lists updated. More... | |
int | connectService () |
Tries to connect to a remote node. More... | |
int | disconnectService (int serviceNumber) |
Disconnect a virtual circuit with the specified connection descriptor. More... | |
int | sendData (int serviceNumber, u_char *buf, int bufLength) |
Causes "length" bytes of data stored at "msg" to be sent through the connection specified by the connection descriptor. More... | |
int | receiveData (int serviceNumber, u_char *buf, int bufLength) |
Reassembles the data received on a service number. More... | |
void | repairConnectionImpl (ServiceEntry *) |
This is a thread that gets called when a VC has been broken. More... | |
int | generateConnectionDescriptor () |
Generate a unique connection descriptor. More... | |
int | generateServiceNumber () |
Generate a unique service number. More... | |
void | handleNetworkEvent (int eventCode, int vcn, NpPacket *packet) |
Called by network layer to inform the service table that something is up. More... | |
int | sendDataPacket (int serviceNumber, TpPacket *queue) |
Sends data over the network by making a request to the networkLayer to send it. More... | |
NetworkLayer * | getNetworkLayer () |
Return the network layer. More... | |
virtual void | toStream (std::ostream &out) |
Static Public Methods | |
void * | repairConnection (void *arg) |
This is a thread that gets called when a VC has been broken. More... | |
Private Methods | |
ServiceEntry * | getServiceEntry (int serviceNumber) |
Return the ServiceEntry associated with the serviceNum. More... | |
ServiceEntry * | getServiceEntryByDescriptor (int connectionDescriptor) |
Return the ServiceEntry associated with the serviceNum. More... | |
void | addServiceEntry (ServiceEntry *) |
Add the service entry object to the table. More... | |
bool | removeServiceEntry (int serviceNumber) |
Remove the specified service entry from the table. More... | |
bool | serviceExists (int serviceNumber) |
Returns true if the service exists. More... | |
bool | handleDataPacket (int connectionDescriptor, NpPacket *packet) |
This function is called by the network layer. More... | |
int | signalListenComplete (int connectionDescriptor) |
Called by network layer on a CONNECT message. More... | |
int | signalConnectComplete (int connectionDescriptor) |
The network layer calls this function when it receives an EST message. More... | |
void | signalDisconnect (int connectionDescriptor, NpPacket *packet) |
Called by network layer when it receives a FIN packet. More... | |
void | signalBreak (int connectionDescriptor) |
This function is called by the network layer. More... | |
Private Attributes | |
list< ServiceEntry *> | m_serviceList |
a linked list of ServiceEntry's. More... | |
Mutex | m_serviceListLock |
lock for service list. More... | |
NetworkLayer * | m_networkLayer |
the network layer. More... | |
Counter | m_serviceCount |
Used to assign new service numbers, service number of 0 is an error. More... | |
Counter | m_descriptorCount |
Used to assign new connection descriptors, 0 is an error. More... | |
int | m_receiveWindowSize |
the receive window size for ALL receive windows. More... | |
bool | m_listening |
signifies whether the service table is listening for an EST message. More... | |
ThreadMessageQueue< ServiceEntry > | m_listenQueue |
an event queue. More... | |
bool | m_listenThreadKilled |
Used when destroying the service table, this variable is used to signal to the listen thread to kill itself. More... | |
Friends | |
class | ServiceTableCommand |
A service number is the number given to a client of this system. A connection descriptor is a VCN. However, the connection descriptor can change during a transmission.
A service entry is kept around until disconnectService is called with its service number. If this is not called for every connection created or accepted, there will be a memory leak.
Definition at line 26 of file ServiceTable.h.
|
Create the ServiceTable. This creates the NetworkLayer. Definition at line 19 of file ServiceTable.cpp. |
|
Destroy the ServiceTable.
Definition at line 40 of file ServiceTable.cpp. |
|
Add the service entry object to the table.
Definition at line 111 of file ServiceTable.cpp. Referenced by connectService(), and listenService().
|
|
Tries to connect to a remote node. It will try a up to CONNECTION_MAX_TRIES times before giving up.
Definition at line 145 of file ServiceTable.cpp. Referenced by TransportLayer::connect().
|
|
Disconnect a virtual circuit with the specified connection descriptor.
Definition at line 242 of file ServiceTable.cpp. Referenced by TransportLayer::disconnect(), and signalDisconnect().
|
|
Generate a unique connection descriptor.
Reimplemented from NetworkLayerListener. Definition at line 474 of file ServiceTable.cpp. Referenced by ServiceEntry::toConnectingState(), and ServiceEntry::toReconnectingState().
|
|
Generate a unique service number.
Definition at line 329 of file ServiceTable.cpp. Referenced by ServiceEntry::connectionAccepted(), and ServiceEntry::toConnectingState().
|
|
Return the network layer.
Definition at line 66 of file ServiceTable.cpp. Referenced by TransportLayer::getNetworkLayer().
|
|
Return the ServiceEntry associated with the serviceNum.
Definition at line 75 of file ServiceTable.cpp. Referenced by disconnectService(), receiveData(), sendData(), sendDataPacket(), and serviceExists().
|
|
Return the ServiceEntry associated with the serviceNum.
Definition at line 93 of file ServiceTable.cpp. Referenced by handleDataPacket(), signalBreak(), signalConnectComplete(), signalDisconnect(), and signalListenComplete().
|
|
This function is called by the network layer. Gives the data packet to the SAR object for the specified connection.
Definition at line 625 of file ServiceTable.cpp. Referenced by handleNetworkEvent().
|
|
Called by network layer to inform the service table that something is up.
Reimplemented from NetworkLayerListener. Definition at line 484 of file ServiceTable.cpp. |
|
Listens for connections from remote nodes and keeps the connection lists updated. only upon receipt of a server connection does this function return. It adds new connections to the connection lists, and removes connections that have died. It also kills a service if requested and there are no more connections running on that service. Definition at line 196 of file ServiceTable.cpp. Referenced by TransportLayer::listenAccept().
|
|
Reassembles the data received on a service number. Note: BAD things happen if service entry deleted while this is happening.
Definition at line 309 of file ServiceTable.cpp. Referenced by TransportLayer::receive().
|
|
Remove the specified service entry from the table.
Definition at line 121 of file ServiceTable.cpp. Referenced by connectService(), disconnectService(), and repairConnectionImpl().
|
|
This is a thread that gets called when a VC has been broken. We repair the connection and then restart transmission.
Definition at line 362 of file ServiceTable.cpp. |
|
This is a thread that gets called when a VC has been broken. We repair the connection and then restart transmission.
Definition at line 387 of file ServiceTable.cpp. Referenced by repairConnection().
|
|
Causes "length" bytes of data stored at "msg" to be sent through the connection specified by the connection descriptor. This function blocks till return. Upon return, application should be able to write-over the data at "msg" without affecting the actual data sent. Note: Its BAD if entry gets deleted midway through a send.
Definition at line 280 of file ServiceTable.cpp. Referenced by TransportLayer::send().
|
|
Sends data over the network by making a request to the networkLayer to send it. Return the number of bytes sent if packet sent successfully, or PB_BAD_SERVICE if the service doesnt exist. Reimplemented from PacketWriter. Definition at line 650 of file ServiceTable.cpp. |
|
Returns true if the service exists.
Definition at line 338 of file ServiceTable.cpp. |
|
This function is called by the network layer. Spawns a repair thread to fix the broken connection. Definition at line 536 of file ServiceTable.cpp. Referenced by handleNetworkEvent(), and signalDisconnect().
|
|
The network layer calls this function when it receives an EST message.
Definition at line 591 of file ServiceTable.cpp. Referenced by handleNetworkEvent().
|
|
Called by network layer when it receives a FIN packet.
Definition at line 509 of file ServiceTable.cpp. Referenced by handleNetworkEvent().
|
|
Called by network layer on a CONNECT message.
Definition at line 566 of file ServiceTable.cpp. Referenced by handleNetworkEvent().
|
|
Reimplemented from BasicObject. Definition at line 661 of file ServiceTable.cpp. |
|
Definition at line 57 of file ServiceTable.h. |
|
Used to assign new connection descriptors, 0 is an error.
Definition at line 100 of file ServiceTable.h. |
|
an event queue.
Definition at line 109 of file ServiceTable.h. |
|
Used when destroying the service table, this variable is used to signal to the listen thread to kill itself.
Definition at line 113 of file ServiceTable.h. |
|
signifies whether the service table is listening for an EST message.
Definition at line 106 of file ServiceTable.h. |
|
the network layer.
Definition at line 94 of file ServiceTable.h. |
|
the receive window size for ALL receive windows.
Definition at line 103 of file ServiceTable.h. |
|
Used to assign new service numbers, service number of 0 is an error.
Definition at line 97 of file ServiceTable.h. |
|
a linked list of ServiceEntry's.
Definition at line 88 of file ServiceTable.h. |
|
lock for service list.
Definition at line 91 of file ServiceTable.h. |