FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
acl_binding_cmds.hpp
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 #ifndef __VOM_ACL_BINDING_CMDS_H__
17 #define __VOM_ACL_BINDING_CMDS_H__
18 
19 #include "vom/acl_binding.hpp"
20 #include "vom/dump_cmd.hpp"
21 #include "vom/rpc_cmd.hpp"
22 
23 #include <vapi/acl.api.vapi.hpp>
24 
25 namespace VOM {
26 namespace ACL {
27 namespace binding_cmds {
28 /**
29  * A command class that binds the ACL to the interface
30  */
31 template <typename BIND>
32 class bind_cmd : public rpc_cmd<HW::item<bool>, BIND>
33 {
34 public:
35  /**
36  * Constructor
37  */
39  const direction_t& direction,
40  const handle_t& itf,
41  const handle_t& acl)
42  : rpc_cmd<HW::item<bool>, BIND>(item)
43  , m_direction(direction)
44  , m_itf(itf)
45  , m_acl(acl)
46  {
47  }
48 
49  /**
50  * Issue the command to VPP/HW
51  */
53 
54  /**
55  * convert to string format for debug purposes
56  */
57  std::string to_string() const;
58 
59  /**
60  * Comparison operator - only used for UT
61  */
62  bool operator==(const bind_cmd& other) const
63  {
64  return ((m_itf == other.m_itf) && (m_acl == m_acl));
65  }
66 
67 private:
68  /**
69  * The direction of the binding
70  */
71  const direction_t m_direction;
72 
73  /**
74  * The interface to bind to
75  */
76  const handle_t m_itf;
77 
78  /**
79  * The ACL to bind
80  */
81  const handle_t m_acl;
82 };
83 
84 /**
85  * A command class that binds the ACL to the interface
86  */
87 template <typename BIND>
88 class unbind_cmd : public rpc_cmd<HW::item<bool>, BIND>
89 {
90 public:
91  /**
92  * Constructor
93  */
95  const direction_t& direction,
96  const handle_t& itf,
97  const handle_t& acl)
98  : rpc_cmd<HW::item<bool>, BIND>(item)
99  , m_direction(direction)
100  , m_itf(itf)
101  , m_acl(acl)
102  {
103  }
104 
105  /**
106  * Issue the command to VPP/HW
107  */
109 
110  /**
111  * convert to string format for debug purposes
112  */
113  std::string to_string() const;
114 
115  /**
116  * Comparison operator - only used for UT
117  */
118  bool operator==(const unbind_cmd& other) const
119  {
120  return ((m_itf == other.m_itf) && (m_acl == m_acl));
121  }
122 
123 private:
124  /**
125  * The direction of the binding
126  */
127  const direction_t m_direction;
128 
129  /**
130  * The interface to bind to
131  */
132  const handle_t m_itf;
133 
134  /**
135  * The ACL to bind
136  */
137  const handle_t m_acl;
138 };
139 
140 /**
141  * A cmd class that Dumps all the ACLs
142  */
143 template <typename DUMP>
144 class dump_cmd : public VOM::dump_cmd<DUMP>
145 {
146 public:
147  /**
148  * Constructor
149  */
150  dump_cmd() = default;
151 
152  /**
153  * Issue the command to VPP/HW
154  */
156 
157  /**
158  * convert to string format for debug purposes
159  */
160  std::string to_string() const;
161 
162 private:
163  /**
164  * HW reutrn code
165  */
166  HW::item<bool> item;
167 };
168 
169 /**
170  * Typedef the L3 ACL binding commands
171  */
175 
176 /**
177  * Typedef the L2 binding type
178  */
182 
183 }; // namespace binding_cmds
184 }; // namespace ACL
185 }; // namespace VOM
186 
187 /*
188  * fd.io coding-style-patch-verification: OFF
189  *
190  * Local Variables:
191  * eval: (c-set-style "mozilla")
192  * End:
193  */
194 
195 #endif
VOM::ACL::binding_cmds::bind_cmd::bind_cmd
bind_cmd(HW::item< bool > &item, const direction_t &direction, const handle_t &itf, const handle_t &acl)
Constructor.
Definition: acl_binding_cmds.hpp:38
VOM::HW::item< bool >
VOM::ACL::binding_cmds::l3_unbind_cmd
unbind_cmd< vapi::Acl_interface_add_del > l3_unbind_cmd
Definition: acl_binding_cmds.hpp:173
VOM::ACL::binding_cmds::dump_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: acl_binding_cmds.cpp:81
VOM::ACL::binding_cmds::unbind_cmd::operator==
bool operator==(const unbind_cmd &other) const
Comparison operator - only used for UT.
Definition: acl_binding_cmds.hpp:118
VOM::ACL::binding_cmds::l3_bind_cmd
bind_cmd< vapi::Acl_interface_add_del > l3_bind_cmd
Typedef the L3 ACL binding commands.
Definition: acl_binding_cmds.hpp:172
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::ACL::binding_cmds::dump_cmd
A cmd class that Dumps all the ACLs.
Definition: acl_binding_cmds.hpp:144
VOM::ACL::binding_cmds::dump_cmd::dump_cmd
dump_cmd()=default
Constructor.
VOM::rpc_cmd
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::ACL::binding_cmds::unbind_cmd::unbind_cmd
unbind_cmd(HW::item< bool > &item, const direction_t &direction, const handle_t &itf, const handle_t &acl)
Constructor.
Definition: acl_binding_cmds.hpp:94
VOM::ACL::binding_cmds::dump_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: acl_binding_cmds.cpp:97
acl_binding.hpp
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
VOM::ACL::binding_cmds::l2_bind_cmd
bind_cmd< vapi::Macip_acl_interface_add_del > l2_bind_cmd
Typedef the L2 binding type.
Definition: acl_binding_cmds.hpp:179
VOM::ACL::binding_cmds::bind_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: acl_binding_cmds.cpp:25
VOM::handle_t
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
VOM::ACL::binding_cmds::unbind_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: acl_binding_cmds.cpp:70
VOM::ACL::binding_cmds::bind_cmd
A command class that binds the ACL to the interface.
Definition: acl_binding_cmds.hpp:32
VOM::ACL::binding_cmds::l3_dump_cmd
dump_cmd< vapi::Acl_interface_list_dump > l3_dump_cmd
Definition: acl_binding_cmds.hpp:174
dump_cmd.hpp
VOM::ACL::binding_cmds::bind_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: acl_binding_cmds.cpp:42
VOM::rpc_cmd< HW::item< bool >, BIND >::item
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
VOM::ACL::binding_cmds::l2_unbind_cmd
unbind_cmd< vapi::Macip_acl_interface_add_del > l2_unbind_cmd
Definition: acl_binding_cmds.hpp:180
VOM::HW
Definition: hw.hpp:34
VOM::ACL::binding_cmds::unbind_cmd
A command class that binds the ACL to the interface.
Definition: acl_binding_cmds.hpp:88
bool
#define bool
Definition: radix.c:95
VOM::ACL::binding_cmds::l2_dump_cmd
dump_cmd< vapi::Macip_acl_interface_list_dump > l2_dump_cmd
Definition: acl_binding_cmds.hpp:181
VOM::direction_t
Feature Directions.
Definition: types.hpp:136
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
VOM::dump_cmd
A base class for VPP dump commands.
Definition: dump_cmd.hpp:43
VOM::ACL::binding_cmds::unbind_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: acl_binding_cmds.cpp:53
VOM::ACL::binding_cmds::bind_cmd::operator==
bool operator==(const bind_cmd &other) const
Comparison operator - only used for UT.
Definition: acl_binding_cmds.hpp:62
direction
direction
Definition: interface_types.api:76
rpc_cmd.hpp
VOM::dependency_t::ACL
@ ACL
ACLs.
string
const char *const string
Definition: cJSON.h:172