Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofmsg_features.h
1 /*
2  * cofmsg_features.h
3  *
4  * Created on: 18.03.2013
5  * Author: andi
6  */
7 
8 #ifndef COFMSG_FEATURES_H_
9 #define COFMSG_FEATURES_H_ 1
10 
11 #include "rofl/common/openflow/messages/cofmsg.h"
12 #include "rofl/common/openflow/cofports.h"
13 #include "rofl/common/cauxid.h"
14 #include "rofl/common/cdpid.h"
15 
16 namespace rofl {
17 namespace openflow {
18 
23  public cofmsg
24 {
25 public:
26 
27 
32  uint8_t of_version = 0,
33  uint32_t xid = 0);
34 
35 
40  cofmsg_features_request const& features_request);
41 
42 
47  operator= (
48  cofmsg_features_request const& features_request);
49 
50 
54  virtual
56 
57 
62 
63 
67  virtual void
68  reset();
69 
70 
74  virtual size_t
75  length() const;
76 
77 
81  virtual void
82  pack(uint8_t *buf = (uint8_t*)0, size_t buflen = 0);
83 
84 
88  virtual void
89  unpack(uint8_t *buf, size_t buflen);
90 
91 
94  virtual void
95  validate();
96 
97 public:
98 
99  friend std::ostream&
100  operator<< (std::ostream& os, cofmsg_features_request const& msg) {
101  os << indent(0) << dynamic_cast<cofmsg const&>( msg );
102  os << indent(2) << "<cofmsg_features_request >" << std::endl;
103  return os;
104  };
105 
106  std::string
107  str() const {
108  std::stringstream ss;
109  ss << "-Features-Request- " << cofmsg::str();
110  return ss.str();
111  };
112 };
113 
114 
119  public cofmsg
120 {
121 private:
122 
124 
125  union {
126  uint8_t* ofhu_switch_features;
127  struct openflow10::ofp_switch_features* ofhu10_switch_features;
128  struct openflow12::ofp_switch_features* ofhu12_switch_features;
129  struct openflow13::ofp_switch_features* ofhu13_switch_features;
130  } ofhu;
131 
132 #define ofh_switch_features ofhu.ofhu_switch_features
133 #define ofh10_switch_features ofhu.ofhu10_switch_features
134 #define ofh12_switch_features ofhu.ofhu12_switch_features
135 #define ofh13_switch_features ofhu.ofhu13_switch_features
136 
137 public:
138 
139 
144  uint8_t of_version = 0,
145  uint32_t xid = 0,
146  uint64_t dpid = 0,
147  uint32_t n_buffers = 0,
148  uint8_t n_tables = 0,
149  uint32_t capabilities = 0,
150  uint32_t of10_actions_bitmap = 0,
151  uint8_t of13_auxiliary_id = 0,
153 
154 
159  cofmsg_features_reply const& features_reply);
160 
161 
166  operator= (
167  cofmsg_features_reply const& features_reply);
168 
169 
173  virtual
175 
176 
180  cofmsg_features_reply(cmemory *memarea);
181 
182 
186  virtual void
187  reset();
188 
189 
193  virtual uint8_t*
194  resize(size_t len);
195 
196 
200  virtual size_t
201  length() const;
202 
203 
207  virtual void
208  pack(uint8_t *buf = (uint8_t*)0, size_t buflen = 0);
209 
210 
214  virtual void
215  unpack(uint8_t *buf, size_t buflen);
216 
217 
220  virtual void
221  validate();
222 
223 
224 public:
225 
226 
230  uint64_t
231  get_dpid() const;
232 
236  void
237  set_dpid(uint64_t dpid);
238 
242  uint32_t
243  get_n_buffers() const;
244 
248  void
249  set_n_buffers(uint32_t n_buffers);
250 
254  uint8_t
255  get_n_tables() const;
256 
260  void
261  set_n_tables(uint8_t n_tables);
262 
266  uint8_t
267  get_auxiliary_id() const;
268 
272  void
273  set_auxiliary_id(uint8_t auxiliary_id);
274 
278  uint32_t
279  get_capabilities() const;
280 
284  void
285  set_capabilities(uint32_t capabilities);
286 
290  uint32_t
291  get_actions_bitmap() const;
292 
296  void
297  set_actions_bitmap(uint32_t actions_bitmap);
298 
303  set_ports();
304 
309  get_ports() const;
310 
311 public:
312 
313  friend std::ostream&
314  operator<< (std::ostream& os, cofmsg_features_reply const& msg) {
315  os << dynamic_cast<cofmsg const&>( msg );
316  os << indent(2) << "<cofmsg_features_reply ";
317  switch (msg.get_version()) {
318  case openflow10::OFP_VERSION: {
319  os << "dpid:" << msg.get_dpid() << " ";
320  os << "#buffers:" << (int)msg.get_n_buffers() << " ";
321  os << "#tables:" << (int)msg.get_n_tables() << " ";
322  os << "capabilities:" << std::hex << (int)msg.get_capabilities() << std::dec << " ";
323  os << "actions:" << (int)msg.get_actions_bitmap() << " ";
324  os << " >" << std::endl;
325  indent i(4);
326  os << msg.ports;
327  } break;
328  case openflow12::OFP_VERSION: {
329  os << "dpid:" << msg.get_dpid() << " ";
330  os << "#buffers:" << (int)msg.get_n_buffers() << " ";
331  os << "#tables:" << (int)msg.get_n_tables() << " ";
332  os << "capabilities:" << std::hex << (int)msg.get_capabilities() << std::dec << " ";
333  os << " >" << std::endl;
334  indent i(4);
335  os << msg.ports;
336  } break;
337  case openflow13::OFP_VERSION: {
338  os << "dpid:" << msg.get_dpid() << " ";
339  os << "#buffers:" << (int)msg.get_n_buffers() << " ";
340  os << "#tables:" << (int)msg.get_n_tables() << " ";
341  os << "capabilities:" << std::hex << (int)msg.get_capabilities() << std::dec << " ";
342  os << " >" << std::endl;
343  } break;
344  default: {
345 
346  } break;
347  }
348  return os;
349  };
350 
351  std::string
352  str() const {
353  std::stringstream ss;
354  ss << "-Features-Reply- " << cofmsg::str() << " ";
355  ss << "dpid: " << cdpid(get_dpid()).str() << ", ";
356  ss << "auxid: " << cauxid(get_auxiliary_id()).str() << ", ";
357  ss << "#buffers: " << (int)get_n_buffers() << ", ";
358  ss << "#tables: " << (int)get_n_tables() << " ";
359  return ss.str();
360  };
361 };
362 
363 } // end of namespace openflow
364 } // end of namespace rofl
365 
366 #endif /* COFMSG_FEATURES_H_ */
Definition: cauxid.h:30
Definition: cdpid.h:20
Definition: openflow12.h:311
virtual void reset()
Definition: cofmsg_features.cc:68
Definition: openflow10.h:261
virtual void pack(uint8_t *buf=(uint8_t *) 0, size_t buflen=0)
Definition: cofmsg_features.cc:84
uint32_t get_actions_bitmap() const
Definition: cofmsg_features.cc:544
cofmsg_features_reply(uint8_t of_version=0, uint32_t xid=0, uint64_t dpid=0, uint32_t n_buffers=0, uint8_t n_tables=0, uint32_t capabilities=0, uint32_t of10_actions_bitmap=0, uint8_t of13_auxiliary_id=0, rofl::openflow::cofports const &ports=rofl::openflow::cofports())
Definition: cofmsg_features.cc:138
virtual void validate()
Definition: cofmsg_features.cc:110
virtual size_t length() const
Definition: cofmsg_features.cc:258
virtual void pack(uint8_t *buf=(uint8_t *) 0, size_t buflen=0)
Definition: cofmsg_features.cc:278
Definition: cofports.h:22
C++ abstraction for malloc'ed memory areas.
Definition: cmemory.h:44
Definition: cofmsg_features.h:118
virtual void reset()
Definition: cofmsg_features.cc:240
virtual void unpack(uint8_t *buf, size_t buflen)
Definition: cofmsg_features.cc:100
virtual size_t length() const
Definition: cofmsg_features.cc:76
virtual void validate()
Definition: cofmsg_features.cc:318
virtual ~cofmsg_features_reply()
Definition: cofmsg_features.cc:232
cofmsg_features_request(uint8_t of_version=0, uint32_t xid=0)
Definition: cofmsg_features.cc:5
virtual ~cofmsg_features_request()
Definition: cofmsg_features.cc:60
Definition: openflow13.h:699
uint8_t get_auxiliary_id() const
Definition: cofmsg_features.cc:476
Definition: logging.h:76
Definition: cofmsg_features.h:22
virtual void unpack(uint8_t *buf, size_t buflen)
Definition: cofmsg_features.cc:308
Definition: cofmsg.h:62