forest-net
an overlay networks for large-scale virtual worlds
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
NetMgrDoowon.h
1 
9 #ifndef NETMGR_H
10 #define NETMGR_H
11 
12 #include <pthread.h>
13 #include "Forest.h"
14 #include "Packet.h"
15 #include "PacketStoreTs.h"
16 #include "NetInfo.h"
17 #include "ComtInfo.h"
18 #include "UiSetPair.h"
19 #include "IdMap.h"
20 #include "Queue.h"
21 #include "CpHandler.h"
22 #include "Substrate.h"
23 #include "NetBuffer.h"
24 #include "Logger.h"
25 #include <map>
26 
27 namespace forest {
28 
29 
36 ipa_t myIp;
37 fAdr_t myAdr;
38 fAdr_t rtrAdr;
41 int netMgr;
42 int nmRtr;
43 
44 Logger *logger;
45 
46 PacketStoreTs *ps;
47 
48 NetInfo *net;
49 ComtInfo *comtrees;
50 
51 Substrate *sub;
52 
53 // Information relating client addresses and router addresses
54 // This is a temporary expedient and will be replaced later
55 int numPrefixes;
56 struct prefixInfo {
57  string prefix;
58  fAdr_t rtrAdr;
59 };
60 struct clientInfo {
61  ipa_t cliIp;
62  fAdr_t rtrAdr;
63  fAdr_t cliAdr;
64  ipa_t rtrIp;
65 };
66 prefixInfo prefixes[1000];
67 
68 bool init(const char*);
69 bool readPrefixInfo(char*);
70 
71 void* handler(void *);
72 bool handleConsole(int,CpHandler&);
73 bool handleConDisc(int,CtlPkt&,CpHandler&);
74 bool handleNewSession(int,CtlPkt&,CpHandler&);
75 bool handleCancelSession(int,CtlPkt&,CpHandler&);
76 bool handleBootLeaf(int,CtlPkt&,CpHandler&);
77 bool handleBootRouter(int,CtlPkt&,CpHandler&);
78 
79 void getNet(NetBuffer&, string&);
80 //feng
81 void getLinkSet(NetBuffer&, string&, CpHandler&);
82 
83 uint64_t generateNonce();
84 fAdr_t setupLeaf(int, pktx, CtlPkt&, int, int, uint64_t,CpHandler&,bool=false);
85 bool setupEndpoint(int, int, pktx, CtlPkt&, CpHandler&, bool=false);
86 bool setupComtree(int, int, pktx, CtlPkt&, CpHandler&, bool=false);
87 bool processReply(pktx, CtlPkt&, pktx, CtlPkt&, CpHandler&, const string&);
88 
89 void sendToCons(int);
90 int recvFromCons();
91 
92 bool findCliRtr(ipa_t,fAdr_t&);
93 
94 } // ends namespace
95 
96 
97 #endif