FD.io VPP  v21.01.1
Vector Packet Processing
nat_binding_cmds.cpp
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 #include "vom/nat_binding_cmds.hpp"
17 
18 namespace VOM {
19 namespace nat_binding_cmds {
21  const handle_t& itf,
22  const nat_binding::zone_t& zone)
23  : rpc_cmd(item)
24  , m_itf(itf)
25  , m_zone(zone)
26 {
27 }
28 
29 bool
31 {
32  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
33 }
34 
35 rc_t
37 {
38  msg_t req(con.ctx(), std::ref(*this));
39 
40  auto& payload = req.get_request().get_payload();
41  payload.is_add = 1;
42  payload.flags = (vapi_enum_nat_config_flags)(
44  payload.sw_if_index = m_itf.value();
45 
46  VAPI_CALL(req.execute());
47 
48  return (wait());
49 }
50 
53 {
54  std::ostringstream s;
55  s << "nat-44-input-binding-create: " << m_hw_item.to_string()
56  << " itf:" << m_itf << " " << m_zone.to_string();
57 
58  return (s.str());
59 }
60 
62  const handle_t& itf,
63  const nat_binding::zone_t& zone)
64  : rpc_cmd(item)
65  , m_itf(itf)
66  , m_zone(zone)
67 {
68 }
69 
70 bool
72 {
73  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
74 }
75 
76 rc_t
78 {
79  msg_t req(con.ctx(), std::ref(*this));
80 
81  auto& payload = req.get_request().get_payload();
82  payload.is_add = 0;
83  payload.flags = (vapi_enum_nat_config_flags)(
85  payload.sw_if_index = m_itf.value();
86 
87  VAPI_CALL(req.execute());
88 
89  return (wait());
90 }
91 
94 {
95  std::ostringstream s;
96  s << "nat-44-input-binding-create: " << m_hw_item.to_string()
97  << " itf:" << m_itf << " " << m_zone.to_string();
98 
99  return (s.str());
100 }
101 
103  const handle_t& itf,
104  const nat_binding::zone_t& zone)
105  : rpc_cmd(item)
106  , m_itf(itf)
107  , m_zone(zone)
108 {
109 }
110 
111 bool
113 {
114  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
115 }
116 
117 rc_t
119 {
120  msg_t req(con.ctx(), std::ref(*this));
121 
122  auto& payload = req.get_request().get_payload();
123  payload.is_add = 1;
124  payload.flags = (vapi_enum_nat_config_flags)(
126  payload.sw_if_index = m_itf.value();
127 
128  VAPI_CALL(req.execute());
129 
130  return (wait());
131 }
132 
135 {
136  std::ostringstream s;
137  s << "nat-44-output-binding-create: " << m_hw_item.to_string()
138  << " itf:" << m_itf << " " << m_zone.to_string();
139 
140  return (s.str());
141 }
142 
144  const handle_t& itf,
145  const nat_binding::zone_t& zone)
146  : rpc_cmd(item)
147  , m_itf(itf)
148  , m_zone(zone)
149 {
150 }
151 
152 bool
154 {
155  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
156 }
157 
158 rc_t
160 {
161  msg_t req(con.ctx(), std::ref(*this));
162 
163  auto& payload = req.get_request().get_payload();
164  payload.is_add = 0;
165  payload.flags = (vapi_enum_nat_config_flags)(
167  payload.sw_if_index = m_itf.value();
168 
169  VAPI_CALL(req.execute());
170 
171  return (wait());
172 }
173 
176 {
177  std::ostringstream s;
178  s << "nat-44-output-binding-create: " << m_hw_item.to_string()
179  << " itf:" << m_itf << " " << m_zone.to_string();
180 
181  return (s.str());
182 }
183 
185 {
186 }
187 
189 {
190 }
191 
192 bool
194 {
195  return (true);
196 }
197 
198 rc_t
200 {
201  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
202 
203  VAPI_CALL(m_dump->execute());
204 
205  wait();
206 
207  return rc_t::OK;
208 }
209 
212 {
213  return ("nat-44-input-binding-dump");
214 }
215 
217 {
218 }
219 
221 {
222 }
223 
224 bool
226 {
227  return (true);
228 }
229 
230 rc_t
232 {
233  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
234 
235  VAPI_CALL(m_dump->execute());
236 
237  wait();
238 
239  return rc_t::OK;
240 }
241 
244 {
245  return ("nat-44-output-binding-dump");
246 }
247 
249  const handle_t& itf,
250  const nat_binding::zone_t& zone)
251  : rpc_cmd(item)
252  , m_itf(itf)
253  , m_zone(zone)
254 {
255 }
256 
257 bool
259 {
260  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
261 }
262 
263 rc_t
265 {
266  msg_t req(con.ctx(), std::ref(*this));
267 
268  auto& payload = req.get_request().get_payload();
269  payload.is_add = 1;
270  payload.flags = (vapi_enum_nat_config_flags)(
272  payload.sw_if_index = m_itf.value();
273 
274  VAPI_CALL(req.execute());
275 
276  wait();
277 
278  return rc_t::OK;
279 }
280 
283 {
284  std::ostringstream s;
285  s << "nat-66-input-binding-create: " << m_hw_item.to_string()
286  << " itf:" << m_itf << " " << m_zone.to_string();
287 
288  return (s.str());
289 }
290 
292  const handle_t& itf,
293  const nat_binding::zone_t& zone)
294  : rpc_cmd(item)
295  , m_itf(itf)
296  , m_zone(zone)
297 {
298 }
299 
300 bool
302 {
303  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
304 }
305 
306 rc_t
308 {
309  msg_t req(con.ctx(), std::ref(*this));
310 
311  auto& payload = req.get_request().get_payload();
312  payload.is_add = 0;
313  payload.flags = (vapi_enum_nat_config_flags)(
315  payload.sw_if_index = m_itf.value();
316 
317  VAPI_CALL(req.execute());
318 
319  wait();
320 
321  return rc_t::OK;
322 }
323 
326 {
327  std::ostringstream s;
328  s << "nat-66-input-binding-create: " << m_hw_item.to_string()
329  << " itf:" << m_itf << " " << m_zone.to_string();
330 
331  return (s.str());
332 }
333 
335 {
336 }
337 
339 {
340 }
341 
342 bool
344 {
345  return (true);
346 }
347 
348 rc_t
350 {
351  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
352 
353  VAPI_CALL(m_dump->execute());
354 
355  wait();
356 
357  return rc_t::OK;
358 }
359 
362 {
363  return ("nat-66-input-binding-dump");
364 }
365 
366 }; // namespace nat_binding_cmds
367 }; // namespace VOM
368 
369 /*
370  * fd.io coding-style-patch-verification: OFF
371  *
372  * Local Variables:
373  * eval: (c-set-style "mozilla")
374  * End:
375  */
A cmd class that Dumps all the nat_statics.
rc_t issue(connection &con)
Issue the command to VPP/HW.
rc_t issue(connection &con)
Issue the command to VPP/HW.
std::string to_string() const
convert to string format for debug purposes
bind_44_output_cmd(HW::item< bool > &item, const handle_t &itf, const nat_binding::zone_t &zone)
Constructor.
A cmd class that unbinds a NAT configuration from an input interface.
uint32_t value() const
get the value of the handle
Definition: types.cpp:93
const char *const string
Definition: cJSON.h:172
A functor class that binds a NAT configuration to an output interface.
rc_t issue(connection &con)
Issue the command to VPP/HW.
A cmd class that unbinds a NAT configuration from an input interface.
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
rc_t issue(connection &con)
Issue the command to VPP/HW.
bool operator==(const dump_output_44_cmd &i) const
Comparison operator - only used for UT.
bool operator==(const bind_66_input_cmd &i) const
Comparison operator - only used for UT.
unbind_66_input_cmd(HW::item< bool > &item, const handle_t &itf, const nat_binding::zone_t &zone)
Constructor.
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
rc_t issue(connection &con)
Issue the command to VPP/HW.
rc_t issue(connection &con)
Issue the command to VPP/HW.
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
convert to string format for debug purposes
static const zone_t INSIDE
Permit Zone.
Definition: nat_binding.hpp:51
A representation of the connection to VPP.
Definition: connection.hpp:33
A cmd class that Dumps all the nat_statics.
rc_t issue(connection &con)
Issue the command to VPP/HW.
unbind_44_input_cmd(HW::item< bool > &item, const handle_t &itf, const nat_binding::zone_t &zone)
Constructor.
bool operator==(const dump_input_66_cmd &i) const
Comparison operator - only used for UT.
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
std::string to_string() const
convert to string format for debug purposes
A functor class that binds a NAT configuration to an input interface.
A functor class that binds a NAT configuration to an input interface.
std::string to_string() const
convert to string format for debug purposes
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
const std::string & to_string() const
convert to string format for debug purposes
Definition: enum_base.hpp:36
cJSON * item
Definition: cJSON.h:222
static const rc_t OK
The HW write was successfull.
Definition: types.hpp:109
unbind_44_output_cmd(HW::item< bool > &item, const handle_t &itf, const nat_binding::zone_t &zone)
Constructor.
bind_44_input_cmd(HW::item< bool > &item, const handle_t &itf, const nat_binding::zone_t &zone)
Constructor.
std::string to_string() const
convert to string format for debug purposes
bool operator==(const unbind_44_output_cmd &i) const
Comparison operator - only used for UT.
bool operator==(const bind_44_output_cmd &i) const
Comparison operator - only used for UT.
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
Definition: connection.cpp:49
bool operator==(const bind_44_input_cmd &i) const
Comparison operator - only used for UT.
A cmd class that Dumps all the nat_statics.
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
rc_t issue(connection &con)
Issue the command to VPP/HW.
bool operator==(const unbind_66_input_cmd &i) const
Comparison operator - only used for UT.
bool operator==(const dump_input_44_cmd &i) const
Comparison operator - only used for UT.
bind_66_input_cmd(HW::item< bool > &item, const handle_t &itf, const nat_binding::zone_t &zone)
Constructor.
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
convert to string format for debug purposes
A cmd class that unbinds a NAT configuration from an output interface.
std::string to_string() const
convert to string format for debug purposes
HW::item< bool > & m_hw_item
A reference to an object&#39;s HW::item that the command will update.
Definition: rpc_cmd.hpp:134
bool operator==(const unbind_44_input_cmd &i) const
Comparison operator - only used for UT.
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
vapi::Nat44_interface_add_del_feature msg_t
convenient typedef
Definition: rpc_cmd.hpp:46
rc_t issue(connection &con)
Issue the command to VPP/HW.