nat: det44 plugin fix style and api cleanup
[vpp.git] / src / plugins / nat / det44 / det44.api
1 /*
2  * Copyright (c) 2020 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 option version = "1.0.0";
17 import "vnet/ip/ip_types.api";
18 import "vnet/interface_types.api";
19 import "plugins/nat/nat_types.api";
20
21 /**
22  * @file det44.api
23  * @brief VPP control-plane API messages.
24  *
25  * This file defines VPP control-plane API messages which are generally
26  * called through a shared memory interface.
27  */
28
29 /** \brief Enable/disable DET44 plugin
30     @param client_index - opaque cookie to identify the sender
31     @param context - sender context, to match reply w/ request
32     @param inside_vrf - inside VRF id
33     @param outside_vrf - outside VRF id
34     @param enable - true if enable, false if disable
35 */
36 autoreply define det44_plugin_enable_disable {
37   u32 client_index;
38   u32 context;
39   u32 inside_vrf;
40   u32 outside_vrf;
41   bool enable;
42   option status="in_progress";
43 };
44
45 /** \brief Enable/disable DET44 feature on the interface
46     @param client_index - opaque cookie to identify the sender
47     @param context - sender context, to match reply w/ request
48     @param is_add - true if add, false if delete
49     @param is_inside - true if interface is inside, false if outside
50     @param sw_if_index - software index of the interface
51 */
52 autoreply define det44_interface_add_del_feature {
53   u32 client_index;
54   u32 context;
55   bool is_add;
56   bool is_inside;
57   vl_api_interface_index_t sw_if_index;
58   option status="in_progress";
59 };
60
61 /** \brief Dump interfaces with DET44 feature
62     @param client_index - opaque cookie to identify the sender
63     @param context - sender context, to match reply w/ request
64 */
65 define det44_interface_dump {
66   u32 client_index;
67   u32 context;
68   option status="in_progress";
69 };
70
71 /** \brief DET44 interface details response
72     @param context - sender context, to match reply w/ request
73     @param is_inside - true if interface is inside, false if outside
74     @param sw_if_index - software index of the interface
75 */
76 define det44_interface_details {
77   u32 context;
78   bool is_inside;
79   bool is_outside;
80   vl_api_interface_index_t sw_if_index;
81   option status="in_progress";
82 };
83
84 /** \brief Add/delete DET44 mapping
85     @param client_index - opaque cookie to identify the sender
86     @param context - sender context, to match reply w/ request
87     @param is_add - true if add, false if delete
88     @param in_addr - inside IPv4 address
89     @param in_plen - inside IPv4 address prefix length
90     @param out_addr - outside IPv4 address
91     @param out_plen - outside IPv4 address prefix length
92 */
93 autoreply define det44_add_del_map {
94   u32 client_index;
95   u32 context;
96   bool is_add;
97   vl_api_ip4_address_t in_addr;
98   u8 in_plen;
99   vl_api_ip4_address_t out_addr;
100   u8 out_plen;
101 };
102
103 /** \brief Get outside address and port range from inside address
104     @param client_index - opaque cookie to identify the sender
105     @param context - sender context, to match reply w/ request
106     @param in_addr - inside IP address
107 */
108 define det44_forward {
109   u32 client_index;
110   u32 context;
111   vl_api_ip4_address_t in_addr;
112 };
113
114 /** \brief Get outside address and port range from inside address
115     @param context - sender context, to match reply w/ request
116     @param retval - return code
117     @param out_port_lo - outside port range start
118     @param out_port_hi - outside port range end
119     @param out_addr - outside IPv4 address
120 */
121 define det44_forward_reply {
122   u32 context;
123   i32 retval;
124   u16 out_port_lo;
125   u16 out_port_hi;
126   vl_api_ip4_address_t out_addr;
127 };
128
129 /** \brief Get inside address from outside address and port
130     @param client_index - opaque cookie to identify the sender
131     @param context - sender context, to match reply w/ request
132     @param out_port - outside port
133     @param out_addr - outside IPv4 address
134 */
135 define det44_reverse {
136   u32 client_index;
137   u32 context;
138   u16 out_port;
139   vl_api_ip4_address_t out_addr;
140 };
141
142 /** \brief Get inside address from outside address and port reply
143     @param context - sender context, to match reply w/ request
144     @param retval - return code
145     @param in_addr - inside IP address
146 */
147 define det44_reverse_reply {
148   u32 context;
149   i32 retval;
150   vl_api_ip4_address_t in_addr;
151 };
152
153 /** \brief Dump DET44 mappings
154     @param client_index - opaque cookie to identify the sender
155     @param context - sender context, to match reply w/ request
156 */
157 define det44_map_dump {
158   u32 client_index;
159   u32 context;
160 };
161
162 /** \brief DET44 users response
163     @param context - sender context, to match reply w/ request
164     @param in_addr - inside IPv4 address
165     @param in_plen - inside IPv4 address prefix length
166     @param out_addr - outside IPv4 address
167     @param out_plen - outside IPv4 address prefix length
168     @param sharing_ratio - outside to inside address sharing ratio
169     @param ports_per_host - number of ports available to a host
170     @param ses_num - number of sessions belonging to this mapping
171 */
172 define det44_map_details {
173   u32 context;
174   vl_api_ip4_address_t in_addr;
175   u8 in_plen;
176   vl_api_ip4_address_t out_addr;
177   u8 out_plen;
178   u32 sharing_ratio;
179   u16 ports_per_host;
180   u32 ses_num;
181 };
182
183 /** \brief Close DET44 session by outside address and port
184     @param client_index - opaque cookie to identify the sender
185     @param context - sender context, to match reply w/ request
186     @param out_addr - outside IPv4 address
187     @param out_port - outside port
188     @param ext_addr - external host IPv4 address
189     @param ext_port - external host port
190 */
191 autoreply define det44_close_session_out {
192   u32 client_index;
193   u32 context;
194   vl_api_ip4_address_t out_addr;
195   u16 out_port;
196   vl_api_ip4_address_t ext_addr;
197   u16 ext_port;
198 };
199
200 /** \brief Close DET44 session by inside address and port
201     @param client_index - opaque cookie to identify the sender
202     @param context - sender context, to match reply w/ request
203     @param in_addr - inside IP address
204     @param in_port - inside port
205     @param ext_addr - external host IP address
206     @param ext_port - external host port
207 */
208 autoreply define det44_close_session_in {
209   u32 client_index;
210   u32 context;
211   vl_api_ip4_address_t in_addr;
212   u16 in_port;
213   vl_api_ip4_address_t ext_addr;
214   u16 ext_port;
215 };
216
217 /** \brief Dump DET44 sessions
218     @param client_index - opaque cookie to identify the sender
219     @param context - sender context, to match reply w/ request
220     @param user_addr - address of an inside user whose sessions to dump
221 */
222 define det44_session_dump {
223   u32 client_index;
224   u32 context;
225   vl_api_ip4_address_t user_addr;
226 };
227
228 /** \brief DET44 sessions reply
229     @param context - sender context, to match reply w/ request
230     @param in_port - inside port
231     @param ext_addr - external host IPv4 address
232     @param ext_port - external host port
233     @param out_port - outside port
234     @param state - session state
235     @param expire - session expiration timestamp
236 */
237 define det44_session_details {
238   u32 context;
239   u16 in_port;
240   vl_api_ip4_address_t ext_addr;
241   u16 ext_port;
242   u16 out_port;
243   u8 state;
244   u32 expire;
245 };
246
247 /** \brief Set values of timeouts for DET44 sessions (seconds)
248     @param client_index - opaque cookie to identify the sender
249     @param context - sender context, to match reply w/ request
250     @param udp - UDP timeout (default 300sec)
251     @param tcp_established - TCP established timeout (default 7440sec)
252     @param tcp_transitory - TCP transitory timeout (default 240sec)
253     @param icmp - ICMP timeout (default 60sec)
254 */
255 autoreply define det44_set_timeouts {
256   u32 client_index;
257   u32 context;
258   u32 udp;
259   u32 tcp_established;
260   u32 tcp_transitory;
261   u32 icmp;
262   option status="in_progress";
263 };
264
265 /** \brief Get values of timeouts for DET44 sessions (seconds)
266     @param client_index - opaque cookie to identify the sender
267     @param context - sender context, to match reply w/ request
268 */
269 define det44_get_timeouts {
270   u32 client_index;
271   u32 context;
272 };
273
274 /** \brief Get values of timeouts for DET44 sessions reply
275     @param context - sender context, to match reply w/ request
276     @param retval - return code
277     @param udp - UDP timeout
278     @param tcp_established - TCP established timeout
279     @param tcp_transitory - TCP transitory timeout
280     @param icmp - ICMP timeout
281 */
282 define det44_get_timeouts_reply {
283   u32 context;
284   i32 retval;
285   u32 udp;
286   u32 tcp_established;
287   u32 tcp_transitory;
288   u32 icmp;
289   option status="in_progress";
290 };
291
292 /*
293  * Obsolete deterministic API to be removed
294  */
295
296 /** \brief Add/delete NAT deterministic mapping
297     @param client_index - opaque cookie to identify the sender
298     @param context - sender context, to match reply w/ request
299     @param is_add - true if add, false if delete
300     @param in_addr - inside IPv4 address
301     @param in_plen - inside IPv4 address prefix length
302     @param out_addr - outside IPv4 address
303     @param out_plen - outside IPv4 address prefix length
304 */
305 autoreply define nat_det_add_del_map {
306   u32 client_index;
307   u32 context;
308   bool is_add;
309   vl_api_ip4_address_t in_addr;
310   u8 in_plen;
311   vl_api_ip4_address_t out_addr;
312   u8 out_plen;
313   option deprecated;
314 };
315
316 /** \brief Get outside address and port range from inside address
317     @param client_index - opaque cookie to identify the sender
318     @param context - sender context, to match reply w/ request
319     @param in_addr - inside IP address
320 */
321 define nat_det_forward {
322   u32 client_index;
323   u32 context;
324   vl_api_ip4_address_t in_addr;
325   option deprecated;
326 };
327
328 /** \brief Get outside address and port range from inside address
329     @param context - sender context, to match reply w/ request
330     @param retval - return code
331     @param out_port_lo - outside port range start
332     @param out_port_hi - outside port range end
333     @param out_addr - outside IPv4 address
334 */
335 define nat_det_forward_reply {
336   u32 context;
337   i32 retval;
338   u16 out_port_lo;
339   u16 out_port_hi;
340   vl_api_ip4_address_t out_addr;
341   option deprecated;
342 };
343
344 /** \brief Get inside address from outside address and port
345     @param client_index - opaque cookie to identify the sender
346     @param context - sender context, to match reply w/ request
347     @param out_port - outside port
348     @param out_addr - outside IPv4 address
349 */
350 define nat_det_reverse {
351   u32 client_index;
352   u32 context;
353   u16 out_port;
354   vl_api_ip4_address_t out_addr;
355   option deprecated;
356 };
357
358 /** \brief Get inside address from outside address and port reply
359     @param context - sender context, to match reply w/ request
360     @param retval - return code
361     @param in_addr - inside IP address
362 */
363 define nat_det_reverse_reply {
364   u32 context;
365   i32 retval;
366   vl_api_ip4_address_t in_addr;
367   option deprecated;
368 };
369
370 /** \brief Dump NAT deterministic mappings
371     @param client_index - opaque cookie to identify the sender
372     @param context - sender context, to match reply w/ request
373 */
374 define nat_det_map_dump {
375   u32 client_index;
376   u32 context;
377   option deprecated;
378 };
379
380 /** \brief NAT users response
381     @param context - sender context, to match reply w/ request
382     @param in_addr - inside IPv4 address
383     @param in_plen - inside IPv4 address prefix length
384     @param out_addr - outside IPv4 address
385     @param out_plen - outside IPv4 address prefix length
386     @param sharing_ratio - outside to inside address sharing ratio
387     @param ports_per_host - number of ports available to a host
388     @param ses_num - number of sessions belonging to this mapping
389 */
390 define nat_det_map_details {
391   u32 context;
392   vl_api_ip4_address_t in_addr;
393   u8 in_plen;
394   vl_api_ip4_address_t out_addr;
395   u8 out_plen;
396   u32 sharing_ratio;
397   u16 ports_per_host;
398   u32 ses_num;
399   option deprecated;
400 };
401
402 /** \brief Close deterministic NAT session by outside address and port
403     @param client_index - opaque cookie to identify the sender
404     @param context - sender context, to match reply w/ request
405     @param out_addr - outside IPv4 address
406     @param out_port - outside port
407     @param ext_addr - external host IPv4 address
408     @param ext_port - external host port
409 */
410 autoreply define nat_det_close_session_out {
411   u32 client_index;
412   u32 context;
413   vl_api_ip4_address_t out_addr;
414   u16 out_port;
415   vl_api_ip4_address_t ext_addr;
416   u16 ext_port;
417   option deprecated;
418 };
419
420 /** \brief Close deterministic NAT session by inside address and port
421     @param client_index - opaque cookie to identify the sender
422     @param context - sender context, to match reply w/ request
423     @param in_addr - inside IP address
424     @param in_port - inside port
425     @param ext_addr - external host IP address
426     @param ext_port - external host port
427 */
428 autoreply define nat_det_close_session_in {
429   u32 client_index;
430   u32 context;
431   vl_api_ip4_address_t in_addr;
432   u16 in_port;
433   vl_api_ip4_address_t ext_addr;
434   u16 ext_port;
435   option deprecated;
436 };
437
438 /** \brief Dump determinstic NAT sessions
439     @param client_index - opaque cookie to identify the sender
440     @param context - sender context, to match reply w/ request
441     @param user_addr - address of an inside user whose sessions to dump
442 */
443 define nat_det_session_dump {
444   u32 client_index;
445   u32 context;
446   vl_api_ip4_address_t user_addr;
447   option deprecated;
448 };
449
450 /** \brief Deterministic NAT sessions reply
451     @param context - sender context, to match reply w/ request
452     @param in_port - inside port
453     @param ext_addr - external host IPv4 address
454     @param ext_port - external host port
455     @param out_port - outside NAT port
456     @param state - session state
457     @param expire - session expiration timestamp
458 */
459 define nat_det_session_details {
460   u32 context;
461   u16 in_port;
462   vl_api_ip4_address_t ext_addr;
463   u16 ext_port;
464   u16 out_port;
465   u8 state;
466   u32 expire;
467   option deprecated;
468 };