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