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.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
43 payload.sw_if_index = m_itf.value();
45 VAPI_CALL(req.execute());
51 bind_44_input_cmd::to_string() const
54 s << "nat-44-input-binding-create: " << m_hw_item.to_string()
55 << " itf:" << m_itf << " " << m_zone.to_string();
60 unbind_44_input_cmd::unbind_44_input_cmd(HW::item<bool>& item,
62 const nat_binding::zone_t& zone)
70 unbind_44_input_cmd::operator==(const unbind_44_input_cmd& other) const
72 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
76 unbind_44_input_cmd::issue(connection& con)
78 msg_t req(con.ctx(), std::ref(*this));
80 auto& payload = req.get_request().get_payload();
82 payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
83 payload.sw_if_index = m_itf.value();
85 VAPI_CALL(req.execute());
91 unbind_44_input_cmd::to_string() const
94 s << "nat-44-input-binding-create: " << m_hw_item.to_string()
95 << " itf:" << m_itf << " " << m_zone.to_string();
100 bind_44_output_cmd::bind_44_output_cmd(HW::item<bool>& item,
102 const nat_binding::zone_t& zone)
110 bind_44_output_cmd::operator==(const bind_44_output_cmd& other) const
112 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
116 bind_44_output_cmd::issue(connection& con)
118 msg_t req(con.ctx(), std::ref(*this));
120 auto& payload = req.get_request().get_payload();
122 payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
123 payload.sw_if_index = m_itf.value();
125 VAPI_CALL(req.execute());
131 bind_44_output_cmd::to_string() const
133 std::ostringstream s;
134 s << "nat-44-output-binding-create: " << m_hw_item.to_string()
135 << " itf:" << m_itf << " " << m_zone.to_string();
140 unbind_44_output_cmd::unbind_44_output_cmd(HW::item<bool>& item,
142 const nat_binding::zone_t& zone)
150 unbind_44_output_cmd::operator==(const unbind_44_output_cmd& other) const
152 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
156 unbind_44_output_cmd::issue(connection& con)
158 msg_t req(con.ctx(), std::ref(*this));
160 auto& payload = req.get_request().get_payload();
162 payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
163 payload.sw_if_index = m_itf.value();
165 VAPI_CALL(req.execute());
171 unbind_44_output_cmd::to_string() const
173 std::ostringstream s;
174 s << "nat-44-output-binding-create: " << m_hw_item.to_string()
175 << " itf:" << m_itf << " " << m_zone.to_string();
180 dump_input_44_cmd::dump_input_44_cmd()
184 dump_input_44_cmd::dump_input_44_cmd(const dump_input_44_cmd& d)
189 dump_input_44_cmd::operator==(const dump_input_44_cmd& other) const
195 dump_input_44_cmd::issue(connection& con)
197 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
199 VAPI_CALL(m_dump->execute());
207 dump_input_44_cmd::to_string() const
209 return ("nat-44-input-binding-dump");
212 dump_output_44_cmd::dump_output_44_cmd()
216 dump_output_44_cmd::dump_output_44_cmd(const dump_output_44_cmd& d)
221 dump_output_44_cmd::operator==(const dump_output_44_cmd& other) const
227 dump_output_44_cmd::issue(connection& con)
229 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
231 VAPI_CALL(m_dump->execute());
239 dump_output_44_cmd::to_string() const
241 return ("nat-44-output-binding-dump");
244 bind_66_input_cmd::bind_66_input_cmd(HW::item<bool>& item,
246 const nat_binding::zone_t& zone)
254 bind_66_input_cmd::operator==(const bind_66_input_cmd& other) const
256 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
260 bind_66_input_cmd::issue(connection& con)
262 msg_t req(con.ctx(), std::ref(*this));
264 auto& payload = req.get_request().get_payload();
266 payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
267 payload.sw_if_index = m_itf.value();
269 VAPI_CALL(req.execute());
277 bind_66_input_cmd::to_string() const
279 std::ostringstream s;
280 s << "nat-66-input-binding-create: " << m_hw_item.to_string()
281 << " itf:" << m_itf << " " << m_zone.to_string();
286 unbind_66_input_cmd::unbind_66_input_cmd(HW::item<bool>& item,
288 const nat_binding::zone_t& zone)
296 unbind_66_input_cmd::operator==(const unbind_66_input_cmd& other) const
298 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
302 unbind_66_input_cmd::issue(connection& con)
304 msg_t req(con.ctx(), std::ref(*this));
306 auto& payload = req.get_request().get_payload();
308 payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
309 payload.sw_if_index = m_itf.value();
311 VAPI_CALL(req.execute());
319 unbind_66_input_cmd::to_string() const
321 std::ostringstream s;
322 s << "nat-66-input-binding-create: " << m_hw_item.to_string()
323 << " itf:" << m_itf << " " << m_zone.to_string();
328 dump_input_66_cmd::dump_input_66_cmd()
332 dump_input_66_cmd::dump_input_66_cmd(const dump_input_66_cmd& d)
337 dump_input_66_cmd::operator==(const dump_input_66_cmd& other) const
343 dump_input_66_cmd::issue(connection& con)
345 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
347 VAPI_CALL(m_dump->execute());
355 dump_input_66_cmd::to_string() const
357 return ("nat-66-input-binding-dump");
360 }; // namespace nat_binding_cmds
364 * fd.io coding-style-patch-verification: ON
367 * eval: (c-set-style "mozilla")