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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef __VOM_ACL_BINDING_CMDS_H__
17 #define __VOM_ACL_BINDING_CMDS_H__
19 #include "vom/acl_binding.hpp"
20 #include "vom/dump_cmd.hpp"
21 #include "vom/rpc_cmd.hpp"
23 #include <vapi/acl.api.vapi.hpp>
27 namespace binding_cmds {
29 * A command class that binds the ACL to the interface
31 template <typename BIND>
32 class bind_cmd : public rpc_cmd<HW::item<bool>, BIND>
38 bind_cmd(HW::item<bool>& item,
39 const direction_t& direction,
42 : rpc_cmd<HW::item<bool>, BIND>(item)
43 , m_direction(direction)
50 * Issue the command to VPP/HW
52 rc_t issue(connection& con);
55 * convert to string format for debug purposes
57 std::string to_string() const;
60 * Comparison operator - only used for UT
62 bool operator==(const bind_cmd& other) const
64 return ((m_itf == other.m_itf) && (m_acl == m_acl));
69 * The direction of the binding
71 const direction_t m_direction;
74 * The interface to bind to
85 * A command class that binds the ACL to the interface
87 template <typename BIND>
88 class unbind_cmd : public rpc_cmd<HW::item<bool>, BIND>
94 unbind_cmd(HW::item<bool>& item,
95 const direction_t& direction,
98 : rpc_cmd<HW::item<bool>, BIND>(item)
99 , m_direction(direction)
106 * Issue the command to VPP/HW
108 rc_t issue(connection& con);
111 * convert to string format for debug purposes
113 std::string to_string() const;
116 * Comparison operator - only used for UT
118 bool operator==(const unbind_cmd& other) const
120 return ((m_itf == other.m_itf) && (m_acl == m_acl));
125 * The direction of the binding
127 const direction_t m_direction;
130 * The interface to bind to
132 const handle_t m_itf;
137 const handle_t m_acl;
141 * A cmd class that Dumps all the ACLs
143 template <typename DUMP>
144 class dump_cmd : public VOM::dump_cmd<DUMP>
150 dump_cmd() = default;
153 * Issue the command to VPP/HW
155 rc_t issue(connection& con);
158 * convert to string format for debug purposes
160 std::string to_string() const;
170 * Typedef the L3 ACL binding commands
172 typedef bind_cmd<vapi::Acl_interface_add_del> l3_bind_cmd;
173 typedef unbind_cmd<vapi::Acl_interface_add_del> l3_unbind_cmd;
174 typedef dump_cmd<vapi::Acl_interface_list_dump> l3_dump_cmd;
177 * Typedef the L2 binding type
179 typedef bind_cmd<vapi::Macip_acl_interface_add_del> l2_bind_cmd;
180 typedef unbind_cmd<vapi::Macip_acl_interface_add_del> l2_unbind_cmd;
181 typedef dump_cmd<vapi::Macip_acl_interface_list_dump> l2_dump_cmd;
183 }; // namespace binding_cmds
188 * fd.io coding-style-patch-verification: ON
191 * eval: (c-set-style "mozilla")