Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofactions.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef COFACTIONS_H
6 #define COFACTIONS_H 1
7 
8 #include <inttypes.h>
9 #include <map>
10 #include <list>
11 #include <algorithm>
12 
13 #include "rofl/common/croflexception.h"
14 #include "rofl/common/openflow/openflow.h"
15 #include "rofl/common/openflow/cofaction.h"
16 #include "rofl/common/openflow/experimental/actions/gtp_actions.h"
17 #include "rofl/common/cindex.h"
18 
19 namespace rofl {
20 namespace openflow {
21 
22 class cofactions {
23 public:
24 
28  cofactions(
29  uint8_t ofp_version = openflow::OFP_VERSION_UNKNOWN);
30 
34  virtual
35  ~cofactions();
36 
40  cofactions(
41  const cofactions& actions);
42 
46  cofactions&
47  operator= (
48  const cofactions& actions);
49 
53  bool
54  operator== (
55  const cofactions& actions);
56 
57 public:
58 
62  size_t
63  length() const;
64 
68  void
69  unpack(
70  uint8_t* buf, size_t buflen);
71 
75  void
76  pack(
77  uint8_t* buf, size_t buflen);
78 
79 public:
80 
84  void
85  clear();
86 
89  int
91  uint16_t type) const;
92 
93 
96  int
98  uint32_t port_no = 0) const;
99 
100 
101 
105  std::list<uint32_t>
106  actions_output_ports() const;
107 
111  void
112  check_prerequisites() const;
113 
114 public:
115 
119  void
120  set_version(uint8_t ofp_version) {
121  this->ofp_version = ofp_version;
122  for (std::map<cindex, cofaction*>::iterator
123  it = actions.begin(); it != actions.end(); ++it) {
124  it->second->set_version(ofp_version);
125  }
126  };
127 
131  uint8_t
132  get_version() const { return ofp_version; };
133 
137  const std::map<cindex, unsigned int>&
138  get_actions_index() const { return actions_index; };
139 
143  std::map<cindex, cofaction*>&
144  set_actions() { return actions; };
145 
149  const std::map<cindex, cofaction*>&
150  get_actions() const { return actions; };
151 
155  size_t
156  size() const { return actions.size(); };
157 
161  bool
162  empty() const { return actions.empty(); };
163 
164 public:
165 
166  void
167  drop_action(const cindex& index);
168 
169  bool
170  has_action(const cindex& index) const;
171 
172 
173  // ActionOutput
174 
176  add_action_output(const cindex& index);
177 
179  set_action_output(const cindex& index);
180 
181  const cofaction_output&
182  get_action_output(const cindex& index) const;
183 
184  void
185  drop_action_output(const cindex& index);
186 
187  bool
188  has_action_output(const cindex& index) const;
189 
190 
191  // ActionSetVlanVid
192 
194  add_action_set_vlan_vid(const cindex& index);
195 
197  set_action_set_vlan_vid(const cindex& index);
198 
200  get_action_set_vlan_vid(const cindex& index) const;
201 
202  void
203  drop_action_set_vlan_vid(const cindex& index);
204 
205  bool
206  has_action_set_vlan_vid(const cindex& index) const;
207 
208 
209  // ActionSetVlanPcp
210 
212  add_action_set_vlan_pcp(const cindex& index);
213 
215  set_action_set_vlan_pcp(const cindex& index);
216 
218  get_action_set_vlan_pcp(const cindex& index) const;
219 
220  void
221  drop_action_set_vlan_pcp(const cindex& index);
222 
223  bool
224  has_action_set_vlan_pcp(const cindex& index) const;
225 
226 
227  // ActionStripVlan
228 
230  add_action_strip_vlan(const cindex& index);
231 
233  set_action_strip_vlan(const cindex& index);
234 
235  const cofaction_strip_vlan&
236  get_action_strip_vlan(const cindex& index) const;
237 
238  void
239  drop_action_strip_vlan(const cindex& index);
240 
241  bool
242  has_action_strip_vlan(const cindex& index) const;
243 
244 
245  // ActionSetDlSrc
246 
248  add_action_set_dl_src(const cindex& index);
249 
251  set_action_set_dl_src(const cindex& index);
252 
253  const cofaction_set_dl_src&
254  get_action_set_dl_src(const cindex& index) const;
255 
256  void
257  drop_action_set_dl_src(const cindex& index);
258 
259  bool
260  has_action_set_dl_src(const cindex& index) const;
261 
262 
263  // ActionSetDlDst
264 
266  add_action_set_dl_dst(const cindex& index);
267 
269  set_action_set_dl_dst(const cindex& index);
270 
271  const cofaction_set_dl_dst&
272  get_action_set_dl_dst(const cindex& index) const;
273 
274  void
275  drop_action_set_dl_dst(const cindex& index);
276 
277  bool
278  has_action_set_dl_dst(const cindex& index) const;
279 
280 
281  // ActionSetNwSrc
282 
284  add_action_set_nw_src(const cindex& index);
285 
287  set_action_set_nw_src(const cindex& index);
288 
289  const cofaction_set_nw_src&
290  get_action_set_nw_src(const cindex& index) const;
291 
292  void
293  drop_action_set_nw_src(const cindex& index);
294 
295  bool
296  has_action_set_nw_src(const cindex& index) const;
297 
298 
299  // ActionSetNwDst
300 
302  add_action_set_nw_dst(const cindex& index);
303 
305  set_action_set_nw_dst(const cindex& index);
306 
307  const cofaction_set_nw_dst&
308  get_action_set_nw_dst(const cindex& index) const;
309 
310  void
311  drop_action_set_nw_dst(const cindex& index);
312 
313  bool
314  has_action_set_nw_dst(const cindex& index) const;
315 
316 
317  // ActionSetNwTos
318 
320  add_action_set_nw_tos(const cindex& index);
321 
323  set_action_set_nw_tos(const cindex& index);
324 
325  const cofaction_set_nw_tos&
326  get_action_set_nw_tos(const cindex& index) const;
327 
328  void
329  drop_action_set_nw_tos(const cindex& index);
330 
331  bool
332  has_action_set_nw_tos(const cindex& index) const;
333 
334 
335  // ActionSetTpSrc
336 
338  add_action_set_tp_src(const cindex& index);
339 
341  set_action_set_tp_src(const cindex& index);
342 
343  const cofaction_set_tp_src&
344  get_action_set_tp_src(const cindex& index) const;
345 
346  void
347  drop_action_set_tp_src(const cindex& index);
348 
349  bool
350  has_action_set_tp_src(const cindex& index) const;
351 
352 
353  // ActionSetTpDst
354 
356  add_action_set_tp_dst(const cindex& index);
357 
359  set_action_set_tp_dst(const cindex& index);
360 
361  const cofaction_set_tp_dst&
362  get_action_set_tp_dst(const cindex& index) const;
363 
364  void
365  drop_action_set_tp_dst(const cindex& index);
366 
367  bool
368  has_action_set_tp_dst(const cindex& index) const;
369 
370 
371  // ActionEnqueue
372 
374  add_action_enqueue(const cindex& index);
375 
377  set_action_enqueue(const cindex& index);
378 
379  const cofaction_enqueue&
380  get_action_enqueue(const cindex& index) const;
381 
382  void
383  drop_action_enqueue(const cindex& index);
384 
385  bool
386  has_action_enqueue(const cindex& index) const;
387 
388 
389  // ActionVendor
390 
392  add_action_vendor(const cindex& index);
393 
395  set_action_vendor(const cindex& index);
396 
397  const cofaction_vendor&
398  get_action_vendor(const cindex& index) const;
399 
400  void
401  drop_action_vendor(const cindex& index);
402 
403  bool
404  has_action_vendor(const cindex& index) const;
405 
406 
407  // ActionCopyTtlOut
408 
410  add_action_copy_ttl_out(const cindex& index);
411 
413  set_action_copy_ttl_out(const cindex& index);
414 
416  get_action_copy_ttl_out(const cindex& index) const;
417 
418  void
419  drop_action_copy_ttl_out(const cindex& index);
420 
421  bool
422  has_action_copy_ttl_out(const cindex& index) const;
423 
424 
425  // ActionCopyTtlIn
426 
428  add_action_copy_ttl_in(const cindex& index);
429 
431  set_action_copy_ttl_in(const cindex& index);
432 
433  const cofaction_copy_ttl_in&
434  get_action_copy_ttl_in(const cindex& index) const;
435 
436  void
437  drop_action_copy_ttl_in(const cindex& index);
438 
439  bool
440  has_action_copy_ttl_in(const cindex& index) const;
441 
442 
443  // ActionSetMplsTtl
444 
446  add_action_set_mpls_ttl(const cindex& index);
447 
449  set_action_set_mpls_ttl(const cindex& index);
450 
452  get_action_set_mpls_ttl(const cindex& index) const;
453 
454  void
455  drop_action_set_mpls_ttl(const cindex& index);
456 
457  bool
458  has_action_set_mpls_ttl(const cindex& index) const;
459 
460 
461  // ActionDecMplsTtl
462 
464  add_action_dec_mpls_ttl(const cindex& index);
465 
467  set_action_dec_mpls_ttl(const cindex& index);
468 
470  get_action_dec_mpls_ttl(const cindex& index) const;
471 
472  void
473  drop_action_dec_mpls_ttl(const cindex& index);
474 
475  bool
476  has_action_dec_mpls_ttl(const cindex& index) const;
477 
478 
479  // ActionPushVlan
480 
482  add_action_push_vlan(const cindex& index);
483 
485  set_action_push_vlan(const cindex& index);
486 
487  const cofaction_push_vlan&
488  get_action_push_vlan(const cindex& index) const;
489 
490  void
491  drop_action_push_vlan(const cindex& index);
492 
493  bool
494  has_action_push_vlan(const cindex& index) const;
495 
496 
497  // ActionPopVlan
498 
500  add_action_pop_vlan(const cindex& index);
501 
503  set_action_pop_vlan(const cindex& index);
504 
505  const cofaction_pop_vlan&
506  get_action_pop_vlan(const cindex& index) const;
507 
508  void
509  drop_action_pop_vlan(const cindex& index);
510 
511  bool
512  has_action_pop_vlan(const cindex& index) const;
513 
514 
515  // ActionPushMpls
516 
518  add_action_push_mpls(const cindex& index);
519 
521  set_action_push_mpls(const cindex& index);
522 
523  const cofaction_push_mpls&
524  get_action_push_mpls(const cindex& index) const;
525 
526  void
527  drop_action_push_mpls(const cindex& index);
528 
529  bool
530  has_action_push_mpls(const cindex& index) const;
531 
532 
533  // ActionPopMpls
534 
536  add_action_pop_mpls(const cindex& index);
537 
539  set_action_pop_mpls(const cindex& index);
540 
541  const cofaction_pop_mpls&
542  get_action_pop_mpls(const cindex& index) const;
543 
544  void
545  drop_action_pop_mpls(const cindex& index);
546 
547  bool
548  has_action_pop_mpls(const cindex& index) const;
549 
550 
551  // ActionGroup
552 
554  add_action_group(const cindex& index);
555 
557  set_action_group(const cindex& index);
558 
559  const cofaction_group&
560  get_action_group(const cindex& index) const;
561 
562  void
563  drop_action_group(const cindex& index);
564 
565  bool
566  has_action_group(const cindex& index) const;
567 
568 
569  // ActionSetNwTtl
570 
572  add_action_set_nw_ttl(const cindex& index);
573 
575  set_action_set_nw_ttl(const cindex& index);
576 
577  const cofaction_set_nw_ttl&
578  get_action_set_nw_ttl(const cindex& index) const;
579 
580  void
581  drop_action_set_nw_ttl(const cindex& index);
582 
583  bool
584  has_action_set_nw_ttl(const cindex& index) const;
585 
586 
587  // ActionDecNwTtl
588 
590  add_action_dec_nw_ttl(const cindex& index);
591 
593  set_action_dec_nw_ttl(const cindex& index);
594 
595  const cofaction_dec_nw_ttl&
596  get_action_dec_nw_ttl(const cindex& index) const;
597 
598  void
599  drop_action_dec_nw_ttl(const cindex& index);
600 
601  bool
602  has_action_dec_nw_ttl(const cindex& index) const;
603 
604 
605  // ActionSetQueue
606 
608  add_action_set_queue(const cindex& index);
609 
611  set_action_set_queue(const cindex& index);
612 
613  const cofaction_set_queue&
614  get_action_set_queue(const cindex& index) const;
615 
616  void
617  drop_action_set_queue(const cindex& index);
618 
619  bool
620  has_action_set_queue(const cindex& index) const;
621 
622 
623  // ActionSetField
624 
626  add_action_set_field(const cindex& index);
627 
629  set_action_set_field(const cindex& index);
630 
631  const cofaction_set_field&
632  get_action_set_field(const cindex& index) const;
633 
634  void
635  drop_action_set_field(const cindex& index);
636 
637  bool
638  has_action_set_field(const cindex& index) const;
639 
640 
641  // ActionExperimenter
642 
644  add_action_experimenter(const cindex& index);
645 
647  set_action_experimenter(const cindex& index);
648 
650  get_action_experimenter(const cindex& index) const;
651 
652  void
653  drop_action_experimenter(const cindex& index);
654 
655  bool
656  has_action_experimenter(const cindex& index) const;
657 
658 
659  // ActionPushPbb
660 
662  add_action_push_pbb(const cindex& index);
663 
665  set_action_push_pbb(const cindex& index);
666 
667  const cofaction_push_pbb&
668  get_action_push_pbb(const cindex& index) const;
669 
670  void
671  drop_action_push_pbb(const cindex& index);
672 
673  bool
674  has_action_push_pbb(const cindex& index) const;
675 
676 
677  // ActionPopPbb
678 
680  add_action_pop_pbb(const cindex& index);
681 
683  set_action_pop_pbb(const cindex& index);
684 
685  const cofaction_pop_pbb&
686  get_action_pop_pbb(const cindex& index) const;
687 
688  void
689  drop_action_pop_pbb(const cindex& index);
690 
691  bool
692  has_action_pop_pbb(const cindex& index) const;
693 
694 
695 public:
696 
697  friend std::ostream&
698  operator<< (std::ostream& os, cofactions const& actions) {
699  os << rofl::indent(0) << "<cofactions ofp-version:" << (int)actions.get_version() <<
700  " #actions:" << (int)actions.get_actions().size() << " >" << std::endl;
701  rofl::indent i(2);
702  for (std::map<cindex, cofaction*>::const_iterator
703  it = actions.actions.begin(); it != actions.actions.end(); ++it) {
704  cofaction::dump(os, *(it->second));
705  }
706  return os;
707  };
708 
709 private:
710 
711  uint8_t ofp_version;
712  std::map<cindex, cofaction*> actions;
713  std::map<cindex, unsigned int> actions_index;
714 
715 };
716 
717 }; // end of namespace openflow
718 }; // end of namespace rofl
719 
720 #endif
std::list< uint32_t > actions_output_ports() const
Definition: cofactions.cc:402
Definition: cofaction.h:1839
Definition: cofaction.h:2089
Definition: cofaction.h:570
Definition: cofaction.h:2644
Definition: cofaction.h:190
Definition: cofaction.h:1679
Definition: cofaction.h:961
Definition: cofaction.h:1344
int count_action_type(uint16_t type) const
Definition: cofactions.cc:369
Definition: cofaction.h:2527
Definition: cofactions.h:22
Definition: cofaction.h:408
Definition: cofaction.h:2179
Definition: cofaction.h:1520
Definition: cofaction.h:502
Definition: cofaction.h:2338
Definition: cofaction.h:764
Definition: cofaction.h:1052
Definition: cofaction.h:667
Definition: cofaction.h:1452
Definition: cofaction.h:313
Definition: cofaction.h:1588
Definition: cofaction.h:862
Definition: cofaction.h:1143
Definition: cofaction.h:2429
int count_action_output(uint32_t port_no=0) const
Definition: cofactions.cc:378
Definition: cindex.h:17
Definition: logging.h:76
Definition: cofaction.h:1998
Definition: cofaction.h:1907
Definition: cofaction.h:2735
Definition: cofaction.h:1748
Definition: cofaction.h:2270
Definition: cofaction.h:1234