Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofmsg_port_status.h
1 /*
2  * cofmsg_port_status.h
3  *
4  * Created on: 18.03.2013
5  * Author: andi
6  */
7 
8 #ifndef COFMSG_PORT_STATUS_H_
9 #define COFMSG_PORT_STATUS_H_ 1
10 
11 #include "rofl/common/openflow/messages/cofmsg.h"
12 #include "rofl/common/openflow/cofport.h"
13 
14 namespace rofl {
15 namespace openflow {
16 
21  public cofmsg
22 {
23 private:
24 
26 
27  union {
28  uint8_t* ofhu_port_status;
29  struct openflow10::ofp_port_status* ofhu10_port_status;
30  struct openflow12::ofp_port_status* ofhu12_port_status;
31  struct openflow13::ofp_port_status* ofhu13_port_status;
32  } ofhu;
33 
34 #define ofh_port_status ofhu.ofhu_port_status
35 #define ofh10_port_status ofhu.ofhu10_port_status
36 #define ofh12_port_status ofhu.ofhu12_port_status
37 #define ofh13_port_status ofhu.ofhu13_port_status
38 
39 public:
40 
41 
46  uint8_t of_version = 0,
47  uint32_t xid = 0,
48  uint8_t reason = 0,
50 
51 
56  cofmsg_port_status const& port_status);
57 
58 
63  operator= (
64  cofmsg_port_status const& port_status);
65 
66 
70  virtual
72 
73 
77  cofmsg_port_status(cmemory *memarea);
78 
79 
83  virtual void
84  reset();
85 
86 
90  virtual uint8_t*
91  resize(size_t len);
92 
93 
97  virtual size_t
98  length() const;
99 
100 
104  virtual void
105  pack(uint8_t *buf = (uint8_t*)0, size_t buflen = 0);
106 
107 
111  virtual void
112  unpack(uint8_t *buf, size_t buflen);
113 
114 
117  virtual void
118  validate();
119 
120 
121 public:
122 
123 
127  uint8_t
128  get_reason() const;
129 
133  void
134  set_reason(uint8_t reason);
135 
140  set_port() { return port; };
141 
146  get_port() const { return port; };
147 
148 public:
149 
150  friend std::ostream&
151  operator<< (std::ostream& os, cofmsg_port_status const& msg) {
152  os << dynamic_cast<cofmsg const&>( msg );
153  os << indent(2) << "<cofmsg_port_status >" << std::endl;
154  switch (msg.get_reason()) {
155  case openflow::OFPPR_ADD: {
156  os << indent(4) << "<reason: -ADD- >" << std::endl;
157  } break;
158  case openflow::OFPPR_DELETE: {
159  os << indent(4) << "<reason: -DELETE- >" << std::endl;
160  } break;
161  case openflow::OFPPR_MODIFY: {
162  os << indent(4) << "<reason: -MODIFY- >" << std::endl;
163  } break;
164  default: {
165  os << indent(4) << "<reason: -UNKNOWN- >" << std::endl;
166  } break;
167  }
168  indent i(4);
169  os << msg.port;
170  return os;
171  };
172 };
173 
174 } // end of namespace openflow
175 } // end of namespace rofl
176 
177 #endif /* COFMSG_PORT_STATUS_H_ */
cofmsg_port_status(uint8_t of_version=0, uint32_t xid=0, uint8_t reason=0, rofl::openflow::cofport const &port=rofl::openflow::cofport())
Definition: cofmsg_port_status.cc:5
virtual void reset()
Definition: cofmsg_port_status.cc:94
Definition: cofmsg_port_status.h:20
Definition: openflow10.h:291
Definition: openflow13.h:1736
Definition: openflow12.h:341
virtual void unpack(uint8_t *buf, size_t buflen)
Definition: cofmsg_port_status.cc:162
virtual ~cofmsg_port_status()
Definition: cofmsg_port_status.cc:86
C++ abstraction for malloc'ed memory areas.
Definition: cmemory.h:44
virtual size_t length() const
Definition: cofmsg_port_status.cc:110
virtual void validate()
Definition: cofmsg_port_status.cc:172
Definition: logging.h:76
Definition: cofport.h:52
virtual void pack(uint8_t *buf=(uint8_t *) 0, size_t buflen=0)
Definition: cofmsg_port_status.cc:131
Definition: cofmsg.h:62