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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #include "vom/nat_binding_cmds.hpp"
19 namespace nat_binding_cmds {
20 bind_44_input_cmd::bind_44_input_cmd(HW::item<bool>& item,
22 const nat_binding::zone_t& zone)
30 bind_44_input_cmd::operator==(const bind_44_input_cmd& other) const
32 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
36 bind_44_input_cmd::issue(connection& con)
38 msg_t req(con.ctx(), std::ref(*this));
40 auto& payload = req.get_request().get_payload();
42 payload.flags = (vapi_enum_nat_config_flags)(
43 nat_binding::zone_t::INSIDE == m_zone ? NAT_IS_INSIDE : 0);
44 payload.sw_if_index = m_itf.value();
46 VAPI_CALL(req.execute());
52 bind_44_input_cmd::to_string() const
55 s << "nat-44-input-binding-create: " << m_hw_item.to_string()
56 << " itf:" << m_itf << " " << m_zone.to_string();
61 unbind_44_input_cmd::unbind_44_input_cmd(HW::item<bool>& item,
63 const nat_binding::zone_t& zone)
71 unbind_44_input_cmd::operator==(const unbind_44_input_cmd& other) const
73 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
77 unbind_44_input_cmd::issue(connection& con)
79 msg_t req(con.ctx(), std::ref(*this));
81 auto& payload = req.get_request().get_payload();
83 payload.flags = (vapi_enum_nat_config_flags)(
84 nat_binding::zone_t::INSIDE == m_zone ? NAT_IS_INSIDE : 0);
85 payload.sw_if_index = m_itf.value();
87 VAPI_CALL(req.execute());
93 unbind_44_input_cmd::to_string() const
96 s << "nat-44-input-binding-create: " << m_hw_item.to_string()
97 << " itf:" << m_itf << " " << m_zone.to_string();
102 bind_44_output_cmd::bind_44_output_cmd(HW::item<bool>& item,
104 const nat_binding::zone_t& zone)
112 bind_44_output_cmd::operator==(const bind_44_output_cmd& other) const
114 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
118 bind_44_output_cmd::issue(connection& con)
120 msg_t req(con.ctx(), std::ref(*this));
122 auto& payload = req.get_request().get_payload();
124 payload.flags = (vapi_enum_nat_config_flags)(
125 nat_binding::zone_t::INSIDE == m_zone ? NAT_IS_INSIDE : 0);
126 payload.sw_if_index = m_itf.value();
128 VAPI_CALL(req.execute());
134 bind_44_output_cmd::to_string() const
136 std::ostringstream s;
137 s << "nat-44-output-binding-create: " << m_hw_item.to_string()
138 << " itf:" << m_itf << " " << m_zone.to_string();
143 unbind_44_output_cmd::unbind_44_output_cmd(HW::item<bool>& item,
145 const nat_binding::zone_t& zone)
153 unbind_44_output_cmd::operator==(const unbind_44_output_cmd& other) const
155 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
159 unbind_44_output_cmd::issue(connection& con)
161 msg_t req(con.ctx(), std::ref(*this));
163 auto& payload = req.get_request().get_payload();
165 payload.flags = (vapi_enum_nat_config_flags)(
166 nat_binding::zone_t::INSIDE == m_zone ? NAT_IS_INSIDE : 0);
167 payload.sw_if_index = m_itf.value();
169 VAPI_CALL(req.execute());
175 unbind_44_output_cmd::to_string() const
177 std::ostringstream s;
178 s << "nat-44-output-binding-create: " << m_hw_item.to_string()
179 << " itf:" << m_itf << " " << m_zone.to_string();
184 dump_input_44_cmd::dump_input_44_cmd()
188 dump_input_44_cmd::dump_input_44_cmd(const dump_input_44_cmd& d)
193 dump_input_44_cmd::operator==(const dump_input_44_cmd& other) const
199 dump_input_44_cmd::issue(connection& con)
201 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
203 VAPI_CALL(m_dump->execute());
211 dump_input_44_cmd::to_string() const
213 return ("nat-44-input-binding-dump");
216 dump_output_44_cmd::dump_output_44_cmd()
220 dump_output_44_cmd::dump_output_44_cmd(const dump_output_44_cmd& d)
225 dump_output_44_cmd::operator==(const dump_output_44_cmd& other) const
231 dump_output_44_cmd::issue(connection& con)
233 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
235 VAPI_CALL(m_dump->execute());
243 dump_output_44_cmd::to_string() const
245 return ("nat-44-output-binding-dump");
248 bind_66_input_cmd::bind_66_input_cmd(HW::item<bool>& item,
250 const nat_binding::zone_t& zone)
258 bind_66_input_cmd::operator==(const bind_66_input_cmd& other) const
260 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
264 bind_66_input_cmd::issue(connection& con)
266 msg_t req(con.ctx(), std::ref(*this));
268 auto& payload = req.get_request().get_payload();
270 payload.flags = (vapi_enum_nat_config_flags)(
271 nat_binding::zone_t::INSIDE == m_zone ? NAT_IS_INSIDE : 0);
272 payload.sw_if_index = m_itf.value();
274 VAPI_CALL(req.execute());
282 bind_66_input_cmd::to_string() const
284 std::ostringstream s;
285 s << "nat-66-input-binding-create: " << m_hw_item.to_string()
286 << " itf:" << m_itf << " " << m_zone.to_string();
291 unbind_66_input_cmd::unbind_66_input_cmd(HW::item<bool>& item,
293 const nat_binding::zone_t& zone)
301 unbind_66_input_cmd::operator==(const unbind_66_input_cmd& other) const
303 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
307 unbind_66_input_cmd::issue(connection& con)
309 msg_t req(con.ctx(), std::ref(*this));
311 auto& payload = req.get_request().get_payload();
313 payload.flags = (vapi_enum_nat_config_flags)(
314 nat_binding::zone_t::INSIDE == m_zone ? NAT_IS_INSIDE : 0);
315 payload.sw_if_index = m_itf.value();
317 VAPI_CALL(req.execute());
325 unbind_66_input_cmd::to_string() const
327 std::ostringstream s;
328 s << "nat-66-input-binding-create: " << m_hw_item.to_string()
329 << " itf:" << m_itf << " " << m_zone.to_string();
334 dump_input_66_cmd::dump_input_66_cmd()
338 dump_input_66_cmd::dump_input_66_cmd(const dump_input_66_cmd& d)
343 dump_input_66_cmd::operator==(const dump_input_66_cmd& other) const
349 dump_input_66_cmd::issue(connection& con)
351 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
353 VAPI_CALL(m_dump->execute());
361 dump_input_66_cmd::to_string() const
363 return ("nat-66-input-binding-dump");
366 }; // namespace nat_binding_cmds
370 * fd.io coding-style-patch-verification: ON
373 * eval: (c-set-style "mozilla")