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