FD.io VPP  v18.01-8-g0eacf49
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>, rc_t, 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>, rc_t, 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  std::ostringstream s;
60  s << "acl-bind:[" << m_direction.to_string() << " itf:" << m_itf.to_string()
61  << " acl:" << m_acl.to_string() << "]";
62 
63  return (s.str());
64  }
65 
66  /**
67  * Comparison operator - only used for UT
68  */
69  bool operator==(const bind_cmd& other) const
70  {
71  return ((m_itf == other.m_itf) && (m_acl == m_acl));
72  }
73 
74 private:
75  /**
76  * The direction of the binding
77  */
78  const direction_t m_direction;
79 
80  /**
81  * The interface to bind to
82  */
83  const handle_t m_itf;
84 
85  /**
86  * The ACL to bind
87  */
88  const handle_t m_acl;
89 };
90 
91 /**
92  * A command class that binds the ACL to the interface
93  */
94 template <typename BIND>
95 class unbind_cmd : public rpc_cmd<HW::item<bool>, rc_t, BIND>
96 {
97 public:
98  /**
99  * Constructor
100  */
102  const direction_t& direction,
103  const handle_t& itf,
104  const handle_t& acl)
105  : rpc_cmd<HW::item<bool>, rc_t, BIND>(item)
106  , m_direction(direction)
107  , m_itf(itf)
108  , m_acl(acl)
109  {
110  }
111 
112  /**
113  * Issue the command to VPP/HW
114  */
115  rc_t issue(connection& con);
116 
117  /**
118  * convert to string format for debug purposes
119  */
120  std::string to_string() const
121  {
122  std::ostringstream s;
123  s << "acl-unbind:[" << m_direction.to_string()
124  << " itf:" << m_itf.to_string() << " acl:" << m_acl.to_string() << "]";
125 
126  return (s.str());
127  }
128 
129  /**
130  * Comparison operator - only used for UT
131  */
132  bool operator==(const unbind_cmd& other) const
133  {
134  return ((m_itf == other.m_itf) && (m_acl == m_acl));
135  }
136 
137 private:
138  /**
139  * The direction of the binding
140  */
141  const direction_t m_direction;
142 
143  /**
144  * The interface to bind to
145  */
146  const handle_t m_itf;
147 
148  /**
149  * The ACL to bind
150  */
151  const handle_t m_acl;
152 };
153 
154 /**
155  * A cmd class that Dumps all the ACLs
156  */
157 template <typename DUMP>
158 class dump_cmd : public VOM::dump_cmd<DUMP>
159 {
160 public:
161  /**
162  * Constructor
163  */
164  dump_cmd() = default;
165 
166  /**
167  * Issue the command to VPP/HW
168  */
169  rc_t issue(connection& con);
170 
171  /**
172  * convert to string format for debug purposes
173  */
174  std::string to_string() const { return ("acl-bind-dump"); }
175 
176 private:
177  /**
178  * HW reutrn code
179  */
181 };
182 
183 /**
184  * Typedef the L3 ACL binding commands
185  */
189 
190 /**
191  * Typedef the L2 binding type
192  */
196 
197 }; // namespace binding_cmds
198 }; // namespace ACL
199 }; // namespace VOM
200 
201 /*
202  * fd.io coding-style-patch-verification: ON
203  *
204  * Local Variables:
205  * eval: (c-set-style "mozilla")
206  * End:
207  */
208 
209 #endif
std::string to_string() const
convert to string format for debug purposes
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:33
Error codes that VPP will return during a HW write.
Definition: types.hpp:84
bind_cmd< vapi::Macip_acl_interface_add_del > l2_bind_cmd
Typedef the L2 binding type.
Feature Directions.
Definition: types.hpp:133
std::string to_string() const
convert to string format for debug purposes
Definition: types.cpp:68
unbind_cmd< vapi::Acl_interface_add_del > l3_unbind_cmd
bool operator==(const bind_cmd &other) const
Comparison operator - only used for UT.
A representation of the connection to VPP.
Definition: connection.hpp:33
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:64
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:38
unbind_cmd(HW::item< bool > &item, const direction_t &direction, const handle_t &itf, const handle_t &acl)
Constructor.
std::string to_string() const
convert to string format for debug purposes
bool operator==(const unbind_cmd &other) const
Comparison operator - only used for UT.
A command class that binds the ACL to the interface.
A type declaration of an interface handle in VPP.
Definition: types.hpp:164
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
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
const std::string & to_string() const
convert to string format for debug purposes
Definition: enum_base.hpp:36
A base class for VPP dump commands.
Definition: dump_cmd.hpp:43
std::string to_string() const
convert to string format for debug purposes
bind_cmd< vapi::Acl_interface_add_del > l3_bind_cmd
Typedef the L3 ACL binding commands.