libfluid
The ONF OpenFlow driver
of10match.hh
1 #ifndef OF10OPENFLOW_MATCH_H
2 #define OF10OPENFLOW_MATCH_H 1
3 
4 #include <string>
5 #include <vector>
6 #include "fluid/util/util.h"
7 #include "fluid/util/ethaddr.hh"
8 #include "fluid/util/ipaddr.hh"
9 #include "openflow-10.h"
10 
11 namespace fluid_msg {
12 
13 namespace of10 {
14 
15 class Match {
16 private:
17  uint32_t wildcards_; /* Wildcard fields. */
18  uint16_t in_port_; /* Input switch port. */
19  EthAddress dl_src_; /* Ethernet source address. */
20  EthAddress dl_dst_; /* Ethernet destination address. */
21  uint16_t dl_vlan_; /* Input VLAN id. */
22  uint8_t dl_vlan_pcp_; /* Input VLAN priority. */
23  uint16_t dl_type_; /* Ethernet frame type. */
24  uint8_t nw_tos_; /* IP ToS (actually DSCP field, 6 bits). */
25  uint8_t nw_proto_; /* IP protocol or lower 8 bits of
26  * ARP opcode. */
27  IPAddress nw_src_; /* IP source address. */
28  IPAddress nw_dst_; /* IP destination address. */
29  uint16_t tp_src_; /* TCP/UDP source port. */
30  uint16_t tp_dst_; /* TCP/UDP destination port. */
31 public:
32  Match();
33  ~Match() {
34  }
35  ;
36  bool operator==(const Match &other) const;
37  bool operator!=(const Match &other) const;
38  size_t pack(uint8_t *buffer);
39  of_error unpack(uint8_t *buffer);
40  uint32_t wildcards() {
41  return this->wildcards_;
42  }
43  uint16_t in_port() {
44  return this->in_port_;
45  }
46  EthAddress dl_src() {
47  return this->dl_src_;
48  }
49  EthAddress dl_dst() {
50  return this->dl_dst_;
51  }
52  uint16_t dl_vlan() {
53  return this->dl_vlan_;
54  }
55  uint8_t dl_vlan_pcp() {
56  return this->dl_vlan_pcp_;
57  }
58  uint16_t dl_type() {
59  return this->dl_type_;
60  }
61  uint8_t nw_tos() {
62  return this->nw_tos_;
63  }
64  uint8_t nw_proto() {
65  return this->nw_proto_;
66  }
67  IPAddress nw_src() {
68  return this->nw_src_;
69  }
70  IPAddress nw_dst() {
71  return this->nw_dst_;
72  }
73  uint16_t tp_src() {
74  return this->tp_src_;
75  }
76  uint16_t tp_dst() {
77  return this->tp_dst_;
78  }
79 
80  void wildcards(uint32_t wildcards);
81  void in_port(uint16_t in_port);
82  void dl_src(const EthAddress &dl_src);
83  void dl_dst(const EthAddress &dl_dst);
84  void dl_vlan(uint16_t dl_vlan);
85  void dl_vlan_pcp(uint8_t dl_vlan_pcp);
86  void dl_type(uint16_t dl_type);
87  void nw_tos(uint8_t nw_tos);
88  void nw_proto(uint8_t nw_proto);
89  void nw_src(const IPAddress &nw_src);
90  void nw_dst(const IPAddress &nw_dst);
91  void nw_src(const IPAddress &nw_src, uint32_t prefix);
92  void nw_dst(const IPAddress &nw_src, uint32_t prefix);
93  void tp_src(uint16_t tp_src);
94  void tp_dst(uint16_t tp_dst);
95 };
96 
97 } //End of Namespace of10
98 } //End of namespace fluid_msg
99 #endif
100