Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofflowstats.h
1 /*
2  * cofflowstatsrequest.h
3  *
4  * Created on: 14.03.2013
5  * Author: andi
6  */
7 
8 #ifndef COFFLOWSTATS_H_
9 #define COFFLOWSTATS_H_ 1
10 
11 #include "rofl/common/cmemory.h"
12 #include "rofl/common/openflow/cofmatch.h"
13 #include "rofl/common/openflow/cofactions.h"
14 #include "rofl/common/openflow/cofinstructions.h"
15 #include "rofl/common/openflow/openflow.h"
16 #include "rofl/common/openflow/openflow_rofl_exceptions.h"
17 #include "rofl/common/croflexception.h"
18 
19 namespace rofl {
20 namespace openflow {
21 
22 class eFlowStatsBase : public RoflException {};
23 class eFlowStatsInval : public eFlowStatsBase {};
25 
27 {
28 private: // data structures
29 
30  uint8_t of_version;
31  cofmatch match;
32  uint8_t table_id;
33  uint32_t out_port;
34  uint32_t out_group;
35  uint64_t cookie;
36  uint64_t cookie_mask;
37 
38 public: // data structures
39 
40 
41 public:
46  uint8_t of_version = 0,
47  uint8_t *buf = (uint8_t*)0,
48  size_t buflen = 0);
49 
54  uint8_t of_version,
55  cofmatch const& match,
56  uint8_t table_id,
57  uint16_t out_port);
58 
59 
64  uint8_t of_version,
65  cofmatch const& match,
66  uint8_t table_id,
67  uint32_t out_port,
68  uint32_t out_group,
69  uint64_t cookie,
70  uint64_t cookie_mask);
71 
72 
76  virtual
78 
79 
84  cofflow_stats_request const& flowstatsrequest);
85 
90  operator= (
91  cofflow_stats_request const& flowstatsrequest);
92 
93 
97  void
98  pack(uint8_t *buf, size_t buflen);
99 
100 
104  void
105  unpack(uint8_t *buf, size_t buflen);
106 
107 
111  size_t
112  length() const;
113 
114 
118  void
119  set_version(uint8_t of_version);
120 
124  uint8_t
125  get_version() const;
126 
130  void
131  set_table_id(uint8_t table_id);
132 
136  uint8_t
137  get_table_id() const;
138 
142  void
143  set_out_port(uint32_t out_port);
144 
148  uint32_t
149  get_out_port() const;
150 
154  void
155  set_out_group(uint32_t out_group);
156 
160  uint32_t
161  get_out_group() const;
162 
166  void
167  set_cookie(uint64_t cookie);
168 
172  uint64_t
173  get_cookie() const;
174 
178  void
179  set_cookie_mask(uint64_t cookie_mask);
180 
184  uint64_t
185  get_cookie_mask() const;
186 
190  void
191  set_match(cofmatch const& match);
192 
196  cofmatch&
197  set_match();
198 
202  cofmatch const&
203  get_match() const;
204 
205 public:
206 
207  friend std::ostream&
208  operator<< (std::ostream& os, cofflow_stats_request const& flow_stats_request) {
209  switch (flow_stats_request.of_version) {
210  case openflow10::OFP_VERSION: {
211  os << indent(0) << "<cofflow_stats_request >" << std::endl;
212  os << indent(2) << "<table-id:" << (int)flow_stats_request.get_table_id() << " >" << std::endl;
213  os << indent(2) << "<out-port:0x" << std::hex << (int)flow_stats_request.get_out_port() << std::dec << " >" << std::endl;
214  indent i(2);
215  os << flow_stats_request.match;
216 
217  } break;
218  case openflow12::OFP_VERSION:
219  case openflow13::OFP_VERSION: {
220  os << indent(0) << "<cofflow_stats_request >" << std::endl;
221  os << indent(2) << "<table-id:" << (int)flow_stats_request.get_table_id() << " >" << std::endl;
222  os << indent(2) << "<out-port:0x" << std::hex << (int)flow_stats_request.get_out_port() << std::dec << " >" << std::endl;
223  os << indent(2) << "<out-group:0x" << std::hex << (int)flow_stats_request.get_out_group() << std::dec << " >" << std::endl;
224  os << indent(2) << "<cookie:0x" << std::hex << (unsigned long long)flow_stats_request.get_cookie() << std::dec << " >" << std::endl;
225  os << indent(2) << "<cookie-mask:0x" << std::hex << (unsigned long long)flow_stats_request.get_cookie_mask() << std::dec << " >" << std::endl;
226  indent i(2);
227  os << flow_stats_request.match;
228 
229  } break;
230  default: {
231  os << "<cofflow_stats_request unknown OFP version >" << std::endl;
232  };
233  }
234  return os;
235  };
236 };
237 
238 
239 
241 {
242 private: // data structures
243 
244  uint8_t of_version;
245  uint8_t table_id;
246  uint32_t duration_sec;
247  uint32_t duration_nsec;
248  uint16_t priority;
249  uint16_t idle_timeout;
250  uint16_t hard_timeout;
251  uint16_t flags; // since OF1.3
252  uint64_t cookie;
253  uint64_t packet_count;
254  uint64_t byte_count;
255  cofmatch match;
256  cofactions actions; // for OF1.0
257  cofinstructions instructions; // since OF1.2
258 
259 #define OFP12_FLOW_STATS_REPLY_STATIC_HDR_LEN 48 // bytes
260 
261 public: // data structures
262 
263 
264 public:
269  uint8_t of_version = 0,
270  uint8_t *buf = (uint8_t*)0,
271  size_t buflen = 0);
272 
273 
278  uint8_t of_version,
279  uint8_t table_id,
280  uint32_t duration_sec,
281  uint32_t duration_nsec,
282  uint16_t priority,
283  uint16_t idle_timeout,
284  uint16_t hard_timeout,
285  uint64_t cookie,
286  uint64_t packet_count,
287  uint64_t byte_count,
288  cofmatch const& match,
289  cofactions const& actions);
290 
291 
296  uint8_t of_version,
297  uint8_t table_id,
298  uint32_t duration_sec,
299  uint32_t duration_nsec,
300  uint16_t priority,
301  uint16_t idle_timeout,
302  uint16_t hard_timeout,
303  uint16_t flags,
304  uint64_t cookie,
305  uint64_t packet_count,
306  uint64_t byte_count,
307  cofmatch const& match,
308  cofinstructions const& instructions);
309 
310 
311 
315  virtual
317 
318 
323  cofflow_stats_reply const& flowstats);
324 
329  operator= (
330  cofflow_stats_reply const& flowstats);
331 
335  bool
336  operator== (
337  cofflow_stats_reply const& flowstats);
338 
339 public:
340 
344  void
345  pack(uint8_t *buf, size_t buflen);
346 
347 
351  void
352  unpack(uint8_t *buf, size_t buflen);
353 
354 
358  size_t
359  length() const;
360 
361 
365  void
366  set_version(uint8_t of_version);
367 
368 
372  uint8_t
373  get_version() const;
374 
375 
379  uint8_t
380  get_table_id() const;
381 
385  uint32_t
386  get_duration_sec() const;
387 
391  uint32_t
392  get_duration_nsec() const;
393 
397  uint16_t
398  get_priority() const;
399 
403  uint16_t
404  get_idle_timeout() const;
405 
409  uint16_t
410  get_hard_timeout() const;
411 
415  uint16_t
416  get_flags() const;
417 
421  uint64_t
422  get_cookie() const;
423 
427  uint64_t
428  get_packet_count() const;
429 
433  uint64_t
434  get_byte_count() const;
435 
436 
437 
438 
439 
440 
441 
445  void
446  set_table_id(uint8_t table_id);
447 
451  void
452  set_duration_sec(uint32_t duration_sec);
453 
457  void
458  set_duration_nsec(uint32_t duration_nsec);
459 
463  void
464  set_priority(uint16_t priority);
465 
469  void
470  set_idle_timeout(uint16_t idle_timeout);
471 
475  void
476  set_hard_timeout(uint16_t hard_timeout);
477 
481  void
482  set_flags(uint16_t flags);
483 
487  void
488  set_cookie(uint64_t cookie);
489 
493  void
494  set_packet_count(uint64_t packet_count);
495 
499  void
500  set_byte_count(uint64_t byte_count);
501 
502 
503 
504 
505 
506 
510  cofmatch&
511  set_match() { return match; };
512 
516  cofactions&
517  set_actions() { return actions; };
518 
523  set_instructions() { return instructions; };
524 
525 
529  cofmatch const&
530  get_match() const { return match; };
531 
535  cofactions const&
536  get_actions() const { return actions; };
537 
541  cofinstructions const&
542  get_instructions() const { return instructions; };
543 
544 
545 public:
546 
547  friend std::ostream&
548  operator<< (std::ostream& os, cofflow_stats_reply const& flow_stats_reply) {
549  switch (flow_stats_reply.of_version) {
550  case rofl::openflow10::OFP_VERSION:
551  case rofl::openflow12::OFP_VERSION:
552  case rofl::openflow13::OFP_VERSION: {
553  os << indent(0) << "<cofflow_stats_reply >" << std::endl;
554  os << indent(2) << "<table-id: " << (int)flow_stats_reply.get_table_id() << " >" << std::endl;
555  os << indent(2) << "<duration-sec: " << (int)flow_stats_reply.get_duration_sec() << " >" << std::endl;
556  os << indent(2) << "<duration-nsec: " << (int)flow_stats_reply.get_duration_nsec() << " >" << std::endl;
557  os << indent(2) << "<priority: 0x" << std::hex << (int)flow_stats_reply.get_priority() << std::dec << " >" << std::endl;
558  os << indent(2) << "<idle-timeout: " << (int)flow_stats_reply.get_idle_timeout() << " >" << std::endl;
559  os << indent(2) << "<hard-timeout: " << (int)flow_stats_reply.get_hard_timeout() << " >" << std::endl;
560  os << indent(2) << "<cookie: 0x" << std::hex << (unsigned long long)flow_stats_reply.get_cookie() << std::dec << " >" << std::endl;
561  os << indent(2) << "<packet-count: " << (int)flow_stats_reply.get_packet_count() << " >" << std::endl;
562  os << indent(2) << "<byte-count: " << (int)flow_stats_reply.get_byte_count() << " >" << std::endl;
563  os << indent(2) << "<flags: " << (int)flow_stats_reply.get_flags() << " >" << std::endl;
564  indent i(2);
565  os << flow_stats_reply.match;
566  } break;
567  default: {
568 
569  };
570  }
571  indent i(2);
572  switch (flow_stats_reply.of_version) {
573  case openflow10::OFP_VERSION: os << flow_stats_reply.actions; break;
574  case openflow12::OFP_VERSION: os << flow_stats_reply.instructions; break;
575  case openflow13::OFP_VERSION: os << flow_stats_reply.instructions; break;
576  default: os << "<unknown OFP version >" << std::endl;
577  }
578  return os;
579  };
580 };
581 
582 } /* end of namespace */
583 } /* end of namespace */
584 
585 #endif /* COFFLOWSTATS_H_ */
Definition: cofflowstats.h:24
Definition: cofactions.h:22
Definition: cofinstructions.h:24
Definition: cofflowstats.h:23
Definition: cofmatch.h:35
Definition: cofflowstats.h:22
Definition: logging.h:76
Definition: cofflowstats.h:240
Definition: croflexception.h:27
Definition: cofflowstats.h:26