Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofhelloelem.h
1 /*
2  * cofhelloelem.h
3  *
4  * Created on: 31.12.2013
5  * Author: andreas
6  */
7 
8 #ifndef COFHELLO_ELEM_H_
9 #define COFHELLO_ELEM_H_
10 
11 #include "rofl/common/cmemory.h"
12 #include "rofl/common/logging.h"
13 #include "rofl/common/openflow/openflow.h"
14 
15 namespace rofl {
16 namespace openflow {
17 
18 class eHelloElemBase : public RoflException {};
19 class eHelloElemInval : public eHelloElemBase {};
20 
22  public cmemory
23 {
24 
25  union {
26  uint8_t *ofhu_hello_elem_generic;
27  struct openflow13::ofp_hello_elem_header *ofhu13_hello_elem_header;
28  } ofhu;
29 
30 #define ofh_hello_elem_generic ofhu.ofhu_hello_elem_generic
31 #define ofh_hello_elem_header ofhu.ofhu13_hello_elem_header
32 
33 public:
34 
39  size_t len);
40 
45  uint8_t *buf, size_t buflen);
46 
51  cofhello_elem const& elem);
52 
56  virtual
57  ~cofhello_elem();
58 
63  operator= (
64  cofhello_elem const& elem);
65 
66 public:
67 
71  virtual uint8_t*
72  resize(size_t len);
73 
77  virtual size_t
78  length() const;
79 
83  void
84  pack(uint8_t *buf, size_t buflen);
85 
89  virtual void
90  unpack(uint8_t *buf, size_t buflen);
91 
95  uint16_t
96  get_type() const { return be16toh(ofh_hello_elem_header->type); };
97 
101  void
102  set_type(uint16_t type) { ofh_hello_elem_header->type = htobe16(type); };
103 
107  uint16_t
108  get_length() const { return be16toh(ofh_hello_elem_header->length); };
109 
113  void
114  set_length(uint16_t len) { ofh_hello_elem_header->length = htobe16(len); };
115 
116 public:
117 
118  friend std::ostream&
119  operator<< (std::ostream& os, cofhello_elem const& elem) {
120  os << indent(0) << "<cofhello_elem type:" << elem.get_type()
121  << " length:" << elem.get_length() << " padding:" << (elem.length()-elem.get_length()) << " >" << std::endl;
122  return os;
123  };
124 };
125 
126 }; /* namespace openflow */
127 }; /* namespace rofl */
128 
129 #endif /* COFHELLO_ELEM_H_ */
130 
131 
Definition: cofhelloelem.h:19
void pack(uint8_t *buf, size_t buflen)
Copies content of this cmemory instance to specified buffer.
Definition: cofhelloelem.cc:85
Definition: cofhelloelem.h:18
virtual void unpack(uint8_t *buf, size_t buflen)
Copies content of specified buffer into this cmemory instance .
Definition: cofhelloelem.cc:95
C++ abstraction for malloc'ed memory areas.
Definition: cmemory.h:44
virtual uint8_t * resize(size_t len)
Resizes allocated memory area by calling C-function realloc().
Definition: cofhelloelem.cc:57
Definition: logging.h:76
Definition: openflow13.h:2024
Definition: cofhelloelem.h:21
Definition: croflexception.h:27