Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
coftablefeatureprops.h
1 /*
2  * coftablefeatureprops.h
3  *
4  * Created on: 04.02.2014
5  * Author: andi
6  */
7 
8 #ifndef COFTABLEFEATUREPROPS_H_
9 #define COFTABLEFEATUREPROPS_H_
10 
11 #include <assert.h>
12 #include <inttypes.h>
13 
14 #include <map>
15 #include <ostream>
16 #include <algorithm>
17 
18 #include "rofl/common/openflow/coftablefeatureprop.h"
19 #include "rofl/common/croflexception.h"
20 #include "rofl/common/logging.h"
21 
22 namespace rofl {
23 namespace openflow {
24 
28 
30 
31  uint8_t ofp_version;
32  std::map<uint16_t, coftable_feature_prop*> tfprops;
33 
34 public:
35 
39  coftable_feature_props(uint8_t ofp_version = OFP_VERSION_UNKNOWN);
40 
44  virtual
46 
51  coftable_feature_props const& tfps);
52 
57  operator= (
58  coftable_feature_props const& tfps);
59 
63  void
64  clear();
65 
66 public:
67 
71  virtual size_t
72  length() const;
73 
77  virtual void
78  pack(uint8_t *buf, size_t buflen);
79 
83  virtual void
84  unpack(uint8_t *buf, size_t buflen);
85 
86 public:
87 
91  uint8_t
92  get_version() const { return ofp_version; };
93 
97  void
98  set_version(uint8_t ofp_version) { this->ofp_version = ofp_version; };
99 
100  /*
101  * OFPTFPF_INSTRUCTIONS
102  */
104  add_tfp_instructions() {
105  return dynamic_cast<coftable_feature_prop_instructions&>( add_tfp(rofl::openflow13::OFPTFPT_INSTRUCTIONS) );
106  };
107 
109  set_tfp_instructions() {
110  return dynamic_cast<coftable_feature_prop_instructions&>( set_tfp(rofl::openflow13::OFPTFPT_INSTRUCTIONS) );
111  };
112 
114  get_tfp_instructions() const {
115  return dynamic_cast<const coftable_feature_prop_instructions&>( get_tfp(rofl::openflow13::OFPTFPT_INSTRUCTIONS) );
116  };
117 
118  void
119  drop_tfp_instructions() {
120  drop_tfp(rofl::openflow13::OFPTFPT_INSTRUCTIONS);
121  };
122 
123  bool
124  has_tfp_instructions() const {
125  return has_tfp(rofl::openflow13::OFPTFPT_INSTRUCTIONS);
126  };
127 
128  /*
129  * OFPTFPF_INSTRUCTIONS_MISS
130  */
132  add_tfp_instructions_miss() {
133  return dynamic_cast<coftable_feature_prop_instructions&>( add_tfp(rofl::openflow13::OFPTFPT_INSTRUCTIONS_MISS) );
134  };
135 
137  set_tfp_instructions_miss() {
138  return dynamic_cast<coftable_feature_prop_instructions&>( set_tfp(rofl::openflow13::OFPTFPT_INSTRUCTIONS_MISS) );
139  };
140 
142  get_tfp_instructions_miss() const {
143  return dynamic_cast<const coftable_feature_prop_instructions&>( get_tfp(rofl::openflow13::OFPTFPT_INSTRUCTIONS_MISS) );
144  };
145 
146  void
147  drop_tfp_instructions_miss() {
148  drop_tfp(rofl::openflow13::OFPTFPT_INSTRUCTIONS_MISS);
149  };
150 
151  bool
152  has_tfp_instructions_miss() const {
153  return has_tfp(rofl::openflow13::OFPTFPT_INSTRUCTIONS_MISS);
154  };
155 
156 
157 
158  /*
159  * OFPTFPF_NEXT_TABLES
160  */
162  add_tfp_next_tables() {
163  return dynamic_cast<coftable_feature_prop_next_tables&>( add_tfp(rofl::openflow13::OFPTFPT_NEXT_TABLES) );
164  };
165 
167  set_tfp_next_tables() {
168  return dynamic_cast<coftable_feature_prop_next_tables&>( set_tfp(rofl::openflow13::OFPTFPT_NEXT_TABLES) );
169  };
170 
172  get_tfp_next_tables() const {
173  return dynamic_cast<const coftable_feature_prop_next_tables&>( get_tfp(rofl::openflow13::OFPTFPT_NEXT_TABLES) );
174  };
175 
176  void
177  drop_tfp_next_tables() {
178  drop_tfp(rofl::openflow13::OFPTFPT_NEXT_TABLES);
179  };
180 
181  bool
182  has_tfp_next_tables() const {
183  return has_tfp(rofl::openflow13::OFPTFPT_NEXT_TABLES);
184  };
185 
186  /*
187  * OFPTFPF_NEXT_TABLES_MISS
188  */
190  add_tfp_next_tables_miss() {
191  return dynamic_cast<coftable_feature_prop_next_tables&>( add_tfp(rofl::openflow13::OFPTFPT_NEXT_TABLES_MISS) );
192  };
193 
195  set_tfp_next_tables_miss() {
196  return dynamic_cast<coftable_feature_prop_next_tables&>( set_tfp(rofl::openflow13::OFPTFPT_NEXT_TABLES_MISS) );
197  };
198 
200  get_tfp_next_tables_miss() const {
201  return dynamic_cast<const coftable_feature_prop_next_tables&>( get_tfp(rofl::openflow13::OFPTFPT_NEXT_TABLES_MISS) );
202  };
203 
204  void
205  drop_tfp_next_tables_miss() {
206  drop_tfp(rofl::openflow13::OFPTFPT_NEXT_TABLES_MISS);
207  };
208 
209  bool
210  has_tfp_next_tables_miss() const {
211  return has_tfp(rofl::openflow13::OFPTFPT_NEXT_TABLES_MISS);
212  };
213 
214 
215 
216 
217  /*
218  * OFPTFPF_WRITE_ACTIONS
219  */
221  add_tfp_write_actions() {
222  return dynamic_cast<coftable_feature_prop_actions&>( add_tfp(rofl::openflow13::OFPTFPT_WRITE_ACTIONS) );
223  };
224 
226  set_tfp_write_actions() {
227  return dynamic_cast<coftable_feature_prop_actions&>( set_tfp(rofl::openflow13::OFPTFPT_WRITE_ACTIONS) );
228  };
229 
231  get_tfp_write_actions() const {
232  return dynamic_cast<const coftable_feature_prop_actions&>( get_tfp(rofl::openflow13::OFPTFPT_WRITE_ACTIONS) );
233  };
234 
235  void
236  drop_tfp_write_actions() {
237  drop_tfp(rofl::openflow13::OFPTFPT_WRITE_ACTIONS);
238  };
239 
240  bool
241  has_tfp_write_actions() const {
242  return has_tfp(rofl::openflow13::OFPTFPT_WRITE_ACTIONS);
243  };
244 
245  /*
246  * OFPTFPF_WRITE_ACTIONS_MISS
247  */
249  add_tfp_write_actions_miss() {
250  return dynamic_cast<coftable_feature_prop_actions&>( add_tfp(rofl::openflow13::OFPTFPT_WRITE_ACTIONS_MISS) );
251  };
252 
254  set_tfp_write_actions_miss() {
255  return dynamic_cast<coftable_feature_prop_actions&>( set_tfp(rofl::openflow13::OFPTFPT_WRITE_ACTIONS_MISS) );
256  };
257 
259  get_tfp_write_actions_miss() const {
260  return dynamic_cast<const coftable_feature_prop_actions&>( get_tfp(rofl::openflow13::OFPTFPT_WRITE_ACTIONS_MISS) );
261  };
262 
263  void
264  drop_tfp_write_actions_miss() {
265  drop_tfp(rofl::openflow13::OFPTFPT_WRITE_ACTIONS_MISS);
266  };
267 
268  bool
269  has_tfp_write_actions_miss() const {
270  return has_tfp(rofl::openflow13::OFPTFPT_WRITE_ACTIONS_MISS);
271  };
272 
273 
274 
275 
276 
277  /*
278  * OFPTFPF_APPLY_ACTIONS
279  */
281  add_tfp_apply_actions() {
282  return dynamic_cast<coftable_feature_prop_actions&>( add_tfp(rofl::openflow13::OFPTFPT_APPLY_ACTIONS) );
283  };
284 
286  set_tfp_apply_actions() {
287  return dynamic_cast<coftable_feature_prop_actions&>( set_tfp(rofl::openflow13::OFPTFPT_APPLY_ACTIONS) );
288  };
289 
291  get_tfp_apply_actions() const {
292  return dynamic_cast<const coftable_feature_prop_actions&>( get_tfp(rofl::openflow13::OFPTFPT_APPLY_ACTIONS) );
293  };
294 
295  void
296  drop_tfp_apply_actions() {
297  drop_tfp(rofl::openflow13::OFPTFPT_APPLY_ACTIONS);
298  };
299 
300  bool
301  has_tfp_apply_actions() const {
302  return has_tfp(rofl::openflow13::OFPTFPT_APPLY_ACTIONS);
303  };
304 
305  /*
306  * OFPTFPF_APPLY_ACTIONS_MISS
307  */
309  add_tfp_apply_actions_miss() {
310  return dynamic_cast<coftable_feature_prop_actions&>( add_tfp(rofl::openflow13::OFPTFPT_APPLY_ACTIONS_MISS) );
311  };
312 
314  set_tfp_apply_actions_miss() {
315  return dynamic_cast<coftable_feature_prop_actions&>( set_tfp(rofl::openflow13::OFPTFPT_APPLY_ACTIONS_MISS) );
316  };
317 
319  get_tfp_apply_actions_miss() const {
320  return dynamic_cast<const coftable_feature_prop_actions&>( get_tfp(rofl::openflow13::OFPTFPT_APPLY_ACTIONS_MISS) );
321  };
322 
323  void
324  drop_tfp_apply_actions_miss() {
325  drop_tfp(rofl::openflow13::OFPTFPT_APPLY_ACTIONS_MISS);
326  };
327 
328  bool
329  has_tfp_apply_actions_miss() const {
330  return has_tfp(rofl::openflow13::OFPTFPT_APPLY_ACTIONS_MISS);
331  };
332 
333 
334 
335 
336 
337  /*
338  * OFPTFPF_MATCH
339  */
341  add_tfp_match() {
342  return dynamic_cast<coftable_feature_prop_oxm&>( add_tfp(rofl::openflow13::OFPTFPT_MATCH) );
343  };
344 
346  set_tfp_match() {
347  return dynamic_cast<coftable_feature_prop_oxm&>( set_tfp(rofl::openflow13::OFPTFPT_MATCH) );
348  };
349 
351  get_tfp_match() const {
352  return dynamic_cast<const coftable_feature_prop_oxm&>( get_tfp(rofl::openflow13::OFPTFPT_MATCH) );
353  };
354 
355  void
356  drop_tfp_match() {
357  drop_tfp(rofl::openflow13::OFPTFPT_MATCH);
358  };
359 
360  bool
361  has_tfp_match() const {
362  return has_tfp(rofl::openflow13::OFPTFPT_MATCH);
363  };
364 
365 
366 
367 
368  /*
369  * OFPTFPF_WILDCARDS
370  */
372  add_tfp_wildcards() {
373  return dynamic_cast<coftable_feature_prop_oxm&>( add_tfp(rofl::openflow13::OFPTFPT_WILDCARDS) );
374  };
375 
377  set_tfp_wildcards() {
378  return dynamic_cast<coftable_feature_prop_oxm&>( set_tfp(rofl::openflow13::OFPTFPT_WILDCARDS) );
379  };
380 
382  get_tfp_wildcards() const {
383  return dynamic_cast<const coftable_feature_prop_oxm&>( get_tfp(rofl::openflow13::OFPTFPT_WILDCARDS) );
384  };
385 
386  void
387  drop_tfp_wildcards() {
388  drop_tfp(rofl::openflow13::OFPTFPT_WILDCARDS);
389  };
390 
391  bool
392  has_tfp_wildcards() const {
393  return has_tfp(rofl::openflow13::OFPTFPT_WILDCARDS);
394  };
395 
396 
397 
398 
399  /*
400  * OFPTFPF_WRITE_SETFIELD
401  */
403  add_tfp_write_setfield() {
404  return dynamic_cast<coftable_feature_prop_oxm&>( add_tfp(rofl::openflow13::OFPTFPT_WRITE_SETFIELD) );
405  };
406 
408  set_tfp_write_setfield() {
409  return dynamic_cast<coftable_feature_prop_oxm&>( set_tfp(rofl::openflow13::OFPTFPT_WRITE_SETFIELD) );
410  };
411 
413  get_tfp_write_setfield() const {
414  return dynamic_cast<const coftable_feature_prop_oxm&>( get_tfp(rofl::openflow13::OFPTFPT_WRITE_SETFIELD) );
415  };
416 
417  void
418  drop_tfp_write_setfield() {
419  drop_tfp(rofl::openflow13::OFPTFPT_WRITE_SETFIELD);
420  };
421 
422  bool
423  has_tfp_write_setfield() const {
424  return has_tfp(rofl::openflow13::OFPTFPT_WRITE_SETFIELD);
425  };
426 
427  /*
428  * OFPTFPF_WRITE_SETFIELD_MISS
429  */
431  add_tfp_write_setfield_miss() {
432  return dynamic_cast<coftable_feature_prop_oxm&>( add_tfp(rofl::openflow13::OFPTFPT_WRITE_SETFIELD_MISS) );
433  };
434 
436  set_tfp_write_setfield_miss() {
437  return dynamic_cast<coftable_feature_prop_oxm&>( set_tfp(rofl::openflow13::OFPTFPT_WRITE_SETFIELD_MISS) );
438  };
439 
441  get_tfp_write_setfield_miss() const {
442  return dynamic_cast<const coftable_feature_prop_oxm&>( get_tfp(rofl::openflow13::OFPTFPT_WRITE_SETFIELD_MISS) );
443  };
444 
445  void
446  drop_tfp_write_setfield_miss() {
447  drop_tfp(rofl::openflow13::OFPTFPT_WRITE_SETFIELD_MISS);
448  };
449 
450  bool
451  has_tfp_write_setfield_miss() const {
452  return has_tfp(rofl::openflow13::OFPTFPT_WRITE_SETFIELD_MISS);
453  };
454 
455 
456 
457 
458 
459  /*
460  * OFPTFPF_APPLY_SETFIELD
461  */
463  add_tfp_apply_setfield() {
464  return dynamic_cast<coftable_feature_prop_oxm&>( add_tfp(rofl::openflow13::OFPTFPT_APPLY_SETFIELD) );
465  };
466 
468  set_tfp_apply_setfield() {
469  return dynamic_cast<coftable_feature_prop_oxm&>( set_tfp(rofl::openflow13::OFPTFPT_APPLY_SETFIELD) );
470  };
471 
473  get_tfp_apply_setfield() const {
474  return dynamic_cast<const coftable_feature_prop_oxm&>( get_tfp(rofl::openflow13::OFPTFPT_APPLY_SETFIELD) );
475  };
476 
477  void
478  drop_tfp_apply_setfield() {
479  drop_tfp(rofl::openflow13::OFPTFPT_APPLY_SETFIELD);
480  };
481 
482  bool
483  has_tfp_apply_setfield() const {
484  return has_tfp(rofl::openflow13::OFPTFPT_APPLY_SETFIELD);
485  };
486 
487  /*
488  * OFPTFPF_APPLY_SETFIELD_MISS
489  */
491  add_tfp_apply_setfield_miss() {
492  return dynamic_cast<coftable_feature_prop_oxm&>( add_tfp(rofl::openflow13::OFPTFPT_APPLY_SETFIELD_MISS) );
493  };
494 
496  set_tfp_apply_setfield_miss() {
497  return dynamic_cast<coftable_feature_prop_oxm&>( set_tfp(rofl::openflow13::OFPTFPT_APPLY_SETFIELD_MISS) );
498  };
499 
501  get_tfp_apply_setfield_miss() const {
502  return dynamic_cast<const coftable_feature_prop_oxm&>( get_tfp(rofl::openflow13::OFPTFPT_APPLY_SETFIELD_MISS) );
503  };
504 
505  void
506  drop_tfp_apply_setfield_miss() {
507  drop_tfp(rofl::openflow13::OFPTFPT_APPLY_SETFIELD_MISS);
508  };
509 
510  bool
511  has_tfp_apply_setfield_miss() const {
512  return has_tfp(rofl::openflow13::OFPTFPT_APPLY_SETFIELD_MISS);
513  };
514 
515 
516  /*
517  * TODO: OFPTFPT_EXPERIMENTER / OFPTFPT_EXPERIMENTER_MISS
518  */
519 
520 
521 private:
522 
523  /*
524  * OFPTFPF_XXX / OFPTFPF_XXX_MISS
525  */
527  add_tfp(unsigned int type);
528 
530  set_tfp(unsigned int type);
531 
532  const coftable_feature_prop&
533  get_tfp(unsigned int type) const;
534 
535  void
536  drop_tfp(unsigned int type);
537 
538  bool
539  has_tfp(unsigned int type) const;
540 
541 public:
542 
543  friend std::ostream&
544  operator<< (std::ostream& os, coftable_feature_props const& tfps) {
545  os << indent(0) << "<coftable_feature_props ofp-version:" << (int)tfps.get_version() << " >" << std::endl;
546  for (std::map<uint16_t, coftable_feature_prop*>::const_iterator
547  it = tfps.tfprops.begin(); it != tfps.tfprops.end(); ++it) {
548  indent i(2);
549 
550  unsigned int type = it->first;
551 
552  switch (type) {
553  case rofl::openflow13::OFPTFPT_INSTRUCTIONS:
554  case rofl::openflow13::OFPTFPT_INSTRUCTIONS_MISS: {
555  os << dynamic_cast<coftable_feature_prop_instructions const&>( *(it->second) );
556  } break;
557  case rofl::openflow13::OFPTFPT_NEXT_TABLES:
558  case rofl::openflow13::OFPTFPT_NEXT_TABLES_MISS: {
559  os << dynamic_cast<coftable_feature_prop_next_tables const&>( *(it->second) );
560  } break;
561  case rofl::openflow13::OFPTFPT_WRITE_ACTIONS:
562  case rofl::openflow13::OFPTFPT_WRITE_ACTIONS_MISS:
563  case rofl::openflow13::OFPTFPT_APPLY_ACTIONS:
564  case rofl::openflow13::OFPTFPT_APPLY_ACTIONS_MISS: {
565  os << dynamic_cast<coftable_feature_prop_actions const&>( *(it->second) );
566  } break;
567  case rofl::openflow13::OFPTFPT_MATCH:
568  case rofl::openflow13::OFPTFPT_WILDCARDS:
569  case rofl::openflow13::OFPTFPT_WRITE_SETFIELD:
570  case rofl::openflow13::OFPTFPT_WRITE_SETFIELD_MISS:
571  case rofl::openflow13::OFPTFPT_APPLY_SETFIELD:
572  case rofl::openflow13::OFPTFPT_APPLY_SETFIELD_MISS: {
573  os << dynamic_cast<coftable_feature_prop_oxm const&>( *(it->second) );
574  } break;
575  default: {
576  os << dynamic_cast<coftable_feature_prop const&>( *(it->second) );
577  } break;
578  }
579  }
580  return os;
581  };
582 };
583 
584 }; // end of namespace openflow
585 }; // end of namespace rofl
586 
587 #endif /* COFTABLEFEATUREPROPS_H_ */
Definition: coftablefeatureprop.h:149
Definition: coftablefeatureprops.h:27
Definition: coftablefeatureprops.h:29
Definition: coftablefeatureprops.h:25
Definition: coftablefeatureprops.h:26
Definition: coftablefeatureprop.h:608
Definition: coftablefeatureprop.h:418
Definition: coftablefeatureprop.h:28
Definition: coftablefeatureprop.h:301
Definition: logging.h:76
Definition: croflexception.h:27