Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofrole.h
1 /*
2  * cofrole.h
3  *
4  * Created on: 18.03.2014
5  * Author: andreas
6  */
7 
8 #ifndef COFROLE_H_
9 #define COFROLE_H_
10 
11 #include <inttypes.h>
12 
13 #include <iostream>
14 
15 #include "rofl/common/logging.h"
16 #include "rofl/common/croflexception.h"
17 #include "rofl/common/openflow/openflow.h"
18 #include "rofl/common/openflow/openflow_rofl_exceptions.h"
19 
20 namespace rofl {
21 namespace openflow {
22 
23 class cofrole
24 {
25  uint8_t ofp_version;
26  uint32_t role;
27  uint64_t generation_id;
28 
29 public:
30 
31  struct role_t {
32  uint32_t role;
33  uint8_t pad[4];
34  uint64_t generation_id;
35  };
36 
37 
41  static int64_t
42  distance(int64_t rcvd_gen_id, int64_t cached_gen_id);
43 
44 public:
45 
49  cofrole(
50  uint8_t ofp_version = rofl::openflow::OFP_VERSION_UNKNOWN);
51 
55  virtual
56  ~cofrole();
57 
61  cofrole(
62  cofrole const& role);
63 
67  cofrole&
68  operator= (
69  cofrole const& role);
70 
71 public:
72 
76  void
77  clear();
78 
82  virtual size_t
83  length() const;
84 
88  virtual void
89  pack(uint8_t *buf, size_t buflen);
90 
94  virtual void
95  unpack(uint8_t *buf, size_t buflen);
96 
97 public:
98 
102  uint8_t
103  get_version() const { return ofp_version; };
104 
108  void
109  set_version(uint8_t ofp_version) { this->ofp_version = ofp_version; };
110 
114  uint32_t const&
115  get_role() const { return role; };
116 
120  void
121  set_role(uint32_t role) { this->role = role; };
122 
126  uint32_t&
127  set_role() { return role; };
128 
132  uint64_t const&
133  get_generation_id() const { return generation_id; };
134 
138  void
139  set_generation_id(uint64_t generation_id) { this->generation_id = generation_id; };
140 
144  uint64_t&
145  set_generation_id() { return generation_id; };
146 
147 public:
148 
152  friend std::ostream&
153  operator<< (std::ostream& os, cofrole const& role) {
154  os << rofl::indent(0) << "<cofrole ofp-version:" << (int)role.get_version() << " >" << std::endl;
155  os << std::hex;
156  os << rofl::indent(2) << "<role: 0x" << (unsigned int)role.get_role() << " >" << std::endl;
157  os << rofl::indent(2) << "<generation-id: 0x" << (unsigned long long)role.get_generation_id() << " >" << std::endl;
158  os << std::dec;
159  return os;
160  };
161 };
162 
163 }; // end of namespace openflow
164 }; // end of namespace rofl
165 
166 #endif /* COFROLE_H_ */
Definition: cofrole.h:23
Definition: logging.h:76
Definition: cofrole.h:31