FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
acl_l2_rule.cpp
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 #include <sstream>
17 
18 #include "vom/acl_l2_rule.hpp"
19 
20 namespace VOM {
21 namespace ACL {
22 
24  const action_t& action,
25  const route::prefix_t& ip,
26  const mac_address_t& mac,
27  const mac_address_t& mac_mask)
28  : m_priority(priority)
29  , m_action(action)
30  , m_src_ip(ip)
31  , m_mac(mac)
32  , m_mac_mask(mac_mask)
33 {
34 }
35 
36 bool
37 l2_rule::operator<(const l2_rule& other) const
38 {
39  return (other.m_priority < m_priority);
40 }
41 
42 bool
43 l2_rule::operator==(const l2_rule& rule) const
44 {
45  return ((m_action == rule.m_action) && (m_src_ip == rule.m_src_ip) &&
46  (m_mac == rule.m_mac) && (m_mac_mask == rule.m_mac_mask));
47 }
48 
51 {
52  std::ostringstream s;
53 
54  s << "L2-rule:["
55  << "priority:" << m_priority << " action:" << m_action.to_string()
56  << " ip:" << m_src_ip.to_string() << " mac:" << m_mac
57  << " mac-mask:" << m_mac_mask << "]";
58 
59  return (s.str());
60 }
61 
62 uint32_t
64 {
65  return m_priority;
66 }
67 
68 const action_t&
70 {
71  return m_action;
72 }
73 
74 const route::prefix_t&
76 {
77  return m_src_ip;
78 }
79 
80 const mac_address_t&
81 l2_rule::mac() const
82 {
83  return m_mac;
84 }
85 
86 const mac_address_t&
88 {
89  return m_mac_mask;
90 }
91 }
92 }
93 /*
94  * fd.io coding-style-patch-verification: OFF
95  *
96  * Local Variables:
97  * eval: (c-set-style "mozilla")
98  * End:
99  */
acl_l2_rule.hpp
VOM::route::prefix_t
A prefix defintion.
Definition: prefix.hpp:131
mac
vl_api_mac_address_t mac
Definition: l2.api:559
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::ACL::l2_rule
An ACL rule is the building block of an ACL.
Definition: acl_l2_rule.hpp:31
VOM::ACL::action_t
ACL Actions.
Definition: acl_types.hpp:26
VOM::route::prefix_t::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: prefix.cpp:214
VOM::ACL::l2_rule::action
const action_t & action() const
Definition: acl_l2_rule.cpp:69
priority
i32 priority
Definition: ipsec.api:95
VOM::ACL::l2_rule::l2_rule
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
VOM::ACL::l2_rule::mac_mask
const mac_address_t & mac_mask() const
Definition: acl_l2_rule.cpp:87
VOM::ACL::l2_rule::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: acl_l2_rule.cpp:50
VOM::ACL::l2_rule::mac
const mac_address_t & mac() const
Definition: acl_l2_rule.cpp:81
VOM::enum_base::to_string
const std::string & to_string() const
convert to string format for debug purposes
Definition: enum_base.hpp:36
VOM::mac_address_t
Type def of a Ethernet address.
Definition: types.hpp:295
VOM::ACL::l2_rule::src_ip
const route::prefix_t & src_ip() const
Definition: acl_l2_rule.cpp:75
VOM::ACL::l2_rule::operator==
bool operator==(const l2_rule &rule) const
comparison operator (for testing)
Definition: acl_l2_rule.cpp:43
VOM::ACL::l2_rule::operator<
bool operator<(const l2_rule &rule) const
less-than operator
Definition: acl_l2_rule.cpp:37
ip
vl_api_address_t ip
Definition: l2.api:558
action
vl_api_mac_event_action_t action
Definition: l2.api:211
VOM::ACL::l2_rule::priority
uint32_t priority() const
Getters.
Definition: acl_l2_rule.cpp:63
VOM::dependency_t::ACL
@ ACL
ACLs.
string
const char *const string
Definition: cJSON.h:172