forest-net
an overlay networks for large-scale virtual worlds
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
CtlPkt.h
Go to the documentation of this file.
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 using namespace std;
18 
19 namespace forest {
20 
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  s16 = 1, u16=2,
95  s32 = 3, u32=4,
96  s64 = 5, u64=6,
97  rateSpec = 7,
98  attrString = 8,
99  intVec = 9
100  };
101 
103  enum CpMode {
104  UNDEF_MODE = 0, REQUEST = 1, POS_REPLY = 2, NEG_REPLY = 3
105  };
106 
107  // constructors/destructor
108  CtlPkt();
109  CtlPkt(const Packet&);
110  ~CtlPkt();
111 
112  // resetting control packet
113  void reset();
114  void reset(const Packet&);
115 
116  void put(int16_t);
117  void put(uint16_t);
118  void put(int32_t);
119  void put(uint32_t);
120  void put(int64_t);
121  void put(uint64_t);
122  void put(Forest::ntyp_t);
123  void put(const RateSpec&);
124  void put(const string&);
125  void put(const vector<int32_t>&);
126 
127  int availSpace();
128 
129  bool get(int16_t&);
130  bool get(uint16_t&);
131  bool get(int32_t&);
132  bool get(uint32_t&);
133  bool get(int64_t&);
134  bool get(uint64_t&);
135  bool get(Forest::ntyp_t&);
136  bool get(RateSpec&);
137  bool get(string&);
138  bool get(vector<int32_t>&);
139 
140  void fmtBase();
141  bool xtrBase();
142  void updateSeqNum();
143 
144  void fmtError(const string&, int64_t=0);
145  bool xtrError(string&);
146 
147  void fmtAddIface(int, ipa_t, RateSpec, int64_t);
148  bool xtrAddIface(int&, ipa_t&, RateSpec&);
149  void fmtAddIfaceReply(ipa_t, ipp_t, int64_t=0);
150  bool xtrAddIfaceReply(ipa_t&, ipp_t&);
151 
152  void fmtDropIface(int, int64_t);
153  bool xtrDropIface(int&);
154  void fmtDropIfaceReply(int64_t=0);
155  bool xtrDropIfaceReply();
156 
157  void fmtModIface(int, RateSpec, int64_t);
158  bool xtrModIface(int&, RateSpec&);
159  void fmtModIfaceReply(int64_t=0);
160  bool xtrModIfaceReply();
161 
162  void fmtGetIface(int, int64_t);
163  bool xtrGetIface(int&);
164  void fmtGetIfaceReply(int, ipa_t, ipp_t, RateSpec,
165  RateSpec, int64_t=0);
166  bool xtrGetIfaceReply(int&, ipa_t&, ipp_t&, RateSpec&,
167  RateSpec&);
168 
169  void fmtGetIfaceSet(int, int, int64_t);
170  bool xtrGetIfaceSet(int&, int&);
171  void fmtGetIfaceSetReply(int, int, string, int64_t=0);
172  bool xtrGetIfaceSetReply(int&, int&, string&);
173 
174  void fmtAddLink(Forest::ntyp_t, int, int, ipa_t, ipp_t,
175  fAdr_t, uint64_t, int64_t);
176  bool xtrAddLink(Forest::ntyp_t&, int&, int&, ipa_t&, ipp_t&,
177  fAdr_t&, uint64_t&);
178  void fmtAddLinkReply(int, fAdr_t, int64_t=0);
179  bool xtrAddLinkReply(int&, fAdr_t&);
180 
181  void fmtDropLink(int, fAdr_t, int64_t);
182  bool xtrDropLink(int&, fAdr_t&);
183  void fmtDropLinkReply(int64_t=0);
184  bool xtrDropLinkReply();
185 
186  void fmtModLink(int, RateSpec, int64_t);
187  bool xtrModLink(int&, RateSpec&);
188  void fmtModLinkReply(int64_t=0);
189  bool xtrModLinkReply();
190 
191  void fmtGetLink(int, int64_t);
192  bool xtrGetLink(int&);
193  void fmtGetLinkReply(int, int, Forest::ntyp_t, ipa_t, ipp_t,
194  fAdr_t, RateSpec&, RateSpec&, int64_t=0);
195  bool xtrGetLinkReply(int&, int&, Forest::ntyp_t&, ipa_t&, ipp_t&,
196  fAdr_t&, RateSpec&, RateSpec&);
197 
198  void fmtGetLinkSet(int, int, int64_t);
199  bool xtrGetLinkSet(int&, int&);
200  void fmtGetLinkSetReply(int, int, string, int64_t=0);
201  bool xtrGetLinkSetReply(int&, int&, string&);
202 
203  void fmtAddComtree(comt_t, int64_t);
204  bool xtrAddComtree(comt_t&);
205  void fmtAddComtreeReply(int64_t=0);
206  bool xtrAddComtreeReply();
207 
208  void fmtDropComtree(comt_t, int64_t);
209  bool xtrDropComtree(comt_t&);
210  void fmtDropComtreeReply(RateSpec, int64_t=0);
211  bool xtrDropComtreeReply(RateSpec&);
212 
213  void fmtModComtree(comt_t, int, int, int64_t);
214  bool xtrModComtree(comt_t&, int&, int&);
215  void fmtModComtreeReply(int64_t=0);
216  bool xtrModComtreeReply();
217 
218  void fmtGetComtree(comt_t, int64_t);
219  bool xtrGetComtree(comt_t&);
220  void fmtGetComtreeReply(comt_t, int, int, int, int64_t=0);
221  bool xtrGetComtreeReply(comt_t&, int&, int&, int&);
222 
223  void fmtGetComtreeSet(comt_t, int, int64_t);
224  bool xtrGetComtreeSet(comt_t&, int&);
225  void fmtGetComtreeSetReply(int, comt_t, string, int64_t=0);
226  bool xtrGetComtreeSetReply(int&, comt_t&, string&);
227 
228  void fmtAddComtreeLink(comt_t, int, int, ipa_t, ipp_t,
229  fAdr_t, int64_t);
230  bool xtrAddComtreeLink(comt_t&, int&, int&, ipa_t&, ipp_t&,
231  fAdr_t&);
232  void fmtAddComtreeLinkReply(int, RateSpec, int64_t=0);
233  bool xtrAddComtreeLinkReply(int&, RateSpec&);
234 
235  void fmtDropComtreeLink(comt_t, int, ipa_t, ipp_t, fAdr_t, int64_t);
236  bool xtrDropComtreeLink(comt_t&, int&, ipa_t&, ipp_t&, fAdr_t&);
237  void fmtDropComtreeLinkReply(RateSpec, int64_t=0);
238  bool xtrDropComtreeLinkReply(RateSpec&);
239 
240  void fmtModComtreeLink(comt_t, int, RateSpec, int64_t);
241  bool xtrModComtreeLink(comt_t&, int&, RateSpec&);
242  void fmtModComtreeLinkReply(RateSpec&, int64_t=0);
243  bool xtrModComtreeLinkReply(RateSpec&);
244 
245  void fmtGetComtreeLink(comt_t, int, int64_t);
246  bool xtrGetComtreeLink(comt_t&, int&);
247  void fmtGetComtreeLinkReply(comt_t, int, RateSpec, int,
248  fAdr_t, int64_t=0);
249  bool xtrGetComtreeLinkReply(comt_t&, int&, RateSpec&, int&,
250  fAdr_t&);
251 
252  void fmtAddRoute(comt_t, fAdr_t, int, int64_t);
253  bool xtrAddRoute(comt_t&, fAdr_t&, int&);
254  void fmtAddRouteReply(int64_t=0);
255  bool xtrAddRouteReply();
256 
257  void fmtDropRoute(comt_t, fAdr_t, int64_t);
258  bool xtrDropRoute(comt_t&, fAdr_t&);
259  void fmtDropRouteReply(int64_t=0);
260  bool xtrDropRouteReply();
261 
262  void fmtModRoute(comt_t, fAdr_t, int, int64_t);
263  bool xtrModRoute(comt_t&, fAdr_t&, int&);
264  void fmtModRouteReply(int64_t=0);
265  bool xtrModRouteReply();
266 
267  void fmtGetRoute(comt_t, fAdr_t, int64_t);
268  bool xtrGetRoute(comt_t&, fAdr_t&);
269  void fmtGetRouteReply(comt_t, fAdr_t, int, int64_t=0);
270  bool xtrGetRouteReply(comt_t&, fAdr_t&, int&);
271 
272  void fmtGetRouteSet(int, int, int64_t);
273  bool xtrGetRouteSet(int&, int&);
274  void fmtGetRouteSetReply(int, int, string, int64_t=0);
275  bool xtrGetRouteSetReply(int&, int&, string&);
276 
277  void fmtAddRouteLink(comt_t, fAdr_t, int, int64_t);
278  bool xtrAddRouteLink(comt_t&, fAdr_t&, int&);
279  void fmtAddRouteLinkReply(int64_t=0);
280  bool xtrAddRouteLinkReply();
281 
282  void fmtDropRouteLink(comt_t, fAdr_t, int, int64_t);
283  bool xtrDropRouteLink(comt_t&, fAdr_t&, int&);
284  void fmtDropRouteLinkReply(int64_t=0);
285  bool xtrDropRouteLinkReply();
286 
287  void fmtAddFilter(int64_t);
288  bool xtrAddFilter();
289  void fmtAddFilterReply(int, int64_t=0);
290  bool xtrAddFilterReply(int&);
291 
292  void fmtDropFilter(int, int64_t);
293  bool xtrDropFilter(int&);
294  void fmtDropFilterReply(int64_t=0);
295  bool xtrDropFilterReply();
296 
297  void fmtModFilter(int, string, int64_t);
298  bool xtrModFilter(int&, string&);
299  void fmtModFilterReply(int64_t=0);
300  bool xtrModFilterReply();
301 
302  void fmtGetFilter(int, int64_t);
303  bool xtrGetFilter(int&);
304  void fmtGetFilterReply(string, int64_t=0);
305  bool xtrGetFilterReply(string&);
306 
307  void fmtGetFilterSet(int, int, int64_t);
308  bool xtrGetFilterSet(int&, int&);
309  void fmtGetFilterSetReply(int, int, string, int64_t=0);
310  bool xtrGetFilterSetReply(int&, int&, string&);
311 
312  void fmtGetLoggedPackets(int64_t);
313  bool xtrGetLoggedPackets();
314  void fmtGetLoggedPacketsReply(int, string, int64_t=0);
315  bool xtrGetLoggedPacketsReply(int&, string&);
316 
317  void fmtEnablePacketLog(int, int, int64_t);
318  bool xtrEnablePacketLog(int&, int&);
319  void fmtEnablePacketLogReply(int64_t=0);
320  bool xtrEnablePacketLogReply();
321 
322  void fmtNewSession(ipa_t, RateSpec, int64_t);
323  bool xtrNewSession(ipa_t&, RateSpec&);
324  void fmtNewSessionReply(fAdr_t, fAdr_t, ipa_t, ipp_t,
325  uint64_t, int64_t=0);
326  bool xtrNewSessionReply(fAdr_t&, fAdr_t&, ipa_t&, ipp_t&,
327  uint64_t&);
328 
329  void fmtCancelSession(fAdr_t, fAdr_t, int64_t);
330  bool xtrCancelSession(fAdr_t&, fAdr_t&);
331  void fmtCancelSessionReply(int64_t=0);
332  bool xtrCancelSessionReply();
333 
334  void fmtClientConnect(fAdr_t, fAdr_t, int64_t);
335  bool xtrClientConnect(fAdr_t&, fAdr_t&);
336  void fmtClientConnectReply(int64_t=0);
337  bool xtrClientConnectReply();
338 
339  void fmtClientDisconnect(fAdr_t, fAdr_t, int64_t);
340  bool xtrClientDisconnect(fAdr_t&, fAdr_t&);
341  void fmtClientDisconnectReply(int64_t=0);
342  bool xtrClientDisconnectReply();
343 
344  void fmtConfigLeaf(fAdr_t, fAdr_t, ipa_t, ipp_t,
345  uint64_t, int64_t);
346  bool xtrConfigLeaf(fAdr_t&, fAdr_t&, ipa_t&, ipp_t&, uint64_t&);
347  void fmtConfigLeafReply(int64_t=0);
348  bool xtrConfigLeafReply();
349 
350  void fmtSetLeafRange(fAdr_t, fAdr_t, int64_t);
351  bool xtrSetLeafRange(fAdr_t&, fAdr_t&);
352  void fmtSetLeafRangeReply(int64_t=0);
353  bool xtrSetLeafRangeReply();
354 
355  void fmtBootRouter(int64_t);
356  bool xtrBootRouter();
357  void fmtBootRouterReply(int64_t=0);
358  bool xtrBootRouterReply();
359 
360  void fmtBootLeaf(int64_t);
361  bool xtrBootLeaf();
362  void fmtBootLeafReply(int64_t=0);
363  bool xtrBootLeafReply();
364 
365  void fmtBootComplete(int64_t);
366  bool xtrBootComplete();
367  void fmtBootCompleteReply(int64_t=0);
368  bool xtrBootCompleteReply();
369 
370  void fmtBootAbort(int64_t);
371  bool xtrBootAbort();
372  void fmtBootAbortReply(int64_t=0);
373  bool xtrBootAbortReply();
374 
375  static string cpType2string(CpType);
376  static string cpMode2string(CpMode);
377  static bool string2cpType(string&, CpType&);
378  static bool string2cpMode(string&, CpMode&);
379 
380  string avPair2string(CpAttr);
381  string toString();
382 
385  int64_t seqNum;
386 
387  char* payload;
388  int paylen;
389 private:
390  char* next;
391 };
392 
397 inline void CtlPkt::fmtBase() {
398  next = payload;
399  *((int16_t*) next)=htons((int16_t) type); next+=sizeof(int16_t);
400  *((int16_t*) next)=htons((int16_t) mode); next+=sizeof(int16_t);
401  *((int32_t*) next)=htonl((int32_t) ((seqNum >> 32) & 0xffffffff));
402  next+=sizeof(int32_t);
403  *((int32_t*) next)=htonl((int32_t) (seqNum & 0xffffffff));
404  next+=sizeof(int32_t);
405  paylen = next - payload;
406 }
407 
412 inline bool CtlPkt::xtrBase() {
413  next = payload;
414  type = (CpType) ntohs(*((int16_t*) next)); next += sizeof(int16_t);
415  mode = (CpMode) ntohs(*((int16_t*) next)); next += sizeof(int16_t);
416  seqNum = ntohl(*((uint32_t*) next)); next += sizeof(uint32_t);
417  seqNum <<= 32;
418  seqNum |= ntohl(*((uint32_t*) next)); next += sizeof(uint32_t);
419  return (paylen >= next - payload);
420 }
421 
424 inline void CtlPkt::updateSeqNum() {
425  char* p = payload + 2*sizeof(int16_t);
426  *((int32_t*) p) = htonl((int32_t) ((seqNum >> 32) & 0xffffffff));
427  p += sizeof(int32_t);
428  *((int32_t*) ) = htonl((int32_t) (seqNum & 0xffffffff));
429 }
430 
434 inline void CtlPkt::put(int16_t x) {
435  *((int16_t*) next)=htons(s16); next+=sizeof(int16_t);
436  *((int16_t*) next)=htons((int16_t) sizeof(x)); next+=sizeof(int16_t);
437  *((int16_t*) next)=htons(x); next+=sizeof(x);
438 }
439 
443 inline void CtlPkt::put(uint16_t x) {
444  *((int16_t*) next)=htons(u16); next+=sizeof(int16_t);
445  *((int16_t*) next)=htons((int16_t) sizeof(x)); next+=sizeof(int16_t);
446  *((uint16_t*) next)=htons(x); next+=sizeof(x);
447 }
448 
452 inline void CtlPkt::put(int32_t x) {
453  *((int16_t*) next)=htons(s32); next+=sizeof(int16_t);
454  *((int16_t*) next)=htons((int16_t) sizeof(x)); next+=sizeof(int16_t);
455  *((int32_t*) next)=htonl(x); next+=sizeof(x);
456 }
457 
461 inline void CtlPkt::put(uint32_t x) {
462  *((int16_t*) next)=htons(u32); next+=sizeof(int16_t);
463  *((int16_t*) next)=htons((int16_t) sizeof(x)); next+=sizeof(int16_t);
464  *((uint32_t*) next)=htonl(x); next+=sizeof(x);
465 }
466 
470 inline void CtlPkt::put(int64_t x) {
471  *((int16_t*) next)=htons(s64); next+=sizeof(int16_t);
472  *((int16_t*) next)=htons((int16_t) sizeof(x)); next+=sizeof(int16_t);
473  *((int32_t*) next)=htonl((int32_t) ((x >> 32) & 0xffffffff));
474  next+=sizeof(int32_t);
475  *((int32_t*) next)=htonl((int32_t) (x & 0xffffffff));
476  next+=sizeof(int32_t);
477 }
478 
482 inline void CtlPkt::put(uint64_t x) {
483  *((int16_t*) next)=htons(u64); next+=sizeof(int16_t);
484  *((int16_t*) next)=htons((int16_t) sizeof(x)); next+=sizeof(int16_t);
485  *((int32_t*) next)=htonl((uint32_t) ((x >> 32) & 0xffffffff));
486  next+=sizeof(int32_t);
487  *((int32_t*) next)=htonl((uint32_t) (x & 0xffffffff));
488  next+=sizeof(int32_t);
489 }
490 
494 inline void CtlPkt::put(Forest::ntyp_t x) {
495  *((int16_t*) next)=htons(u64); next+=sizeof(int16_t);
496  *((int16_t*) next)=htons((int16_t) sizeof(int16_t));
497  next+=sizeof(int16_t);
498  *((int16_t*) next)=htons((int16_t) x); next+=sizeof(int16_t);
499 }
500 
504 inline void CtlPkt::put(const RateSpec& rs) {
505  *((int16_t*) next)=htons(rateSpec); next+=sizeof(int16_t);
506  *((int16_t*) next)=htons((int16_t) sizeof(rs)); next+=sizeof(int16_t);
507  *((int32_t*) next)=htonl(rs.bitRateUp); next+=sizeof(uint32_t);
508  *((int32_t*) next)=htonl(rs.bitRateDown); next+=sizeof(uint32_t);
509  *((int32_t*) next)=htonl(rs.pktRateUp); next+=sizeof(uint32_t);
510  *((int32_t*) next)=htonl(rs.pktRateDown); next+=sizeof(uint32_t);
511 }
512 
516 inline void CtlPkt::put(const string& s) {
517  *((int16_t*) next) = htons(attrString); next+=sizeof(int16_t);
518  *((int16_t*) next) = htons((int16_t) s.length()); next+=sizeof(int16_t);
519  std::copy(s.c_str(),s.c_str()+s.length(),next); next+=s.length();
520 }
521 
525 inline void CtlPkt::put(const vector<int32_t>& v) {
526  *((int16_t*) next) = htons(intVec); next+=sizeof(int16_t);
527  *((int16_t*) next) = htons((int16_t) v.size()*sizeof(int32_t));
528  next+=sizeof(int16_t);
529  std::copy(v.begin(),v.end(),(int32_t*) next);
530  next+=v.size()*sizeof(int32_t);
531 }
532 
537 inline int CtlPkt::availSpace() {
538  return (payload + (Forest::MAX_PLENG-Forest::OVERHEAD))
539  - (next + 2*sizeof(int16_t));
540 }
541 
542 
546 inline bool CtlPkt::get(int16_t& x) {
547  if (ntohs(*((int16_t*) next)) != s16) return false;
548  next += sizeof(int16_t);
549  if (ntohs(*((int16_t*) next)) != sizeof(x)) return false;
550  next += sizeof(int16_t);
551  x = ntohs(*((int16_t*) next));
552  next += sizeof(x);
553  return true;
554 }
555 
559 inline bool CtlPkt::get(uint16_t& x) {
560  if (ntohs(*((int16_t*) next)) != u16) return false;
561  next += sizeof(int16_t);
562  if (ntohs(*((int16_t*) next)) != sizeof(x)) return false;
563  next += sizeof(int16_t);
564  x = ntohs(*((uint16_t*) next));
565  next += sizeof(x);
566  return true;
567 }
568 
572 inline bool CtlPkt::get(int32_t& x) {
573  if (ntohs(*((int16_t*) next)) != s32) return false;
574  next += sizeof(int16_t);
575  if (ntohs(*((int16_t*) next)) != sizeof(x)) return false;
576  next += sizeof(int16_t);
577  x = ntohl(*((int32_t*) next));
578  next += sizeof(x);
579  return true;
580 }
581 
585 inline bool CtlPkt::get(uint32_t& x) {
586  if (ntohs(*((int16_t*) next)) != u32) return false;
587  next += sizeof(int16_t);
588  if (ntohs(*((int16_t*) next)) != sizeof(x)) return false;
589  next += sizeof(int16_t);
590  x = ntohl(*((uint32_t*) next));
591  next += sizeof(x);
592  return true;
593 }
594 
598 inline bool CtlPkt::get(int64_t& x) {
599  if (ntohs(*((int16_t*) next)) != s64) return false;
600  next += sizeof(int16_t);
601  if (ntohs(*((int16_t*) next)) != sizeof(x)) return false;
602  next += sizeof(int16_t);
603  x = ntohl(*((int64_t*) next));
604  next += sizeof(x);
605  return true;
606 }
607 
611 inline bool CtlPkt::get(uint64_t& x) {
612  if (ntohs(*((int16_t*) next)) != u64) return false;
613  next += sizeof(int16_t);
614  if (ntohs(*((int16_t*) next)) != sizeof(x)) return false;
615  next += sizeof(int16_t);
616  x = ntohl(*((uint64_t*) next));
617  next += sizeof(x);
618  return true;
619 }
620 
624 inline bool CtlPkt::get(Forest::ntyp_t& x) {
625  if (ntohs(*((int16_t*) next)) != u32) return false;
626  next += sizeof(int16_t);
627  if (ntohs(*((int16_t*) next)) != sizeof(int16_t)) return false;
628  next += sizeof(int16_t);
629  x = (Forest::ntyp_t) ntohs(*((uint16_t*) next));
630  next += sizeof(int16_t);
631  return true;
632 }
633 
637 inline bool CtlPkt::get(RateSpec& rs) {
638  if (ntohs(*((int16_t*) next)) != rateSpec) return false;
639  next += sizeof(int16_t);
640  if (ntohs(*((int16_t*) next)) != sizeof(rs)) return false;
641  next += sizeof(int16_t);
642  rs.bitRateUp = ntohl(*((int64_t*) next)); next += sizeof(uint32_t);
643  rs.bitRateDown = ntohl(*((int64_t*) next)); next += sizeof(uint32_t);
644  rs.pktRateUp = ntohl(*((int64_t*) next)); next += sizeof(uint32_t);
645  rs.pktRateDown = ntohl(*((int64_t*) next)); next += sizeof(uint32_t);
646  return true;
647 }
648 
652 inline bool CtlPkt::get(string& s) {
653  if (ntohs(*((int16_t*) next)) != attrString) return false;
654  next += sizeof(int16_t);
655  int len = ntohs(*((int16_t*) next));
656  next += sizeof(int16_t);
657  std::copy(next, next+len, s.begin());
658  next += len;
659  return true;
660 }
661 
665 inline bool CtlPkt::get(vector<int32_t>& v) {
666  if (ntohs(*((int16_t*) next)) != attrString) return false;
667  next += sizeof(int16_t);
668  int len = ntohs(*((int16_t*) next))/sizeof(int32_t);
669  next += sizeof(int16_t);
670  int32_t* vv = (int32_t*) next;
671  std::copy(vv, vv+len, v.begin());
672  next += len * sizeof(int32_t);
673  return true;
674 }
675 
676 } // ends namespace
677 
678 #endif