NAT44: asymmetrical static mapping rule (VPP-1135)
[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 vl_api_version 2.3.0
17
18 /**
19  * @file nat.api
20  * @brief VPP control-plane API messages.
21  *
22  * This file defines VPP control-plane API messages which are generally
23  * called through a shared memory interface.
24  */
25
26 /*
27  * Common NAT plugin APIs
28  */
29
30 /** \brief Control ping from client to api server request
31     @param client_index - opaque cookie to identify the sender
32     @param context - sender context, to match reply w/ request
33 */
34 define nat_control_ping
35 {
36   u32 client_index;
37   u32 context;
38 };
39
40 /** \brief Control ping from the client to the server response
41     @param client_index - opaque cookie to identify the sender
42     @param context - sender context, to match reply w/ request
43     @param retval - return code for the request
44     @param vpe_pid - the pid of the vpe, returned by the server
45 */
46 define nat_control_ping_reply
47 {
48   u32 context;
49   i32 retval;
50   u32 client_index;
51   u32 vpe_pid;
52 };
53
54 /** \brief Show NAT plugin startup config
55     @param client_index - opaque cookie to identify the sender
56     @param context - sender context, to match reply w/ request
57 */
58 define nat_show_config
59 {
60   u32 client_index;
61   u32 context;
62 };
63
64 /** \brief Show NAT plugin startup config reply
65     @param context - sender context, to match reply w/ request
66     @param retval - return code for the request
67     @param static_mapping_only - if 1 dynamic translations disabled
68     @param static_mapping_connection_tracking - if 1 create session data
69     @param deterministic - if 1 deterministic mapping
70     @param translation_buckets - number of translation hash buckets
71     @param translation_memory_size - translation hash memory size
72     @param user_buckets - number of user hash buckets
73     @param user_memory_size - user hash memory size
74     @param max_translations_per_user - maximum number of translations per user
75     @param outside_vrf_id - outside VRF id
76     @param inside_vrf_id - default inside VRF id
77 */
78 define nat_show_config_reply
79 {
80   u32 context;
81   i32 retval;
82   u8 static_mapping_only;
83   u8 static_mapping_connection_tracking;
84   u8 deterministic;
85   u32 translation_buckets;
86   u32 translation_memory_size;
87   u32 user_buckets;
88   u32 user_memory_size;
89   u32 max_translations_per_user;
90   u32 outside_vrf_id;
91   u32 inside_vrf_id;
92 };
93
94 /** \brief Set NAT workers
95     @param client_index - opaque cookie to identify the sender
96     @param context - sender context, to match reply w/ request
97     @param worker_mask - NAT workers mask
98 */
99 autoreply define nat_set_workers {
100   u32 client_index;
101   u32 context;
102   u64 worker_mask;
103 };
104
105 /** \brief Dump NAT workers
106     @param client_index - opaque cookie to identify the sender
107     @param context - sender context, to match reply w/ request
108 */
109 define nat_worker_dump {
110   u32 client_index;
111   u32 context;
112 };
113
114 /** \brief NAT workers details response
115     @param context - sender context, to match reply w/ request
116     @param worker_index - worker index
117     @param lcore_id - lcore ID
118     @param name - worker name
119 */
120 define nat_worker_details {
121   u32 context;
122   u32 worker_index;
123   u32 lcore_id;
124   u8 name[64];
125 };
126
127 /** \brief Enable/disable NAT IPFIX logging
128     @param client_index - opaque cookie to identify the sender
129     @param context - sender context, to match reply w/ request
130     @param domain_id - observation domain ID
131     @param src_port - source port number
132     @param enable - 1 if enable, 0 if disable
133 */
134 autoreply define nat_ipfix_enable_disable {
135   u32 client_index;
136   u32 context;
137   u32 domain_id;
138   u16 src_port;
139   u8 enable;
140 };
141
142 /** \brief Set NAT virtual fragmentation reassembly
143     @param client_index - opaque cookie to identify the sender
144     @param context - sender context, to match reply w/ request
145     @param timeout - reassembly timeout
146     @param max_reass - maximum number of concurrent reassemblies
147     @param max_frag - maximum number of fragmets per reassembly
148     @param drop_frag - if 0 translate fragments, otherwise drop fragments
149     @param is_ip6 - 1 if IPv6, 0 if IPv4
150 */
151 autoreply define nat_set_reass {
152   u32 client_index;
153   u32 context;
154   u32 timeout;
155   u16 max_reass;
156   u8  max_frag;
157   u8  drop_frag;
158   u8  is_ip6;
159 };
160
161 /** \brief Get NAT virtual fragmentation reassembly configuration
162     @param client_index - opaque cookie to identify the sender
163     @param context - sender context, to match reply w/ request
164 */
165 define nat_get_reass {
166   u32 client_index;
167   u32 context;
168 };
169
170 /** \brief Get NAT virtual fragmentation reassembly configuration reply
171     @param context - sender context, to match reply w/ request
172     @param retval - return code
173     @param ip4_timeout - reassembly timeout
174     @param ip4_max_reass - maximum number of concurrent reassemblies
175     @param ip4_max_frag - maximum number of fragmets per reassembly
176     @param ip4_drop_frag - if 0 translate fragments, otherwise drop fragments
177     @param ip6_timeout - reassembly timeout
178     @param ip6_max_reass - maximum number of concurrent reassemblies
179     @param ip6_max_frag - maximum number of fragmets per reassembly
180     @param ip6_drop_frag - if 0 translate fragments, otherwise drop fragments
181 */
182 define nat_get_reass_reply {
183   u32 context;
184   i32 retval;
185   u32 ip4_timeout;
186   u16 ip4_max_reass;
187   u8  ip4_max_frag;
188   u8  ip4_drop_frag;
189   u32 ip6_timeout;
190   u16 ip6_max_reass;
191   u8  ip6_max_frag;
192   u8  ip6_drop_frag;
193 };
194
195 /** \brief Dump NAT virtual fragmentation reassemblies
196     @param client_index - opaque cookie to identify the sender
197     @param context - sender context, to match reply w/ request
198 */
199 define nat_reass_dump {
200   u32 client_index;
201   u32 context;
202 };
203
204 /** \brief NAT virtual fragmentation reassemblies response
205     @param context - sender context, to match reply w/ request
206     @param is_ip4 - 1 if address type is IPv4
207     @param src_addr - source IP address
208     @param dst_addr - destination IP address
209     @param frag_id - fragment ID
210     @param proto - protocol
211     @param frag_n - number of cached fragments
212 */
213 define nat_reass_details {
214   u32 context;
215   u8 is_ip4;
216   u8 src_addr[16];
217   u8 dst_addr[16];
218   u32 frag_id;
219   u8 proto;
220   u8 frag_n;
221 };
222
223 /*
224  * NAT44 APIs
225  */
226
227 /** \brief Add/del NAT44 address range
228     @param client_index - opaque cookie to identify the sender
229     @param context - sender context, to match reply w/ request
230     @param first_ip_address - first IPv4 address
231     @param last_ip_address - last IPv4 address
232     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
233     @param twice_nat - twice NAT address range for extenal hosts
234     @param is_add - 1 if add, 0 if delete
235 */
236 autoreply define nat44_add_del_address_range {
237   u32 client_index;
238   u32 context;
239   u8 first_ip_address[4];
240   u8 last_ip_address[4];
241   u32 vrf_id;
242   u8 twice_nat;
243   u8 is_add;
244 };
245
246 /** \brief Dump NAT44 addresses
247     @param client_index - opaque cookie to identify the sender
248     @param context - sender context, to match reply w/ request
249 */
250 define nat44_address_dump {
251   u32 client_index;
252   u32 context;
253 };
254
255 /** \brief NAT44 address details response
256     @param context - sender context, to match reply w/ request
257     @param ip_address - IPv4 address
258     @param twice_nat - twice NAT address range for extenal hosts
259     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
260 */
261 define nat44_address_details {
262   u32 context;
263   u8 ip_address[4];
264   u8 twice_nat;
265   u32 vrf_id;
266 };
267
268 /** \brief Enable/disable NAT44 feature on the interface
269     @param client_index - opaque cookie to identify the sender
270     @param context - sender context, to match reply w/ request
271     @param is_add - 1 if add, 0 if delete
272     @param is_inside - 1 if inside, 0 if outside
273     @param sw_if_index - software index of the interface
274 */
275 autoreply define nat44_interface_add_del_feature {
276   u32 client_index;
277   u32 context;
278   u8 is_add;
279   u8 is_inside;
280   u32 sw_if_index;
281 };
282
283 /** \brief Dump interfaces with NAT44 feature
284     @param client_index - opaque cookie to identify the sender
285     @param context - sender context, to match reply w/ request
286 */
287 define nat44_interface_dump {
288   u32 client_index;
289   u32 context;
290 };
291
292 /** \brief NAT44 interface details response
293     @param context - sender context, to match reply w/ request
294     @param is_inside - 1 if inside, 0 if outside, 2 if inside and outside
295     @param sw_if_index - software index of the interface
296 */
297 define nat44_interface_details {
298   u32 context;
299   u8 is_inside;
300   u32 sw_if_index;
301 };
302
303 /** \brief Enable/disbale NAT44 as an interface output feature (postrouting
304            in2out translation)
305     @param client_index - opaque cookie to identify the sender
306     @param context - sender context, to match reply w/ request
307     @param is_add - 1 if add, 0 if delete
308     @param is_inside - 1 if inside, 0 if outside
309     @param sw_if_index - software index of the interface
310 */
311 autoreply define nat44_interface_add_del_output_feature {
312   u32 client_index;
313   u32 context;
314   u8 is_add;
315   u8 is_inside;
316   u32 sw_if_index;
317 };
318
319 /** \brief Dump interfaces with NAT44 output feature
320     @param client_index - opaque cookie to identify the sender
321     @param context - sender context, to match reply w/ request
322 */
323 define nat44_interface_output_feature_dump {
324   u32 client_index;
325   u32 context;
326 };
327
328 /** \brief NAT44 interface with output feature details response
329     @param context - sender context, to match reply w/ request
330     @param is_inside - 1 if inside, 0 if outside
331     @param sw_if_index - software index of the interface
332 */
333 define nat44_interface_output_feature_details {
334   u32 context;
335   u8 is_inside;
336   u32 sw_if_index;
337 };
338
339 /** \brief Add/delete NAT44 static mapping
340     @param client_index - opaque cookie to identify the sender
341     @param context - sender context, to match reply w/ request
342     @param is_add - 1 if add, 0 if delete
343     @param addr_only - 1 if address only mapping
344     @param local_ip_address - local IPv4 address
345     @param external_ip_address - external IPv4 address
346     @param protocol - IP protocol
347     @param local_port - local port number
348     @param external_port - external port number
349     @param external_sw_if_index - external interface (if set
350                                   external_ip_address is ignored, ~0 means not
351                                   used)
352     @param vfr_id - VRF ID
353     @param twice_nat - if 1 translate external host address and port, only for
354                        1:1 NAPT (addr_only must be 0)
355     @param out2in_only - if 1 rule match only out2in direction
356 */
357 autoreply define nat44_add_del_static_mapping {
358   u32 client_index;
359   u32 context;
360   u8 is_add;
361   u8 addr_only;
362   u8 local_ip_address[4];
363   u8 external_ip_address[4];
364   u8 protocol;
365   u16 local_port;
366   u16 external_port;
367   u32 external_sw_if_index;
368   u32 vrf_id;
369   u8 twice_nat;
370   u8 out2in_only;
371 };
372
373 /** \brief Dump NAT44 static mappings
374     @param client_index - opaque cookie to identify the sender
375     @param context - sender context, to match reply w/ request
376 */
377 define nat44_static_mapping_dump {
378   u32 client_index;
379   u32 context;
380 };
381
382 /** \brief NAT44 static mapping details response
383     @param context - sender context, to match reply w/ request
384     @param addr_only - 1 if address only mapping
385     @param local_ip_address - local IPv4 address
386     @param external_ip_address - external IPv4 address
387     @param protocol - IP protocol
388     @param local_port - local port number
389     @param external_port - external port number
390     @param external_sw_if_index - external interface
391     @param vfr_id - VRF ID
392     @param twice_nat - if 1 translate external host address and port
393     @param out2in_only - if 1 rule match only out2in direction
394 */
395 define nat44_static_mapping_details {
396   u32 context;
397   u8 addr_only;
398   u8 local_ip_address[4];
399   u8 external_ip_address[4];
400   u8 protocol;
401   u16 local_port;
402   u16 external_port;
403   u32 external_sw_if_index;
404   u32 vrf_id;
405   u8 twice_nat;
406   u8 out2in_only;
407 };
408
409 /** \brief Add/delete NAT44 identity mapping
410     @param client_index - opaque cookie to identify the sender
411     @param context - sender context, to match reply w/ request
412     @param is_add - 1 if add, 0 if delete
413     @param addr_only - 1 if address only mapping
414     @param ip_address - IPv4 address
415     @param protocol - IP protocol
416     @param port - port number
417     @param sw_if_index - interface (if set ip_address is ignored, ~0 means not
418                                     used)
419     @param vfr_id - VRF ID (if ~0 use default VRF)
420 */
421 autoreply define nat44_add_del_identity_mapping {
422   u32 client_index;
423   u32 context;
424   u8 is_add;
425   u8 addr_only;
426   u8 ip_address[4];
427   u8 protocol;
428   u16 port;
429   u32 sw_if_index;
430   u32 vrf_id;
431 };
432
433 /** \brief Dump NAT44 identity mappings
434     @param client_index - opaque cookie to identify the sender
435     @param context - sender context, to match reply w/ request
436 */
437 define nat44_identity_mapping_dump {
438   u32 client_index;
439   u32 context;
440 };
441
442 /** \brief NAT44 identity mapping details response
443     @param context - sender context, to match reply w/ request
444     @param addr_only - 1 if address only mapping
445     @param ip_address - IPv4 address
446     @param protocol - IP protocol
447     @param port - port number
448     @param sw_if_index - interface
449     @param vfr_id - VRF ID
450 */
451 define nat44_identity_mapping_details {
452   u32 context;
453   u8 addr_only;
454   u8 ip_address[4];
455   u8 protocol;
456   u16 port;
457   u32 sw_if_index;
458   u32 vrf_id;
459 };
460
461 /** \brief Add/delete NAT44 pool address from specific interfce
462     @param client_index - opaque cookie to identify the sender
463     @param context - sender context, to match reply w/ request
464     @param is_add - 1 if add, 0 if delete
465     @param twice_nat - twice NAT address for extenal hosts
466     @param sw_if_index - software index of the interface
467 */
468 autoreply define nat44_add_del_interface_addr {
469   u32 client_index;
470   u32 context;
471   u8 is_add;
472   u8 twice_nat;
473   u32 sw_if_index;
474 };
475
476 /** \brief Dump NAT44 pool addresses interfaces
477     @param client_index - opaque cookie to identify the sender
478     @param context - sender context, to match reply w/ request
479 */
480 define nat44_interface_addr_dump {
481   u32 client_index;
482   u32 context;
483 };
484
485 /** \brief NAT44 pool addresses interfaces details response
486     @param context - sender context, to match reply w/ request
487     @param sw_if_index - software index of the interface
488     @param twice_nat - twice NAT address for extenal hosts
489 */
490 define nat44_interface_addr_details {
491   u32 context;
492   u32 sw_if_index;
493   u8 twice_nat;
494 };
495
496 /** \brief Dump NAT44 users
497     @param client_index - opaque cookie to identify the sender
498     @param context - sender context, to match reply w/ request
499 */
500 define nat44_user_dump {
501   u32 client_index;
502   u32 context;
503 };
504
505 /** \brief NAT44 users response
506     @param context - sender context, to match reply w/ request
507     @vrf_id - VRF ID
508     @param ip_adress - IPv4 address
509     @param nsessions - number of dynamic sessions
510     @param nstaticsessions - number of static sessions
511 */
512 define nat44_user_details {
513   u32 context;
514   u32 vrf_id;
515   u8 ip_address[4];
516   u32 nsessions;
517   u32 nstaticsessions;
518 };
519
520 /** \brief NAT44 user's sessions
521     @param client_index - opaque cookie to identify the sender
522     @param context - sender context, to match reply w/ request
523     @param is_ip4 - 1 if address type is IPv4
524     @param user_ip - IP address of the user to dump
525     @param vrf_id - VRF_ID
526 */
527 define nat44_user_session_dump {
528   u32 client_index;
529   u32 context;
530   u8 ip_address[4];
531   u32 vrf_id;
532 };
533
534 /** \brief NAT44 user's sessions response
535     @param context - sender context, to match reply w/ request
536     @param outside_ip_address - outside IPv4 address
537     @param outside_port - outside port
538     @param inside_ip_address - inside IPv4 address
539     @param inside_port - inside port
540     @param protocol - protocol
541     @param is_static - 1 if session is static
542     @param last_heard - last heard timer
543     @param total_bytes - count of bytes sent through session
544     @param total_pkts - count of pakets sent through session
545 */
546 define nat44_user_session_details {
547   u32 context;
548   u8 outside_ip_address[4];
549   u16 outside_port;
550   u8 inside_ip_address[4];
551   u16 inside_port;
552   u16 protocol;
553   u8 is_static;
554   u64 last_heard;
555   u64 total_bytes;
556   u32 total_pkts;
557 };
558
559 typeonly manual_endian define nat44_lb_addr_port {
560   u8 addr[4];
561   u16 port;
562   u8 probability;
563 };
564
565 autoreply manual_endian define nat44_add_del_lb_static_mapping {
566   u32 client_index;
567   u32 context;
568   u8 is_add;
569   u8 external_addr[4];
570   u16 external_port;
571   u8 protocol;
572   u32 vrf_id;
573   u8 twice_nat;
574   u8 out2in_only;
575   u8 local_num;
576   vl_api_nat44_lb_addr_port_t locals[local_num];
577 };
578
579 define nat44_lb_static_mapping_dump {
580   u32 client_index;
581   u32 context;
582 };
583
584 manual_endian define nat44_lb_static_mapping_details {
585   u32 context;
586   u8 external_addr[4];
587   u16 external_port;
588   u8 protocol;
589   u32 vrf_id;
590   u8 twice_nat;
591   u8 out2in_only;
592   u8 local_num;
593   vl_api_nat44_lb_addr_port_t locals[local_num];
594 };
595
596 /** \brief Delete NAT44 session
597     @param client_index - opaque cookie to identify the sender
598     @param context - sender context, to match reply w/ request
599     @param is_in - 1 if inside network addres and port pari, 0 if outside
600     @param ip_address - IPv4 address
601     @param protocol - IP protocol
602     @param port - port number
603     @param vfr_id - VRF ID
604 */
605 autoreply define nat44_del_session {
606   u32 client_index;
607   u32 context;
608   u8 is_in;
609   u8 address[4];
610   u8 protocol;
611   u16 port;
612   u32 vrf_id;
613 };
614
615 /** \brief Enable/disable forwarding for NAT44
616     Forward packets which don't match existing translation
617     or static mapping instead of dropping them.
618     @param client_index - opaque cookie to identify the sender
619     @param context - sender context, to match reply w/ request
620     @param enable - 0 for enable, 1 for disable
621 */
622 autoreply define nat44_forwarding_enable_disable {
623   u32 client_index;
624   u32 context;
625   u8 enable;
626 };
627
628 /** \brief Check if forwarding is enabled or disabled
629     @param client_index - opaque cookie to identify the sender
630     @param context - sender context, to match reply w/ request
631 */
632 define nat44_forwarding_is_enabled {
633   u32 client_index;
634   u32 context;
635 };
636
637 /** \brief Response to check if forwarding is enabled or disabled
638     @param context - sender context, to match reply w/ request
639     @param enabled - 1 if enabled, 0 if disabled
640 */
641 define nat44_forwarding_is_enabled_reply {
642   u32 context;
643   u8 enabled;
644 };
645
646
647 /*
648  * Deterministic NAT (CGN) APIs
649  */
650
651 /** \brief Add/delete NAT deterministic mapping
652     @param client_index - opaque cookie to identify the sender
653     @param context - sender context, to match reply w/ request
654     @param is_add - 1 if add, 0 if delete
655     @param is_nat44 - 1 if NAT44
656     @param in_addr - inside IP address
657     @param in_plen - inside IP address prefix length
658     @param out_addr - outside IPv4 address
659     @param out_addr - outside IPv4 address prefix length
660 */
661 autoreply define nat_det_add_del_map {
662   u32 client_index;
663   u32 context;
664   u8 is_add;
665   u8 is_nat44;
666   u8 addr_only;
667   u8 in_addr[16];
668   u8 in_plen;
669   u8 out_addr[4];
670   u8 out_plen;
671 };
672
673 /** \brief Get outside address and port range from inside address
674     @param client_index - opaque cookie to identify the sender
675     @param context - sender context, to match reply w/ request
676     @param is_nat44 - 1 if NAT44
677     @param in_addr - inside IP address
678 */
679 define nat_det_forward {
680   u32 client_index;
681   u32 context;
682   u8 is_nat44;
683   u8 in_addr[16];
684 };
685
686 /** \brief Get outside address and port range from inside address
687     @param context - sender context, to match reply w/ request
688     @param retval - return code
689     @param out_port_lo - outside port range start
690     @param out_port_hi - outside port range end
691     @param out_addr - outside IPv4 address
692 */
693 define nat_det_forward_reply {
694   u32 context;
695   i32 retval;
696   u16 out_port_lo;
697   u16 out_port_hi;
698   u8 out_addr[4];
699 };
700
701 /** \brief Get inside address from outside address and port
702     @param client_index - opaque cookie to identify the sender
703     @param context - sender context, to match reply w/ request
704     @param out_port - outside port
705     @param out_addr - outside IPv4 address
706 */
707 define nat_det_reverse {
708   u32 client_index;
709   u32 context;
710   u16 out_port;
711   u8 out_addr[4];
712 };
713
714 /** \brief Get inside address from outside address and port reply
715     @param context - sender context, to match reply w/ request
716     @param retval - return code
717     @param is_nat44 - 1 if NAT44
718     @param in_addr - inside IP address
719 */
720 define nat_det_reverse_reply {
721   u32 context;
722   i32 retval;
723   u8 is_nat44;
724   u8 in_addr[16];
725 };
726
727 /** \brief Dump NAT deterministic mappings
728     @param client_index - opaque cookie to identify the sender
729     @param context - sender context, to match reply w/ request
730 */
731 define nat_det_map_dump {
732   u32 client_index;
733   u32 context;
734 };
735
736 /** \brief NAT users response
737     @param context - sender context, to match reply w/ request
738     @param is_nat44 - 1 if NAT44
739     @param in_addr - inside IP address
740     @param in_plen - inside IP address prefix length
741     @param out_addr - outside IPv4 address
742     @param out_plen - outside IPv4 address prefix length
743     @param sharing_ratio - outside to inside address sharing ratio
744     @param ports_per_host - number of ports available to a host
745     @param ses_num - number of sessions belonging to this mapping
746 */
747 define nat_det_map_details {
748   u32 context;
749   u8 is_nat44;
750   u8 in_addr[16];
751   u8 in_plen;
752   u8 out_addr[4];
753   u8 out_plen;
754   u32 sharing_ratio;
755   u16 ports_per_host;
756   u32 ses_num;
757 };
758
759 /** \brief Set values of timeouts for deterministic NAT (seconds, 0 = default)
760     @param client_index - opaque cookie to identify the sender
761     @param context - sender context, to match reply w/ request
762     @param udp - UDP timeout (default 300sec)
763     @param tcp_established - TCP established timeout (default 7440sec)
764     @param tcp_transitory - TCP transitory timeout (default 240sec)
765     @param icmp - ICMP timeout (default 60sec)
766 */
767 autoreply define nat_det_set_timeouts {
768   u32 client_index;
769   u32 context;
770   u32 udp;
771   u32 tcp_established;
772   u32 tcp_transitory;
773   u32 icmp;
774 };
775
776 /** \brief Get values of timeouts for deterministic NAT (seconds)
777     @param client_index - opaque cookie to identify the sender
778     @param context - sender context, to match reply w/ request
779 */
780 define nat_det_get_timeouts {
781   u32 client_index;
782   u32 context;
783 };
784
785 /** \brief Get values of timeouts for deterministic NAT reply
786     @param context - sender context, to match reply w/ request
787     @param retval - return code
788     @param udp - UDP timeout (default 300sec)
789     @param tcp_established - TCP established timeout (default 7440sec)
790     @param tcp_transitory - TCP transitory timeout (default 240sec)
791     @param icmp - ICMP timeout (default 60sec)
792 */
793 define nat_det_get_timeouts_reply {
794   u32 context;
795   i32 retval;
796   u32 udp;
797   u32 tcp_established;
798   u32 tcp_transitory;
799   u32 icmp;
800 };
801
802 /** \brief Close deterministic NAT session by outside address and port
803     @param client_index - opaque cookie to identify the sender
804     @param context - sender context, to match reply w/ request
805     @param out_addr - outside IPv4 address
806     @param out_port - outside port
807     @param ext_addr - external host IPv4 address
808     @param ext_port - external host port
809 */
810 autoreply define nat_det_close_session_out {
811   u32 client_index;
812   u32 context;
813   u8 out_addr[4];
814   u16 out_port;
815   u8 ext_addr[4];
816   u16 ext_port;
817 };
818
819 /** \brief Close deterministic NAT session by inside address and port
820     @param client_index - opaque cookie to identify the sender
821     @param context - sender context, to match reply w/ request
822     @param is_nat44 - 1 if NAT44
823     @param in_addr - inside IP address
824     @param in_port - inside port
825     @param ext_addr - external host IP address
826     @param ext_port - external host port
827 */
828 autoreply define nat_det_close_session_in {
829   u32 client_index;
830   u32 context;
831   u8 is_nat44;
832   u8 in_addr[16];
833   u16 in_port;
834   u8 ext_addr[16];
835   u16 ext_port;
836 };
837
838 /** \brief Dump determinstic NAT sessions
839     @param client_index - opaque cookie to identify the sender
840     @param context - sender context, to match reply w/ request
841     @param is_nat44 - 1 if NAT44
842     @param user_addr - address of an inside user whose sessions to dump
843 */
844 define nat_det_session_dump {
845   u32 client_index;
846   u32 context;
847   u8 is_nat44;
848   u8 user_addr[16];
849 };
850
851 /** \brief Deterministic NAT sessions reply
852     @param context - sender context, to match reply w/ request
853     @param in_port - inside port
854     @param ext_addr - external host address
855     @param ext_port - external host port
856     @param out_port - outside NAT port
857     @param state - session state
858     @param expire - session expiration timestamp
859 */
860 define nat_det_session_details {
861   u32 client_index;
862   u32 context;
863   u16 in_port;
864   u8 ext_addr[4];
865   u16 ext_port;
866   u16 out_port;
867   u8 state;
868   u32 expire;
869 };
870
871 /*
872  * NAT64 APIs
873  */
874
875 /** \brief Add/delete address range to NAT64 pool
876     @param client_index - opaque cookie to identify the sender
877     @param context - sender context, to match reply w/ request
878     @param start_addr - start address of the range
879     @param end_addr - end address of the range
880     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
881     @param is_add - 1 if add, 0 if delete
882 */
883 autoreply define nat64_add_del_pool_addr_range {
884   u32 client_index;
885   u32 context;
886   u8 start_addr[4];
887   u8 end_addr[4];
888   u32 vrf_id;
889   u8 is_add;
890 };
891
892 /** \brief Dump NAT64 pool addresses
893     @param client_index - opaque cookie to identify the sender
894     @param context - sender context, to match reply w/ request
895 */
896 define nat64_pool_addr_dump {
897   u32 client_index;
898   u32 context;
899 };
900
901 /** \brief NAT64 pool address details response
902     @param context - sender context, to match reply w/ request
903     @param address - IPv4 address
904     @param vfr_id - VRF id of tenant, ~0 means independent of VRF
905 */
906 define nat64_pool_addr_details {
907   u32 context;
908   u8 address[4];
909   u32 vrf_id;
910 };
911
912 /** \brief Enable/disable NAT64 feature on the interface
913     @param client_index - opaque cookie to identify the sender
914     @param context - sender context, to match reply w/ request
915     @param sw_if_index - index of the interface
916     @param is_inside - 1 if inside, 0 if outside
917     @param is_add - 1 if add, 0 if delete
918 */
919 autoreply define nat64_add_del_interface {
920   u32 client_index;
921   u32 context;
922   u32 sw_if_index;
923   u8 is_inside;
924   u8 is_add;
925 };
926
927 /** \brief Dump interfaces with NAT64 feature
928     @param client_index - opaque cookie to identify the sender
929     @param context - sender context, to match reply w/ request
930 */
931 define nat64_interface_dump {
932   u32 client_index;
933   u32 context;
934 };
935
936 /** \brief NAT64 interface details response
937     @param context - sender context, to match reply w/ request
938     @param is_inside - 1 if inside, 0 if outside
939     @param sw_if_index - index of the interface
940 */
941 define nat64_interface_details {
942   u32 context;
943   u8 is_inside;
944   u32 sw_if_index;
945 };
946
947 /** \brief Add/delete NAT64 static BIB entry
948     @param client_index - opaque cookie to identify the sender
949     @param context - sender context, to match reply w/ request
950     @param i_addr - inside IPv6 address
951     @param o_addr - outside IPv4 address
952     @param i_port - inside port number
953     @param o_port - outside port number
954     @param vrf_id - VRF id of tenant
955     @param proto - protocol number
956     @param is_add - 1 if add, 0 if delete
957 */
958  autoreply define nat64_add_del_static_bib {
959   u32 client_index;
960   u32 context;
961   u8 i_addr[16];
962   u8 o_addr[4];
963   u16 i_port;
964   u16 o_port;
965   u32 vrf_id;
966   u8 proto;
967   u8 is_add;
968 };
969
970 /** \brief Dump NAT64 BIB
971     @param client_index - opaque cookie to identify the sender
972     @param context - sender context, to match reply w/ request
973     @param proto - protocol of the BIB: 255 - all BIBs
974                                         6 - TCP BIB
975                                         17 - UDP BIB
976                                         1/58 - ICMP BIB
977                                         otherwise - "unknown" protocol BIB
978 */
979 define nat64_bib_dump {
980   u32 client_index;
981   u32 context;
982   u8 proto;
983 };
984
985 /** \brief NAT64 BIB details response
986     @param context - sender context, to match reply w/ request
987     @param i_addr - inside IPv6 address
988     @param o_addr - outside IPv4 address
989     @param i_port - inside port number
990     @param o_port - outside port number
991     @param vrf_id - VRF id of tenant
992     @param proto - protocol number
993     @param is_static - 1 if static BIB entry, 0 if dynamic
994     @param ses_num - number of sessions associated with the BIB entry
995 */
996 define nat64_bib_details {
997   u32 context;
998   u8 i_addr[16];
999   u8 o_addr[4];
1000   u16 i_port;
1001   u16 o_port;
1002   u32 vrf_id;
1003   u8 proto;
1004   u8 is_static;
1005   u32 ses_num;
1006 };
1007
1008 /** \brief Set values of timeouts for NAT64 (seconds, 0 = default)
1009     @param client_index - opaque cookie to identify the sender
1010     @param context - sender context, to match reply w/ request
1011     @param udp - UDP timeout (default 300sec)
1012     @param icmp - ICMP timeout (default 60sec)
1013     @param tcp_trans - TCP transitory timeout (default 240sec)
1014     @param tcp_est - TCP established timeout (default 7440sec)
1015     @param tcp_incoming_syn - TCP incoming SYN timeout (default 6sec)
1016 */
1017 autoreply define nat64_set_timeouts {
1018   u32 client_index;
1019   u32 context;
1020   u32 udp;
1021   u32 icmp;
1022   u32 tcp_trans;
1023   u32 tcp_est;
1024   u32 tcp_incoming_syn;
1025 };
1026
1027 /** \brief Get values of timeouts for NAT64 (seconds)
1028     @param client_index - opaque cookie to identify the sender
1029     @param context - sender context, to match reply w/ request
1030 */
1031 define nat64_get_timeouts {
1032   u32 client_index;
1033   u32 context;
1034 };
1035
1036 /** \brief Get values of timeouts for NAT64 reply
1037     @param context - sender context, to match reply w/ request
1038     @param retval - return code
1039     @param udp - UDP timeout
1040     @param icmp - ICMP timeout
1041     @param tcp_trans - TCP transitory timeout
1042     @param tcp_est - TCP established timeout
1043     @param tcp_incoming_syn - TCP incoming SYN timeout
1044 */
1045 define nat64_get_timeouts_reply {
1046   u32 context;
1047   i32 retval;
1048   u32 udp;
1049   u32 icmp;
1050   u32 tcp_trans;
1051   u32 tcp_est;
1052   u32 tcp_incoming_syn;
1053 };
1054
1055 /** \brief Dump NAT64 session table
1056     @param client_index - opaque cookie to identify the sender
1057     @param context - sender context, to match reply w/ request
1058     @param proto - protocol of the session table: 255 - all STs
1059                                                   6 - TCP ST
1060                                                   17 - UDP ST
1061                                                   1/58 - ICMP ST
1062                                                   otherwise - "unknown" proto ST
1063 */
1064 define nat64_st_dump {
1065   u32 client_index;
1066   u32 context;
1067   u8 proto;
1068 };
1069
1070 /** \brief NAT64 session table details response
1071     @param context - sender context, to match reply w/ request
1072     @param il_addr - inside IPv6 address of the local host
1073     @param ol_addr - outside IPv4 address of the local host
1074     @param il_port - inside port number id of the local host/inside ICMP id
1075     @param ol_port - outside port number of the local host/outside ICMP id
1076     @param il_addr - inside IPv6 address of the remote host
1077     @param ol_addr - outside IPv4 address of the remote host
1078     @param l_port - port number of the remote host (not used for ICMP)
1079     @param vrf_id - VRF id of tenant
1080     @param proto - protocol number
1081 */
1082 define nat64_st_details {
1083   u32 context;
1084   u8 il_addr[16];
1085   u8 ol_addr[4];
1086   u16 il_port;
1087   u16 ol_port;
1088   u8 ir_addr[16];
1089   u8 or_addr[4];
1090   u16 r_port;
1091   u32 vrf_id;
1092   u8 proto;
1093 };
1094
1095 /** \brief Add/del NAT64 prefix
1096     @param client_index - opaque cookie to identify the sender
1097     @param context - sender context, to match reply w/ request
1098     @param prefix - NAT64 prefix
1099     @param prefix - NAT64 prefix length
1100     @param vrf_id - VRF id of tenant
1101     @param is_add - 1 if add, 0 if delete
1102 */
1103 autoreply define nat64_add_del_prefix {
1104   u32 client_index;
1105   u32 context;
1106   u8 prefix[16];
1107   u8 prefix_len;
1108   u32 vrf_id;
1109   u8 is_add;
1110 };
1111
1112 /** \brief Dump NAT64 prefix
1113     @param client_index - opaque cookie to identify the sender
1114     @param context - sender context, to match reply w/ request
1115 */
1116 define nat64_prefix_dump {
1117   u32 client_index;
1118   u32 context;
1119 };
1120
1121 /** \brief Dump NAT64 prefix details response
1122     @param context - sender context, to match reply w/ request
1123     @param prefix - NAT64 prefix
1124     @param prefix - NAT64 prefix length
1125     @param vrf_id - VRF id of tenant
1126 */
1127 define nat64_prefix_details {
1128   u32 context;
1129   u8 prefix[16];
1130   u8 prefix_len;
1131   u32 vrf_id;
1132 };
1133
1134 /** \brief Add/delete NAT64 pool address from specific interfce
1135     @param client_index - opaque cookie to identify the sender
1136     @param context - sender context, to match reply w/ request
1137     @param is_add - 1 if add, 0 if delete
1138     @param sw_if_index - software index of the interface
1139 */
1140 autoreply define nat64_add_del_interface_addr {
1141   u32 client_index;
1142   u32 context;
1143   u8 is_add;
1144   u8 is_inside;
1145   u32 sw_if_index;
1146 };
1147
1148
1149 /*
1150  * DS-Lite APIs
1151  */
1152
1153 /** \brief Add/delete address range to DS-Lite pool
1154     @param client_index - opaque cookie to identify the sender
1155     @param context - sender context, to match reply w/ request
1156     @param start_addr - start address of the range
1157     @param end_addr - end address of the range
1158     @param is_add - 1 if add, 0 if delete
1159 */
1160 autoreply define dslite_add_del_pool_addr_range {
1161   u32 client_index;
1162   u32 context;
1163   u8 start_addr[4];
1164   u8 end_addr[4];
1165   u8 is_add;
1166 };
1167
1168 /** \brief Set AFTR IPv6 and IPv4 addresses
1169     @param client_index - opaque cookie to identify the sender
1170     @param context - sender context, to match reply w/ request
1171     @param ip4_addr - IPv4 address
1172     @param ip6_addr - IP64 address
1173 */
1174 autoreply define dslite_set_aftr_addr {
1175   u32 client_index;
1176   u32 context;
1177   u8 ip4_addr[4];
1178   u8 ip6_addr[16];
1179 };
1180
1181 /** \brief Get AFTR IPv6 and IPv4 addresses
1182     @param client_index - opaque cookie to identify the sender
1183     @param context - sender context, to match reply w/ request
1184 */
1185 define dslite_get_aftr_addr {
1186   u32 client_index;
1187   u32 context;
1188 };
1189
1190 /** \brief Response to get AFTR IPv6 and IPv4 addresses
1191     @param context - sender context, to match reply w/ request
1192     @param retval - return code
1193     @param ip4_addr - IPv4 address
1194     @param ip6_addr - IP64 address
1195 */
1196 define dslite_get_aftr_addr_reply {
1197   u32 context;
1198   i32 retval;
1199   u8 ip4_addr[4];
1200   u8 ip6_addr[16];
1201 };
1202
1203 /** \brief Set B4 IPv6 and IPv4 addresses
1204     @param client_index - opaque cookie to identify the sender
1205     @param context - sender context, to match reply w/ request
1206     @param ip4_addr - IPv4 address
1207     @param ip6_addr - IP64 address
1208 */
1209 autoreply define dslite_set_b4_addr {
1210   u32 client_index;
1211   u32 context;
1212   u8 ip4_addr[4];
1213   u8 ip6_addr[16];
1214 };
1215
1216 /** \brief Get B4 IPv6 and IPv4 addresses
1217     @param client_index - opaque cookie to identify the sender
1218     @param context - sender context, to match reply w/ request
1219 */
1220 define dslite_get_b4_addr {
1221   u32 client_index;
1222   u32 context;
1223 };
1224
1225 /** \brief Response to get B4 IPv6 and IPv4 addresses
1226     @param context - sender context, to match reply w/ request
1227     @param retval - return code
1228     @param ip4_addr - IPv4 address
1229     @param ip6_addr - IP64 address
1230 */
1231 define dslite_get_b4_addr_reply {
1232   u32 context;
1233   i32 retval;
1234   u8 ip4_addr[4];
1235   u8 ip6_addr[16];
1236 };