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>, rc_t, BIND>
38 bind_cmd(HW::item<bool>& item,
39 const direction_t& direction,
42 : rpc_cmd<HW::item<bool>, rc_t, 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 s << "acl-bind:[" << m_direction.to_string() << " itf:" << m_itf.to_string()
61 << " acl:" << m_acl.to_string() << "]";
67 * Comparison operator - only used for UT
69 bool operator==(const bind_cmd& other) const
71 return ((m_itf == other.m_itf) && (m_acl == m_acl));
76 * The direction of the binding
78 const direction_t m_direction;
81 * The interface to bind to
92 * A command class that binds the ACL to the interface
94 template <typename BIND>
95 class unbind_cmd : public rpc_cmd<HW::item<bool>, rc_t, BIND>
101 unbind_cmd(HW::item<bool>& item,
102 const direction_t& direction,
105 : rpc_cmd<HW::item<bool>, rc_t, BIND>(item)
106 , m_direction(direction)
113 * Issue the command to VPP/HW
115 rc_t issue(connection& con);
118 * convert to string format for debug purposes
120 std::string to_string() const
122 std::ostringstream s;
123 s << "acl-unbind:[" << m_direction.to_string()
124 << " itf:" << m_itf.to_string() << " acl:" << m_acl.to_string() << "]";
130 * Comparison operator - only used for UT
132 bool operator==(const unbind_cmd& other) const
134 return ((m_itf == other.m_itf) && (m_acl == m_acl));
139 * The direction of the binding
141 const direction_t m_direction;
144 * The interface to bind to
146 const handle_t m_itf;
151 const handle_t m_acl;
155 * A cmd class that Dumps all the ACLs
157 template <typename DUMP>
158 class dump_cmd : public VOM::dump_cmd<DUMP>
164 dump_cmd() = default;
167 * Issue the command to VPP/HW
169 rc_t issue(connection& con);
172 * convert to string format for debug purposes
174 std::string to_string() const { return ("acl-bind-dump"); }
184 * Typedef the L3 ACL binding commands
186 typedef bind_cmd<vapi::Acl_interface_add_del> l3_bind_cmd;
187 typedef unbind_cmd<vapi::Acl_interface_add_del> l3_unbind_cmd;
188 typedef dump_cmd<vapi::Acl_interface_list_dump> l3_dump_cmd;
191 * Typedef the L2 binding type
193 typedef bind_cmd<vapi::Macip_acl_interface_add_del> l2_bind_cmd;
194 typedef unbind_cmd<vapi::Macip_acl_interface_add_del> l2_unbind_cmd;
195 typedef dump_cmd<vapi::Macip_acl_interface_list_dump> l2_dump_cmd;
197 }; // namespace binding_cmds
202 * fd.io coding-style-patch-verification: ON
205 * eval: (c-set-style "mozilla")