Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofgroupmod.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef COFGROUPMOD_H_
6 #define COFGROUPMOD_H_ 1
7 
8 #include <string>
9 #include <vector>
10 
11 #include "rofl/common/cmemory.h"
12 #include "rofl/common/caddress.h"
13 #include "rofl/common/croflexception.h"
14 #include "rofl/common/openflow/cofmatch.h"
15 #include "rofl/common/openflow/cofbuckets.h"
16 #include "rofl/common/openflow/cofinstruction.h"
17 
18 namespace rofl {
19 namespace openflow {
20 
21 class eGroupEntryBase : public RoflException {};
23 
25 {
26  uint8_t ofp_version;
27 
28 public:
29 
30  union {
31  uint8_t *gmu_grp_mod;
32  struct openflow12::ofp_group_mod *gmu12_grp_mod; // pointer to group_mod_area (see below)
33  struct openflow13::ofp_group_mod *gmu13_grp_mod;
34  } ofgm_gmu;
35 
36 #define grp_mod ofgm_gmu.gmu_grp_mod
37 #define of12_grp_mod ofgm_gmu.gmu12_grp_mod
38 #define of13_grp_mod ofgm_gmu.gmu13_grp_mod
39 
40 private: // data structures
41 
42  cmemory group_mod_area; // group mod memory area
43 
44 
45 public: // data structures
46 
47  cofbuckets buckets; // bucket list
48 
49 
50 public: // methods
51 
55  cofgroupmod(uint8_t ofp_version);
56 
57 
61  virtual
62  ~cofgroupmod();
63 
64 
69  operator= (
70  const cofgroupmod& fe);
71 
72 
76  void
77  clear();
78 
79 
83  size_t
84  pack();
85 
86 
87 
88 public: // setter methods for ofp_group_mod structure
89 
93  uint16_t
94  get_command() const;
95 
99  void
100  set_command(
101  uint16_t command);
102 
106  uint8_t
107  get_type() const;
108 
112  void
113  set_type(
114  uint8_t type);
115 
119  uint32_t
120  get_group_id() const;
121 
125  void
126  set_group_id(
127  uint32_t group_id);
128 
129 
133  cofbuckets&
134  set_buckets() { return buckets; };
135 
139  cofbuckets const&
140  get_buckets() const { return buckets; };
141 
142 public:
143 
144  friend std::ostream&
145  operator<< (std::ostream& os, cofgroupmod const& ge) {
146  os << "<cgroupentry ";
147  os << "cmd:";
148  switch (ge.ofp_version) {
149  case openflow12::OFP_VERSION: {
150  switch (ge.get_command()) {
151  case openflow12::OFPGC_ADD: os << "ADD "; break;
152  case openflow12::OFPGC_MODIFY: os << "MODIFY "; break;
153  case openflow12::OFPGC_DELETE: os << "DELETE "; break;
154  default: os << "UNKNOWN "; break;
155  }
156  os << "type:";
157  switch (ge.get_type()) {
158  case openflow12::OFPGT_ALL: os << "ALL "; break;
159  case openflow12::OFPGT_SELECT: os << "SELECT "; break;
160  case openflow12::OFPGT_INDIRECT:os << "INDIRECT "; break;
161  case openflow12::OFPGT_FF: os << "FAST-FAILOVER"; break;
162  default: os << "UNKNOWN"; break;
163  }
164  } break;
165  case openflow13::OFP_VERSION: {
166  switch (ge.get_command()) {
167  case openflow13::OFPGC_ADD: os << "ADD "; break;
168  case openflow13::OFPGC_MODIFY: os << "MODIFY "; break;
169  case openflow13::OFPGC_DELETE: os << "DELETE "; break;
170  default: os << "UNKNOWN "; break;
171  }
172  os << "type:";
173  switch (ge.get_type()) {
174  case openflow13::OFPGT_ALL: os << "ALL "; break;
175  case openflow13::OFPGT_SELECT: os << "SELECT "; break;
176  case openflow13::OFPGT_INDIRECT:os << "INDIRECT "; break;
177  case openflow13::OFPGT_FF: os << "FAST-FAILOVER"; break;
178  default: os << "UNKNOWN"; break;
179  }
180  } break;
181  default:
182  throw eBadVersion();
183  }
184  os << "group-id:" << (int)ge.get_group_id() << " >" << std::endl;
185  os << indent(2) << "<buckets: >" << std::endl;
186  indent i(4);
187  os << ge.buckets;
188  return os;
189  };
190 };
191 
192 }; // end of namespace
193 }; // end of namespace
194 
195 #endif
Definition: croflexception.h:73
Definition: cofgroupmod.h:24
void clear()
reset instance
Definition: cofgroupmod.cc:58
Definition: openflow13.h:859
Definition: cofbuckets.h:28
Definition: cofgroupmod.h:22
virtual ~cofgroupmod()
destructor
Definition: cofgroupmod.cc:35
C++ abstraction for malloc'ed memory areas.
Definition: cmemory.h:44
cofgroupmod & operator=(const cofgroupmod &fe)
assignment operator
Definition: cofgroupmod.cc:42
Definition: cofgroupmod.h:21
Definition: logging.h:76
cofgroupmod(uint8_t ofp_version)
constructor
Definition: cofgroupmod.cc:10
Definition: openflow12.h:1000
Definition: croflexception.h:27