VOM: support for pipes
[vpp.git] / extras / vom / vom / nat_binding_cmds.hpp
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 #ifndef __VOM_NAT_BINDING_CMDS_H__
17 #define __VOM_NAT_BINDING_CMDS_H__
18
19 #include "vom/dump_cmd.hpp"
20 #include "vom/nat_binding.hpp"
21 #include "vom/rpc_cmd.hpp"
22
23 #include <vapi/nat.api.vapi.hpp>
24
25 namespace VOM {
26 namespace nat_binding_cmds {
27 /**
28  * A functor class that binds a NAT configuration to an input interface
29  */
30 class bind_44_input_cmd
31   : public rpc_cmd<HW::item<bool>, vapi::Nat44_interface_add_del_feature>
32 {
33 public:
34   /**
35    * Constructor
36    */
37   bind_44_input_cmd(HW::item<bool>& item,
38                     const handle_t& itf,
39                     const nat_binding::zone_t& zone);
40
41   /**
42    * Issue the command to VPP/HW
43    */
44   rc_t issue(connection& con);
45   /**
46    * convert to string format for debug purposes
47    */
48   std::string to_string() const;
49
50   /**
51    * Comparison operator - only used for UT
52    */
53   bool operator==(const bind_44_input_cmd& i) const;
54
55 private:
56   /**
57    * The interface to bind
58    */
59   const handle_t m_itf;
60
61   /**
62    * The zone the interface is in
63    */
64   const nat_binding::zone_t m_zone;
65 };
66
67 /**
68  * A cmd class that unbinds a NAT configuration from an input interface
69  */
70 class unbind_44_input_cmd
71   : public rpc_cmd<HW::item<bool>, vapi::Nat44_interface_add_del_feature>
72 {
73 public:
74   /**
75    * Constructor
76    */
77   unbind_44_input_cmd(HW::item<bool>& item,
78                       const handle_t& itf,
79                       const nat_binding::zone_t& zone);
80
81   /**
82    * Issue the command to VPP/HW
83    */
84   rc_t issue(connection& con);
85   /**
86    * convert to string format for debug purposes
87    */
88   std::string to_string() const;
89
90   /**
91    * Comparison operator - only used for UT
92    */
93   bool operator==(const unbind_44_input_cmd& i) const;
94
95 private:
96   /**
97    * The interface to bind
98    */
99   const handle_t m_itf;
100
101   /**
102    * The zone the interface is in
103    */
104   const nat_binding::zone_t m_zone;
105 };
106
107 /**
108  * A functor class that binds a NAT configuration to an output interface
109  */
110 class bind_44_output_cmd
111   : public rpc_cmd<HW::item<bool>, vapi::Nat44_interface_add_del_output_feature>
112 {
113 public:
114   /**
115    * Constructor
116    */
117   bind_44_output_cmd(HW::item<bool>& item,
118                      const handle_t& itf,
119                      const nat_binding::zone_t& zone);
120
121   /**
122    * Issue the command to VPP/HW
123    */
124   rc_t issue(connection& con);
125   /**
126    * convert to string format for debug purposes
127    */
128   std::string to_string() const;
129
130   /**
131    * Comparison operator - only used for UT
132    */
133   bool operator==(const bind_44_output_cmd& i) const;
134
135 private:
136   /**
137    * The interface to bind
138    */
139   const handle_t m_itf;
140
141   /**
142    * The zone the interface is in
143    */
144   const nat_binding::zone_t m_zone;
145 };
146
147 /**
148  * A cmd class that unbinds a NAT configuration from an output interface
149  */
150 class unbind_44_output_cmd
151   : public rpc_cmd<HW::item<bool>, vapi::Nat44_interface_add_del_output_feature>
152 {
153 public:
154   /**
155    * Constructor
156    */
157   unbind_44_output_cmd(HW::item<bool>& item,
158                        const handle_t& itf,
159                        const nat_binding::zone_t& zone);
160
161   /**
162    * Issue the command to VPP/HW
163    */
164   rc_t issue(connection& con);
165   /**
166    * convert to string format for debug purposes
167    */
168   std::string to_string() const;
169
170   /**
171    * Comparison operator - only used for UT
172    */
173   bool operator==(const unbind_44_output_cmd& i) const;
174
175 private:
176   /**
177    * The interface to bind
178    */
179   const handle_t m_itf;
180
181   /**
182    * The zone the interface is in
183    */
184   const nat_binding::zone_t m_zone;
185 };
186
187 /**
188  * A cmd class that Dumps all the nat_statics
189  */
190 class dump_input_44_cmd : public dump_cmd<vapi::Nat44_interface_dump>
191 {
192 public:
193   /**
194    * Constructor
195    */
196   dump_input_44_cmd();
197   dump_input_44_cmd(const dump_input_44_cmd& d);
198
199   /**
200    * Issue the command to VPP/HW
201    */
202   rc_t issue(connection& con);
203   /**
204    * convert to string format for debug purposes
205    */
206   std::string to_string() const;
207
208   /**
209    * Comparison operator - only used for UT
210    */
211   bool operator==(const dump_input_44_cmd& i) const;
212
213 private:
214   /**
215    * HW reutrn code
216    */
217   HW::item<bool> item;
218 };
219
220 /**
221  * A cmd class that Dumps all the nat_statics
222  */
223 class dump_output_44_cmd
224   : public dump_cmd<vapi::Nat44_interface_output_feature_dump>
225 {
226 public:
227   /**
228    * Constructor
229    */
230   dump_output_44_cmd();
231   dump_output_44_cmd(const dump_output_44_cmd& d);
232
233   /**
234    * Issue the command to VPP/HW
235    */
236   rc_t issue(connection& con);
237   /**
238    * convert to string format for debug purposes
239    */
240   std::string to_string() const;
241
242   /**
243    * Comparison operator - only used for UT
244    */
245   bool operator==(const dump_output_44_cmd& i) const;
246
247 private:
248   /**
249    * HW reutrn code
250    */
251   HW::item<bool> item;
252 };
253
254 /////
255 /**
256 * A functor class that binds a NAT configuration to an input interface
257 */
258 class bind_66_input_cmd
259   : public rpc_cmd<HW::item<bool>, vapi::Nat66_add_del_interface>
260 {
261 public:
262   /**
263    * Constructor
264    */
265   bind_66_input_cmd(HW::item<bool>& item,
266                     const handle_t& itf,
267                     const nat_binding::zone_t& zone);
268
269   /**
270    * Issue the command to VPP/HW
271    */
272   rc_t issue(connection& con);
273   /**
274    * convert to string format for debug purposes
275    */
276   std::string to_string() const;
277
278   /**
279    * Comparison operator - only used for UT
280    */
281   bool operator==(const bind_66_input_cmd& i) const;
282
283 private:
284   /**
285    * The interface to bind
286    */
287   const handle_t m_itf;
288
289   /**
290    * The zone the interface is in
291    */
292   const nat_binding::zone_t m_zone;
293 };
294
295 /**
296  * A cmd class that unbinds a NAT configuration from an input interface
297  */
298 class unbind_66_input_cmd
299   : public rpc_cmd<HW::item<bool>, vapi::Nat66_add_del_interface>
300 {
301 public:
302   /**
303    * Constructor
304    */
305   unbind_66_input_cmd(HW::item<bool>& item,
306                       const handle_t& itf,
307                       const nat_binding::zone_t& zone);
308
309   /**
310    * Issue the command to VPP/HW
311    */
312   rc_t issue(connection& con);
313   /**
314    * convert to string format for debug purposes
315    */
316   std::string to_string() const;
317
318   /**
319    * Comparison operator - only used for UT
320    */
321   bool operator==(const unbind_66_input_cmd& i) const;
322
323 private:
324   /**
325    * The interface to bind
326    */
327   const handle_t m_itf;
328
329   /**
330    * The zone the interface is in
331    */
332   const nat_binding::zone_t m_zone;
333 };
334
335 /**
336  * A cmd class that Dumps all the nat_statics
337  */
338 class dump_input_66_cmd : public dump_cmd<vapi::Nat66_interface_dump>
339 {
340 public:
341   /**
342    * Constructor
343    */
344   dump_input_66_cmd();
345   dump_input_66_cmd(const dump_input_66_cmd& d);
346
347   /**
348    * Issue the command to VPP/HW
349    */
350   rc_t issue(connection& con);
351   /**
352    * convert to string format for debug purposes
353    */
354   std::string to_string() const;
355
356   /**
357    * Comparison operator - only used for UT
358    */
359   bool operator==(const dump_input_66_cmd& i) const;
360
361 private:
362   /**
363    * HW reutrn code
364    */
365   HW::item<bool> item;
366 };
367
368 }; // namespace nat_binding_cmds
369 }; // namespace VOM
370
371 /*
372  * fd.io coding-style-patch-verification: ON
373  *
374  * Local Variables:
375  * eval: (c-set-style "mozilla")
376  * End:
377  */
378
379 #endif