Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofhelloelemversionbitmap.h
1 /*
2  * cofhelloelemversionbitmap.h
3  *
4  * Created on: 31.12.2013
5  * Author: andreas
6  */
7 
8 #ifndef COFHELLOELEMVERSIONBITMAP_H_
9 #define COFHELLOELEMVERSIONBITMAP_H_
10 
11 #include <inttypes.h>
12 #include <vector>
13 
14 #include "rofl/common/openflow/cofhelloelem.h"
15 
16 namespace rofl {
17 namespace openflow {
18 
21 
23  public cofhello_elem
24 {
25  std::vector<uint32_t> bitmaps;
26 
27  union {
28  uint8_t *ofhu_hello_elem_versionbitmap_generic;
29  openflow13::ofp_hello_elem_versionbitmap *ofhu13_versionbitmap;
30  } ofhu;
31 
32 #define ofh_hello_elem_version_bitmap_generic ofhu.ofhu_hello_elem_versionbitmap_generic
33 #define ofh_versionbitmap ofhu.ofhu13_versionbitmap
34 
35 public:
36 
41 
46  uint8_t *buf, size_t buflen);
47 
52  cofhello_elem const& elem);
53 
58  cofhello_elem_versionbitmap const& elem);
59 
63  virtual
65 
70  operator= (
71  cofhello_elem_versionbitmap const& elem);
72 
77  operator& (
78  cofhello_elem_versionbitmap const& versionbitmap) const;
79 
80 public:
81 
85  virtual uint8_t*
86  resize(size_t len);
87 
91  virtual size_t
92  length() const;
93 
97  void
98  pack(uint8_t *buf, size_t buflen);
99 
103  virtual void
104  unpack(uint8_t *buf, size_t buflen);
105 
106 public:
107 
111  void
112  add_ofp_version(uint8_t ofp_version);
113 
117  void
118  drop_ofp_version(uint8_t ofp_version);
119 
123  bool
124  has_ofp_version(uint8_t ofp_version) const;
125 
129  void
130  clear_ofp_versions();
131 
135  uint8_t
136  get_highest_ofp_version() const;
137 
138 public:
139 
140  friend std::ostream&
141  operator<< (std::ostream& os, cofhello_elem_versionbitmap const& elem) {
142  os << dynamic_cast<cofhello_elem const&>( elem );
143  os << indent(2) << "<cofhello_elem_versionbitmap >" << std::endl;
144  for (unsigned int i = 0; i < elem.bitmaps.size(); i++) {
145  os << indent(4) << "<bitmap[" << i << "] 0x" <<
146  std::setfill('0') << std::setw(8) <<
147  std::hex << elem.bitmaps[i] << std::dec <<
148  std::setw(0) << std::setfill(' ') << " >" << std::endl;
149  }
150  return os;
151  };
152 
153  std::string
154  str() const {
155  std::stringstream ss;
156  ss << "VersionBitmap ";
157  if (has_ofp_version(rofl::openflow10::OFP_VERSION)) {
158  ss << "1.0 ";
159  }
160  if (has_ofp_version(rofl::openflow12::OFP_VERSION)) {
161  ss << "1.2 ";
162  }
163  if (has_ofp_version(rofl::openflow13::OFP_VERSION)) {
164  ss << "1.3 ";
165  }
166  return ss.str();
167  };
168 };
169 
170 }; /* namespace openflow */
171 }; /* namespace rofl */
172 
173 
174 
175 #endif /* COFHELLOELEMVERSIONBITMAP_H_ */
virtual void unpack(uint8_t *buf, size_t buflen)
Copies content of specified buffer into this cmemory instance .
Definition: cofhelloelemversionbitmap.cc:151
Definition: cofhelloelemversionbitmap.h:22
void pack(uint8_t *buf, size_t buflen)
Copies content of this cmemory instance to specified buffer.
Definition: cofhelloelemversionbitmap.cc:133
cofhello_elem_versionbitmap operator&(cofhello_elem_versionbitmap const &versionbitmap) const
Calculates (*this AND versionbitmap) and returns a new copy of cofhello_elem_versionbitmap.
Definition: cofhelloelemversionbitmap.cc:84
Definition: cofhelloelemversionbitmap.h:19
virtual uint8_t * resize(size_t len)
Resizes allocated memory area by calling C-function realloc().
Definition: cofhelloelemversionbitmap.cc:104
Definition: cofhelloelem.h:18
Definition: cofhelloelemversionbitmap.h:20
Definition: logging.h:76
Definition: cofhelloelem.h:21