FD.io VPP  v18.07-rc0-415-g6c78436
Vector Packet Processing
acl_l2_rule.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __VOM_L2_ACL_RULE_H__
17 #define __VOM_L2_ACL_RULE_H__
18 
19 #include "vom/acl_types.hpp"
20 #include "vom/prefix.hpp"
21 
22 namespace VOM {
23 namespace ACL {
24 /**
25  * An ACL rule is the building block of an ACL. An ACL, which is
26  * the object applied to an interface, is comprised of an ordersed
27  * sequence of ACL rules.
28  * This class is a wrapper around the VAPI generated struct and exports
29  * an API with better types.
30  */
31 class l2_rule
32 {
33 public:
34  /**
35  * Construct a new object matching the desried state
36  */
37  l2_rule(uint32_t priority,
38  const action_t& action,
39  const route::prefix_t& ip,
40  const mac_address_t& mac,
41  const mac_address_t& mac_mask);
42 
43  /**
44  * Copy Constructor
45  */
46  l2_rule(const l2_rule& o) = default;
47 
48  /**
49  * Destructor
50  */
51  ~l2_rule() = default;
52 
53  /**
54  * convert to string format for debug purposes
55  */
56  std::string to_string() const;
57 
58  /**
59  * less-than operator
60  */
61  bool operator<(const l2_rule& rule) const;
62 
63  /**
64  * comparison operator (for testing)
65  */
66  bool operator==(const l2_rule& rule) const;
67 
68  /**
69  * Getters
70  */
71  uint32_t priority() const;
72  const action_t& action() const;
73  const route::prefix_t& src_ip() const;
74  const mac_address_t& mac() const;
75  const mac_address_t& mac_mask() const;
76 
77 private:
78  /**
79  * Priority. Used to sort the rules in a list in the order
80  * in which they are applied
81  */
82  uint32_t m_priority;
83 
84  /**
85  * Action on match
86  */
87  action_t m_action;
88 
89  /**
90  * Source Prefix
91  */
92  route::prefix_t m_src_ip;
93 
94  /**
95  * Source Mac
96  */
97  mac_address_t m_mac;
98 
99  /**
100  * Source MAC mask
101  */
102  mac_address_t m_mac_mask;
103 };
104 };
105 };
106 
107 /*
108  * fd.io coding-style-patch-verification: ON
109  *
110  * Local Variables:
111  * eval: (c-set-style "mozilla")
112  * End:
113  */
114 
115 #endif
const mac_address_t & mac() const
Definition: acl_l2_rule.cpp:81
uint32_t priority() const
Getters.
Definition: acl_l2_rule.cpp:63
const route::prefix_t & src_ip() const
Definition: acl_l2_rule.cpp:75
std::string to_string() const
convert to string format for debug purposes
Definition: acl_l2_rule.cpp:50
~l2_rule()=default
Destructor.
An ACL rule is the building block of an ACL.
Definition: acl_l2_rule.hpp:31
const mac_address_t & mac_mask() const
Definition: acl_l2_rule.cpp:87
const action_t & action() const
Definition: acl_l2_rule.cpp:69
l2_rule(uint32_t priority, const action_t &action, const route::prefix_t &ip, const mac_address_t &mac, const mac_address_t &mac_mask)
Construct a new object matching the desried state.
Definition: acl_l2_rule.cpp:23
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
bool operator==(const l2_rule &rule) const
comparison operator (for testing)
Definition: acl_l2_rule.cpp:43
bool operator<(const l2_rule &rule) const
less-than operator
Definition: acl_l2_rule.cpp:37
ACL Actions.
Definition: acl_types.hpp:26
Type def of a Ethernet address.
Definition: types.hpp:298
A prefix defintion.
Definition: prefix.hpp:93