forest-net
an overlay networks for large-scale virtual worlds
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
CtlPktDoowon.h
1 
9 #ifndef CTLPKT_H
10 #define CTLPKT_H
11 
12 #include "Forest.h"
13 #include "Packet.h"
14 #include "RateSpec.h"
15 #include "LinkTable.h"
16 
17 namespace forest {
18 
19 
43 class CtlPkt {
44 public:
46  enum CpType {
47  UNDEF_CPTYPE = 0,
48 
49  CLIENT_ADD_COMTREE = 10, CLIENT_DROP_COMTREE = 11,
50  CLIENT_GET_COMTREE = 12, CLIENT_MOD_COMTREE = 13,
51  CLIENT_JOIN_COMTREE = 14, CLIENT_LEAVE_COMTREE = 15,
52  CLIENT_RESIZE_COMTREE = 16,
53  CLIENT_GET_LEAF_RATE = 17, CLIENT_MOD_LEAF_RATE = 18,
54 
55  CLIENT_NET_SIG_SEP = 29,
56 
57  ADD_IFACE = 30, DROP_IFACE = 31,
58  GET_IFACE = 32, MOD_IFACE = 33,
59 
60  ADD_LINK = 40, DROP_LINK = 41,
61  GET_LINK = 42, MOD_LINK = 43,
62 
63  ADD_COMTREE = 50, DROP_COMTREE = 51,
64  GET_COMTREE = 52, MOD_COMTREE = 53,
65 
66  ADD_COMTREE_LINK = 54, DROP_COMTREE_LINK = 55,
67  MOD_COMTREE_LINK = 56, GET_COMTREE_LINK = 57,
68 
69  ADD_ROUTE = 70, DROP_ROUTE = 71,
70  GET_ROUTE = 72, MOD_ROUTE = 73,
71  ADD_ROUTE_LINK = 74, DROP_ROUTE_LINK = 75,
72  //feng
73  GET_LINK_SET = 76,
74 
75  NEW_SESSION = 100, CANCEL_SESSION = 103,
76  CLIENT_CONNECT = 101, CLIENT_DISCONNECT = 102,
77 
78  SET_LEAF_RANGE = 110, CONFIG_LEAF = 111,
79 
80  BOOT_ROUTER = 120, BOOT_COMPLETE = 121, BOOT_ABORT = 122,
81  BOOT_LEAF = 123
82  };
83 
84  // Control packet attribute types
85  enum CpAttr {
86  UNDEF_ATTR = 0,
87  ADR1 = 1, ADR2 = 2, ADR3 = 3,
88  IP1 = 5, IP2 = 6,
89  PORT1 = 9, PORT2 = 10,
90  RSPEC1 = 13, RSPEC2 = 14,
91  NONCE = 17,
92  CORE_FLAG = 20,
93  IFACE = 21,
94  LINK = 22,
95  NODE_TYPE = 23,
96  COMTREE = 50,
97  COMTREE_OWNER = 51,
98  COUNT = 70,
99  QUEUE = 71,
100  ZIPCODE = 72,
101  LINKTABLE = 73, //feng
102  LINKSET = 74, //Doowon
103  FIRST_LINK_NUM = 75, //Doowon
104  NUM_OF_LINK = 76, //Doowon
105  NEXT_LINK_NUM = 78, //Doowon
106  ERRMSG = 100
107  };
108  static const int MAX_STRING = 200;
109 
111  enum CpMode {
112  UNDEF_MODE = 0, REQUEST = 1, POS_REPLY = 2, NEG_REPLY = 3
113  };
114 
115  // constructors/destructor
116  CtlPkt();
117  CtlPkt(const Packet&);
118  CtlPkt(uint32_t*,int);
119  CtlPkt(CpType,CpMode,uint64_t);
120  CtlPkt(CpType,CpMode,uint64_t,uint32_t*);
121  ~CtlPkt();
122 
123  // resetting control packet
124  void reset();
125  void reset(const Packet&);
126  void reset(uint32_t*, int);
127  void reset(CpType,CpMode,uint64_t);
128  void reset(CpType,CpMode,uint64_t,uint32_t*);
129 
130  int pack();
131  bool unpack();
132 
133  string& typeName(string&);
134  string& modeName(string&);
135  string& avPair2string(CpAttr, string&);
136  string& toString(string&);
137 
138  CpType type;
139  CpMode mode;
140  int64_t seqNum;
141 
142  fAdr_t adr1, adr2, adr3;
143  ipa_t ip1, ip2;
144  ipp_t port1, port2;
145  RateSpec rspec1, rspec2;
146  uint64_t nonce;
147  int8_t coreFlag;
148  int iface;
149  int link;
153  int count;
154  int queue;
155  int zipCode;
157  uint32_t* payload;
158  int paylen;
159 
160  //dwkim
161  int firstLinkNum; // first link #
162  int numOfLinks; // # of links
163  int nextLinkNum; // the next link #
164 
165  string errMsg;
166 
167 private:
168 };
169 
170 } // ends namespace
171 
172 
173 #endif