Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
coxmatches.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 /*
6  * coxmlist.h
7  *
8  * Created on: 10.07.2012
9  * Author: andreas
10  */
11 
12 #ifndef COXMATCHES_H_
13 #define COXMATCHES_H_
14 
15 #include <ostream>
16 #include <string>
17 #include <deque>
18 #include <map>
19 
20 #include <algorithm>
21 
22 #include "rofl/common/cmemory.h"
23 #include "rofl/common/croflexception.h"
24 #include "rofl/common/openflow/openflow_rofl_exceptions.h"
25 
26 #include "rofl/common/openflow/coxmatch.h"
27 #include "rofl/common/openflow/coxmatch_output.h"
28 #include "rofl/common/openflow/experimental/matches/pppoe_matches.h"
29 #include "rofl/common/openflow/experimental/matches/gtp_matches.h"
30 #include "rofl/common/openflow/experimental/matches/capwap_matches.h"
31 #include "rofl/common/openflow/experimental/matches/wlan_matches.h"
32 
33 namespace rofl {
34 namespace openflow {
35 
36 class eOxmListBase : public RoflException {};
37 class eOxmListInval : public eOxmListBase {}; // invalid parameter
38 class eOxmListBadLen : public eOxmListBase {}; // bad length
39 class eOxmListNotFound : public eOxmListBase {}; // element not found
40 class eOxmListOutOfRange : public eOxmListBase {}; // out of range
41 
42 
48 {
49  std::map<uint32_t, coxmatch> matches;
50 
51 public:
52 
56  coxmatches();
57 
61  virtual
62  ~coxmatches();
63 
67  coxmatches(
68  coxmatches const& oxms);
69 
73  coxmatches&
74  operator= (
75  coxmatches const& oxms);
76 
80  bool
81  operator== (
82  coxmatches const& oxms) const;
83 
84 
85 public:
86 
90  virtual size_t
91  length() const;
92 
96  virtual void
97  unpack(
98  uint8_t* buf, size_t buflen);
99 
103  virtual void
104  pack(
105  uint8_t* buf, size_t buflen);
106 
107 public:
108 
112  std::map<uint32_t, coxmatch>&
113  set_matches() { return matches; }
114 
118  std::map<uint32_t, coxmatch> const&
119  get_matches() const { return matches; }
120 
124  coxmatch&
125  add_match(
126  coxmatch const& oxm);
127 
131  coxmatch&
132  add_match(
133  uint32_t oxm_id);
134 
138  void
139  drop_match(
140  uint32_t oxm_id);
141 
145  coxmatch&
146  set_match(
147  uint32_t oxm_id);
148 
152  coxmatch const&
153  get_match(
154  uint32_t oxm_id) const;
155 
156 
160  bool
161  has_match(
162  uint32_t oxm_id) const;
163 
164 public:
165 
169  void
170  clear();
171 
175  bool
176  contains(
177  coxmatches const& matches,
178  bool strict = false);
179 
183  bool
184  is_part_of(
185  coxmatches const& matches,
186  uint16_t& exact_hits,
187  uint16_t& wildcard_hits,
188  uint16_t& missed);
189 
190 public:
191 
192  friend std::ostream&
193  operator<< (std::ostream& os, coxmatches const& oxl) {
194  os << rofl::indent(0) << "<coxmatches #matches:" << oxl.matches.size() << " >" << std::endl;
195  rofl::indent i(2);
196  for (std::map<uint32_t, coxmatch>::const_iterator
197  it = oxl.matches.begin(); it != oxl.matches.end(); ++it) {
198  os << coxmatch_output(it->second);
199  }
200  return os;
201  };
202 };
203 
204 }; // end of namespace openflow
205 }; // end of namespace rofl
206 
207 #endif /* COXMLIST_H_ */
Definition: coxmatches.h:38
Definition: coxmatch.h:49
Definition: coxmatches.h:40
Definition: coxmatches.h:39
Definition: coxmatches.h:36
Definition: coxmatch_output.h:25
Definition: coxmatches.h:47
Definition: logging.h:76
Definition: coxmatches.h:37
Definition: croflexception.h:27