NAT: Rename snat plugin to nat (VPP-955)
[vpp.git] / src / plugins / nat / nat.api
1 /*
2  * Copyright (c) 2016 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  * @file nat.api
17  * @brief VPP control-plane API messages.
18  *
19  * This file defines VPP control-plane API messages which are generally
20  * called through a shared memory interface.
21  */
22
23 /*
24  * Old "snat" APIs, will be deprecated after 17.10
25  */
26
27 /** \brief Add/del NAT44 address range
28     @param client_index - opaque cookie to identify the sender
29     @param context - sender context, to match reply w/ request
30     @param is_ip4 - 1 if address type is IPv4
31     @param first_ip_address - first IP address
32     @param last_ip_address - last IP address
33     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
34     @param is_add - 1 if add, 0 if delete
35 */
36 autoreply define snat_add_address_range {
37   u32 client_index;
38   u32 context;
39   u8 is_ip4;
40   u8 first_ip_address[16];
41   u8 last_ip_address[16];
42   u32 vrf_id;
43   u8 is_add;
44 };
45
46 /** \brief Dump NAT44 addresses
47     @param client_index - opaque cookie to identify the sender
48     @param context - sender context, to match reply w/ request
49 */
50 define snat_address_dump {
51   u32 client_index;
52   u32 context;
53 };
54
55 /** \brief NAT44 address details response
56     @param context - sender context, to match reply w/ request
57     @param is_ip4 - 1 if address type is IPv4
58     @param ip_address - IP address
59     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
60 */
61 define snat_address_details {
62   u32 context;
63   u8 is_ip4;
64   u8 ip_address[16];
65   u32 vrf_id;
66 };
67
68 /** \brief Enable/disable NAT44 feature on the interface
69     @param client_index - opaque cookie to identify the sender
70     @param context - sender context, to match reply w/ request
71     @param is_add - 1 if add, 0 if delete
72     @param is_inside - 1 if inside, 0 if outside
73     @param sw_if_index - software index of the interface
74 */
75 autoreply define snat_interface_add_del_feature {
76   u32 client_index;
77   u32 context;
78   u8 is_add;
79   u8 is_inside;
80   u32 sw_if_index;
81 };
82
83 /** \brief Dump interfaces with NAT44 feature
84     @param client_index - opaque cookie to identify the sender
85     @param context - sender context, to match reply w/ request
86 */
87 define snat_interface_dump {
88   u32 client_index;
89   u32 context;
90 };
91
92 /** \brief NAT44 interface details response
93     @param context - sender context, to match reply w/ request
94     @param is_inside - 1 if inside, 0 if outside
95     @param sw_if_index - software index of the interface
96 */
97 define snat_interface_details {
98   u32 context;
99   u8 is_inside;
100   u32 sw_if_index;
101 };
102
103 /** \brief Enable/disbale NAT44 as an interface output feature (postrouting
104            in2out translation)
105     @param client_index - opaque cookie to identify the sender
106     @param context - sender context, to match reply w/ request
107     @param is_add - 1 if add, 0 if delete
108     @param is_inside - 1 if inside, 0 if outside
109     @param sw_if_index - software index of the interface
110 */
111 autoreply define snat_interface_add_del_output_feature {
112   u32 client_index;
113   u32 context;
114   u8 is_add;
115   u8 is_inside;
116   u32 sw_if_index;
117 };
118
119 /** \brief Dump interfaces with NAT44 output feature
120     @param client_index - opaque cookie to identify the sender
121     @param context - sender context, to match reply w/ request
122 */
123 define snat_interface_output_feature_dump {
124   u32 client_index;
125   u32 context;
126 };
127
128 /** \brief NAT44 interface with output feature details response
129     @param context - sender context, to match reply w/ request
130     @param is_inside - 1 if inside, 0 if outside
131     @param sw_if_index - software index of the interface
132 */
133 define snat_interface_output_feature_details {
134   u32 context;
135   u8 is_inside;
136   u32 sw_if_index;
137 };
138
139 /** \brief Add/delete NAT44 static mapping
140     @param client_index - opaque cookie to identify the sender
141     @param context - sender context, to match reply w/ request
142     @param is_add - 1 if add, 0 if delete
143     @param is_ip4 - 1 if address type is IPv4
144     @param addr_only - 1 if address only mapping
145     @param local_ip_address - local IP address
146     @param external_ip_address - external IP address
147     @param protocol - IP protocol
148     @param local_port - local port number
149     @param external_port - external port number
150     @param external_sw_if_index - external interface (if set
151                                   external_ip_address is ignored, ~0 means not
152                                   used)
153     @param vfr_id - VRF ID
154 */
155 autoreply define snat_add_static_mapping {
156   u32 client_index;
157   u32 context;
158   u8 is_add;
159   u8 is_ip4;
160   u8 addr_only;
161   u8 local_ip_address[16];
162   u8 external_ip_address[16];
163   u8 protocol;
164   u16 local_port;
165   u16 external_port;
166   u32 external_sw_if_index;
167   u32 vrf_id;
168 };
169
170 /** \brief Dump NAT44 static mappings
171     @param client_index - opaque cookie to identify the sender
172     @param context - sender context, to match reply w/ request
173 */
174 define snat_static_mapping_dump {
175   u32 client_index;
176   u32 context;
177 };
178
179 /** \brief NAT44 static mapping details response
180     @param context - sender context, to match reply w/ request
181     @param is_ip4 - 1 if address type is IPv4
182     @param addr_only - 1 if address only mapping
183     @param local_ip_address - local IP address
184     @param external_ip_address - external IP address
185     @param protocol - IP protocol
186     @param local_port - local port number
187     @param external_port - external port number
188     @param external_sw_if_index - external interface
189     @param vfr_id - VRF ID
190 */
191 define snat_static_mapping_details {
192   u32 context;
193   u8 is_ip4;
194   u8 addr_only;
195   u8 local_ip_address[16];
196   u8 external_ip_address[16];
197   u8 protocol;
198   u16 local_port;
199   u16 external_port;
200   u32 external_sw_if_index;
201   u32 vrf_id;
202 };
203
204 /** \brief Control ping from client to api server request
205     @param client_index - opaque cookie to identify the sender
206     @param context - sender context, to match reply w/ request
207 */
208 define snat_control_ping
209 {
210   u32 client_index;
211   u32 context;
212 };
213
214 /** \brief Control ping from the client to the server response
215     @param client_index - opaque cookie to identify the sender
216     @param context - sender context, to match reply w/ request
217     @param retval - return code for the request
218     @param vpe_pid - the pid of the vpe, returned by the server
219 */
220 define snat_control_ping_reply
221 {
222   u32 context;
223   i32 retval;
224   u32 client_index;
225   u32 vpe_pid;
226 };
227
228 /** \brief Show NAT plugin startup config
229     @param client_index - opaque cookie to identify the sender
230     @param context - sender context, to match reply w/ request
231 */
232 define snat_show_config
233 {
234   u32 client_index;
235   u32 context;
236 };
237
238 /** \brief Show NAT plugin startup config reply
239     @param context - sender context, to match reply w/ request
240     @param retval - return code for the request
241     @param static_mapping_only - if 1 dynamic translations disabled
242     @param static_mapping_connection_tracking - if 1 create session data
243     @param deterministic - if 1 deterministic mapping
244     @param translation_buckets - number of translation hash buckets
245     @param translation_memory_size - translation hash memory size
246     @param user_buckets - number of user hash buckets
247     @param user_memory_size - user hash memory size
248     @param max_translations_per_user - maximum number of translations per user
249     @param outside_vrf_id - outside VRF id
250     @param inside_vrf_id - default inside VRF id
251 */
252 define snat_show_config_reply
253 {
254   u32 context;
255   i32 retval;
256   u8 static_mapping_only;
257   u8 static_mapping_connection_tracking;
258   u8 deterministic;
259   u32 translation_buckets;
260   u32 translation_memory_size;
261   u32 user_buckets;
262   u32 user_memory_size;
263   u32 max_translations_per_user;
264   u32 outside_vrf_id;
265   u32 inside_vrf_id;
266 };
267
268 /** \brief Set NAT workers
269     @param client_index - opaque cookie to identify the sender
270     @param context - sender context, to match reply w/ request
271     @param worker_mask - NAT workers mask
272 */
273 autoreply define snat_set_workers {
274   u32 client_index;
275   u32 context;
276   u64 worker_mask;
277 };
278
279 /** \brief Dump NAT workers
280     @param client_index - opaque cookie to identify the sender
281     @param context - sender context, to match reply w/ request
282 */
283 define snat_worker_dump {
284   u32 client_index;
285   u32 context;
286 };
287
288 /** \brief NAT workers details response
289     @param context - sender context, to match reply w/ request
290     @param worker_index - worker index
291     @param lcore_id - lcore ID
292     @param name - worker name
293 */
294 define snat_worker_details {
295   u32 context;
296   u32 worker_index;
297   u32 lcore_id;
298   u8 name[64];
299 };
300
301 /** \brief Add/delete NAT44 pool address from specific interfce
302     @param client_index - opaque cookie to identify the sender
303     @param context - sender context, to match reply w/ request
304     @param is_add - 1 if add, 0 if delete
305     @param sw_if_index - software index of the interface
306 */
307 autoreply define snat_add_del_interface_addr {
308   u32 client_index;
309   u32 context;
310   u8 is_add;
311   u8 is_inside;
312   u32 sw_if_index;
313 };
314
315 /** \brief Dump NAT44 pool addresses interfaces
316     @param client_index - opaque cookie to identify the sender
317     @param context - sender context, to match reply w/ request
318 */
319 define snat_interface_addr_dump {
320   u32 client_index;
321   u32 context;
322 };
323
324 /** \brief NAT44 pool addresses interfaces details response
325     @param context - sender context, to match reply w/ request
326     @param sw_if_index - software index of the interface
327 */
328 define snat_interface_addr_details {
329   u32 context;
330   u32 sw_if_index;
331 };
332
333 /** \brief Enable/disable NAT IPFIX logging
334     @param client_index - opaque cookie to identify the sender
335     @param context - sender context, to match reply w/ request
336     @param domain_id - observation domain ID
337     @param src_port - source port number
338     @param enable - 1 if enable, 0 if disable
339 */
340 autoreply define snat_ipfix_enable_disable {
341   u32 client_index;
342   u32 context;
343   u32 domain_id;
344   u16 src_port;
345   u8 enable;
346 };
347
348 /** \brief Dump NAT44 users
349     @param client_index - opaque cookie to identify the sender
350     @param context - sender context, to match reply w/ request
351 */
352 define snat_user_dump {
353   u32 client_index;
354   u32 context;
355 };
356
357 /** \brief NAT44 users response
358     @param context - sender context, to match reply w/ request
359     @vrf_id - VRF ID
360     @param is_ip4 - 1 if address type is IPv4
361     @param ip_adress - IP address
362     @param nsessions - number of dynamic sessions
363     @param nstaticsessions - number of static sessions
364 */
365 define snat_user_details {
366   u32 context;
367   u32 vrf_id;
368   u8 is_ip4;
369   u8 ip_address[16];
370   u32 nsessions;
371   u32 nstaticsessions;
372 };
373
374 /** \brief NAT44 user's sessions
375     @param client_index - opaque cookie to identify the sender
376     @param context - sender context, to match reply w/ request
377     @param is_ip4 - 1 if address type is IPv4
378     @param user_ip - IP address of the user to dump
379     @param vrf_id - VRF_ID
380 */
381 define snat_user_session_dump {
382   u32 client_index;
383   u32 context;
384   u8 is_ip4;
385   u8 ip_address[16];
386   u32 vrf_id;
387 };
388
389 /** \brief NAT44 user's sessions response
390     @param context - sender context, to match reply w/ request
391     @param is_ip4 - 1 if address type is IPv4
392     @param outside_ip_address - outside IP address
393     @param outside_port - outside port
394     @param inside_ip_address - inside IP address
395     @param inside_port - inside port
396     @param protocol - protocol
397     @param is_static - 1 if session is static
398     @param last_heard - last heard timer
399     @param total_bytes - count of bytes sent through session
400     @param total_pkts - count of pakets sent through session
401 */
402 define snat_user_session_details {
403   u32 context;
404   u8 is_ip4;
405   u8 outside_ip_address[16];
406   u16 outside_port;
407   u8 inside_ip_address[16];
408   u16 inside_port;
409   u16 protocol;
410   u8 is_static;
411   u64 last_heard;
412   u64 total_bytes;
413   u32 total_pkts;
414 };
415
416 /** \brief Add/delete NAT deterministic mapping
417     @param client_index - opaque cookie to identify the sender
418     @param context - sender context, to match reply w/ request
419     @param is_add - 1 if add, 0 if delete
420     @param is_ip4 - 1 if address type is IPv4
421     @param in_addr - inside IP address
422     @param in_plen - inside IP address prefix length
423     @param out_addr - outside IP address
424     @param out_addr - outside IP address prefix length
425 */
426 autoreply define snat_add_det_map {
427   u32 client_index;
428   u32 context;
429   u8 is_add;
430   u8 is_ip4;
431   u8 addr_only;
432   u8 in_addr[16];
433   u8 in_plen;
434   u8 out_addr[16];
435   u8 out_plen;
436 };
437
438 /** \brief Get outside address and port range from inside address
439     @param client_index - opaque cookie to identify the sender
440     @param context - sender context, to match reply w/ request
441     @param is_ip4 - 1 if address type is IPv4
442     @param in_addr - inside IP address
443 */
444 define snat_det_forward {
445   u32 client_index;
446   u32 context;
447   u8 is_ip4;
448   u8 in_addr[16];
449 };
450
451 /** \brief Get outside address and port range from inside address
452     @param context - sender context, to match reply w/ request
453     @param retval - return code
454     @param out_port_lo - outside port range start
455     @param out_port_hi - outside port range end
456     @param is_ip4 - 1 if address type is IPv4
457     @param out_addr - outside IP address
458 */
459 define snat_det_forward_reply {
460   u32 context;
461   i32 retval;
462   u16 out_port_lo;
463   u16 out_port_hi;
464   u8 is_ip4;
465   u8 out_addr[16];
466 };
467
468 /** \brief Get inside address from outside address and port
469     @param client_index - opaque cookie to identify the sender
470     @param context - sender context, to match reply w/ request
471     @param out_port - outside port
472     @param is_ip4 - 1 if address type is IPv4
473     @param out_addr - outside IP address
474 */
475 define snat_det_reverse {
476   u32 client_index;
477   u32 context;
478   u16 out_port;
479   u8 is_ip4;
480   u8 out_addr[16];
481 };
482
483 /** \brief Get inside address from outside address and port reply
484     @param context - sender context, to match reply w/ request
485     @param retval - return code
486     @param is_ip4 - 1 if address type is IPv4
487     @param in_addr - inside IP address
488 */
489 define snat_det_reverse_reply {
490   u32 context;
491   i32 retval;
492   u8 is_ip4;
493   u8 in_addr[16];
494 };
495
496 /** \brief Dump NAT deterministic mappings
497     @param client_index - opaque cookie to identify the sender
498     @param context - sender context, to match reply w/ request
499 */
500 define snat_det_map_dump {
501   u32 client_index;
502   u32 context;
503 };
504
505 /** \brief NAT users response
506     @param context - sender context, to match reply w/ request
507     @param is_ip4 - 1 if address type is IPv4
508     @param in_addr - inside IP address
509     @param in_plen - inside IP address prefix length
510     @param out_addr - outside IP address
511     @param out_plen - outside IP address prefix length
512     @param sharing_ratio - outside to inside address sharing ratio
513     @param ports_per_host - number of ports available to a host
514     @param ses_num - number of sessions belonging to this mapping
515 */
516 define snat_det_map_details {
517   u32 context;
518   u8 is_ip4;
519   u8 in_addr[16];
520   u8 in_plen;
521   u8 out_addr[16];
522   u8 out_plen;
523   u32 sharing_ratio;
524   u16 ports_per_host;
525   u32 ses_num;
526 };
527
528 /** \brief Set values of timeouts for deterministic NAT (seconds, 0 = default)
529     @param client_index - opaque cookie to identify the sender
530     @param context - sender context, to match reply w/ request
531     @param udp - UDP timeout (default 300sec)
532     @param tcp_established - TCP established timeout (default 7440sec)
533     @param tcp_transitory - TCP transitory timeout (default 240sec)
534     @param icmp - ICMP timeout (default 60sec)
535 */
536 autoreply define snat_det_set_timeouts {
537   u32 client_index;
538   u32 context;
539   u32 udp;
540   u32 tcp_established;
541   u32 tcp_transitory;
542   u32 icmp;
543 };
544
545 /** \brief Get values of timeouts for deterministic NAT (seconds)
546     @param client_index - opaque cookie to identify the sender
547     @param context - sender context, to match reply w/ request
548 */
549 define snat_det_get_timeouts {
550   u32 client_index;
551   u32 context;
552 };
553
554 /** \brief Get values of timeouts for deterministic NAT reply
555     @param context - sender context, to match reply w/ request
556     @param retval - return code
557     @param udp - UDP timeout (default 300sec)
558     @param tcp_established - TCP established timeout (default 7440sec)
559     @param tcp_transitory - TCP transitory timeout (default 240sec)
560     @param icmp - ICMP timeout (default 60sec)
561 */
562 define snat_det_get_timeouts_reply {
563   u32 context;
564   i32 retval;
565   u32 udp;
566   u32 tcp_established;
567   u32 tcp_transitory;
568   u32 icmp;
569 };
570
571 /** \brief Close deterministic NAT session by outside address and port
572     @param client_index - opaque cookie to identify the sender
573     @param context - sender context, to match reply w/ request
574     @param is_ip4 - 1 if address type is IPv4
575     @param out_addr - outside IP address
576     @param out_port - outside port
577     @param ext_addr - external host address
578     @param ext_port - external host port
579 */
580 autoreply define snat_det_close_session_out {
581   u32 client_index;
582   u32 context;
583   u8 is_ip4;
584   u8 out_addr[16];
585   u16 out_port;
586   u8 ext_addr[16];
587   u16 ext_port;
588 };
589
590 /** \brief Close deterministic NAT session by inside address and port
591     @param client_index - opaque cookie to identify the sender
592     @param context - sender context, to match reply w/ request
593     @param is_ip4 - 1 if address type is IPv4
594     @param in_addr - inside IP address
595     @param in_port - inside port
596     @param ext_addr - external host address
597     @param ext_port - external host port
598 */
599 autoreply define snat_det_close_session_in {
600   u32 client_index;
601   u32 context;
602   u8 is_ip4;
603   u8 in_addr[16];
604   u16 in_port;
605   u8 ext_addr[16];
606   u16 ext_port;
607 };
608
609 /** \brief Dump determinstic NAT sessions
610     @param client_index - opaque cookie to identify the sender
611     @param context - sender context, to match reply w/ request
612     @param is_ip4 - 1 if address type is IPv4
613     @param user_addr - address of an inside user whose sessions to dump
614 */
615 define snat_det_session_dump {
616   u32 client_index;
617   u32 context;
618   u8 is_ip4;
619   u8 user_addr[16];
620 };
621
622 /** \brief Deterministic NAT sessions reply
623     @param context - sender context, to match reply w/ request
624     @param is_ip4 - 1 if address type is IPv4
625     @param in_port - inside port
626     @param ext_addr - external host address
627     @param ext_port - external host port
628     @param out_port - outside NAT port
629     @param state - session state
630     @param expire - session expiration timestamp
631 */
632 define snat_det_session_details {
633   u32 client_index;
634   u32 context;
635   u8 is_ip4;
636   u16 in_port;
637   u8 ext_addr[16];
638   u16 ext_port;
639   u16 out_port;
640   u8 state;
641   u32 expire;
642 };
643
644 /*
645  * Common NAT plugin APIs
646  */
647
648 /** \brief Control ping from client to api server request
649     @param client_index - opaque cookie to identify the sender
650     @param context - sender context, to match reply w/ request
651 */
652 define nat_control_ping
653 {
654   u32 client_index;
655   u32 context;
656 };
657
658 /** \brief Control ping from the client to the server response
659     @param client_index - opaque cookie to identify the sender
660     @param context - sender context, to match reply w/ request
661     @param retval - return code for the request
662     @param vpe_pid - the pid of the vpe, returned by the server
663 */
664 define nat_control_ping_reply
665 {
666   u32 context;
667   i32 retval;
668   u32 client_index;
669   u32 vpe_pid;
670 };
671
672 /** \brief Show NAT plugin startup config
673     @param client_index - opaque cookie to identify the sender
674     @param context - sender context, to match reply w/ request
675 */
676 define nat_show_config
677 {
678   u32 client_index;
679   u32 context;
680 };
681
682 /** \brief Show NAT plugin startup config reply
683     @param context - sender context, to match reply w/ request
684     @param retval - return code for the request
685     @param static_mapping_only - if 1 dynamic translations disabled
686     @param static_mapping_connection_tracking - if 1 create session data
687     @param deterministic - if 1 deterministic mapping
688     @param translation_buckets - number of translation hash buckets
689     @param translation_memory_size - translation hash memory size
690     @param user_buckets - number of user hash buckets
691     @param user_memory_size - user hash memory size
692     @param max_translations_per_user - maximum number of translations per user
693     @param outside_vrf_id - outside VRF id
694     @param inside_vrf_id - default inside VRF id
695 */
696 define nat_show_config_reply
697 {
698   u32 context;
699   i32 retval;
700   u8 static_mapping_only;
701   u8 static_mapping_connection_tracking;
702   u8 deterministic;
703   u32 translation_buckets;
704   u32 translation_memory_size;
705   u32 user_buckets;
706   u32 user_memory_size;
707   u32 max_translations_per_user;
708   u32 outside_vrf_id;
709   u32 inside_vrf_id;
710 };
711
712 /** \brief Set NAT workers
713     @param client_index - opaque cookie to identify the sender
714     @param context - sender context, to match reply w/ request
715     @param worker_mask - NAT workers mask
716 */
717 autoreply define nat_set_workers {
718   u32 client_index;
719   u32 context;
720   u64 worker_mask;
721 };
722
723 /** \brief Dump NAT workers
724     @param client_index - opaque cookie to identify the sender
725     @param context - sender context, to match reply w/ request
726 */
727 define nat_worker_dump {
728   u32 client_index;
729   u32 context;
730 };
731
732 /** \brief NAT workers details response
733     @param context - sender context, to match reply w/ request
734     @param worker_index - worker index
735     @param lcore_id - lcore ID
736     @param name - worker name
737 */
738 define nat_worker_details {
739   u32 context;
740   u32 worker_index;
741   u32 lcore_id;
742   u8 name[64];
743 };
744
745 /** \brief Enable/disable NAT IPFIX logging
746     @param client_index - opaque cookie to identify the sender
747     @param context - sender context, to match reply w/ request
748     @param domain_id - observation domain ID
749     @param src_port - source port number
750     @param enable - 1 if enable, 0 if disable
751 */
752 autoreply define nat_ipfix_enable_disable {
753   u32 client_index;
754   u32 context;
755   u32 domain_id;
756   u16 src_port;
757   u8 enable;
758 };
759
760 /*
761  * NAT44 APIs
762  */
763
764 /** \brief Add/del NAT44 address range
765     @param client_index - opaque cookie to identify the sender
766     @param context - sender context, to match reply w/ request
767     @param first_ip_address - first IPv4 address
768     @param last_ip_address - last IPv4 address
769     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
770     @param is_add - 1 if add, 0 if delete
771 */
772 autoreply define nat44_add_del_address_range {
773   u32 client_index;
774   u32 context;
775   u8 first_ip_address[4];
776   u8 last_ip_address[4];
777   u32 vrf_id;
778   u8 is_add;
779 };
780
781 /** \brief Dump NAT44 addresses
782     @param client_index - opaque cookie to identify the sender
783     @param context - sender context, to match reply w/ request
784 */
785 define nat44_address_dump {
786   u32 client_index;
787   u32 context;
788 };
789
790 /** \brief NAT44 address details response
791     @param context - sender context, to match reply w/ request
792     @param ip_address - IPv4 address
793     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
794 */
795 define nat44_address_details {
796   u32 context;
797   u8 ip_address[4];
798   u32 vrf_id;
799 };
800
801 /** \brief Enable/disable NAT44 feature on the interface
802     @param client_index - opaque cookie to identify the sender
803     @param context - sender context, to match reply w/ request
804     @param is_add - 1 if add, 0 if delete
805     @param is_inside - 1 if inside, 0 if outside
806     @param sw_if_index - software index of the interface
807 */
808 autoreply define nat44_interface_add_del_feature {
809   u32 client_index;
810   u32 context;
811   u8 is_add;
812   u8 is_inside;
813   u32 sw_if_index;
814 };
815
816 /** \brief Dump interfaces with NAT44 feature
817     @param client_index - opaque cookie to identify the sender
818     @param context - sender context, to match reply w/ request
819 */
820 define nat44_interface_dump {
821   u32 client_index;
822   u32 context;
823 };
824
825 /** \brief NAT44 interface details response
826     @param context - sender context, to match reply w/ request
827     @param is_inside - 1 if inside, 0 if outside
828     @param sw_if_index - software index of the interface
829 */
830 define nat44_interface_details {
831   u32 context;
832   u8 is_inside;
833   u32 sw_if_index;
834 };
835
836 /** \brief Enable/disbale NAT44 as an interface output feature (postrouting
837            in2out translation)
838     @param client_index - opaque cookie to identify the sender
839     @param context - sender context, to match reply w/ request
840     @param is_add - 1 if add, 0 if delete
841     @param is_inside - 1 if inside, 0 if outside
842     @param sw_if_index - software index of the interface
843 */
844 autoreply define nat44_interface_add_del_output_feature {
845   u32 client_index;
846   u32 context;
847   u8 is_add;
848   u8 is_inside;
849   u32 sw_if_index;
850 };
851
852 /** \brief Dump interfaces with NAT44 output feature
853     @param client_index - opaque cookie to identify the sender
854     @param context - sender context, to match reply w/ request
855 */
856 define nat44_interface_output_feature_dump {
857   u32 client_index;
858   u32 context;
859 };
860
861 /** \brief NAT44 interface with output feature details response
862     @param context - sender context, to match reply w/ request
863     @param is_inside - 1 if inside, 0 if outside
864     @param sw_if_index - software index of the interface
865 */
866 define nat44_interface_output_feature_details {
867   u32 context;
868   u8 is_inside;
869   u32 sw_if_index;
870 };
871
872 /** \brief Add/delete NAT44 static mapping
873     @param client_index - opaque cookie to identify the sender
874     @param context - sender context, to match reply w/ request
875     @param is_add - 1 if add, 0 if delete
876     @param addr_only - 1 if address only mapping
877     @param local_ip_address - local IPv4 address
878     @param external_ip_address - external IPv4 address
879     @param protocol - IP protocol
880     @param local_port - local port number
881     @param external_port - external port number
882     @param external_sw_if_index - external interface (if set
883                                   external_ip_address is ignored, ~0 means not
884                                   used)
885     @param vfr_id - VRF ID
886 */
887 autoreply define nat44_add_del_static_mapping {
888   u32 client_index;
889   u32 context;
890   u8 is_add;
891   u8 addr_only;
892   u8 local_ip_address[4];
893   u8 external_ip_address[4];
894   u8 protocol;
895   u16 local_port;
896   u16 external_port;
897   u32 external_sw_if_index;
898   u32 vrf_id;
899 };
900
901 /** \brief Dump NAT44 static mappings
902     @param client_index - opaque cookie to identify the sender
903     @param context - sender context, to match reply w/ request
904 */
905 define nat44_static_mapping_dump {
906   u32 client_index;
907   u32 context;
908 };
909
910 /** \brief NAT44 static mapping details response
911     @param context - sender context, to match reply w/ request
912     @param addr_only - 1 if address only mapping
913     @param local_ip_address - local IPv4 address
914     @param external_ip_address - external IPv4 address
915     @param protocol - IP protocol
916     @param local_port - local port number
917     @param external_port - external port number
918     @param external_sw_if_index - external interface
919     @param vfr_id - VRF ID
920 */
921 define nat44_static_mapping_details {
922   u32 context;
923   u8 addr_only;
924   u8 local_ip_address[4];
925   u8 external_ip_address[4];
926   u8 protocol;
927   u16 local_port;
928   u16 external_port;
929   u32 external_sw_if_index;
930   u32 vrf_id;
931 };
932
933 /** \brief Add/delete NAT44 pool address from specific interfce
934     @param client_index - opaque cookie to identify the sender
935     @param context - sender context, to match reply w/ request
936     @param is_add - 1 if add, 0 if delete
937     @param sw_if_index - software index of the interface
938 */
939 autoreply define nat44_add_del_interface_addr {
940   u32 client_index;
941   u32 context;
942   u8 is_add;
943   u8 is_inside;
944   u32 sw_if_index;
945 };
946
947 /** \brief Dump NAT44 pool addresses interfaces
948     @param client_index - opaque cookie to identify the sender
949     @param context - sender context, to match reply w/ request
950 */
951 define nat44_interface_addr_dump {
952   u32 client_index;
953   u32 context;
954 };
955
956 /** \brief NAT44 pool addresses interfaces details response
957     @param context - sender context, to match reply w/ request
958     @param sw_if_index - software index of the interface
959 */
960 define nat44_interface_addr_details {
961   u32 context;
962   u32 sw_if_index;
963 };
964
965 /** \brief Dump NAT44 users
966     @param client_index - opaque cookie to identify the sender
967     @param context - sender context, to match reply w/ request
968 */
969 define nat44_user_dump {
970   u32 client_index;
971   u32 context;
972 };
973
974 /** \brief NAT44 users response
975     @param context - sender context, to match reply w/ request
976     @vrf_id - VRF ID
977     @param ip_adress - IPv4 address
978     @param nsessions - number of dynamic sessions
979     @param nstaticsessions - number of static sessions
980 */
981 define nat44_user_details {
982   u32 context;
983   u32 vrf_id;
984   u8 ip_address[4];
985   u32 nsessions;
986   u32 nstaticsessions;
987 };
988
989 /** \brief NAT44 user's sessions
990     @param client_index - opaque cookie to identify the sender
991     @param context - sender context, to match reply w/ request
992     @param is_ip4 - 1 if address type is IPv4
993     @param user_ip - IP address of the user to dump
994     @param vrf_id - VRF_ID
995 */
996 define nat44_user_session_dump {
997   u32 client_index;
998   u32 context;
999   u8 ip_address[4];
1000   u32 vrf_id;
1001 };
1002
1003 /** \brief NAT44 user's sessions response
1004     @param context - sender context, to match reply w/ request
1005     @param outside_ip_address - outside IPv4 address
1006     @param outside_port - outside port
1007     @param inside_ip_address - inside IPv4 address
1008     @param inside_port - inside port
1009     @param protocol - protocol
1010     @param is_static - 1 if session is static
1011     @param last_heard - last heard timer
1012     @param total_bytes - count of bytes sent through session
1013     @param total_pkts - count of pakets sent through session
1014 */
1015 define nat44_user_session_details {
1016   u32 context;
1017   u8 outside_ip_address[4];
1018   u16 outside_port;
1019   u8 inside_ip_address[4];
1020   u16 inside_port;
1021   u16 protocol;
1022   u8 is_static;
1023   u64 last_heard;
1024   u64 total_bytes;
1025   u32 total_pkts;
1026 };
1027
1028 /*
1029  * Deterministic NAT (CGN) APIs
1030  */
1031
1032 /** \brief Add/delete NAT deterministic mapping
1033     @param client_index - opaque cookie to identify the sender
1034     @param context - sender context, to match reply w/ request
1035     @param is_add - 1 if add, 0 if delete
1036     @param is_nat44 - 1 if NAT44
1037     @param in_addr - inside IP address
1038     @param in_plen - inside IP address prefix length
1039     @param out_addr - outside IPv4 address
1040     @param out_addr - outside IPv4 address prefix length
1041 */
1042 autoreply define nat_det_add_del_map {
1043   u32 client_index;
1044   u32 context;
1045   u8 is_add;
1046   u8 is_nat44;
1047   u8 addr_only;
1048   u8 in_addr[16];
1049   u8 in_plen;
1050   u8 out_addr[4];
1051   u8 out_plen;
1052 };
1053
1054 /** \brief Get outside address and port range from inside address
1055     @param client_index - opaque cookie to identify the sender
1056     @param context - sender context, to match reply w/ request
1057     @param is_nat44 - 1 if NAT44
1058     @param in_addr - inside IP address
1059 */
1060 define nat_det_forward {
1061   u32 client_index;
1062   u32 context;
1063   u8 is_nat44;
1064   u8 in_addr[16];
1065 };
1066
1067 /** \brief Get outside address and port range from inside address
1068     @param context - sender context, to match reply w/ request
1069     @param retval - return code
1070     @param out_port_lo - outside port range start
1071     @param out_port_hi - outside port range end
1072     @param out_addr - outside IPv4 address
1073 */
1074 define nat_det_forward_reply {
1075   u32 context;
1076   i32 retval;
1077   u16 out_port_lo;
1078   u16 out_port_hi;
1079   u8 out_addr[4];
1080 };
1081
1082 /** \brief Get inside address from outside address and port
1083     @param client_index - opaque cookie to identify the sender
1084     @param context - sender context, to match reply w/ request
1085     @param out_port - outside port
1086     @param out_addr - outside IPv4 address
1087 */
1088 define nat_det_reverse {
1089   u32 client_index;
1090   u32 context;
1091   u16 out_port;
1092   u8 out_addr[4];
1093 };
1094
1095 /** \brief Get inside address from outside address and port reply
1096     @param context - sender context, to match reply w/ request
1097     @param retval - return code
1098     @param is_nat44 - 1 if NAT44
1099     @param in_addr - inside IP address
1100 */
1101 define nat_det_reverse_reply {
1102   u32 context;
1103   i32 retval;
1104   u8 is_nat44;
1105   u8 in_addr[16];
1106 };
1107
1108 /** \brief Dump NAT deterministic mappings
1109     @param client_index - opaque cookie to identify the sender
1110     @param context - sender context, to match reply w/ request
1111 */
1112 define nat_det_map_dump {
1113   u32 client_index;
1114   u32 context;
1115 };
1116
1117 /** \brief NAT users response
1118     @param context - sender context, to match reply w/ request
1119     @param is_nat44 - 1 if NAT44
1120     @param in_addr - inside IP address
1121     @param in_plen - inside IP address prefix length
1122     @param out_addr - outside IPv4 address
1123     @param out_plen - outside IPv4 address prefix length
1124     @param sharing_ratio - outside to inside address sharing ratio
1125     @param ports_per_host - number of ports available to a host
1126     @param ses_num - number of sessions belonging to this mapping
1127 */
1128 define nat_det_map_details {
1129   u32 context;
1130   u8 is_nat44;
1131   u8 in_addr[16];
1132   u8 in_plen;
1133   u8 out_addr[4];
1134   u8 out_plen;
1135   u32 sharing_ratio;
1136   u16 ports_per_host;
1137   u32 ses_num;
1138 };
1139
1140 /** \brief Set values of timeouts for deterministic NAT (seconds, 0 = default)
1141     @param client_index - opaque cookie to identify the sender
1142     @param context - sender context, to match reply w/ request
1143     @param udp - UDP timeout (default 300sec)
1144     @param tcp_established - TCP established timeout (default 7440sec)
1145     @param tcp_transitory - TCP transitory timeout (default 240sec)
1146     @param icmp - ICMP timeout (default 60sec)
1147 */
1148 autoreply define nat_det_set_timeouts {
1149   u32 client_index;
1150   u32 context;
1151   u32 udp;
1152   u32 tcp_established;
1153   u32 tcp_transitory;
1154   u32 icmp;
1155 };
1156
1157 /** \brief Get values of timeouts for deterministic NAT (seconds)
1158     @param client_index - opaque cookie to identify the sender
1159     @param context - sender context, to match reply w/ request
1160 */
1161 define nat_det_get_timeouts {
1162   u32 client_index;
1163   u32 context;
1164 };
1165
1166 /** \brief Get values of timeouts for deterministic NAT reply
1167     @param context - sender context, to match reply w/ request
1168     @param retval - return code
1169     @param udp - UDP timeout (default 300sec)
1170     @param tcp_established - TCP established timeout (default 7440sec)
1171     @param tcp_transitory - TCP transitory timeout (default 240sec)
1172     @param icmp - ICMP timeout (default 60sec)
1173 */
1174 define nat_det_get_timeouts_reply {
1175   u32 context;
1176   i32 retval;
1177   u32 udp;
1178   u32 tcp_established;
1179   u32 tcp_transitory;
1180   u32 icmp;
1181 };
1182
1183 /** \brief Close deterministic NAT session by outside address and port
1184     @param client_index - opaque cookie to identify the sender
1185     @param context - sender context, to match reply w/ request
1186     @param out_addr - outside IPv4 address
1187     @param out_port - outside port
1188     @param ext_addr - external host IPv4 address
1189     @param ext_port - external host port
1190 */
1191 autoreply define nat_det_close_session_out {
1192   u32 client_index;
1193   u32 context;
1194   u8 out_addr[4];
1195   u16 out_port;
1196   u8 ext_addr[4];
1197   u16 ext_port;
1198 };
1199
1200 /** \brief Close deterministic NAT session by inside address and port
1201     @param client_index - opaque cookie to identify the sender
1202     @param context - sender context, to match reply w/ request
1203     @param is_nat44 - 1 if NAT44
1204     @param in_addr - inside IP address
1205     @param in_port - inside port
1206     @param ext_addr - external host IP address
1207     @param ext_port - external host port
1208 */
1209 autoreply define nat_det_close_session_in {
1210   u32 client_index;
1211   u32 context;
1212   u8 is_nat44;
1213   u8 in_addr[16];
1214   u16 in_port;
1215   u8 ext_addr[16];
1216   u16 ext_port;
1217 };
1218
1219 /** \brief Dump determinstic NAT sessions
1220     @param client_index - opaque cookie to identify the sender
1221     @param context - sender context, to match reply w/ request
1222     @param is_nat44 - 1 if NAT44
1223     @param user_addr - address of an inside user whose sessions to dump
1224 */
1225 define nat_det_session_dump {
1226   u32 client_index;
1227   u32 context;
1228   u8 is_nat44;
1229   u8 user_addr[16];
1230 };
1231
1232 /** \brief Deterministic NAT sessions reply
1233     @param context - sender context, to match reply w/ request
1234     @param in_port - inside port
1235     @param ext_addr - external host address
1236     @param ext_port - external host port
1237     @param out_port - outside NAT port
1238     @param state - session state
1239     @param expire - session expiration timestamp
1240 */
1241 define nat_det_session_details {
1242   u32 client_index;
1243   u32 context;
1244   u16 in_port;
1245   u8 ext_addr[4];
1246   u16 ext_port;
1247   u16 out_port;
1248   u8 state;
1249   u32 expire;
1250 };
1251
1252 /*
1253  * NAT64 APIs
1254  */
1255
1256 /** \brief Add/delete address range to NAT64 pool
1257     @param client_index - opaque cookie to identify the sender
1258     @param context - sender context, to match reply w/ request
1259     @param start_addr - start address of the range
1260     @param end_addr - end address of the range
1261     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
1262     @param is_add - 1 if add, 0 if delete
1263 */
1264 autoreply define nat64_add_del_pool_addr_range {
1265   u32 client_index;
1266   u32 context;
1267   u8 start_addr[4];
1268   u8 end_addr[4];
1269   u32 vrf_id;
1270   u8 is_add;
1271 };
1272
1273 /** \brief Dump NAT64 pool addresses
1274     @param client_index - opaque cookie to identify the sender
1275     @param context - sender context, to match reply w/ request
1276 */
1277 define nat64_pool_addr_dump {
1278   u32 client_index;
1279   u32 context;
1280 };
1281
1282 /** \brief NAT64 pool address details response
1283     @param context - sender context, to match reply w/ request
1284     @param address - IPv4 address
1285     @param vfr_id - VRF id of tenant, ~0 means independent of VRF
1286 */
1287 define nat64_pool_addr_details {
1288   u32 context;
1289   u8 address[4];
1290   u32 vrf_id;
1291 };
1292
1293 /** \brief Enable/disable NAT64 feature on the interface
1294     @param client_index - opaque cookie to identify the sender
1295     @param context - sender context, to match reply w/ request
1296     @param sw_if_index - index of the interface
1297     @param is_inside - 1 if inside, 0 if outside
1298     @param is_add - 1 if add, 0 if delete
1299 */
1300 autoreply define nat64_add_del_interface {
1301   u32 client_index;
1302   u32 context;
1303   u32 sw_if_index;
1304   u8 is_inside;
1305   u8 is_add;
1306 };
1307
1308 /** \brief Dump interfaces with NAT64 feature
1309     @param client_index - opaque cookie to identify the sender
1310     @param context - sender context, to match reply w/ request
1311 */
1312 define nat64_interface_dump {
1313   u32 client_index;
1314   u32 context;
1315 };
1316
1317 /** \brief NAT64 interface details response
1318     @param context - sender context, to match reply w/ request
1319     @param is_inside - 1 if inside, 0 if outside
1320     @param sw_if_index - index of the interface
1321 */
1322 define nat64_interface_details {
1323   u32 context;
1324   u8 is_inside;
1325   u32 sw_if_index;
1326 };
1327
1328 /** \brief Add/delete NAT64 static BIB entry
1329     @param client_index - opaque cookie to identify the sender
1330     @param context - sender context, to match reply w/ request
1331     @param i_addr - inside IPv6 address
1332     @param o_addr - outside IPv4 address
1333     @param i_port - inside port number
1334     @param o_port - outside port number
1335     @param vrf_id - VRF id of tenant
1336     @param proto - protocol number
1337     @param is_add - 1 if add, 0 if delete
1338 */
1339  autoreply define nat64_add_del_static_bib {
1340   u32 client_index;
1341   u32 context;
1342   u8 i_addr[16];
1343   u8 o_addr[4];
1344   u16 i_port;
1345   u16 o_port;
1346   u32 vrf_id;
1347   u8 proto;
1348   u8 is_add;
1349 };
1350
1351 /** \brief Dump NAT64 BIB
1352     @param client_index - opaque cookie to identify the sender
1353     @param context - sender context, to match reply w/ request
1354     @param proto - protocol of the BIB: 255 - all BIBs
1355                                         6 - TCP BIB
1356                                         17 - UDP BIB
1357                                         1/58 - ICMP BIB
1358                                         otherwise - "unknown" protocol BIB
1359 */
1360 define nat64_bib_dump {
1361   u32 client_index;
1362   u32 context;
1363   u8 proto;
1364 };
1365
1366 /** \brief NAT64 BIB details response
1367     @param context - sender context, to match reply w/ request
1368     @param i_addr - inside IPv6 address
1369     @param o_addr - outside IPv4 address
1370     @param i_port - inside port number
1371     @param o_port - outside port number
1372     @param vrf_id - VRF id of tenant
1373     @param proto - protocol number
1374     @param is_static - 1 if static BIB entry, 0 if dynamic
1375     @param ses_num - number of sessions associated with the BIB entry
1376 */
1377 define nat64_bib_details {
1378   u32 context;
1379   u8 i_addr[16];
1380   u8 o_addr[4];
1381   u16 i_port;
1382   u16 o_port;
1383   u32 vrf_id;
1384   u8 proto;
1385   u8 is_static;
1386   u32 ses_num;
1387 };
1388
1389 /** \brief Set values of timeouts for NAT64 (seconds, 0 = default)
1390     @param client_index - opaque cookie to identify the sender
1391     @param context - sender context, to match reply w/ request
1392     @param udp - UDP timeout (default 300sec)
1393     @param icmp - ICMP timeout (default 60sec)
1394     @param tcp_trans - TCP transitory timeout (default 240sec)
1395     @param tcp_est - TCP established timeout (default 7440sec)
1396     @param tcp_incoming_syn - TCP incoming SYN timeout (default 6sec)
1397 */
1398 autoreply define nat64_set_timeouts {
1399   u32 client_index;
1400   u32 context;
1401   u32 udp;
1402   u32 icmp;
1403   u32 tcp_trans;
1404   u32 tcp_est;
1405   u32 tcp_incoming_syn;
1406 };
1407
1408 /** \brief Get values of timeouts for NAT64 (seconds)
1409     @param client_index - opaque cookie to identify the sender
1410     @param context - sender context, to match reply w/ request
1411 */
1412 define nat64_get_timeouts {
1413   u32 client_index;
1414   u32 context;
1415 };
1416
1417 /** \brief Get values of timeouts for NAT64 reply
1418     @param context - sender context, to match reply w/ request
1419     @param retval - return code
1420     @param udp - UDP timeout
1421     @param icmp - ICMP timeout
1422     @param tcp_trans - TCP transitory timeout
1423     @param tcp_est - TCP established timeout
1424     @param tcp_incoming_syn - TCP incoming SYN timeout
1425 */
1426 define nat64_get_timeouts_reply {
1427   u32 context;
1428   i32 retval;
1429   u32 udp;
1430   u32 icmp;
1431   u32 tcp_trans;
1432   u32 tcp_est;
1433   u32 tcp_incoming_syn;
1434 };
1435
1436 /** \brief Dump NAT64 session table
1437     @param client_index - opaque cookie to identify the sender
1438     @param context - sender context, to match reply w/ request
1439     @param proto - protocol of the session table: 255 - all STs
1440                                                   6 - TCP ST
1441                                                   17 - UDP ST
1442                                                   1/58 - ICMP ST
1443                                                   otherwise - "unknown" proto ST
1444 */
1445 define nat64_st_dump {
1446   u32 client_index;
1447   u32 context;
1448   u8 proto;
1449 };
1450
1451 /** \brief NAT64 session table details response
1452     @param context - sender context, to match reply w/ request
1453     @param il_addr - inside IPv6 address of the local host
1454     @param ol_addr - outside IPv4 address of the local host
1455     @param il_port - inside port number id of the local host/inside ICMP id
1456     @param ol_port - outside port number of the local host/outside ICMP id
1457     @param il_addr - inside IPv6 address of the remote host
1458     @param ol_addr - outside IPv4 address of the remote host
1459     @param l_port - port number of the remote host (not used for ICMP)
1460     @param vrf_id - VRF id of tenant
1461     @param proto - protocol number
1462 */
1463 define nat64_st_details {
1464   u32 context;
1465   u8 il_addr[16];
1466   u8 ol_addr[4];
1467   u16 il_port;
1468   u16 ol_port;
1469   u8 ir_addr[16];
1470   u8 or_addr[4];
1471   u16 r_port;
1472   u32 vrf_id;
1473   u8 proto;
1474 };
1475
1476 /** \brief Add/del NAT64 prefix
1477     @param client_index - opaque cookie to identify the sender
1478     @param context - sender context, to match reply w/ request
1479     @param prefix - NAT64 prefix
1480     @param prefix - NAT64 prefix length
1481     @param vrf_id - VRF id of tenant
1482     @param is_add - 1 if add, 0 if delete
1483 */
1484 autoreply define nat64_add_del_prefix {
1485   u32 client_index;
1486   u32 context;
1487   u8 prefix[16];
1488   u8 prefix_len;
1489   u32 vrf_id;
1490   u8 is_add;
1491 };
1492
1493 /** \brief Dump NAT64 prefix
1494     @param client_index - opaque cookie to identify the sender
1495     @param context - sender context, to match reply w/ request
1496 */
1497 define nat64_prefix_dump {
1498   u32 client_index;
1499   u32 context;
1500 };
1501
1502 /** \brief Dump NAT64 prefix details response
1503     @param context - sender context, to match reply w/ request
1504     @param prefix - NAT64 prefix
1505     @param prefix - NAT64 prefix length
1506     @param vrf_id - VRF id of tenant
1507 */
1508 define nat64_prefix_details {
1509   u32 context;
1510   u8 prefix[16];
1511   u8 prefix_len;
1512   u32 vrf_id;
1513 };