Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofmeterband.h
1 /*
2  * cofqueueprop.h
3  *
4  * Created on: 29.04.2013
5  * Author: andi
6  */
7 
8 #ifndef COFMETERBAND_H_
9 #define COFMETERBAND_H_ 1
10 
11 #include <ostream>
12 #include <endian.h>
13 #ifndef htobe16
14  #include "../endian_conversion.h"
15 #endif
16 
17 #include "rofl/common/cmemory.h"
18 #include "rofl/common/croflexception.h"
19 #include "rofl/common/openflow/openflow.h"
20 #include "rofl/common/openflow/openflow_rofl_exceptions.h"
21 
22 namespace rofl {
23 namespace openflow {
24 
25 class eRofMeterBandBase : public RoflException {};
27 
28 
30 public:
31 
36  uint8_t of_version = rofl::openflow::OFP_VERSION_UNKNOWN,
37  size_t len = sizeof(struct rofl::openflow13::ofp_meter_band_header));
38 
39 
43  virtual
44  ~cofmeter_band();
45 
46 
51  const cofmeter_band& mb);
52 
53 
58  operator= (
59  const cofmeter_band& mb);
60 
61 
62 
66  const bool
67  operator== (
68  const cofmeter_band& mb) const;
69 
70 
71 public:
72 
73 
77  uint8_t*
78  resize(size_t len) { return body.resize(len); }
79 
80 
84  virtual size_t
85  length() const;
86 
87 
91  virtual void
92  pack(uint8_t *buf, size_t buflen);
93 
94 
98  virtual void
99  unpack(uint8_t *buf, size_t buflen);
100 
101 
102 public:
103 
104 
108  uint8_t
109  get_version() const { return of_version; };
110 
111 
115  void
116  set_version(
117  uint8_t of_version) { this->of_version = of_version; };
118 
119 
123  uint16_t
124  get_type() const { return type; }
125 
126 
130  void
131  set_type(
132  uint16_t type) { this->type = type; };
133 
134 
138  uint16_t
139  get_length() const { return len; };
140 
141 
145  void
146  set_length(uint16_t len) { this->len = len; };
147 
148 
152  uint32_t
153  get_rate() const { return rate; };
154 
155 
159  void
160  set_rate(
161  uint32_t rate) { this->rate = rate; };
162 
163 
167  uint32_t
168  get_burst_size() const { return burst_size; };
169 
170 
174  void
175  set_burst_size(
176  uint32_t burst_size) { this->burst_size = burst_size; };
177 
178 
183  set_body() { return body; };
184 
185 
189  rofl::cmemory const&
190  get_body() const { return body; };
191 
192 
193 public:
194 
198  friend std::ostream&
199  operator<< (std::ostream& os, cofmeter_band const& mb) {
200  os << rofl::indent(0) << "<cofmeter_band "
201  << std::hex
202  << " type: 0x" << mb.get_type()
203  << " len: 0x" << mb.get_length()
204  << " rate: 0x" << mb.get_rate()
205  << " burst_size: 0x" << mb.get_burst_size()
206  << std::dec
207  << " >" << std::endl;
208  { rofl::indent i(2); os << mb.get_body(); }
209  return os;
210  };
211 
212 private:
213 
214  uint8_t of_version;
215  uint16_t type;
216  uint16_t len;
217  uint32_t rate;
218  uint32_t burst_size;
219  rofl::cmemory body;
220 };
221 
222 
223 
224 
225 
226 
227 
229  public cofmeter_band
230 {
231 public:
232 
237  uint8_t of_version = rofl::openflow13::OFP_VERSION);
238 
239 
243  virtual
245 
246 
247 
252  const cofmeter_band_drop& mb);
253 
254 
255 
260  operator= (
261  const cofmeter_band_drop& mb);
262 
263 
267  const bool
268  operator== (
269  const cofmeter_band_drop& mb) const;
270 
271 
272 public:
273 
274  friend std::ostream&
275  operator<< (std::ostream& os, const cofmeter_band_drop& mb) {
276  os << rofl::indent(0) << "<cofmeter_band_drop >" << std::endl;
277  rofl::indent i(2);
278  os << dynamic_cast<const cofmeter_band&>( mb );
279  return os;
280  };
281 };
282 
283 
284 
285 
286 
287 
288 
290  public cofmeter_band
291 {
292 public:
293 
298  uint8_t of_version = rofl::openflow13::OFP_VERSION);
299 
300 
304  virtual
306 
307 
308 
313  const cofmeter_band_dscp_remark& mb);
314 
315 
316 
321  operator= (
322  const cofmeter_band_dscp_remark& mb);
323 
324 
328  const bool
329  operator== (
330  const cofmeter_band_dscp_remark& mb) const;
331 
332 
333 public:
334 
335 
339  virtual size_t
340  length() const;
341 
342 
346  virtual void
347  pack(uint8_t *buf, size_t buflen);
348 
349 
353  virtual void
354  unpack(uint8_t *buf, size_t buflen);
355 
356 
357 public:
358 
359 
363  uint8_t
364  get_prec_level() const { return prec_level; };
365 
366 
370  void
371  set_prec_level(uint8_t prec_level) { this->prec_level = prec_level; };
372 
373 public:
374 
375  friend std::ostream&
376  operator<< (std::ostream& os, const cofmeter_band_dscp_remark& mb) {
377  os << rofl::indent(0) << "<cofmeter_band_dscp_remark prec-level: 0x"
378  << std::hex << (int)mb.get_prec_level() << std::dec << " >" << std::endl;
379  rofl::indent i(2);
380  os << dynamic_cast<const cofmeter_band&>( mb );
381  return os;
382  };
383 
384 private:
385 
386  uint8_t prec_level;
387 };
388 
389 
390 
391 
392 
394  public cofmeter_band
395 {
396 public:
397 
402  uint8_t of_version = rofl::openflow13::OFP_VERSION);
403 
404 
408  virtual
410 
411 
416  const cofmeter_band_experimenter& mb);
417 
418 
423  operator= (
424  const cofmeter_band_experimenter& mb);
425 
426 
430  const bool
431  operator== (
432  const cofmeter_band_experimenter& mb) const;
433 
434 
435 public:
436 
437 
441  virtual size_t
442  length() const;
443 
444 
448  virtual void
449  pack(uint8_t *buf, size_t buflen);
450 
451 
455  virtual void
456  unpack(uint8_t *buf, size_t buflen);
457 
458 
459 public:
460 
461 
465  uint32_t
466  get_exp_id() const { return exp_id; };
467 
468 
472  void
473  set_exp_id(uint32_t exp_id) { this->exp_id = exp_id; };
474 
475 
479  cmemory const&
480  get_exp_body() const { return exp_body; };
481 
482 
486  cmemory&
487  set_exp_body() { return exp_body; };
488 
489 
493  cmemory const&
494  get_body() const { return exp_body; };
495 
496 
500  cmemory&
501  set_body() { return exp_body; };
502 
503 
504 public:
505 
506  friend std::ostream&
507  operator<< (std::ostream& os, const cofmeter_band_experimenter& mb) {
508  os << rofl::indent(0) << "<cofmeter_band_experimenter exp_id: 0x"
509  << std::hex << (int)mb.get_exp_id() << std::dec << " >" << std::endl;
510  { rofl::indent i(2); os << dynamic_cast<const cofmeter_band&>( mb ); }
511  os << rofl::indent(2) << "<experimental body: >" << std::endl;
512  { rofl::indent i(4); os << mb.get_exp_body(); }
513  return os;
514  };
515 
516 private:
517 
518  uint32_t exp_id;
519  rofl::cmemory exp_body;
520 };
521 
522 }
523 }
524 
525 #endif /* COFMETERBAND_H_ */
Definition: cofmeterband.h:289
Definition: cofmeterband.h:228
Definition: openflow13.h:936
Definition: cofmeterband.h:26
Definition: cofmeterband.h:393
virtual uint8_t * resize(size_t len)
Resizes allocated memory area by calling C-function realloc().
Definition: cmemory.cc:253
C++ abstraction for malloc'ed memory areas.
Definition: cmemory.h:44
Definition: cofmeterband.h:25
Definition: logging.h:76
Definition: cofmeterband.h:29
Definition: croflexception.h:27