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