Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofgroupstats.h
1 /*
2  * cofgroupstats.h
3  *
4  * Created on: 14.03.2013
5  * Author: andi
6  */
7 
8 #ifndef COFGROUPSTATS_H_
9 #define COFGROUPSTATS_H_ 1
10 
11 #include "rofl/common/cmemory.h"
12 #include "rofl/common/openflow/openflow.h"
13 #include "rofl/common/openflow/openflow_rofl_exceptions.h"
14 #include "rofl/common/openflow/cofbucketcounters.h"
15 
16 namespace rofl {
17 namespace openflow {
18 
19 class eGroupStatsBase : public RoflException {};
22 
24 {
25 private: // data structures
26 
27  uint8_t of_version;
28  uint32_t group_id;
29 
30 public: // data structures
31 
32 
33 public:
38  uint8_t of_version = 0);
39 
44  uint8_t of_version,
45  uint32_t group_id);
46 
50  virtual
52 
53 
58  cofgroup_stats_request const& stats);
59 
64  operator= (
65  cofgroup_stats_request const& stats);
66 
67 
71  void
72  pack(uint8_t *buf, size_t buflen) const;
73 
77  void
78  unpack(uint8_t *buf, size_t buflen);
79 
80 
84  size_t
85  length() const;
86 
87 
88 public:
89 
90 
94  void
95  set_version(uint8_t of_version) { this->of_version = of_version; };
96 
97 
101  uint8_t
102  get_version() const { return of_version; };
103 
104 
108  uint32_t
109  get_group_id() const { return group_id; };
110 
111 
115  void
116  set_group_id(uint32_t group_id) { this->group_id = group_id; };
117 
118 public:
119 
120  friend std::ostream&
121  operator<< (std::ostream& os, cofgroup_stats_request const& r) {
122  os << indent(0) << "<cofgroup_stats_request >" << std::endl;
123  os << indent(2) << "<group-id: " << (int)r.get_group_id() << " >" << std::endl;
124  return os;
125  };
126 };
127 
128 
129 
131 {
132 private: // data structures
133 
134  uint8_t of_version;
135  uint32_t group_id;
136  uint32_t ref_count;
137  uint64_t packet_count;
138  uint64_t byte_count;
139  uint32_t duration_sec;
140  uint32_t duration_nsec;
141  cofbucket_counters bucket_counters;
142 
143 
144 public: // data structures
145 
146 
147 public:
152  uint8_t of_version = 0);
153 
158  uint8_t of_version,
159  uint32_t group_id,
160  uint32_t ref_count,
161  uint64_t packet_count,
162  uint64_t byte_count,
163  uint32_t duration_sec,
164  uint32_t duration_nsec);
165 
169  virtual
171 
172 
177  cofgroup_stats_reply const& stats);
178 
183  operator= (
184  cofgroup_stats_reply const& stats);
185 
189  bool
190  operator== (
191  cofgroup_stats_reply const& stats);
192 
196  void
197  pack(uint8_t *buf, size_t buflen);
198 
202  void
203  unpack(uint8_t *buf, size_t buflen);
204 
205 
209  size_t
210  length() const;
211 
212 
213 public:
214 
218  uint8_t
219  get_version() const { return of_version; };
220 
224  uint32_t
225  get_group_id() const { return group_id; };
226 
230  uint32_t
231  get_ref_count() const { return ref_count; };
232 
236  uint64_t
237  get_packet_count() const { return packet_count; };
238 
242  uint64_t
243  get_byte_count() const { return byte_count; };
244 
248  uint32_t
249  get_duration_sec() const { return duration_sec; };
250 
254  uint32_t
255  get_duration_nsec() const { return duration_nsec; };
256 
261  set_bucket_counters() { return bucket_counters; };
262 
266  cofbucket_counters const&
267  get_bucket_counters() const { return bucket_counters; };
268 
272  void
273  set_version(uint8_t of_version) { this->of_version = of_version; };
274 
278  void
279  set_group_id(uint32_t group_id) { this->group_id = group_id; };
280 
284  void
285  set_ref_count(uint32_t ref_count) { this->ref_count = ref_count; };
286 
290  void
291  set_packet_count(uint64_t packet_count) { this->packet_count = packet_count; };
292 
296  void
297  set_byte_count(uint64_t byte_count) { this->byte_count = byte_count; };
298 
302  void
303  set_duration_sec(uint32_t duration_sec) { this->duration_sec = duration_sec; };
304 
308  void
309  set_duration_nsec(uint32_t duration_nsec) { this->duration_nsec = duration_nsec; };
310 
311 public:
312 
313  friend std::ostream&
314  operator<< (std::ostream& os, cofgroup_stats_reply const& r) {
315  os << indent(0) << "<cofgroup_stats_reply >" << std::endl;
316  os << std::hex;
317  os << indent(2) << "<group-id: 0x" << (int)r.get_group_id() << " >" << std::endl;
318  os << indent(2) << "<ref-count: 0x" << (int)r.get_ref_count() << " >" << std::endl;
319  os << indent(2) << "<packet-count: 0x" << (int)r.get_packet_count() << " >" << std::endl;
320  os << indent(2) << "<byte-count: 0x" << (int)r.get_byte_count() << " >" << std::endl;
321  os << std::dec;
322  switch (r.get_version()) {
323  case rofl::openflow13::OFP_VERSION: {
324  os << std::hex;
325  os << indent(2) << "<duration-sec: 0x" << (int)r.get_duration_sec() << " >" << std::endl;
326  os << indent(2) << "<duration-nsec: 0x" << (int)r.get_duration_nsec() << " >" << std::endl;
327  os << std::dec;
328  } break;
329  default: {
330  };
331  }
332  indent i(2);
333  os << r.bucket_counters;
334  return os;
335  };
336 };
337 
338 }
339 }
340 
341 #endif /* COFGROUPSTATS_H_ */
Definition: cofgroupstats.h:20
Definition: cofgroupstats.h:19
Definition: cofgroupstats.h:23
Definition: cofgroupstats.h:21
Definition: cofbucketcounters.h:22
Definition: cofgroupstats.h:130
Definition: logging.h:76
Definition: croflexception.h:27