forest-net
an overlay networks for large-scale virtual worlds
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
CtlPktFeng.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 <vector>
16 
17 namespace forest {
18 
42 class CtlPkt {
43 public:
45  enum CpType {
46  UNDEF_CPTYPE = 0,
47 
48  CLIENT_ADD_COMTREE = 10, CLIENT_DROP_COMTREE = 11,
49  CLIENT_GET_COMTREE = 12, CLIENT_MOD_COMTREE = 13,
50  CLIENT_JOIN_COMTREE = 14, CLIENT_LEAVE_COMTREE = 15,
51  CLIENT_RESIZE_COMTREE = 16,
52  CLIENT_GET_LEAF_RATE = 17, CLIENT_MOD_LEAF_RATE = 18,
53 
54  CLIENT_NET_SIG_SEP = 29,
55 
56  ADD_IFACE = 30, DROP_IFACE = 31,
57  GET_IFACE = 32, MOD_IFACE = 33,
58  GET_IFACE_SET = 34,
59 
60  ADD_LINK = 40, DROP_LINK = 41,
61  GET_LINK = 42, MOD_LINK = 43,
62  GET_LINK_SET = 44,
63 
64  ADD_COMTREE = 50, DROP_COMTREE = 51,
65  GET_COMTREE = 52, MOD_COMTREE = 53,
66 
67  ADD_COMTREE_LINK = 54, DROP_COMTREE_LINK = 55,
68  MOD_COMTREE_LINK = 56, GET_COMTREE_LINK = 57,
69  GET_COMTREE_SET = 58,
70 
71  ADD_ROUTE = 70, DROP_ROUTE = 71,
72  GET_ROUTE = 72, MOD_ROUTE = 73,
73  ADD_ROUTE_LINK = 74, DROP_ROUTE_LINK = 75,
74  GET_ROUTE_SET = 76,
75 
76  ADD_FILTER = 80, DROP_FILTER = 81,
77  GET_FILTER = 82, MOD_FILTER = 83,
78  GET_FILTER_SET = 84, GET_LOGGED_PACKETS = 85,
79  ENABLE_PACKET_LOG = 86,
80 
81  NEW_SESSION = 100, CANCEL_SESSION = 103,
82  CLIENT_CONNECT = 101, CLIENT_DISCONNECT = 102,
83 
84  SET_LEAF_RANGE = 110, CONFIG_LEAF = 111,
85 
86  BOOT_ROUTER = 120, BOOT_COMPLETE = 121, BOOT_ABORT = 122,
87  BOOT_LEAF = 123,
88 
89  COMTREE_PATH = 130, COMTREE_NEW_LEAF = 131,
90  COMTREE_ADD_BRANCH = 132, ADD_BRANCH_CONFIRM = 133,
91  COMTREE_PRUNE = 134
92  };
93 
94  // Control packet attribute types
95  enum CpAttr {
96  UNDEF_ATTR = 0,
97  ADR1 = 1, ADR2 = 2, ADR3 = 3,
98  IP1 = 5, IP2 = 6,
99  PORT1 = 9, PORT2 = 10,
100  RSPEC1 = 13, RSPEC2 = 14,
101  NONCE = 17,
102  CORE_FLAG = 20,
103  IFACE = 21,
104  LINK = 22,
105  NODE_TYPE = 23,
106  COMTREE = 50,
107  COMTREE_OWNER = 51,
108  INDEX1 = 60, INDEX2 = 61,
109  COUNT = 70,
110  QUEUE = 71,
111  ZIPCODE = 72,
112  ERRMSG = 100,
113  STRING = 101,
114  RAWBUF = 102,
115  INTVEC = 103
116  };
117  static const int MAX_STRING = 200;
118 
120  enum CpMode {
121  UNDEF_MODE = 0, REQUEST = 1, POS_REPLY = 2, NEG_REPLY = 3
122  };
123 
124  // constructors/destructor
125  CtlPkt();
126  CtlPkt(const Packet&);
127  CtlPkt(uint32_t*,int);
128  CtlPkt(CpType,CpMode,uint64_t);
129  CtlPkt(CpType,CpMode,uint64_t,uint32_t*);
130  ~CtlPkt();
131 
132  // resetting control packet
133  void reset();
134  void reset(const Packet&);
135  void reset(uint32_t*, int);
136  void reset(CpType,CpMode,uint64_t);
137  void reset(CpType,CpMode,uint64_t,uint32_t*);
138 
139  int pack();
140  bool unpack();
141 
142  static string& cpType2string(CpType,string&);
143  static string& cpMode2string(CpMode,string&);
144  static bool string2cpType(string&, CpType&);
145  static bool string2cpMode(string&, CpMode&);
146 
147  string& avPair2string(CpAttr, string&);
148  string& toString(string&);
149 
150  CpType type;
151  CpMode mode;
152  int64_t seqNum;
153 
154  fAdr_t adr1, adr2, adr3;
155  ipa_t ip1, ip2;
156  ipp_t port1, port2;
157  RateSpec rspec1, rspec2;
158  uint64_t nonce;
159  int8_t coreFlag;
160  int iface;
161  int link;
163  comt_t comtree;
165  int index1, index2;
166  int count;
167  int queue;
168  int zipCode;
169 
170  uint32_t* payload;
171  int paylen;
172 
173  string errMsg;
174  string stringData;
175  vector<int> ivec;
176 
177 private:
178 };
179 
180 } // ends namespace
181 
182 
183 #endif