blob: 4faa628ca116a2790481e6e04bf89faa5ff2dcf1 [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#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
Neale Ranns812ed392017-10-16 04:20:13 -070022namespace VOM {
23namespace 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 */
31class l2_rule
32{
33public:
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 /**
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070069 * Getters
Neale Ranns812ed392017-10-16 04:20:13 -070070 */
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070071 uint32_t priority() const;
72 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;
Neale Ranns812ed392017-10-16 04:20:13 -070076
77private:
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