Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofmsg_flow_removed.h
1 /*
2  * cofmsg_flow_removed.h
3  *
4  * Created on: 18.03.2013
5  * Author: andi
6  */
7 
8 #ifndef COFMSG_FLOW_REMOVED_H_
9 #define COFMSG_FLOW_REMOVED_H_ 1
10 
11 #include "cofmsg.h"
12 #include "rofl/common/openflow/cofmatch.h"
13 
14 namespace rofl {
15 namespace openflow {
16 
21  public cofmsg
22 {
23 private:
24 
25  cofmatch match;
26 
27  union {
28  uint8_t* ofhu_flow_removed;
29  struct openflow10::ofp_flow_removed* ofhu10_flow_removed;
30  struct openflow12::ofp_flow_removed* ofhu12_flow_removed;
31  struct openflow13::ofp_flow_removed* ofhu13_flow_removed;
32  } ofhu;
33 
34 #define ofh_flow_removed ofhu.ofhu_flow_removed
35 #define ofh10_flow_removed ofhu.ofhu10_flow_removed
36 #define ofh12_flow_removed ofhu.ofhu12_flow_removed
37 #define ofh13_flow_removed ofhu.ofhu13_flow_removed
38 
39 #define OFP10_FLOW_REMOVED_STATIC_HDR_LEN 88
40 #define OFP12_FLOW_REMOVED_STATIC_HDR_LEN 48 // length without struct openflow12::ofp_match
41 #define OFP13_FLOW_REMOVED_STATIC_HDR_LEN 48 // length without struct openflow13::ofp_match
42 
43 public:
44 
45 
50  uint8_t of_version = 0,
51  uint32_t xid = 0,
52  uint64_t cookie = 0,
53  uint16_t priority = 0,
54  uint8_t reason = 0,
55  uint8_t table_id = 0,
56  uint32_t duration_sec = 0,
57  uint32_t duration_nsec = 0,
58  uint16_t idle_timeout = 0,
59  uint16_t hard_timeout = 0,
60  uint64_t packet_count = 0,
61  uint64_t byte_count = 0,
62  cofmatch const& match = cofmatch());
63 
64 
69  cofmsg_flow_removed const& flow_removed);
70 
71 
76  operator= (
77  cofmsg_flow_removed const& flow_removed);
78 
79 
83  virtual
85 
86 
90  cofmsg_flow_removed(cmemory *memarea);
91 
92 
96  virtual void
97  reset();
98 
99 
103  virtual uint8_t*
104  resize(size_t len);
105 
106 
110  virtual size_t
111  length() const;
112 
113 
117  virtual void
118  pack(uint8_t *buf = (uint8_t*)0, size_t buflen = 0);
119 
120 
124  virtual void
125  unpack(uint8_t *buf, size_t buflen);
126 
127 
130  virtual void
131  validate();
132 
133 
134 public:
135 
136 
140  uint64_t
141  get_cookie() const;
142 
146  void
147  set_cookie(uint64_t cookie);
148 
152  uint16_t
153  get_priority() const;
154 
158  void
159  set_priority(uint64_t priority);
160 
164  uint8_t
165  get_reason() const;
166 
170  void
171  set_reason(uint8_t reason);
172 
176  uint8_t
177  get_table_id() const;
178 
182  void
183  set_table_id(uint8_t table_id);
184 
188  uint32_t
189  get_duration_sec() const;
190 
194  void
195  set_duration_sec(uint32_t duration_sec);
196 
200  uint32_t
201  get_duration_nsec() const;
202 
206  void
207  set_duration_nsec(uint32_t duration_nsec);
208 
212  uint16_t
213  get_idle_timeout() const;
214 
218  void
219  set_idle_timeout(uint16_t idle_timeout);
220 
224  uint16_t
225  get_hard_timeout() const;
226 
230  void
231  set_hard_timeout(uint16_t hard_timeout);
232 
236  uint64_t
237  get_packet_count() const;
238 
242  void
243  set_packet_count(uint64_t packet_count);
244 
248  uint64_t
249  get_byte_count() const;
250 
254  void
255  set_byte_count(uint64_t byte_count);
256 
260  cofmatch&
261  get_match();
262 
263 
264 public:
265 
266  friend std::ostream&
267  operator<< (std::ostream& os, cofmsg_flow_removed const& msg) {
268  switch (msg.get_version()) {
269  case rofl::openflow10::OFP_VERSION: {
270  os << indent(0) << dynamic_cast<cofmsg const&>( msg );
271  os << indent(2) << "<cofmsg_flow_removed >" << std::endl;
272  os << indent(4) << "<cookie:0x" << std::hex << (int)msg.get_cookie() << std::dec << " >" << std::endl;
273  os << indent(4) << "<priority:0x" << std::hex << (int)msg.get_priority() << std::dec << " >" << std::endl;
274  switch (msg.get_reason()) {
275  case rofl::openflow10::OFPRR_IDLE_TIMEOUT: {
276  os << indent(4) << "<reason: -IDLE-TIMEOUT- >" << std::endl;
277  } break;
278  case rofl::openflow10::OFPRR_HARD_TIMEOUT: {
279  os << indent(4) << "<reason: -HARD-TIMEOUT- >" << std::endl;
280  } break;
281  case rofl::openflow10::OFPRR_DELETE: {
282  os << indent(4) << "<reason: -DELETE- >" << std::endl;
283  } break;
284  default: {
285  os << indent(4) << "<reason: -UNKNOWN- >" << std::endl;
286  };
287  }
288  os << indent(4) << "<duration-sec:" << (int)msg.get_duration_sec() << " >" << std::endl;
289  os << indent(4) << "<duration-nsec:" << (int)msg.get_duration_nsec() << " >" << std::endl;
290  os << indent(4) << "<idle-timeout:" << (int)msg.get_idle_timeout() << " >" << std::endl;
291  os << indent(4) << "<packet-count:" << (int)msg.get_packet_count() << " >" << std::endl;
292  os << indent(4) << "<byte-count:" << (int)msg.get_byte_count() << " >" << std::endl;
293  os << indent(4) << "<matches: >" << std::endl;
294  indent i(6);
295  os << msg.match;
296 
297  } break;
298  case rofl::openflow12::OFP_VERSION:
299  case rofl::openflow13::OFP_VERSION: {
300  os << indent(0) << dynamic_cast<cofmsg const&>( msg );
301  os << indent(2) << "<cofmsg_flow_removed >" << std::endl;
302  os << indent(4) << "<cookie:0x" << std::hex << (int)msg.get_cookie() << std::dec << " >" << std::endl;
303  os << indent(4) << "<priority:0x" << std::hex << (int)msg.get_priority() << std::dec << " >" << std::endl;
304  switch (msg.get_reason()) {
305  case rofl::openflow12::OFPRR_IDLE_TIMEOUT: {
306  os << indent(4) << "<reason: -IDLE-TIMEOUT- >" << std::endl;
307  } break;
308  case rofl::openflow12::OFPRR_HARD_TIMEOUT: {
309  os << indent(4) << "<reason: -HARD-TIMEOUT- >" << std::endl;
310  } break;
311  case rofl::openflow12::OFPRR_DELETE: {
312  os << indent(4) << "<reason: -DELETE- >" << std::endl;
313  } break;
314  case rofl::openflow12::OFPRR_GROUP_DELETE: {
315  os << indent(4) << "<reason: -GROUP-DELETE- >" << std::endl;
316  } break;
317  default: {
318  os << indent(4) << "<reason: -UNKNOWN- >" << std::endl;
319  };
320  }
321  os << indent(4) << "<table-id:" << (int)msg.get_table_id() << " >" << std::endl;
322  os << indent(4) << "<duration-sec:" << (int)msg.get_duration_sec() << " >" << std::endl;
323  os << indent(4) << "<duration-nsec:" << (int)msg.get_duration_nsec() << " >" << std::endl;
324  os << indent(4) << "<idle-timeout:" << (int)msg.get_idle_timeout() << " >" << std::endl;
325  os << indent(4) << "<hard-timeout:" << (int)msg.get_hard_timeout() << " >" << std::endl;
326  os << indent(4) << "<packet-count:" << (int)msg.get_packet_count() << " >" << std::endl;
327  os << indent(4) << "<byte-count:" << (int)msg.get_byte_count() << " >" << std::endl;
328  os << indent(4) << "<matches: >" << std::endl;
329  indent i(6);
330  os << msg.match;
331 
332  } break;
333  }
334  return os;
335  };
336 };
337 
338 
339 #if 0
340 OFPRR_IDLE_TIMEOUT, /* Flow idle time exceeded idle_timeout. */
341 OFPRR_HARD_TIMEOUT, /* Time exceeded hard_timeout. */
342 OFPRR_DELETE /* Evicted by a DELETE flow mod. */
343 
344 struct ofp_header header;
345 struct ofp_match match; /* Description of fields. */
346 uint64_t cookie; /* Opaque controller-issued identifier. */
347 
348 uint16_t priority; /* Priority level of flow entry. */
349 uint8_t reason; /* One of OFPRR_*. */
350 uint8_t pad[1]; /* Align to 32-bits. */
351 
352 uint32_t duration_sec; /* Time flow was alive in seconds. */
353 uint32_t duration_nsec; /* Time flow was alive in nanoseconds beyond
354  duration_sec. */
355 uint16_t idle_timeout; /* Idle timeout from original flow mod. */
356 uint8_t pad2[2]; /* Align to 64-bits. */
357 uint64_t packet_count;
358 uint64_t byte_count;
359 #endif
360 
361 #if 0
362 OFPRR_IDLE_TIMEOUT, /* Flow idle time exceeded idle_timeout. */
363 OFPRR_HARD_TIMEOUT, /* Time exceeded hard_timeout. */
364 OFPRR_DELETE, /* Evicted by a DELETE flow mod. */
365 OFPRR_GROUP_DELETE /* Group was removed. */
366 
367 struct ofp_header header;
368 uint64_t cookie; /* Opaque controller-issued identifier. */
369 
370 uint16_t priority; /* Priority level of flow entry. */
371 uint8_t reason; /* One of OFPRR_*. */
372 uint8_t table_id; /* ID of the table */
373 
374 uint32_t duration_sec; /* Time flow was alive in seconds. */
375 uint32_t duration_nsec; /* Time flow was alive in nanoseconds beyond
376  duration_sec. */
377 uint16_t idle_timeout; /* Idle timeout from original flow mod. */
378 uint16_t hard_timeout; /* Idle timeout from original flow mod. */
379 uint64_t packet_count;
380 uint64_t byte_count;
381 struct ofp_match match; /* Description of fields. */
382 #endif
383 
384 } // end of namespace openflow
385 } // end of namespace rofl
386 
387 #endif /* COFMSG_FLOW_REMOVED_H_ */
Definition: openflow_common.h:493
virtual void reset()
Definition: cofmsg_flow_removed.cc:126
virtual size_t length() const
Definition: cofmsg_flow_removed.cc:143
Definition: openflow12.h:1029
virtual void validate()
Definition: cofmsg_flow_removed.cc:210
Definition: cofmatch.h:35
virtual void unpack(uint8_t *buf, size_t buflen)
Definition: cofmsg_flow_removed.cc:200
Definition: openflow10.h:624
Definition: openflow_common.h:58
cofmsg_flow_removed(uint8_t of_version=0, uint32_t xid=0, uint64_t cookie=0, uint16_t priority=0, uint8_t reason=0, uint8_t table_id=0, uint32_t duration_sec=0, uint32_t duration_nsec=0, uint16_t idle_timeout=0, uint16_t hard_timeout=0, uint64_t packet_count=0, uint64_t byte_count=0, cofmatch const &match=cofmatch())
Definition: cofmsg_flow_removed.cc:5
C++ abstraction for malloc'ed memory areas.
Definition: cmemory.h:44
Definition: openflow13.h:1704
virtual ~cofmsg_flow_removed()
Definition: cofmsg_flow_removed.cc:118
Definition: logging.h:76
Definition: cofmsg_flow_removed.h:20
virtual void pack(uint8_t *buf=(uint8_t *) 0, size_t buflen=0)
Definition: cofmsg_flow_removed.cc:165
Definition: cofmsg.h:62