Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofqueueprop.h
1 /*
2  * cofqueueprop.h
3  *
4  * Created on: 29.04.2013
5  * Author: andi
6  */
7 
8 #ifndef COFQUEUEPROP_H_
9 #define COFQUEUEPROP_H_ 1
10 
11 #include <assert.h>
12 #include <ostream>
13 #include <endian.h>
14 #ifndef htobe16
15  #include "../endian_conversion.h"
16 #endif
17 
18 #include "rofl/common/openflow/openflow_rofl_exceptions.h"
19 #include "rofl/common/cmemory.h"
20 #include "rofl/common/croflexception.h"
21 #include "rofl/common/openflow/openflow.h"
22 
23 namespace rofl {
24 namespace openflow {
25 
26 class eQueuePropBase : public RoflException {};
28 
29 
31 public:
32 
37  uint8_t of_version = openflow::OFP_VERSION_UNKNOWN,
38  uint16_t property = 0) :
39  ofp_version(of_version),
40  property(property),
41  len(sizeof(struct rofl::openflow12::ofp_queue_prop_header)) {};
42 
43 
47  virtual
48  ~cofqueue_prop() {};
49 
50 
55  const cofqueue_prop& prop) {
56  *this = prop;
57  };
58 
59 
64  operator= (
65  const cofqueue_prop& qp) {
66  if (this == &qp)
67  return *this;
68 
69  ofp_version = qp.ofp_version;
70  property = qp.property;
71  len = qp.len;
72 
73  return *this;
74  };
75 
76 
77 public:
78 
79 
83  virtual size_t
84  length() const;
85 
86 
90  virtual void
91  pack(
92  uint8_t *buf, size_t buflen);
93 
94 
98  virtual void
99  unpack(
100  uint8_t *buf, size_t buflen);
101 
102 
103 public:
104 
108  uint8_t
109  get_version() const { return ofp_version; };
110 
114  void
115  set_version(uint8_t ofp_version) { this->ofp_version = ofp_version; };
116 
120  uint16_t
121  get_property() const { return property; };
122 
123 
127  void
128  set_property(
129  uint16_t property) { this->property = property; };
130 
131 
135  uint16_t
136  get_length() const { return len; };
137 
138 
142  void
143  set_length(uint16_t len) { this->len = len; };
144 
145 public:
146 
150  friend std::ostream&
151  operator<< (std::ostream& os, cofqueue_prop const& prop) {
152  os << rofl::indent(0) << "<cofqueue_prop "
153  << "version: " << (int)prop.get_version() << " "
154  << std::hex
155  << "property: 0x" << (int)prop.get_property() << " "
156  << std::dec
157  << "length: " << (int)prop.get_length() << " "
158  << ">" << std::endl;
159  return os;
160  };
161 
162 
163 private:
164 
165  uint8_t ofp_version;
166  uint16_t property;
167  mutable uint16_t len;
168 };
169 
170 
171 
173 public:
174 
179  uint8_t ofp_version = rofl::openflow::OFP_VERSION_UNKNOWN,
180  uint16_t min_rate = OFPQ_MIN_RATE_UNCFG) :
181  cofqueue_prop(ofp_version, rofl::openflow13::OFPQT_MIN_RATE),
182  min_rate(min_rate) {};
183 
187  virtual
189 
194  const cofqueue_prop_min_rate& prop) {
195  *this = prop;
196  };
197 
202  operator= (
203  const cofqueue_prop_min_rate& prop) {
204  if (this == &prop)
205  return *this;
206  cofqueue_prop::operator= (prop);
207  min_rate = prop.min_rate;
208  return *this;
209  };
210 
211 public:
212 
216  virtual size_t
217  length() const;
218 
222  virtual void
223  pack(
224  uint8_t *buf, size_t buflen);
225 
226 
230  virtual void
231  unpack(
232  uint8_t *buf, size_t buflen);
233 
234 
235 public:
236 
237 
241  uint16_t
242  get_min_rate() const { return min_rate; };
243 
244 
248  void
249  set_min_rate(uint16_t min_rate) { this->min_rate = min_rate; };
250 
251 public:
252 
253  friend std::ostream&
254  operator<< (std::ostream& os, const cofqueue_prop_min_rate& prop) {
255  os << rofl::indent(0) << "<cofqueue_prop_min_rate version: " << (unsigned int)prop.get_version() << " >" << std::endl;
256  { rofl::indent i(2); os << dynamic_cast<const cofqueue_prop&>( prop ); }
257  os << rofl::indent(4) << "<min-rate: 0x" << std::hex << (unsigned int)prop.get_min_rate() << std::dec << " >" << std::endl;
258  return os;
259  };
260 
261 private:
262 
263  uint16_t min_rate;
264 };
265 
266 
267 
269 public:
270 
275  uint8_t ofp_version = rofl::openflow::OFP_VERSION_UNKNOWN,
276  uint16_t max_rate = OFPQ_MAX_RATE_UNCFG) :
277  cofqueue_prop(ofp_version, rofl::openflow13::OFPQT_MAX_RATE),
278  max_rate(max_rate) {};
279 
283  virtual
285 
290  const cofqueue_prop_max_rate& prop) {
291  *this = prop;
292  };
293 
298  operator= (
299  const cofqueue_prop_max_rate& prop) {
300  if (this == &prop)
301  return *this;
302  cofqueue_prop::operator= (prop);
303  max_rate = prop.max_rate;
304  return *this;
305  };
306 
307 public:
308 
312  virtual size_t
313  length() const;
314 
318  virtual void
319  pack(
320  uint8_t *buf, size_t buflen);
321 
322 
326  virtual void
327  unpack(
328  uint8_t *buf, size_t buflen);
329 
330 
331 public:
332 
333 
337  uint16_t
338  get_max_rate() const { return max_rate; };
339 
340 
344  void
345  set_max_rate(uint16_t max_rate) { this->max_rate = max_rate; };
346 
347 public:
348 
349  friend std::ostream&
350  operator<< (std::ostream& os, const cofqueue_prop_max_rate& prop) {
351  os << rofl::indent(0) << "<cofqueue_prop_max_rate version: " << (unsigned int)prop.get_version() << " >" << std::endl;
352  { rofl::indent i(2); os << dynamic_cast<const cofqueue_prop&>( prop ); }
353  os << rofl::indent(4) << "<max-rate: 0x" << std::hex << (unsigned int)prop.get_max_rate() << std::dec << " >" << std::endl;
354  return os;
355  };
356 
357 private:
358 
359  uint16_t max_rate;
360 };
361 
362 
363 
365 public:
366 
371  uint8_t ofp_version = rofl::openflow::OFP_VERSION_UNKNOWN,
372  uint32_t exp_id = 0,
373  const rofl::cmemory& exp_body = rofl::cmemory((size_t)0)) :
374  cofqueue_prop(ofp_version, rofl::openflow13::OFPQT_EXPERIMENTER),
375  exp_id(exp_id),
376  exp_body(exp_body) {};
377 
381  virtual
383 
388  const cofqueue_prop_experimenter& prop) {
389  *this = prop;
390  };
391 
396  operator= (
397  const cofqueue_prop_experimenter& prop) {
398  if (this == &prop)
399  return *this;
400  cofqueue_prop::operator= (prop);
401  exp_id = prop.exp_id;
402  exp_body = prop.exp_body;
403  return *this;
404  };
405 
406 public:
407 
411  virtual size_t
412  length() const;
413 
417  virtual void
418  pack(
419  uint8_t *buf, size_t buflen);
420 
421 
425  virtual void
426  unpack(
427  uint8_t *buf, size_t buflen);
428 
429 
430 public:
431 
432 
436  uint32_t
437  get_exp_id() const { return exp_id; };
438 
439 
443  void
444  set_exp_id(uint32_t exp_id) { this->exp_id = exp_id; };
445 
449  const rofl::cmemory&
450  get_exp_body() const { return exp_body; };
451 
456  set_exp_body() { return exp_body; };
457 
458 public:
459 
460  friend std::ostream&
461  operator<< (std::ostream& os, const cofqueue_prop_experimenter& prop) {
462  os << rofl::indent(0) << "<cofqueue_prop_experimenter version: " << (unsigned int)prop.get_version() << " >" << std::endl;
463  { rofl::indent i(2); os << dynamic_cast<const cofqueue_prop&>( prop ); }
464  os << rofl::indent(4) << "<exp-id: 0x" << std::hex << (unsigned int)prop.get_exp_id() << " >" << std::dec << std::endl;
465  { rofl::indent i(4); os << prop.get_exp_body(); }
466  return os;
467  };
468 
469 private:
470 
471  uint32_t exp_id;
472  rofl::cmemory exp_body;
473 };
474 
475 }; // end of namespace openflow
476 }; // end of namespace rofl
477 
478 #endif /* COFQUEUEPROP_H_ */
Definition: cofqueueprop.h:30
Definition: cofqueueprop.h:172
Definition: cofqueueprop.h:27
Definition: cofqueueprop.h:268
Definition: cofqueueprop.h:26
C++ abstraction for malloc'ed memory areas.
Definition: cmemory.h:44
Definition: openflow12.h:1587
Definition: logging.h:76
Definition: cofqueueprop.h:364
Definition: croflexception.h:27