forest-net
an overlay networks for large-scale virtual worlds
|
The CtlPkt class is used to pack and unpack forest control messages. More...
Classes | |
class | AdminTable |
Class that implements a table of information about Forest administrators. More... | |
class | Avatar |
Class that implements a simulated avatar in a virtual world. More... | |
class | ClientTable |
Class that implements a table of information about users. More... | |
struct | QueuePair |
struct | EventStruct |
struct | ThreadInfo |
class | LinkMod |
Class used to represent information used to modify a link. More... | |
class | ComtInfo |
Maintains information about the comtrees in a Forest network. More... | |
class | ComtreeRegister |
Class that implements a register of information about comtrees, for use by ClientMgr. More... | |
class | ComtreeTable |
Class that implements a table of information on comtrees. More... | |
class | CpHandler |
This class is designed for use with multi-threaded controllers (NetMgr, ComtCtl, etc) that use control packets to communicate with routers and other components. More... | |
class | CtlPkt |
This class provides a mechanism for handling forest signalling packets. More... | |
class | DBConnector |
class | Forest |
Miscellaneous utility functions. More... | |
class | Host |
Host implements a forest host. More... | |
class | IfaceTable |
class | IoProcessor |
class | LinkTable |
Maintains information about a Forest router's virtual links. More... | |
class | Logger |
This is a very simple logger class to control the logging of error messages. More... | |
class | Misc |
class | Monitor |
Monitor observes status reports sent by Avatars in a virtual world and reports them to a remote client that implements a graphical display of the moving Avatars. More... | |
class | NetBuffer |
This class implements a simple user-space buffer for use when reading from a stream socket. More... | |
class | NetInfo |
Maintains information about an entire Forest network. More... | |
struct | prefixInfo |
struct | clientInfo |
class | Np4d |
Network programming for dummies. More... | |
class | Packet |
Class that defines fields in Forest packets. More... | |
class | PacketFilter |
Support class used by PacketLog to control packet logging. More... | |
class | PacketLog |
class | PacketStore |
Maintains a set of packets with selected header fields and a separate set of buffers. More... | |
class | PacketStoreTs |
Maintains a set of packets with selected header fields and a separate set of buffers. More... | |
class | Queue |
This class implements a simple thread-safe queue for communication among threads. More... | |
class | QuManager |
The QuManager class, manages a set of queues for each of the links in a router. More... | |
class | Quu |
This class implements a simple thread-safe queue for communication among threads. More... | |
class | RateSpec |
This class stores bit rates and packet rates for links in both directions. More... | |
class | Repeater |
Class to manage repeated sending of control packets. More... | |
class | RepeatHandler |
Class to aid in handling repeated control packets. More... | |
struct | RouterInfo |
Structure used to carry information about a router. More... | |
class | Router |
class | RouterControl |
This class handles incoming and outgoing control packets on behalf of a router core. More... | |
class | RouterCore |
class | RouterInProc |
class | RouterOutProc |
class | RouteTable |
Maintains a set of routes. More... | |
class | StatsModule |
class | Substrate |
This class provides a common substrate used by various controllers. More... | |
Typedefs | |
typedef int | pktx |
typedef int32_t | fAdr_t |
denotes a forest address | |
typedef uint32_t | comt_t |
denotes a comtree | |
typedef uint8_t | flgs_t |
flags field from packet header | |
typedef uint32_t | buffer_t [Forest::BUF_SIZ/sizeof(uint32_t)] |
typedef in_addr_t | ipa_t |
typedef in_port_t | ipp_t |
typedef int | fltx |
Enumerations | |
enum | acctRecType { UNDEF, NEWSESSION, CANCELSESSION, CONNECT_REC, DISCONNECT_REC } |
Used to identify the type of an accounting record. More... | |
Functions | |
bool | init (ipa_t nmIp1, ipa_t myIp1) |
Initializes sockets, and acts as a psuedo-constructor. More... | |
bool | bootMe (ipa_t nmIp, ipa_t myIp, fAdr_t &nmAdr, fAdr_t &myAdr, fAdr_t &rtrAdr, ipa_t &rtrIp, ipp_t &rtrPort, uint64_t &nonce) |
Send a boot request to NetMgr and process configuraton packets. More... | |
void * | handler (void *qp) |
Control packet handler. More... | |
bool | handleClient (int sock, CpHandler &cph) |
Handle a connection from a client. More... | |
bool | loginDialog (int sock, NetBuffer &buf, string &clientName) |
Carry out login dialog and verify that client/password is correct. More... | |
void | userDialog (int sock, CpHandler &cph, NetBuffer &buf, string &clientName) |
bool | newSession (int sock, CpHandler &cph, NetBuffer &buf, string &clientName, string &reply) |
Handle a request for a new forest session. More... | |
void | getProfile (NetBuffer &buf, string &clientName, string &reply) |
Handle a get profile request. More... | |
void | updateProfile (NetBuffer &buf, string &clientName, string &reply) |
Handle an update profile request. More... | |
void | changePassword (NetBuffer &buf, string &clientName, string &reply) |
Handle a change password request. More... | |
void | uploadPhoto (int sock, NetBuffer &buf, string &clientName, string &reply) |
Handle an upload photo request. More... | |
void | getSessions (NetBuffer &buf, string &clientName, string &reply) |
Respond to getSessions request from a client. More... | |
void | cancelSession (NetBuffer &buf, string &clientName, string &reply) |
void | addComtree (NetBuffer &buf, string &clientName, string &reply) |
bool | handleConnDisc (pktx px, CtlPkt &cp, CpHandler &cph) |
Handle a connect or disconnect message from the NetBgr. More... | |
void | writeAcctRecord (const string &cname, fAdr_t cliAdr, ipa_t cliIp, fAdr_t rtrAdr, acctRecType recType) |
Writes a record to the accounting file. More... | |
void | writeRecord (int clx) |
Write a client record to clientFile. More... | |
bool | login (NetBuffer &buf, string &clientName, string &reply) |
Handle a login request. More... | |
bool | newAccount (NetBuffer &buf, string &clientName, string &reply) |
Handle a new account request. More... | |
int | checkPrivileges (string clientName, string targetName) |
Verify that a client may perform privileged operations on a target. More... | |
void | uploadFile (string &type, int sock, NetBuffer &buf, string &clientName, string &reply) |
Handle an upload request. More... | |
void | cancelSession (NetBuffer &buf, string &clientName, CpHandler &cph, string &reply) |
Respond to cancelSessions request from a client. More... | |
void | cancelAllSessions (NetBuffer &buf, string &clientName, CpHandler &cph, string &reply) |
Respond to cancelAllSessions request from a client. More... | |
bool | sendReqPkt (int sock, CtlPkt &reqPkt, fAdr_t target, CtlPkt &replyPkt) |
Send a request packet, then wait for and return reply. More... | |
bool | setAttributes (CtlPkt &cpTemplate, CpTypeIndex type, CtlPkt &reqPkt) |
Set request packet attributes, based on template. More... | |
void | parseLine (string line, list< string > &tokenList) |
Parse an input line and produce a list of tokens. More... | |
void | buildWordList (string line, list< string > &wordList) |
Build a list of words from a line. More... | |
bool | validTokenList (list< string > tokenList) |
Verify that a tokenList is valid Specificialy, check that if it starts with a command phrase or abbreviation, then it's a valid command phrase or abbreviation. More... | |
void | processTokenList (list< string > tokenList, fAdr_t &target, CpTypeIndex &cpType, CtlPkt &cpTemplate) |
Process a list of tokens that has passed basic checks. More... | |
void | posResponse (CtlPkt &) |
int | main (int argc, char *argv[]) |
usage: Console NetMgrIp More... | |
bool | init (const char *topoFile) |
Initialization of NetMgr. More... | |
void | cleanup () |
bool | handleConsole (int sock, CpHandler &cph) |
Handle a connection from a remote console. More... | |
void | addFilter (NetBuffer &buf, string &reply, CpHandler &cph) |
Allocate log filter in router and return filter index to Console. More... | |
void | modFilter (NetBuffer &buf, string &reply, CpHandler &cph) |
Modify log filter in router. More... | |
void | dropFilter (NetBuffer &buf, string &reply, CpHandler &cph) |
Drop log filter from router. More... | |
void | getFilter (NetBuffer &buf, string &reply, CpHandler &cph) |
Get log filter from router and return to Console. More... | |
void | getFilterSet (NetBuffer &buf, string &reply, CpHandler &cph) |
Get log filter set from router and return to Console. More... | |
void | getLoggedPackets (NetBuffer &buf, string &reply, CpHandler &cph) |
Get logged packets from router and return to Console. More... | |
void | enableLocalLog (NetBuffer &buf, string &reply, CpHandler &cph) |
Enable local log in router Reads router name from the socket. More... | |
void | getLinkTable (NetBuffer &buf, string &reply, CpHandler &cph) |
Get link table from router and return to Console. More... | |
void | getComtreeTable (NetBuffer &buf, string &reply, CpHandler &cph) |
Get comtree table from router and return to Console. More... | |
void | getIfaceTable (NetBuffer &buf, string &reply, CpHandler &cph) |
Get iface table from router and return to Console. More... | |
void | getRouteTable (NetBuffer &buf, string &reply, CpHandler &cph) |
Get route table from router and return to Console. More... | |
bool | handleConDisc (pktx px, CtlPkt &cp, CpHandler &cph) |
Handle a connection/disconnection notification from a router. More... | |
bool | handleNewSession (pktx px, CtlPkt &cp, CpHandler &cph) |
Handle a new session request. More... | |
fAdr_t | setupLeaf (int leaf, pktx px, CtlPkt &cp, int rtr, int iface, uint64_t nonce, CpHandler &cph, bool useTunnel) |
Setup a leaf by sending configuration packets to its access router. More... | |
bool | handleCancelSession (pktx px, CtlPkt &cp, CpHandler &cph) |
Handle a cancel session request. More... | |
bool | handleBootLeaf (pktx px, CtlPkt &cp, CpHandler &cph) |
Handle boot process for a pre-configured leaf node. More... | |
uint64_t | generateNonce () |
Return a random nonce suitable for use when connecting a leaf. More... | |
bool | processReply (pktx px, CtlPkt &cp, pktx reply, CtlPkt &repCp, CpHandler &cph, const string &msg) |
Process the reply from an outgoing request packet This method implements a common pattern used by handlers that are configuring routers in response to a received request. More... | |
bool | handleBootRouter (pktx px, CtlPkt &cp, CpHandler &cph) |
Handle a boot request from a router. More... | |
bool | setupEndpoint (int lnk, int rtr, pktx px, CtlPkt &cp, CpHandler &cph, bool useTunnel) |
Configure a link endpoint at a router. More... | |
bool | setupComtree (int ctx, int rtr, pktx px, CtlPkt &cp, CpHandler &cph, bool useTunnel) |
Setup a pre-configured comtree at a booting router. More... | |
bool | findCliRtr (ipa_t cliIp, fAdr_t &rtrAdr) |
Finds the router address of the router based on IP prefix. More... | |
bool | readPrefixInfo (char filename[]) |
Reads the prefix file. More... | |
void | writeAdminRecord (int adx) |
Write a record to the file of network administrators. More... | |
void | getNet (NetBuffer &buf, string &reply) |
void | getLinkSet (NetBuffer &buf, string &reply, CpHandler &cph) |
void | uploadFile (string, int, NetBuffer &, string &, string &) |
bool | init (ipa_t, ipa_t, int, int, const char *topoFile) |
void * | run (void *) |
bool | handleComtreeDisplay (int) |
bool | handleAddComtReq (int, CtlPkt &, CpHandler &) |
bool | handleDropComtReq (int, CtlPkt &, CpHandler &) |
bool | handleJoinComtReq (int, CtlPkt &, CpHandler &) |
bool | handleLeaveComtReq (int, CtlPkt &, CpHandler &) |
bool | handleComtPath (int, CtlPkt &, CpHandler &) |
bool | handleComtNewLeaf (int, CtlPkt &, CpHandler &) |
bool | handleComtPrune (int, CtlPkt &, CpHandler &) |
void | removeSubtree (int, fAdr_t) |
int | newComtreeNum () |
void | releaseComtreeNum (int) |
bool | setupPath (int, list< LinkMod > &, CpHandler &) |
bool | teardownPath (int, list< LinkMod > &, CpHandler &) |
bool | setupComtNode (int, int, CpHandler &) |
bool | teardownComtNode (int, int, CpHandler &) |
bool | setupComtLink (int, int, int, CpHandler &) |
int | setupClientLink (int, fAdr_t, int, CpHandler &) |
bool | teardownClientLink (int, fAdr_t, int, CpHandler &) |
bool | setupComtAttrs (int, int, CpHandler &) |
bool | setComtLinkRates (int, int, int, CpHandler &) |
bool | setComtLeafRates (int, fAdr_t, CpHandler &) |
bool | modComtRates (int, list< LinkMod > &, bool, CpHandler &) |
void | connect () |
void | disconnect () |
void | sendToRemote (int) |
int | recvFromRemote () |
void | sendToForest (int) |
int | rcvFromForest () |
static bool | isSigComt (comt_t comt) |
Determine if comtree is a signalling comtree or not. More... | |
bool | readPrefixInfo (char *) |
void | enablePacketLog (NetBuffer &buf, string &reply, CpHandler &cph) |
void | sendToCons (int) |
int | recvFromCons () |
bool | processArgs (int argc, char *argv[], RouterInfo &args) |
Process command line arguments for starting a forest router. More... | |
Variables | |
const short | NM_PORT = 30122 |
server port# for NetMgr | |
fAdr_t | myAdr |
Forest address of self. More... | |
ipa_t | myIp |
address of interface to use More... | |
fAdr_t | rtrAdr |
Forest address of router. More... | |
ipa_t | rtrIp |
IP address for forest router. | |
ipp_t | rtrPort |
port number for forest router | |
ipa_t | nmIp |
IP address of NetMgr. More... | |
fAdr_t | nmAdr |
Forest address of NetMgr. More... | |
char * | dummyRecord |
dummy record for padding client file More... | |
int | maxRecord |
largest record number in client file More... | |
PacketStoreTs * | ps |
pointer to packet store | |
Substrate * | sub |
substrate for handling packets More... | |
ClientTable * | cliTbl |
data about clients and active sessions | |
Logger * | logger |
error message logger | |
ofstream | acctFile |
stream for writing accounting records | |
fstream | clientFile |
stream for reading/updating client data | |
pthread_mutex_t | clientFileLock |
so only one thread can update at a time | |
static int const | RECORD_SIZE = 256 |
size of a client file record | |
NetInfo * | net |
global view of net topology | |
ComtInfo * | comtrees |
definition of all comtrees More... | |
int | maxComtree |
max# of comtrees | |
int | firstComt |
int | lastComt |
defines range of comtrees controlled | |
UiSetPair * | comtSet |
in-use and unused comtrees | |
pthread_mutex_t | comtSetLock |
used to lock comtSet | |
static const int | NORESPONSE = (1 << 31) |
indicates non-response to ctl pkt | |
static const int | TPSIZE = 500 |
number of concurrent threads at ComtCtl | |
ThreadInfo * | pool |
pool[i]: i-th thread in pool | |
UiSetPair * | threads |
in-use and unused thread indices | |
IdMap * | reqMap |
maps rcvd requests to handling thread | |
IdMap * | tMap |
maps sequence numbers to thread index | |
fAdr_t | cliMgrAdr |
forest address of the client manager | |
fAdr_t | comtCtlAdr |
forest address of the comtree controller | |
int | netMgr |
node number of net manager in NetInfo | |
int | nmRtr |
node number of net manager's router | |
AdminTable * | admTbl |
data about administrators | |
int | numPrefixes |
prefixInfo | prefixes [1000] |
fstream | adminFile |
stream for reading/updating admin data | |
pthread_mutex_t | adminFileLock |
so only one thread can update at a time | |
static int const | RECORD_SIZE = 256 |
size of an admin file record | |
The CtlPkt class is used to pack and unpack forest control messages.
The class has a public field for every field that can be used in in a control packet. To create a control packet, the user constructs a CtlPkt object. The user then specifies selected fields and calls pack, which packs the specified fields into the packet's payload and returns the length of the payload.
To unpack a buffer, the user constructs a CtlPkt object and then calls unpack, specifying the length of the payload. The control packet fields can then be retrieved from the corresponding fields of the CtlPkt object.
The class has a public field for every field that can be used in in a control packet. To create a control packet, the user constructs a CtlPkt object. The user then specifies selected fields and calls pack, which packs the specified fields into the packet's payload the length of the payload.
To unpack a buffer, the user constructs a CtlPkt object and then calls unpack, specifying the length of the payload. The control packet fields can then be retrieved from the corresponding fields of the CtlPkt object.
enum forest::acctRecType |
Used to identify the type of an accounting record.
Definition at line 41 of file ClientMgr.h.
Allocate log filter in router and return filter index to Console.
Reads router name from the socket.
buf | is a reference to a NetBuffer object for the socket |
reply | is a reference to a string to be returned to console |
cph | is a reference to this thread's control packet hander |
Definition at line 465 of file NetMgr.cpp.
bool forest::bootMe | ( | ipa_t | nmIp, |
ipa_t | myIp, | ||
fAdr_t & | nmAdr, | ||
fAdr_t & | myAdr, | ||
fAdr_t & | rtrAdr, | ||
ipa_t & | rtrIp, | ||
ipp_t & | rtrPort, | ||
uint64_t & | nonce | ||
) |
Send a boot request to NetMgr and process configuraton packets.
nmIp | is the ip address of the network manager |
myIp | is the ip address to bind to the local socket |
nmAdr | is a reference to a forest address in which the network manager's address is returned |
myAdr | is a reference to a forest address in which this client manager's address is returned |
rtrAdr | is a reference to a forest address in which this client manager's access router's address is returned |
rtrIp | is a reference to an ip address in which this client manager's access router's ip address is returned |
rtrPort | is a reference to an ip port number in which this client manager's access router's port number is returned |
nonce | is a reference to a 64 bit nonce in which the nonce used by this client manager to connect to the forest network is returned |
Definition at line 107 of file ClientMgr-sav.cpp.
void forest::buildWordList | ( | string | line, |
list< string > & | wordList | ||
) |
Build a list of words from a line.
Creates a list of words from the line, where a word is either an '=' sign, or a string of characters containing neither white space of an '=' sign.
line | is the line to be processed, |
wordList | is the list in which the words are returned |
Definition at line 271 of file Console.cpp.
void forest::cancelAllSessions | ( | NetBuffer & | buf, |
string & | clientName, | ||
CpHandler & | cph, | ||
string & | reply | ||
) |
Respond to cancelAllSessions request from a client.
buf | is a NetBuffer for the socket to the client. |
clientName | is the client's name |
reply | is a string in which a reply to the client can be returned |
Definition at line 849 of file ClientMgr.cpp.
void forest::cancelSession | ( | NetBuffer & | buf, |
string & | clientName, | ||
CpHandler & | cph, | ||
string & | reply | ||
) |
Respond to cancelSessions request from a client.
buf | is a NetBuffer for the socket to the client. |
clientName | is the client's name |
cph | is the control packet handler for this thread |
reply | is a string in which a reply to the client can be returned |
Definition at line 786 of file ClientMgr.cpp.
void forest::changePassword | ( | NetBuffer & | buf, |
string & | clientName, | ||
string & | reply | ||
) |
Handle a change password request.
Reads from the socket to identify the target client. This operation requires either that the target client is the currently logged-in client, or that the logged-in client has administrative privileges.
buf | is a NetBuffer associated with the stream socket to a client |
clientName | is the name of the currently logged-in client |
reply | is a reference to a string in which an error message may be returned if the operation does not succeed. |
Reads from the socket to identify the target admin. This operation requires either that the target admin is the currently logged-in admin, or that the logged-in admin has administrative privileges.
buf | is a NetBuffer associated with the stream socket to an admin |
adminName | is the name of the currently logged-in admin |
reply | is a reference to a string in which an error message may be returned if the operation does not succeed. |
Definition at line 647 of file ClientMgr-sav.cpp.
int forest::checkPrivileges | ( | string | clientName, |
string | targetName | ||
) |
Verify that a client may perform privileged operations on a target.
clientName | is the name of the client who is currently logged in |
targetName | is the name of the client on which some privileged operation is to be performed |
Definition at line 550 of file ClientMgr.cpp.
Drop log filter from router.
Reads router name and filter index from the socket.
buf | is a reference to a NetBuffer object for the socket |
reply | is a reference to a string to be returned to console |
cph | is a reference to this thread's control packet hander |
Definition at line 515 of file NetMgr.cpp.
Enable local log in router Reads router name from the socket.
buf | is a reference to a NetBuffer object for the socket |
reply | is a reference to a string to be returned to console |
cph | is a reference to this thread's control packet hander |
Definition at line 616 of file NetMgr.cpp.
bool forest::findCliRtr | ( | ipa_t | cliIp, |
fAdr_t & | rtrAdr | ||
) |
Finds the router address of the router based on IP prefix.
gives the rtrAdr of the prefix
cliIp | is the ip of the client |
rtrAdr | is the address of the router associated with this IP prefix |
Definition at line 1325 of file NetMgr.cpp.
uint64_t forest::generateNonce | ( | ) |
Return a random nonce suitable for use when connecting a leaf.
Definition at line 1034 of file NetMgr.cpp.
Get comtree table from router and return to Console.
Table is returned as a text string which each entry on a separate line.
buf | is a reference to a NetBuffer object for the socket |
reply | is a reference to a string to be returned to console |
cph | is a reference to this thread's control packet hander |
Definition at line 665 of file NetMgr.cpp.
Get log filter from router and return to Console.
Reads router name and filter index from the socket. Log filter is returned as a string line.
buf | is a reference to a NetBuffer object for the socket |
reply | is a reference to a string to be returned to console |
cph | is a reference to this thread's control packet hander |
Definition at line 538 of file NetMgr.cpp.
Get log filter set from router and return to Console.
Reads router name from the socket. Log filter sets are returned as a text string which each entry on a seprate line.
buf | is a reference to a NetBuffer object for the socket |
reply | is a reference to a string to be returned to console |
cph | is a reference to this thread's control packet hander |
Definition at line 564 of file NetMgr.cpp.
Get iface table from router and return to Console.
Table is returned as a text string which each entry on a separate line.
buf | is a reference to a NetBuffer object for the socket |
reply | is a reference to a string to be returned to console |
cph | is a reference to this thread's control packet hander |
Definition at line 692 of file NetMgr.cpp.
Get link table from router and return to Console.
Table is returned as a text string which each entry on a separate line.
buf | is a reference to a NetBuffer object for the socket |
reply | is a reference to a string to be returned to console |
cph | is a reference to this thread's control packet hander |
Definition at line 638 of file NetMgr.cpp.
Get logged packets from router and return to Console.
Reads router name from the socket. Logged packets are returned as a text string which each entry on a separate line.
buf | is a reference to a NetBuffer object for the socket |
reply | is a reference to a string to be returned to console |
cph | is a reference to this thread's control packet hander |
Definition at line 593 of file NetMgr.cpp.
void forest::getProfile | ( | NetBuffer & | buf, |
string & | clientName, | ||
string & | reply | ||
) |
Handle a get profile request.
Reads from the socket to identify the target client. This operation requires either that the target client is the currently logged-in client, or that the logged-in client has administrative privileges.
buf | is a NetBuffer associated with the stream socket to a client |
clientName | is the name of the currently logged-in client |
reply | is a reference to a string in which an error message may be returned if the operation does not succeed. |
Reads from the socket to identify the target admin.
buf | is a NetBuffer associated with the stream socket to an admin |
adminName | is the name of the currently logged-in admin |
reply | is a reference to a string in which an error message may be returned if the operation does not succeed. |
Definition at line 514 of file ClientMgr-sav.cpp.
Get route table from router and return to Console.
Table is returned as a text string which each entry on a separate line.
buf | is a reference to a NetBuffer object for the socket |
reply | is a reference to a string to be returned to console |
cph | is a reference to this thread's control packet hander |
Definition at line 719 of file NetMgr.cpp.
void forest::getSessions | ( | NetBuffer & | buf, |
string & | clientName, | ||
string & | reply | ||
) |
Respond to getSessions request from a client.
buf | is a NetBuffer for the socket to the client. |
clientName | is the client's name |
reply | is a string in which a reply to the client can be returned |
Definition at line 745 of file ClientMgr-sav.cpp.
Handle boot process for a pre-configured leaf node.
This handler is intended primarily for controllers. It first configures the router, so it will accept new leaf. It then sends leaf configuration information to a new leaf node, including address information for it, and its router, as well as a nonce to be used when it connects.
px | is the index of the incoming boot request packet |
cp | is the control packet (already unpacked) |
cph | is a reference to the control packet handler used to send packets out |
Definition at line 968 of file NetMgr.cpp.
Handle a boot request from a router.
This requires sending a series of control packets to the router to configure its interface table, its link table and its comtree table. When configuration is complete, we send a boot complete message to the router. The operation can fail for a variety of reasons, at different points in the process. Any failure causes a negative reply to be sent back to the original requestor.
px | is the packet number of the request packet |
cp | is the control packet structure for p (already unpacked) |
cph | is the control packet handler for this thread |
Definition at line 1096 of file NetMgr.cpp.
Handle a cancel session request.
px | is the packet number of the request packet |
cp | is the control packet structure for p (already unpacked) |
cph | is the control packet handler for this thread |
Definition at line 927 of file NetMgr.cpp.
bool forest::handleClient | ( | int | sock, |
CpHandler & | cph | ||
) |
Handle a connection from a client.
sock | is a socket number for an open stream socket |
Interprets variety of requests from a remote client, including requests to login, get profile information, change a password, and so forth.
sock | is a socket number for an open stream socket |
Definition at line 288 of file ClientMgr-sav.cpp.
Handle a connection/disconnection notification from a router.
The request is acknowledged and then forwarded to the client manager.
px | is the packet number of the request packet |
cp | is the control packet structure for p (already unpacked) |
cph | is the control packet handler for this thread |
Definition at line 752 of file NetMgr.cpp.
Handle a connect or disconnect message from the NetBgr.
px | is the index of the packet |
cp | is the control packet contained in px |
cph | is a reference to the control packet handler for this thread |
Definition at line 764 of file ClientMgr-sav.cpp.
bool forest::handleConsole | ( | int | sock, |
CpHandler & | cph | ||
) |
Handle a connection from a remote console.
Handle a connection from the remote console.
Interprets variety of requests from a remote console, including requests to login, get information about routers, monitor packet flows and so forth.
sock | is a socket number for an open stream socket |
This involves forwarding the packet to a remote router.
px | is the packet number of the request packet |
cp | is the control packet structure for p (already unpacked) |
return | true on successful completion, else false |
Definition at line 234 of file NetMgr.cpp.
Handle a new session request.
This requires selecting a router and sending a sequence of control messages to configure the router to handle a new client connection. The operation can fail for a variety of reasons, at different points in the process. Any failure causes a negative reply to be sent back to the original requestor.
px | is the packet number of the request packet |
cp | is the control packet structure for p (already unpacked) |
cph | is the control packet handler for this thread |
Definition at line 782 of file NetMgr.cpp.
void * forest::handler | ( | void * | qp) |
Control packet handler.
Main handler for thread.
Control packet handler for client manager.
This method is run as a separate thread and does not terminate until the process does. It communicates with the main thread through a pair of queues, passing packet numbers back and forth across the thread boundary. When a packet number is passed to a handler, the handler "owns" the corresponding packet and can read/write it without locking. The handler is required to free any packets that it no longer needs to the packet store. When the handler has completed the requested operation, it sends a 0 value back to the main thread, signalling that it is available to handle another task. If the main thread passes a negative number through the queue, it is interpreted as a negated socket number, for an accepted stream socket to a remote display application.
qp | is a pair of queues; one is the input queue to the handler, the other is its output queue |
On receiving a control packet in its input queue, it calls the appropriate individual handler. If a negative number is received through the queue, it is interpreted as a negated socket number, for an accepted stream socket.
qp | is a pair of queues; one is the input queue to the handler, the other is its output queue |
This method is run as a separate thread and does not terminate until the process does. It communicates with the main thread through a pair of queues, passing packet numbers back and forth across the thread boundary. When a packet number is passed to a handler, the handler "owns" the corresponding packet and can read/write it without locking. The handler is required free any packets that it no longer needs to the packet store. When the handler has completed the requested operation, it sends a 0 value back to the main thread, signalling that it is available to handle another task.
qp | is a pair of queues; on is the input queue to the handler, the other is its output queue |
Definition at line 245 of file ClientMgr-sav.cpp.
bool forest::init | ( | const char * | topoFile) |
Initialization of NetMgr.
Definition at line 43 of file NetMgr.cpp.
bool forest::init | ( | ipa_t | nmIp1, |
ipa_t | myIp1 | ||
) |
Initializes sockets, and acts as a psuedo-constructor.
nmIp1 | is the IP address of the network manager |
myIp1 | is the IP address to bind sockets to |
Definition at line 50 of file ClientMgr-sav.cpp.
|
inlinestatic |
bool forest::login | ( | NetBuffer & | buf, |
string & | clientName, | ||
string & | reply | ||
) |
Handle a login request.
Reads from the socket to identify client and obtain password
buf | is a NetBuffer associated with the stream socket to a client |
clientName | is a reference to a string in which the name of the client is returned |
reply | is a reference to a string in which an error message may be returned if the operation does not succeed. |
Reads from the socket to identify admin and obtain password
buf | is a NetBuffer associated with the stream socket to an admin |
adminName | is a reference to a string in which the name of the admin is returned |
reply | is a reference to a string in which an error message may be returned if the operation does not succeed. |
Definition at line 378 of file ClientMgr.cpp.
bool forest::loginDialog | ( | int | sock, |
NetBuffer & | buf, | ||
string & | clientName | ||
) |
Carry out login dialog and verify that client/password is correct.
sock | is an open socket to the client |
buf | is a reference to a NetBuffer bound to the socket |
clientName | is a reference to a string in which user's name is retured |
return | true on success, false on failure |
Definition at line 303 of file ClientMgr-sav.cpp.
int forest::main | ( | int | argc, |
char * | argv[] | ||
) |
usage: Console NetMgrIp
Main program for starting a forest router.
Definition at line 31 of file Console.cpp.
Modify log filter in router.
Reads router name and filter index from the socket.
buf | is a reference to a NetBuffer object for the socket |
reply | is a reference to a string to be returned to console |
cph | is a reference to this thread's control packet hander |
Definition at line 491 of file NetMgr.cpp.
bool forest::newAccount | ( | NetBuffer & | buf, |
string & | clientName, | ||
string & | reply | ||
) |
Handle a new account request.
Reads from the socket to identify client and obtain password
buf | is a NetBuffer associated with the stream socket to a client |
clientName | is a reference to a string in which the name of the client is returned |
reply | is a reference to a string in which an error message may be returned if the operation does not succeed. |
Reads from the socket to identify admin and obtain password
buf | is a NetBuffer associated with the stream socket to an admin |
adminName | is a reference to a string in which the name of the admin is returned |
reply | is a reference to a string in which an error message may be returned if the operation does not succeed. |
Definition at line 413 of file ClientMgr.cpp.
void forest::newSession | ( | int | sock, |
CpHandler & | cph, | ||
NetBuffer & | buf, | ||
string & | clientName, | ||
string & | reply | ||
) |
Handle a request for a new forest session.
Reads from the socket to get an optional rate spec.
sock | is the socket number for the socket to the client |
cph | is a reference to the control packet handler, used for sending control packets to the NetMgr |
buf | is a NetBuffer associated with the stream socket to a client |
clientName | is the name of the currently logged-in client |
reply | is a reference to a string in which an error message may be returned if the operation does not succeed. |
Definition at line 435 of file ClientMgr-sav.cpp.
void forest::parseLine | ( | string | line, |
list< string > & | tokenList | ||
) |
Parse an input line and produce a list of tokens.
If the line starts with a command abbreviation or phrase, the first token will be that abbreviation/phrase with no extra white space. Subsequent tokens will take the form word=word.
Definition at line 215 of file Console.cpp.
bool forest::processArgs | ( | int | argc, |
char * | argv[], | ||
RouterInfo & | args | ||
) |
Process command line arguments for starting a forest router.
All arguments are strings of the form "name=value".
argc | is the number of arguments (including the command name) |
argv | contains the command line arguments as C-style strings |
is | a reference to a RouterInfo structure; on return, it will contain all the values that were specified on the command line; unspecified numeric values are set to 0 and unspecified string values are set to the empty string |
Definition at line 24 of file RouterCoreSave.cpp.
bool forest::processReply | ( | pktx | px, |
CtlPkt & | cp, | ||
pktx | reply, | ||
CtlPkt & | repCp, | ||
CpHandler & | cph, | ||
const string & | msg | ||
) |
Process the reply from an outgoing request packet This method implements a common pattern used by handlers that are configuring routers in response to a received request.
The handler typically sends out a series of request packets and must then handle each reply. A missing or negative reply causes a negative response to be sent back to the sender of the original request.
px | is the packet index of the incoming request that initiated the handler |
cp | is the unpacked control packet for px |
reply | is the packet index for a reply to some outgoing control packet that was sent by this handler |
repCp | is a reference to the control packet for reply |
cph | is a reference to this handler's control packet handler |
msg | is an error message to be sent back to the original sender of px, if reply=0 or the associated control packet indicates a failure |
Definition at line 1062 of file NetMgr.cpp.
void forest::processTokenList | ( | list< string > | tokenList, |
fAdr_t & | target, | ||
CpTypeIndex & | cpType, | ||
CtlPkt & | cpTemplate | ||
) |
Process a list of tokens that has passed basic checks.
tokenList | is the list of tokens to be processed. |
target | if the token list includes an assignment of the form "target=forest address", target will be set to the specified forest address on return |
cpType | if the token list starts with a command phrase or abbreviation, cpType will be set to the CpTypeIndex for the corresponding request packet type on return |
cpTemplate | is a control packet in which attribute values are returned; every attribute assignment in the token list updates the corresponding attribute in cpTemplate |
Definition at line 352 of file Console.cpp.
bool forest::readPrefixInfo | ( | char | filename[]) |
Reads the prefix file.
filename | is the name of the prefix file |
Definition at line 1355 of file NetMgr.cpp.
bool forest::sendReqPkt | ( | int | sock, |
CtlPkt & | reqPkt, | ||
fAdr_t | target, | ||
CtlPkt & | replyPkt | ||
) |
Send a request packet, then wait for and return reply.
If no reply received after a second, try again up to five times. Print progress indicator on command line while waiting.
sock | is the socket on which request is to be sent |
reqPkt | is the control packet to be sent |
target | is the forest address of the control packet destination |
replyPkt | will contain the reply packet on a successful return |
Definition at line 149 of file Console.cpp.
bool forest::setAttributes | ( | CtlPkt & | cpTemplate, |
CpTypeIndex | type, | ||
CtlPkt & | reqPkt | ||
) |
Set request packet attributes, based on template.
cpTemplate | is a control packet from which attributes are copied |
type | is the type of the control packet to be sent |
reqPkt | is the formatted control packet on return |
Definition at line 195 of file Console.cpp.
bool forest::setupComtree | ( | int | ctx, |
int | rtr, | ||
pktx | px, | ||
CtlPkt & | cp, | ||
CpHandler & | cph, | ||
bool | useTunnel | ||
) |
Setup a pre-configured comtree at a booting router.
ctx | is the index of the comtree being setup |
rtr | is the number of the router |
px | is the number of the packet that initiated the current operation |
cp | is the control packet for px (already unpacked) |
cph | is a reference to the control packet handler for this thread |
Definition at line 1263 of file NetMgr.cpp.
bool forest::setupEndpoint | ( | int | lnk, |
int | rtr, | ||
pktx | px, | ||
CtlPkt & | cp, | ||
CpHandler & | cph, | ||
bool | useTunnel | ||
) |
Configure a link endpoint at a router.
This method is used when booting a router. It configures a link going to another router.
lnk | is the global link number for the link being configured |
rtr | is the number of the router that is to be configured |
px | is the packet that triggered this operation |
cp | is the control packet from px |
cph | is the handler for this thread |
useTunnel | is an optional parameter that defaults to false; when it is true, it specifies that control packets should be addressed to the tunnel (ip,port) configured in the cph; |
Definition at line 1217 of file NetMgr.cpp.
fAdr_t forest::setupLeaf | ( | int | leaf, |
pktx | px, | ||
CtlPkt & | cp, | ||
int | rtr, | ||
int | iface, | ||
uint64_t | nonce, | ||
CpHandler & | cph, | ||
bool | useTunnel | ||
) |
Setup a leaf by sending configuration packets to its access router.
leaf | is the node number for the leaf if this is a pre-configured leaf for which NetInfo object specifies various leaf parameters; it is 0 for leaf nodes that are added dynamically |
px | is the packet number of the original request packet that initiated the setup process |
cp | is the corresponding control packet (already unpacked) |
rtr | is the node number of the access router for the new leaf |
iface | is the interface of the access router where leaf connects |
nonce | is the nonce that the leaf will use to connect |
cph | is a reference to the control packet handler for the thread handling this operation |
useTunnel | is an optional parameter that defaults to false; when it is true, it specifies that control packets should be addressed to the tunnel (ip,port) configured in the cph; |
Definition at line 830 of file NetMgr.cpp.
void forest::updateProfile | ( | NetBuffer & | buf, |
string & | clientName, | ||
string & | reply | ||
) |
Handle an update profile request.
Reads from the socket to identify the target client. This operation requires either that the target client is the currently logged-in client, or that the logged-in client has administrative privileges.
buf | is a NetBuffer associated with the stream socket to a client |
clientName | is the name of the currently logged-in client |
reply | is a reference to a string in which an error message may be returned if the operation does not succeed. |
Reads from the socket to identify the target admin. This operation requires either that the target admin is the currently logged-in admin, or that the logged-in admin has administrative privileges.
buf | is a NetBuffer associated with the stream socket to an admin |
adminName | is the name of the currently logged-in admin |
reply | is a reference to a string in which an error message may be returned if the operation does not succeed. |
Definition at line 559 of file ClientMgr-sav.cpp.
void forest::uploadFile | ( | string & | type, |
int | sock, | ||
NetBuffer & | buf, | ||
string & | clientName, | ||
string & | reply | ||
) |
Handle an upload request.
Reads from the socket to identify the target client. This operation requires either that the target client is the currently logged-in client, or that the logged-in client has administrative privileges.
sock | is the socket number for the stream socket to the client |
buf | is a NetBuffer associated with the stream socket to a client |
clientName | is the name of the currently logged-in client |
reply | is a reference to a string in which an error message may be returned if the operation does not succeed. |
Definition at line 695 of file ClientMgr.cpp.
void forest::uploadPhoto | ( | int | sock, |
NetBuffer & | buf, | ||
string & | clientName, | ||
string & | reply | ||
) |
Handle an upload photo request.
Reads from the socket to identify the target client. This operation requires either that the target client is the currently logged-in client, or that the logged-in client has administrative privileges.
sock | is the socket number for the stream socket to the client |
buf | is a NetBuffer associated with the stream socket to a client |
clientName | is the name of the currently logged-in client |
reply | is a reference to a string in which an error message may be returned if the operation does not succeed. |
Definition at line 707 of file ClientMgr-sav.cpp.
bool forest::validTokenList | ( | list< string > | tokenList) |
Verify that a tokenList is valid Specificialy, check that if it starts with a command phrase or abbreviation, then it's a valid command phrase or abbreviation.
Also, check each attribute-value assignment to verify that the attribute is valid
tokenList | is a list of tokens |
Definition at line 302 of file Console.cpp.
void forest::writeAcctRecord | ( | const string & | cname, |
fAdr_t | cliAdr, | ||
ipa_t | cliIp, | ||
fAdr_t | rtrAdr, | ||
acctRecType | recType | ||
) |
Writes a record to the accounting file.
cname | is the name of the client |
cliAdr | is the Forest address assigned to the client |
cliIp | is the IP address used by client to login |
rtrAdr | is the Forest address for the router assigned to the client |
recType | is the type of accounting record |
Definition at line 803 of file ClientMgr-sav.cpp.
void forest::writeAdminRecord | ( | int | adx) |
Write a record to the file of network administrators.
The calling thread is assumed to hold a lock on the client.
adx | is a non-negative integer |
Definition at line 1379 of file NetMgr.cpp.
void forest::writeRecord | ( | int | clx) |
Write a client record to clientFile.
Read a client record from an input file and initialize its table entry.
The calling thread is assumed to hold a lock on the client.
clx | is a non-negative integer |
A record includes a client name, password, real name (in quotes), an email address, a default rate spec and a total rate spec.
in | is an open file stream |
clx | is an optional argument specifying the client index for this entry; if zero, a client index is selected automatically (this is the default behavior) bool ClientTable::readEntry(istream& in, int clx) { string cname, pwd, privString, realName, email; RateSpec defRates, totalRates; |
if (!in.good()) return false; if (Misc::verify(in,'+')) { if (!Misc::readName(in, cname) || !Misc::verify(in,',') || !Misc::readWord(in, pwd) || !Misc::verify(in,',') || !Misc::readWord(in, privString) || !Misc::verify(in,',') || !Misc::readString(in, realName) || !Misc::verify(in,',') || !Misc::readWord(in, email) || !Misc::verify(in,',') || !defRates.read(in) || !Misc::verify(in,',') || !totalRates.read(in)) { return false; } Misc::cflush(in,'
'); } else if (Misc::verify(in,'-')) { maxClx = max(clx, maxClx); Misc::cflush(in,'
'); return true; } else { Misc::cflush(in,'
'); return false; }
privileges priv; if (privString == "limited") priv = LIMITED; else if (privString == "standard") priv = STANDARD; else if (privString == "admin") priv = ADMIN; else if (privString == "root") priv = ROOT; else priv = NUL_PRIV;
if (addClient(cname, pwd, priv,clx) == 0) return false; setRealName(clx,realName); setEmail(clx,email); getDefRates(clx) = defRates; getTotalRates(clx) = totalRates; getAvailRates(clx) = totalRates; releaseClient(clx); return true; } Read a client entry from a NetBuffer. The entry must be on a line by itself. An entry consists of a client name, password, real name (in quotes), an email address and a default rate spec.
buf | is a NetBuffer that contains a valid client table entry |
clx | specifies the client number for this entry |
if (!buf.skipSpaceInLine(in)) return false; if (!buf.readName(cname) || !buf.verify(',') || !buf.readWord(pwd) || !buf.verify(',') || !buf.readWord(privString) || !buf.verify(',') || !buf.readString(realName) || !buf.verify(',') || !buf.readWord(email) || !buf.verify(',') || !buf.readRspec(defRates) || !buf.verify(',') || !buf.readRspec(totalRates)) { return 0; } buf.nextLine();
privileges priv; if (privString == "limited") priv = LIMITED; else if (privString == "standard") priv = STANDARD; else if (privString == "admin") priv = ADMIN; else if (privString == "root") priv = ROOT; else priv = NUL_PRIV;
if (addClient(cname, pwd, priv, clx) == 0) return -1; setRealName(clx,realName); setEmail(clx,email); getDefRates(clx) = defRates; getTotalRates(clx) = totalRates; getAvailRates(clx) = totalRates; releaseClient(clx); return 1; } Read client table entries from an input stream. The first line of the input must contain an integer, giving the number of entries to be read. The input may include blank lines and comment lines (any text starting with '#'). The operation may fail if the input is misformatted or if an entry does not pass some basic sanity checks. In this case, an error message is printed that identifies the entry on which a problem was detected
in | is an open input stream |
Definition at line 843 of file ClientMgr-sav.cpp.
ComtInfo * forest::comtrees |
char * forest::dummyRecord |
dummy record for padding client file
dummy record for padding admin file
Definition at line 27 of file ClientMgr.h.
int forest::maxRecord |
largest record number in client file
largest record number in admin file
Definition at line 28 of file ClientMgr.h.
fAdr_t forest::myAdr |
ipa_t forest::myIp |
address of interface to use
NetMgr manages a Forest network.
IP address bound to sockets.
It relays control packets from a remote Console and provides some autonomous control capabilities. IP address of this host
Definition at line 21 of file ClientMgr.h.
fAdr_t forest::nmAdr |
Forest address of NetMgr.
forest address for network manager
Definition at line 26 of file ClientMgr.h.
ipa_t forest::nmIp |
IP address of NetMgr.
ComtCtl manages a set of comtrees in a forest network.
It receives signalling requests from clients and configures comtrees in response to those requests.IP address for network manager
Definition at line 25 of file ClientMgr.h.
fAdr_t forest::rtrAdr |
Forest address of router.
forest address of router
forest address of access router
Definition at line 22 of file ClientMgr.h.
Substrate * forest::sub |
substrate for handling packets
substrate for routing control packets
substrate for steering packets
Definition at line 32 of file ClientMgr.h.