blob: 1fb06e29b8101f630b03556dddceb6304ef9573e [file] [log] [blame]
Neale Ranns812ed392017-10-16 04:20:13 -07001/*
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
20namespace VOM {
21namespace ACL {
22
23l2_rule::l2_rule(uint32_t priority,
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
36bool
37l2_rule::operator<(const l2_rule& other) const
38{
39 return (other.m_priority < m_priority);
40}
41
Neale Ranns812ed392017-10-16 04:20:13 -070042bool
43l2_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
49std::string
50l2_rule::to_string() const
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}
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070061
62uint32_t
63l2_rule::priority() const
64{
65 return m_priority;
66}
67
68action_t
69l2_rule::action() const
70{
71 return m_action;
72}
73
74const route::prefix_t&
75l2_rule::src_ip() const
76{
77 return m_src_ip;
78}
79
80const mac_address_t&
81l2_rule::mac() const
82{
83 return m_mac;
84}
85
86const mac_address_t&
87l2_rule::mac_mask() const
88{
89 return m_mac_mask;
90}
Neale Ranns812ed392017-10-16 04:20:13 -070091}
92}
93/*
94 * fd.io coding-style-patch-verification: ON
95 *
96 * Local Variables:
97 * eval: (c-set-style "mozilla")
98 * End:
99 */