Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofportstats.h
1 /*
2  * cofportstatsrequest.h
3  *
4  * Created on: 14.03.2013
5  * Author: andi
6  */
7 
8 #ifndef COFPORTSTATS_H_
9 #define COFPORTSTATS_H_ 1
10 
11 #include "rofl/common/cmemory.h"
12 #include "rofl/common/openflow/cofactions.h"
13 #include "rofl/common/openflow/cofinstructions.h"
14 #include "rofl/common/openflow/openflow.h"
15 #include "rofl/common/openflow/openflow_rofl_exceptions.h"
16 
17 namespace rofl {
18 namespace openflow {
19 
20 class ePortStatsBase : public RoflException {};
21 class ePortStatsInval : public ePortStatsBase {};
23 
25 {
26 private: // data structures
27 
28  uint8_t of_version;
29  uint32_t port_no;
30 
31 public: // data structures
32 
33 
34 public:
39  uint8_t of_version = 0,
40  uint8_t *buf = (uint8_t*)0,
41  size_t buflen = 0);
42 
47  uint8_t of_version,
48  uint32_t port_no);
49 
50 
54  virtual
56 
57 
62  cofport_stats_request const& port_stats_request);
63 
68  operator= (
69  cofport_stats_request const& port_stats_request);
70 
71 
75  void
76  pack(uint8_t *buf, size_t buflen) const;
77 
78 
82  void
83  unpack(uint8_t *buf, size_t buflen);
84 
85 
89  size_t
90  length() const;
91 
92 
96  void
97  set_version(uint8_t of_version);
98 
99 
103  uint8_t
104  get_version() const;
105 
106 
110  uint32_t
111  get_portno() const;
112 
113 public:
114 
115  friend std::ostream&
116  operator<< (std::ostream& os, cofport_stats_request const& r) {
117  os << indent(0) << "<cofport_stats_request >" << std::endl;
118  os << indent(2) << "<port-no: 0x" << std::hex << (int)r.get_portno() << std::dec << " >" << std::endl;
119  return os;
120  };
121 };
122 
123 
124 
126 {
127 private: // data structures
128 
129  uint8_t of_version;
130  uint32_t port_no;
131  uint64_t rx_packets;
132  uint64_t tx_packets;
133  uint64_t rx_bytes;
134  uint64_t tx_bytes;
135  uint64_t rx_dropped;
136  uint64_t tx_dropped;
137  uint64_t rx_errors;
138  uint64_t tx_errors;
139  uint64_t rx_frame_err;
140  uint64_t rx_over_err;
141  uint64_t rx_crc_err;
142  uint64_t collisions;
143  uint32_t duration_sec; // since OF1.3
144  uint32_t duration_nsec; // since OF1.3
145 
146 
147 public: // data structures
148 
149 
150 public:
155  uint8_t of_version = 0,
156  uint8_t *buf = (uint8_t*)0,
157  size_t buflen = 0);
158 
159 
164  uint8_t of_version,
165  uint32_t port_no,
166  uint64_t rx_packets,
167  uint64_t tx_packets,
168  uint64_t rx_bytes,
169  uint64_t tx_bytes,
170  uint64_t rx_dropped,
171  uint64_t tx_dropped,
172  uint64_t rx_errors,
173  uint64_t tx_errors,
174  uint64_t rx_frame_err,
175  uint64_t rx_over_err,
176  uint64_t rx_crc_err,
177  uint64_t collisions,
178  uint32_t durarion_sec,
179  uint32_t duration_nsec);
180 
181 
182 
186  virtual
188 
189 
194  cofport_stats_reply const& port_stats_reply);
195 
200  operator= (
201  cofport_stats_reply const& port_stats_reply);
202 
206  bool
207  operator== (
208  cofport_stats_reply const& port_stats_reply);
209 
213  void
214  pack(uint8_t *buf, size_t buflen) const;
215 
216 
220  void
221  unpack(uint8_t *buf, size_t buflen);
222 
223 
227  size_t
228  length() const;
229 
230 
234  void
235  reset();
236 
237 
241  void
242  set_version(uint8_t of_version);
243 
244 
248  uint8_t
249  get_version() const;
250 
251 
255  uint32_t
256  get_port_no() const;
257 
261  uint64_t
262  get_rx_packets() const;
263 
267  uint64_t
268  get_tx_packets() const;
269 
273  uint64_t
274  get_rx_bytes() const;
275 
279  uint64_t
280  get_tx_bytes() const;
281 
285  uint64_t
286  get_rx_dropped() const;
287 
291  uint64_t
292  get_tx_dropped() const;
293 
297  uint64_t
298  get_rx_errors() const;
299 
303  uint64_t
304  get_tx_errors() const;
305 
309  uint64_t
310  get_rx_frame_err() const;
311 
315  uint64_t
316  get_rx_over_err() const;
317 
321  uint64_t
322  get_rx_crc_err() const;
323 
327  uint64_t
328  get_collisions() const;
329 
333  uint32_t
334  get_duration_sec() const;
335 
339  uint32_t
340  get_duration_nsec() const;
341 
345  void
346  set_port_no(uint32_t port_no);
347 
351  void
352  set_rx_packets(uint64_t rx_packets);
353 
357  void
358  set_tx_packets(uint64_t tx_packets);
359 
363  void
364  set_rx_bytes(uint64_t rx_bytes);
365 
369  void
370  set_tx_bytes(uint64_t tx_bytes);
371 
375  void
376  set_rx_dropped(uint64_t rx_dropped);
377 
381  void
382  set_tx_dropped(uint64_t tx_dropped);
383 
387  void
388  set_rx_errors(uint64_t rx_errors);
389 
393  void
394  set_tx_errors(uint64_t tx_errors);
395 
399  void
400  set_rx_frame_err(uint64_t rx_frame_err);
401 
405  void
406  set_rx_over_err(uint64_t rx_over_err);
407 
411  void
412  set_rx_crc_err(uint64_t rx_crc_err);
413 
417  void
418  set_collisions(uint64_t collisions);
419 
423  void
424  set_duration_sec(uint32_t duration_sec);
425 
429  void
430  set_duration_nsec(uint32_t duration_nsec);
431 
432 public:
433 
434  friend std::ostream&
435  operator<< (std::ostream& os, cofport_stats_reply const& r) {
436  os << indent(0) << "<cofport_stats_reply >" << std::endl;
437  os << std::hex;
438  os << indent(2) << "<port-no: 0x" << (int)r.get_port_no() << " >" << std::endl;
439  os << indent(2) << "<rx-packets: 0x" << (unsigned long long)r.get_rx_packets() << " >" << std::endl;
440  os << indent(2) << "<tx-packets: 0x" << (unsigned long long)r.get_tx_packets() << " >" << std::endl;
441  os << indent(2) << "<rx-bytes: 0x" << (unsigned long long)r.get_rx_bytes() << " >" << std::endl;
442  os << indent(2) << "<tx-bytes: 0x" << (unsigned long long)r.get_tx_bytes() << " >" << std::endl;
443  os << indent(2) << "<rx-dropped: 0x" << (unsigned long long)r.get_rx_dropped() << " >" << std::endl;
444  os << indent(2) << "<tx-dropped: 0x" << (unsigned long long)r.get_tx_dropped() << " >" << std::endl;
445  os << indent(2) << "<rx-errors: 0x" << (unsigned long long)r.get_rx_errors() << " >" << std::endl;
446  os << indent(2) << "<tx-errors: 0x" << (unsigned long long)r.get_tx_errors() << " >" << std::endl;
447  os << indent(2) << "<rx-frame-err: 0x" << (unsigned long long)r.get_rx_frame_err() << " >" << std::endl;
448  os << indent(2) << "<rx-over-err: 0x" << (unsigned long long)r.get_rx_over_err() << " >" << std::endl;
449  os << indent(2) << "<rx-crc-err: 0x" << (unsigned long long)r.get_rx_crc_err() << " >" << std::endl;
450  os << indent(2) << "<collisions: 0x" << (unsigned long long)r.get_collisions() << " >" << std::endl;
451  os << std::dec;
452  switch (r.get_version()) {
453  case rofl::openflow13::OFP_VERSION: {
454  os << indent(2) << "<duration-sec: " << (unsigned long long)r.get_duration_sec() << " >" << std::endl;
455  os << indent(2) << "<duration-nsec: " << (unsigned long long)r.get_duration_nsec() << " >" << std::endl;
456  } break;
457  default: {
458  };
459  }
460  return os;
461  };
462 };
463 
464 } /* end of namespace */
465 } /* end of namespace */
466 
467 #endif /* COFFLOWSTATS_H_ */
Definition: cofportstats.h:22
Definition: cofportstats.h:21
Definition: cofportstats.h:24
Definition: cofportstats.h:125
Definition: logging.h:76
Definition: cofportstats.h:20
Definition: croflexception.h:27