FD.io VPP  v19.01.3-6-g70449b9b9
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  */
52  rc_t issue(connection& con);
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  */
108  rc_t issue(connection& con);
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  */
155  rc_t issue(connection& con);
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  */
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: ON
189  *
190  * Local Variables:
191  * eval: (c-set-style "mozilla")
192  * End:
193  */
194 
195 #endif
A command class that binds the ACL to the interface.
rc_t issue(connection &con)
Issue the command to VPP/HW.
bind_cmd(HW::item< bool > &item, const direction_t &direction, const handle_t &itf, const handle_t &acl)
Constructor.
Definition: hw.hpp:34
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
bind_cmd< vapi::Macip_acl_interface_add_del > l2_bind_cmd
Typedef the L2 binding type.
Feature Directions.
Definition: types.hpp:136
bool operator==(const unbind_cmd &other) const
Comparison operator - only used for UT.
unbind_cmd< vapi::Acl_interface_add_del > l3_unbind_cmd
A representation of the connection to VPP.
Definition: connection.hpp:33
std::string to_string() const
convert to string format for debug purposes
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
unbind_cmd(HW::item< bool > &item, const direction_t &direction, const handle_t &itf, const handle_t &acl)
Constructor.
A command class that binds the ACL to the interface.
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
A cmd class that Dumps all the ACLs.
dump_cmd< vapi::Macip_acl_interface_list_dump > l2_dump_cmd
dump_cmd< vapi::Acl_interface_list_dump > l3_dump_cmd
#define bool
Definition: radix.c:95
unbind_cmd< vapi::Macip_acl_interface_add_del > l2_unbind_cmd
bool operator==(const bind_cmd &other) const
Comparison operator - only used for UT.
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
A base class for VPP dump commands.
Definition: dump_cmd.hpp:43
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
bind_cmd< vapi::Acl_interface_add_del > l3_bind_cmd
Typedef the L3 ACL binding commands.