FD.io VPP  v19.04.2-12-g66b1689
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.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
43  payload.sw_if_index = m_itf.value();
44 
45  VAPI_CALL(req.execute());
46 
47  return (wait());
48 }
49 
50 std::string
52 {
53  std::ostringstream s;
54  s << "nat-44-input-binding-create: " << m_hw_item.to_string()
55  << " itf:" << m_itf << " " << m_zone.to_string();
56 
57  return (s.str());
58 }
59 
61  const handle_t& itf,
62  const nat_binding::zone_t& zone)
63  : rpc_cmd(item)
64  , m_itf(itf)
65  , m_zone(zone)
66 {
67 }
68 
69 bool
71 {
72  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
73 }
74 
75 rc_t
77 {
78  msg_t req(con.ctx(), std::ref(*this));
79 
80  auto& payload = req.get_request().get_payload();
81  payload.is_add = 0;
82  payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
83  payload.sw_if_index = m_itf.value();
84 
85  VAPI_CALL(req.execute());
86 
87  return (wait());
88 }
89 
90 std::string
92 {
93  std::ostringstream s;
94  s << "nat-44-input-binding-create: " << m_hw_item.to_string()
95  << " itf:" << m_itf << " " << m_zone.to_string();
96 
97  return (s.str());
98 }
99 
101  const handle_t& itf,
102  const nat_binding::zone_t& zone)
103  : rpc_cmd(item)
104  , m_itf(itf)
105  , m_zone(zone)
106 {
107 }
108 
109 bool
111 {
112  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
113 }
114 
115 rc_t
117 {
118  msg_t req(con.ctx(), std::ref(*this));
119 
120  auto& payload = req.get_request().get_payload();
121  payload.is_add = 1;
122  payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
123  payload.sw_if_index = m_itf.value();
124 
125  VAPI_CALL(req.execute());
126 
127  return (wait());
128 }
129 
130 std::string
132 {
133  std::ostringstream s;
134  s << "nat-44-output-binding-create: " << m_hw_item.to_string()
135  << " itf:" << m_itf << " " << m_zone.to_string();
136 
137  return (s.str());
138 }
139 
141  const handle_t& itf,
142  const nat_binding::zone_t& zone)
143  : rpc_cmd(item)
144  , m_itf(itf)
145  , m_zone(zone)
146 {
147 }
148 
149 bool
151 {
152  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
153 }
154 
155 rc_t
157 {
158  msg_t req(con.ctx(), std::ref(*this));
159 
160  auto& payload = req.get_request().get_payload();
161  payload.is_add = 0;
162  payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
163  payload.sw_if_index = m_itf.value();
164 
165  VAPI_CALL(req.execute());
166 
167  return (wait());
168 }
169 
170 std::string
172 {
173  std::ostringstream s;
174  s << "nat-44-output-binding-create: " << m_hw_item.to_string()
175  << " itf:" << m_itf << " " << m_zone.to_string();
176 
177  return (s.str());
178 }
179 
181 {
182 }
183 
185 {
186 }
187 
188 bool
190 {
191  return (true);
192 }
193 
194 rc_t
196 {
197  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
198 
199  VAPI_CALL(m_dump->execute());
200 
201  wait();
202 
203  return rc_t::OK;
204 }
205 
206 std::string
208 {
209  return ("nat-44-input-binding-dump");
210 }
211 
213 {
214 }
215 
217 {
218 }
219 
220 bool
222 {
223  return (true);
224 }
225 
226 rc_t
228 {
229  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
230 
231  VAPI_CALL(m_dump->execute());
232 
233  wait();
234 
235  return rc_t::OK;
236 }
237 
238 std::string
240 {
241  return ("nat-44-output-binding-dump");
242 }
243 
245  const handle_t& itf,
246  const nat_binding::zone_t& zone)
247  : rpc_cmd(item)
248  , m_itf(itf)
249  , m_zone(zone)
250 {
251 }
252 
253 bool
255 {
256  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
257 }
258 
259 rc_t
261 {
262  msg_t req(con.ctx(), std::ref(*this));
263 
264  auto& payload = req.get_request().get_payload();
265  payload.is_add = 1;
266  payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
267  payload.sw_if_index = m_itf.value();
268 
269  VAPI_CALL(req.execute());
270 
271  wait();
272 
273  return rc_t::OK;
274 }
275 
276 std::string
278 {
279  std::ostringstream s;
280  s << "nat-66-input-binding-create: " << m_hw_item.to_string()
281  << " itf:" << m_itf << " " << m_zone.to_string();
282 
283  return (s.str());
284 }
285 
287  const handle_t& itf,
288  const nat_binding::zone_t& zone)
289  : rpc_cmd(item)
290  , m_itf(itf)
291  , m_zone(zone)
292 {
293 }
294 
295 bool
297 {
298  return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
299 }
300 
301 rc_t
303 {
304  msg_t req(con.ctx(), std::ref(*this));
305 
306  auto& payload = req.get_request().get_payload();
307  payload.is_add = 0;
308  payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
309  payload.sw_if_index = m_itf.value();
310 
311  VAPI_CALL(req.execute());
312 
313  wait();
314 
315  return rc_t::OK;
316 }
317 
318 std::string
320 {
321  std::ostringstream s;
322  s << "nat-66-input-binding-create: " << m_hw_item.to_string()
323  << " itf:" << m_itf << " " << m_zone.to_string();
324 
325  return (s.str());
326 }
327 
329 {
330 }
331 
333 {
334 }
335 
336 bool
338 {
339  return (true);
340 }
341 
342 rc_t
344 {
345  m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
346 
347  VAPI_CALL(m_dump->execute());
348 
349  wait();
350 
351  return rc_t::OK;
352 }
353 
354 std::string
356 {
357  return ("nat-66-input-binding-dump");
358 }
359 
360 }; // namespace nat_binding_cmds
361 }; // namespace VOM
362 
363 /*
364  * fd.io coding-style-patch-verification: ON
365  *
366  * Local Variables:
367  * eval: (c-set-style "mozilla")
368  * End:
369  */
bool operator==(const dump_input_44_cmd &i) const
Comparison operator - only used for UT.
A cmd class that Dumps all the nat_statics.
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
rc_t issue(connection &con)
Issue the command to VPP/HW.
bind_44_output_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
A cmd class that unbinds a NAT configuration from an input interface.
bool operator==(const unbind_44_output_cmd &i) const
Comparison operator - only used for UT.
uint32_t value() const
get the value of the handle
Definition: types.cpp:93
std::string to_string() const
convert to string format for debug purposes
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.
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
std::string to_string() const
convert to string format for debug purposes
rc_t issue(connection &con)
Issue the command to VPP/HW.
std::string to_string() const
convert to string format for debug purposes
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.
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.
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
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
Definition: types.hpp:29
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 functor class that binds a NAT configuration to an input interface.
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
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.
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
Definition: connection.cpp:49
A cmd class that Dumps all the nat_statics.
bool operator==(const dump_output_44_cmd &i) const
Comparison operator - only used for UT.
bool operator==(const bind_44_input_cmd &i) const
Comparison operator - only used for UT.
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_44_input_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.
const std::string & to_string() const
convert to string format for debug purposes
Definition: enum_base.hpp:36
bool operator==(const bind_66_input_cmd &i) const
Comparison operator - only used for UT.
A cmd class that unbinds a NAT configuration from an output interface.
bool operator==(const dump_input_66_cmd &i) const
Comparison operator - only used for UT.
bool operator==(const bind_44_output_cmd &i) const
Comparison operator - only used for UT.
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
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.
std::string to_string() const
convert to string format for debug purposes