Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofmsg_config.h
1 /*
2  * cofmsg_config.h
3  *
4  * Created on: 18.03.2013
5  * Author: andi
6  */
7 
8 #ifndef COFMSG_CONFIG_H_
9 #define COFMSG_CONFIG_H_ 1
10 
11 #include "rofl/common/openflow/messages/cofmsg.h"
12 
13 namespace rofl {
14 namespace openflow {
15 
20  public cofmsg
21 {
22 public:
23 
24 
29  uint8_t of_version = 0,
30  uint32_t xid = 0);
31 
32 
37  cofmsg_get_config_request const& get_config_request);
38 
39 
44  operator= (
45  cofmsg_get_config_request const& get_config_request);
46 
47 
51  virtual
53 
54 
59 
60 
64  virtual void
65  reset();
66 
67 
71  virtual size_t
72  length() const;
73 
74 
78  virtual void
79  pack(uint8_t *buf = (uint8_t*)0, size_t buflen = 0);
80 
81 
85  virtual void
86  unpack(uint8_t *buf, size_t buflen);
87 
88 
91  virtual void
92  validate();
93 
94 public:
95 
96  friend std::ostream&
97  operator<< (std::ostream& os, cofmsg_get_config_request const& msg) {
98  os << indent(0) << dynamic_cast<cofmsg const&>( msg );
99  os << indent(2) << "<cofmsg_get_config_request >" << std::endl;;
100  return os;
101  };
102 
103  std::string
104  str() const {
105  std::stringstream ss;
106  ss << "-Get-Config-Request- " << cofmsg::str() << " ";
107  return ss.str();
108  };
109 };
110 
111 
116  public cofmsg
117 {
118 private:
119 
120  union {
121  uint8_t* ofhu_switch_config;
122  struct openflow10::ofp_switch_config* ofhu10_switch_config;
123  struct openflow12::ofp_switch_config* ofhu12_switch_config;
124  struct openflow13::ofp_switch_config* ofhu13_switch_config;
125  } ofhu;
126 
127 #define ofh_switch_config ofhu.ofhu_switch_config
128 #define ofh10_switch_config ofhu.ofhu10_switch_config
129 #define ofh12_switch_config ofhu.ofhu12_switch_config
130 #define ofh13_switch_config ofhu.ofhu13_switch_config
131 
132 public:
133 
134 
139  uint8_t of_version = 0,
140  uint32_t xid = 0,
141  uint16_t flags = 0,
142  uint16_t miss_send_len = 0);
143 
144 
149  cofmsg_get_config_reply const& config);
150 
151 
156  operator= (
157  cofmsg_get_config_reply const& config);
158 
159 
163  virtual
165 
166 
171 
172 
176  virtual void
177  reset();
178 
179 
183  virtual uint8_t*
184  resize(size_t len);
185 
186 
190  virtual size_t
191  length() const;
192 
193 
197  virtual void
198  pack(uint8_t *buf = (uint8_t*)0, size_t buflen = 0);
199 
200 
204  virtual void
205  unpack(uint8_t *buf, size_t buflen);
206 
207 
210  virtual void
211  validate();
212 
213 
214 public:
215 
216 
220  uint16_t
221  get_flags() const;
222 
226  void
227  set_flags(uint16_t flags);
228 
232  uint16_t
233  get_miss_send_len() const;
234 
238  void
239  set_miss_send_len(uint16_t miss_send_len);
240 
241 public:
242 
243  friend std::ostream&
244  operator<< (std::ostream& os, cofmsg_get_config_reply const& msg) {
245  std::string s_flags;
246  switch (msg.get_version()) {
247  case rofl::openflow10::OFP_VERSION: {
248  if ((msg.get_flags() & rofl::openflow10::OFPC_FRAG_DROP) == rofl::openflow10::OFPC_FRAG_NORMAL)
249  s_flags.append("FRAG-NORMAL ");
250  if (msg.get_flags() & rofl::openflow10::OFPC_FRAG_DROP)
251  s_flags.append("FRAG-DROP ");
252  if (msg.get_flags() & rofl::openflow10::OFPC_FRAG_REASM)
253  s_flags.append("FRAG-REASM ");
254  } break;
255  case rofl::openflow12::OFP_VERSION: {
256  if ((msg.get_flags() & rofl::openflow12::OFPC_FRAG_DROP) == rofl::openflow12::OFPC_FRAG_NORMAL)
257  s_flags.append("FRAG-NORMAL ");
258  if (msg.get_flags() & rofl::openflow12::OFPC_FRAG_DROP)
259  s_flags.append("FRAG-DROP ");
260  if (msg.get_flags() & rofl::openflow12::OFPC_FRAG_REASM)
261  s_flags.append("FRAG-REASM ");
262  if (msg.get_flags() & rofl::openflow12::OFPC_INVALID_TTL_TO_CONTROLLER)
263  s_flags.append("INVALID-TTL-TO-CONTROLLER ");
264  } break;
265  case rofl::openflow13::OFP_VERSION: {
266  if ((msg.get_flags() & rofl::openflow13::OFPC_FRAG_DROP) == rofl::openflow13::OFPC_FRAG_NORMAL)
267  s_flags.append("FRAG-NORMAL ");
268  if (msg.get_flags() & rofl::openflow13::OFPC_FRAG_DROP)
269  s_flags.append("FRAG-DROP ");
270  if (msg.get_flags() & rofl::openflow13::OFPC_FRAG_REASM)
271  s_flags.append("FRAG-REASM ");
272  } break;
273  default:
274  s_flags.append("unsupported OF version");
275  break;
276  }
277  os << indent(0) << dynamic_cast<cofmsg const&>( msg );
278  os << indent(2) << "<cofmsg_get_config_reply ";
279  os << "miss-send-len:" << (int)msg.get_miss_send_len() << " ";
280  os << "flags:" << s_flags << " ";
281  os << " >" << std::endl;
282  return os;
283  };
284 
285  std::string
286  str() const {
287  std::stringstream ss;
288  ss << "-Get-Config-Reply- " << cofmsg::str() << " ";
289  ss << "miss_send_len: " << (unsigned int)get_miss_send_len() << ", ";
290  std::string s_flags;
291  switch (get_version()) {
292  case rofl::openflow10::OFP_VERSION: {
293  if ((get_flags() & rofl::openflow10::OFPC_FRAG_DROP) == rofl::openflow10::OFPC_FRAG_NORMAL)
294  s_flags.append("FRAG-NORMAL ");
295  if (get_flags() & rofl::openflow10::OFPC_FRAG_DROP)
296  s_flags.append("FRAG-DROP ");
297  if (get_flags() & rofl::openflow10::OFPC_FRAG_REASM)
298  s_flags.append("FRAG-REASM ");
299  } break;
300  case rofl::openflow12::OFP_VERSION: {
301  if ((get_flags() & rofl::openflow12::OFPC_FRAG_DROP) == rofl::openflow12::OFPC_FRAG_NORMAL)
302  s_flags.append("FRAG-NORMAL ");
303  if (get_flags() & rofl::openflow12::OFPC_FRAG_DROP)
304  s_flags.append("FRAG-DROP ");
305  if (get_flags() & rofl::openflow12::OFPC_FRAG_REASM)
306  s_flags.append("FRAG-REASM ");
307  if (get_flags() & rofl::openflow12::OFPC_INVALID_TTL_TO_CONTROLLER)
308  s_flags.append("INVALID-TTL-TO-CONTROLLER ");
309  } break;
310  case rofl::openflow13::OFP_VERSION: {
311  if ((get_flags() & rofl::openflow13::OFPC_FRAG_DROP) == rofl::openflow13::OFPC_FRAG_NORMAL)
312  s_flags.append("FRAG-NORMAL ");
313  if (get_flags() & rofl::openflow13::OFPC_FRAG_DROP)
314  s_flags.append("FRAG-DROP ");
315  if (get_flags() & rofl::openflow13::OFPC_FRAG_REASM)
316  s_flags.append("FRAG-REASM ");
317  } break;
318  default:
319  s_flags.append("unsupported OF version");
320  break;
321  }
322  ss << "flags: " << s_flags << " ";
323  return ss.str();
324  };
325 };
326 
327 
328 
333  public cofmsg
334 {
335 private:
336 
337  union {
338  uint8_t* ofhu_switch_config;
339  struct openflow10::ofp_switch_config* ofhu10_switch_config;
340  struct openflow12::ofp_switch_config* ofhu12_switch_config;
341  struct openflow13::ofp_switch_config* ofhu13_switch_config;
342  } ofhu;
343 
344 #define ofh_switch_config ofhu.ofhu_switch_config
345 #define ofh10_switch_config ofhu.ofhu10_switch_config
346 #define ofh12_switch_config ofhu.ofhu12_switch_config
347 #define ofh13_switch_config ofhu.ofhu13_switch_config
348 
349 public:
350 
351 
356  uint8_t of_version = 0,
357  uint32_t xid = 0,
358  uint16_t flags = 0,
359  uint16_t miss_send_len = 0);
360 
361 
366  cofmsg_set_config const& config);
367 
368 
373  operator= (
374  cofmsg_set_config const& config);
375 
376 
380  virtual
382 
383 
387  cofmsg_set_config(cmemory *memarea);
388 
389 
393  virtual void
394  reset();
395 
396 
400  virtual uint8_t*
401  resize(size_t len);
402 
403 
407  virtual size_t
408  length() const;
409 
410 
414  virtual void
415  pack(uint8_t *buf = (uint8_t*)0, size_t buflen = 0);
416 
417 
421  virtual void
422  unpack(uint8_t *buf, size_t buflen);
423 
424 
427  virtual void
428  validate();
429 
430 
431 public:
432 
433 
437  uint16_t
438  get_flags() const;
439 
443  void
444  set_flags(uint16_t flags);
445 
449  uint16_t
450  get_miss_send_len() const;
451 
455  void
456  set_miss_send_len(uint16_t miss_send_len);
457 
458 public:
459 
460  friend std::ostream&
461  operator<< (std::ostream& os, cofmsg_set_config const& msg) {
462  std::string s_flags;
463  switch (msg.get_version()) {
464  case rofl::openflow10::OFP_VERSION: {
465  if ((msg.get_flags() & rofl::openflow10::OFPC_FRAG_DROP) == rofl::openflow10::OFPC_FRAG_NORMAL)
466  s_flags.append("FRAG-NORMAL ");
467  if (msg.get_flags() & rofl::openflow10::OFPC_FRAG_DROP)
468  s_flags.append("FRAG-DROP ");
469  if (msg.get_flags() & rofl::openflow10::OFPC_FRAG_REASM)
470  s_flags.append("FRAG-REASM ");
471  } break;
472  case rofl::openflow12::OFP_VERSION: {
473  if ((msg.get_flags() & rofl::openflow12::OFPC_FRAG_DROP) == rofl::openflow12::OFPC_FRAG_NORMAL)
474  s_flags.append("FRAG-NORMAL ");
475  if (msg.get_flags() & rofl::openflow12::OFPC_FRAG_DROP)
476  s_flags.append("FRAG-DROP ");
477  if (msg.get_flags() & rofl::openflow12::OFPC_FRAG_REASM)
478  s_flags.append("FRAG-REASM ");
479  if (msg.get_flags() & rofl::openflow12::OFPC_INVALID_TTL_TO_CONTROLLER)
480  s_flags.append("INVALID-TTL-TO-CONTROLLER ");
481  } break;
482  case rofl::openflow13::OFP_VERSION: {
483  if ((msg.get_flags() & rofl::openflow13::OFPC_FRAG_DROP) == rofl::openflow13::OFPC_FRAG_NORMAL)
484  s_flags.append("FRAG-NORMAL ");
485  if (msg.get_flags() & rofl::openflow13::OFPC_FRAG_DROP)
486  s_flags.append("FRAG-DROP ");
487  if (msg.get_flags() & rofl::openflow13::OFPC_FRAG_REASM)
488  s_flags.append("FRAG-REASM ");
489  } break;
490  default:
491  s_flags.append("unsupported OF version");
492  break;
493  }
494  os << dynamic_cast<cofmsg const&>( msg );
495  os << indent(2) << "<cofmsg_set_config ";
496  os << "miss-send-len:" << (int)msg.get_miss_send_len() << " ";
497  os << "flags:" << s_flags << " ";
498  os << " >" << std::endl;
499  return os;
500  };
501 
502  std::string
503  str() const {
504  std::stringstream ss;
505  ss << "-Set-Config-Reply- " << cofmsg::str() << " ";
506  ss << "miss_send_len: " << (unsigned int)get_miss_send_len() << ", ";
507  std::string s_flags;
508  switch (get_version()) {
509  case rofl::openflow10::OFP_VERSION: {
510  if ((get_flags() & rofl::openflow10::OFPC_FRAG_DROP) == rofl::openflow10::OFPC_FRAG_NORMAL)
511  s_flags.append("FRAG-NORMAL ");
512  if (get_flags() & rofl::openflow10::OFPC_FRAG_DROP)
513  s_flags.append("FRAG-DROP ");
514  if (get_flags() & rofl::openflow10::OFPC_FRAG_REASM)
515  s_flags.append("FRAG-REASM ");
516  } break;
517  case rofl::openflow12::OFP_VERSION: {
518  if ((get_flags() & rofl::openflow12::OFPC_FRAG_DROP) == rofl::openflow12::OFPC_FRAG_NORMAL)
519  s_flags.append("FRAG-NORMAL ");
520  if (get_flags() & rofl::openflow12::OFPC_FRAG_DROP)
521  s_flags.append("FRAG-DROP ");
522  if (get_flags() & rofl::openflow12::OFPC_FRAG_REASM)
523  s_flags.append("FRAG-REASM ");
524  if (get_flags() & rofl::openflow12::OFPC_INVALID_TTL_TO_CONTROLLER)
525  s_flags.append("INVALID-TTL-TO-CONTROLLER ");
526  } break;
527  case rofl::openflow13::OFP_VERSION: {
528  if ((get_flags() & rofl::openflow13::OFPC_FRAG_DROP) == rofl::openflow13::OFPC_FRAG_NORMAL)
529  s_flags.append("FRAG-NORMAL ");
530  if (get_flags() & rofl::openflow13::OFPC_FRAG_DROP)
531  s_flags.append("FRAG-DROP ");
532  if (get_flags() & rofl::openflow13::OFPC_FRAG_REASM)
533  s_flags.append("FRAG-REASM ");
534  } break;
535  default:
536  s_flags.append("unsupported OF version");
537  break;
538  }
539  ss << "flags: " << s_flags << " ";
540  return ss.str();
541  };
542 };
543 
544 } // end of namespace openflow
545 } // end of namespace rofl
546 
547 #endif /* COFMSG_CONFIG_H_ */
virtual void unpack(uint8_t *buf, size_t buflen)
Definition: cofmsg_config.cc:102
Definition: cofmsg_config.h:115
virtual ~cofmsg_get_config_reply()
Definition: cofmsg_config.cc:217
virtual ~cofmsg_set_config()
Definition: cofmsg_config.cc:494
virtual size_t length() const
Definition: cofmsg_config.cc:242
virtual void pack(uint8_t *buf=(uint8_t *) 0, size_t buflen=0)
Definition: cofmsg_config.cc:86
cofmsg_get_config_reply(uint8_t of_version=0, uint32_t xid=0, uint16_t flags=0, uint16_t miss_send_len=0)
Definition: cofmsg_config.cc:140
virtual void validate()
Definition: cofmsg_config.cc:112
virtual void validate()
Definition: cofmsg_config.cc:578
virtual void pack(uint8_t *buf=(uint8_t *) 0, size_t buflen=0)
Definition: cofmsg_config.cc:263
Definition: openflow12.h:194
virtual void reset()
Definition: cofmsg_config.cc:70
virtual void unpack(uint8_t *buf, size_t buflen)
Definition: cofmsg_config.cc:291
Definition: cofmsg_config.h:19
virtual void unpack(uint8_t *buf, size_t buflen)
Definition: cofmsg_config.cc:568
virtual void reset()
Definition: cofmsg_config.cc:225
virtual size_t length() const
Definition: cofmsg_config.cc:519
C++ abstraction for malloc'ed memory areas.
Definition: cmemory.h:44
virtual void pack(uint8_t *buf=(uint8_t *) 0, size_t buflen=0)
Definition: cofmsg_config.cc:540
virtual ~cofmsg_get_config_request()
Definition: cofmsg_config.cc:62
Definition: logging.h:76
Definition: openflow13.h:731
cofmsg_set_config(uint8_t of_version=0, uint32_t xid=0, uint16_t flags=0, uint16_t miss_send_len=0)
Definition: cofmsg_config.cc:417
virtual void validate()
Definition: cofmsg_config.cc:301
cofmsg_get_config_request(uint8_t of_version=0, uint32_t xid=0)
Definition: cofmsg_config.cc:5
virtual size_t length() const
Definition: cofmsg_config.cc:78
Definition: openflow10.h:173
virtual void reset()
Definition: cofmsg_config.cc:502
Definition: cofmsg_config.h:332
Definition: cofmsg.h:62