blob: 66b2827abc23b4ce20f00b1177981df9e6c84477 [file] [log] [blame]
Neale Ranns812ed392017-10-16 04:20:13 -07001/*
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
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070016#include "vom/nat_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070017
18namespace VOM {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070019namespace nat_binding_cmds {
20bind_44_input_cmd::bind_44_input_cmd(HW::item<bool>& item,
21 const handle_t& itf,
22 const nat_binding::zone_t& zone)
Neale Ranns812ed392017-10-16 04:20:13 -070023 : rpc_cmd(item)
24 , m_itf(itf)
25 , m_zone(zone)
26{
27}
28
29bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070030bind_44_input_cmd::operator==(const bind_44_input_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -070031{
32 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
33}
34
35rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070036bind_44_input_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -070037{
38 msg_t req(con.ctx(), std::ref(*this));
39
40 auto& payload = req.get_request().get_payload();
41 payload.is_add = 1;
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070042 payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
Neale Ranns812ed392017-10-16 04:20:13 -070043 payload.sw_if_index = m_itf.value();
44
45 VAPI_CALL(req.execute());
46
47 m_hw_item.set(wait());
48
49 return rc_t::OK;
50}
51
52std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070053bind_44_input_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -070054{
55 std::ostringstream s;
56 s << "nat-44-input-binding-create: " << m_hw_item.to_string()
57 << " itf:" << m_itf << " " << m_zone.to_string();
58
59 return (s.str());
60}
61
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070062unbind_44_input_cmd::unbind_44_input_cmd(HW::item<bool>& item,
63 const handle_t& itf,
64 const nat_binding::zone_t& zone)
Neale Ranns812ed392017-10-16 04:20:13 -070065 : rpc_cmd(item)
66 , m_itf(itf)
67 , m_zone(zone)
68{
69}
70
71bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070072unbind_44_input_cmd::operator==(const unbind_44_input_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -070073{
74 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
75}
76
77rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070078unbind_44_input_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -070079{
80 msg_t req(con.ctx(), std::ref(*this));
81
82 auto& payload = req.get_request().get_payload();
83 payload.is_add = 0;
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070084 payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
Neale Ranns812ed392017-10-16 04:20:13 -070085 payload.sw_if_index = m_itf.value();
86
87 VAPI_CALL(req.execute());
88
89 m_hw_item.set(wait());
90
91 return rc_t::OK;
92}
93
94std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070095unbind_44_input_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -070096{
97 std::ostringstream s;
98 s << "nat-44-input-binding-create: " << m_hw_item.to_string()
99 << " itf:" << m_itf << " " << m_zone.to_string();
100
101 return (s.str());
102}
103
Neale Ranns041fa502017-12-20 08:49:51 -0800104bind_44_output_cmd::bind_44_output_cmd(HW::item<bool>& item,
105 const handle_t& itf,
106 const nat_binding::zone_t& zone)
107 : rpc_cmd(item)
108 , m_itf(itf)
109 , m_zone(zone)
Neale Ranns812ed392017-10-16 04:20:13 -0700110{
111}
112
113bool
Neale Ranns041fa502017-12-20 08:49:51 -0800114bind_44_output_cmd::operator==(const bind_44_output_cmd& other) const
115{
116 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
117}
118
119rc_t
120bind_44_output_cmd::issue(connection& con)
121{
122 msg_t req(con.ctx(), std::ref(*this));
123
124 auto& payload = req.get_request().get_payload();
125 payload.is_add = 1;
126 payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
127 payload.sw_if_index = m_itf.value();
128
129 VAPI_CALL(req.execute());
130
131 m_hw_item.set(wait());
132
133 return rc_t::OK;
134}
135
136std::string
137bind_44_output_cmd::to_string() const
138{
139 std::ostringstream s;
140 s << "nat-44-output-binding-create: " << m_hw_item.to_string()
141 << " itf:" << m_itf << " " << m_zone.to_string();
142
143 return (s.str());
144}
145
146unbind_44_output_cmd::unbind_44_output_cmd(HW::item<bool>& item,
147 const handle_t& itf,
148 const nat_binding::zone_t& zone)
149 : rpc_cmd(item)
150 , m_itf(itf)
151 , m_zone(zone)
152{
153}
154
155bool
156unbind_44_output_cmd::operator==(const unbind_44_output_cmd& other) const
157{
158 return ((m_itf == other.m_itf) && (m_zone == other.m_zone));
159}
160
161rc_t
162unbind_44_output_cmd::issue(connection& con)
163{
164 msg_t req(con.ctx(), std::ref(*this));
165
166 auto& payload = req.get_request().get_payload();
167 payload.is_add = 0;
168 payload.is_inside = (nat_binding::zone_t::INSIDE == m_zone ? 1 : 0);
169 payload.sw_if_index = m_itf.value();
170
171 VAPI_CALL(req.execute());
172
173 m_hw_item.set(wait());
174
175 return rc_t::OK;
176}
177
178std::string
179unbind_44_output_cmd::to_string() const
180{
181 std::ostringstream s;
182 s << "nat-44-output-binding-create: " << m_hw_item.to_string()
183 << " itf:" << m_itf << " " << m_zone.to_string();
184
185 return (s.str());
186}
187
188dump_input_44_cmd::dump_input_44_cmd()
189{
190}
191
192dump_input_44_cmd::dump_input_44_cmd(const dump_input_44_cmd& d)
193{
194}
195
196bool
197dump_input_44_cmd::operator==(const dump_input_44_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -0700198{
199 return (true);
200}
201
202rc_t
Neale Ranns041fa502017-12-20 08:49:51 -0800203dump_input_44_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700204{
205 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
206
207 VAPI_CALL(m_dump->execute());
208
209 wait();
210
211 return rc_t::OK;
212}
213
214std::string
Neale Ranns041fa502017-12-20 08:49:51 -0800215dump_input_44_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700216{
Neale Ranns041fa502017-12-20 08:49:51 -0800217 return ("nat-input-binding-dump");
Neale Ranns812ed392017-10-16 04:20:13 -0700218}
Neale Ranns041fa502017-12-20 08:49:51 -0800219
220dump_output_44_cmd::dump_output_44_cmd()
221{
Neale Ranns812ed392017-10-16 04:20:13 -0700222}
Neale Ranns041fa502017-12-20 08:49:51 -0800223
224dump_output_44_cmd::dump_output_44_cmd(const dump_output_44_cmd& d)
225{
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700226}
Neale Ranns812ed392017-10-16 04:20:13 -0700227
Neale Ranns041fa502017-12-20 08:49:51 -0800228bool
229dump_output_44_cmd::operator==(const dump_output_44_cmd& other) const
230{
231 return (true);
232}
233
234rc_t
235dump_output_44_cmd::issue(connection& con)
236{
237 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
238
239 VAPI_CALL(m_dump->execute());
240
241 wait();
242
243 return rc_t::OK;
244}
245
246std::string
247dump_output_44_cmd::to_string() const
248{
249 return ("nat-output-binding-dump");
250}
251
252}; // namespace nat_binding_cmds
253}; // namespace VOM
254
Neale Ranns812ed392017-10-16 04:20:13 -0700255/*
256 * fd.io coding-style-patch-verification: ON
257 *
258 * Local Variables:
259 * eval: (c-set-style "mozilla")
260 * End:
261 */