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());
47 m_hw_item.set(wait());
53 bind_44_input_cmd::to_string() const
56 s << "nat-44-input-binding-create: " << m_hw_item.to_string()
57 << " itf:" << m_itf << " " << m_zone.to_string();
62 unbind_44_input_cmd::unbind_44_input_cmd(HW::item<bool>& item,
64 const nat_binding::zone_t& zone)
72 unbind_44_input_cmd::operator==(const unbind_44_input_cmd& other) const
74 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
78 unbind_44_input_cmd::issue(connection& con)
80 msg_t req(con.ctx(), std::ref(*this));
82 auto& payload = req.get_request().get_payload();
84 payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
85 payload.sw_if_index = m_itf.value();
87 VAPI_CALL(req.execute());
89 m_hw_item.set(wait());
95 unbind_44_input_cmd::to_string() const
98 s << "nat-44-input-binding-create: " << m_hw_item.to_string()
99 << " itf:" << m_itf << " " << m_zone.to_string();
104 bind_44_output_cmd::bind_44_output_cmd(HW::item<bool>& item,
106 const nat_binding::zone_t& zone)
114 bind_44_output_cmd::operator==(const bind_44_output_cmd& other) const
116 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
120 bind_44_output_cmd::issue(connection& con)
122 msg_t req(con.ctx(), std::ref(*this));
124 auto& payload = req.get_request().get_payload();
126 payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
127 payload.sw_if_index = m_itf.value();
129 VAPI_CALL(req.execute());
131 m_hw_item.set(wait());
137 bind_44_output_cmd::to_string() const
139 std::ostringstream s;
140 s << "nat-44-output-binding-create: " << m_hw_item.to_string()
141 << " itf:" << m_itf << " " << m_zone.to_string();
146 unbind_44_output_cmd::unbind_44_output_cmd(HW::item<bool>& item,
148 const nat_binding::zone_t& zone)
156 unbind_44_output_cmd::operator==(const unbind_44_output_cmd& other) const
158 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
162 unbind_44_output_cmd::issue(connection& con)
164 msg_t req(con.ctx(), std::ref(*this));
166 auto& payload = req.get_request().get_payload();
168 payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
169 payload.sw_if_index = m_itf.value();
171 VAPI_CALL(req.execute());
173 m_hw_item.set(wait());
179 unbind_44_output_cmd::to_string() const
181 std::ostringstream s;
182 s << "nat-44-output-binding-create: " << m_hw_item.to_string()
183 << " itf:" << m_itf << " " << m_zone.to_string();
188 dump_input_44_cmd::dump_input_44_cmd()
192 dump_input_44_cmd::dump_input_44_cmd(const dump_input_44_cmd& d)
197 dump_input_44_cmd::operator==(const dump_input_44_cmd& other) const
203 dump_input_44_cmd::issue(connection& con)
205 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
207 VAPI_CALL(m_dump->execute());
215 dump_input_44_cmd::to_string() const
217 return ("nat-input-binding-dump");
220 dump_output_44_cmd::dump_output_44_cmd()
224 dump_output_44_cmd::dump_output_44_cmd(const dump_output_44_cmd& d)
229 dump_output_44_cmd::operator==(const dump_output_44_cmd& other) const
235 dump_output_44_cmd::issue(connection& con)
237 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
239 VAPI_CALL(m_dump->execute());
247 dump_output_44_cmd::to_string() const
249 return ("nat-output-binding-dump");
252 }; // namespace nat_binding_cmds
256 * fd.io coding-style-patch-verification: ON
259 * eval: (c-set-style "mozilla")