NAT: Twice NAT44 (VPP-969)
[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.1.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 */
356 autoreply define nat44_add_del_static_mapping {
357   u32 client_index;
358   u32 context;
359   u8 is_add;
360   u8 addr_only;
361   u8 local_ip_address[4];
362   u8 external_ip_address[4];
363   u8 protocol;
364   u16 local_port;
365   u16 external_port;
366   u32 external_sw_if_index;
367   u32 vrf_id;
368   u8 twice_nat;
369 };
370
371 /** \brief Dump NAT44 static mappings
372     @param client_index - opaque cookie to identify the sender
373     @param context - sender context, to match reply w/ request
374 */
375 define nat44_static_mapping_dump {
376   u32 client_index;
377   u32 context;
378 };
379
380 /** \brief NAT44 static mapping details response
381     @param context - sender context, to match reply w/ request
382     @param addr_only - 1 if address only mapping
383     @param local_ip_address - local IPv4 address
384     @param external_ip_address - external IPv4 address
385     @param protocol - IP protocol
386     @param local_port - local port number
387     @param external_port - external port number
388     @param external_sw_if_index - external interface
389     @param vfr_id - VRF ID
390     @param twice_nat - if 1 translate external host address and port
391 */
392 define nat44_static_mapping_details {
393   u32 context;
394   u8 addr_only;
395   u8 local_ip_address[4];
396   u8 external_ip_address[4];
397   u8 protocol;
398   u16 local_port;
399   u16 external_port;
400   u32 external_sw_if_index;
401   u32 vrf_id;
402   u8 twice_nat;
403 };
404
405 /** \brief Add/delete NAT44 identity mapping
406     @param client_index - opaque cookie to identify the sender
407     @param context - sender context, to match reply w/ request
408     @param is_add - 1 if add, 0 if delete
409     @param addr_only - 1 if address only mapping
410     @param ip_address - IPv4 address
411     @param protocol - IP protocol
412     @param port - port number
413     @param sw_if_index - interface (if set ip_address is ignored, ~0 means not
414                                     used)
415     @param vfr_id - VRF ID (if ~0 use default VRF)
416 */
417 autoreply define nat44_add_del_identity_mapping {
418   u32 client_index;
419   u32 context;
420   u8 is_add;
421   u8 addr_only;
422   u8 ip_address[4];
423   u8 protocol;
424   u16 port;
425   u32 sw_if_index;
426   u32 vrf_id;
427 };
428
429 /** \brief Dump NAT44 identity mappings
430     @param client_index - opaque cookie to identify the sender
431     @param context - sender context, to match reply w/ request
432 */
433 define nat44_identity_mapping_dump {
434   u32 client_index;
435   u32 context;
436 };
437
438 /** \brief NAT44 identity mapping details response
439     @param context - sender context, to match reply w/ request
440     @param addr_only - 1 if address only mapping
441     @param ip_address - IPv4 address
442     @param protocol - IP protocol
443     @param port - port number
444     @param sw_if_index - interface
445     @param vfr_id - VRF ID
446 */
447 define nat44_identity_mapping_details {
448   u32 context;
449   u8 addr_only;
450   u8 ip_address[4];
451   u8 protocol;
452   u16 port;
453   u32 sw_if_index;
454   u32 vrf_id;
455 };
456
457 /** \brief Add/delete NAT44 pool address from specific interfce
458     @param client_index - opaque cookie to identify the sender
459     @param context - sender context, to match reply w/ request
460     @param is_add - 1 if add, 0 if delete
461     @param twice_nat - twice NAT address for extenal hosts
462     @param sw_if_index - software index of the interface
463 */
464 autoreply define nat44_add_del_interface_addr {
465   u32 client_index;
466   u32 context;
467   u8 is_add;
468   u8 twice_nat;
469   u32 sw_if_index;
470 };
471
472 /** \brief Dump NAT44 pool addresses interfaces
473     @param client_index - opaque cookie to identify the sender
474     @param context - sender context, to match reply w/ request
475 */
476 define nat44_interface_addr_dump {
477   u32 client_index;
478   u32 context;
479 };
480
481 /** \brief NAT44 pool addresses interfaces details response
482     @param context - sender context, to match reply w/ request
483     @param sw_if_index - software index of the interface
484     @param twice_nat - twice NAT address for extenal hosts
485 */
486 define nat44_interface_addr_details {
487   u32 context;
488   u32 sw_if_index;
489   u8 twice_nat;
490 };
491
492 /** \brief Dump NAT44 users
493     @param client_index - opaque cookie to identify the sender
494     @param context - sender context, to match reply w/ request
495 */
496 define nat44_user_dump {
497   u32 client_index;
498   u32 context;
499 };
500
501 /** \brief NAT44 users response
502     @param context - sender context, to match reply w/ request
503     @vrf_id - VRF ID
504     @param ip_adress - IPv4 address
505     @param nsessions - number of dynamic sessions
506     @param nstaticsessions - number of static sessions
507 */
508 define nat44_user_details {
509   u32 context;
510   u32 vrf_id;
511   u8 ip_address[4];
512   u32 nsessions;
513   u32 nstaticsessions;
514 };
515
516 /** \brief NAT44 user's sessions
517     @param client_index - opaque cookie to identify the sender
518     @param context - sender context, to match reply w/ request
519     @param is_ip4 - 1 if address type is IPv4
520     @param user_ip - IP address of the user to dump
521     @param vrf_id - VRF_ID
522 */
523 define nat44_user_session_dump {
524   u32 client_index;
525   u32 context;
526   u8 ip_address[4];
527   u32 vrf_id;
528 };
529
530 /** \brief NAT44 user's sessions response
531     @param context - sender context, to match reply w/ request
532     @param outside_ip_address - outside IPv4 address
533     @param outside_port - outside port
534     @param inside_ip_address - inside IPv4 address
535     @param inside_port - inside port
536     @param protocol - protocol
537     @param is_static - 1 if session is static
538     @param last_heard - last heard timer
539     @param total_bytes - count of bytes sent through session
540     @param total_pkts - count of pakets sent through session
541 */
542 define nat44_user_session_details {
543   u32 context;
544   u8 outside_ip_address[4];
545   u16 outside_port;
546   u8 inside_ip_address[4];
547   u16 inside_port;
548   u16 protocol;
549   u8 is_static;
550   u64 last_heard;
551   u64 total_bytes;
552   u32 total_pkts;
553 };
554
555 typeonly manual_endian define nat44_lb_addr_port {
556   u8 addr[4];
557   u16 port;
558   u8 probability;
559 };
560
561 autoreply manual_endian define nat44_add_del_lb_static_mapping {
562   u32 client_index;
563   u32 context;
564   u8 is_add;
565   u8 external_addr[4];
566   u16 external_port;
567   u8 protocol;
568   u32 vrf_id;
569   u8 twice_nat;
570   u8 local_num;
571   vl_api_nat44_lb_addr_port_t locals[local_num];
572 };
573
574 define nat44_lb_static_mapping_dump {
575   u32 client_index;
576   u32 context;
577 };
578
579 manual_endian define nat44_lb_static_mapping_details {
580   u32 context;
581   u8 external_addr[4];
582   u16 external_port;
583   u8 protocol;
584   u32 vrf_id;
585   u8 twice_nat;
586   u8 local_num;
587   vl_api_nat44_lb_addr_port_t locals[local_num];
588 };
589
590 /** \brief Delete NAT44 session
591     @param client_index - opaque cookie to identify the sender
592     @param context - sender context, to match reply w/ request
593     @param is_in - 1 if inside network addres and port pari, 0 if outside
594     @param ip_address - IPv4 address
595     @param protocol - IP protocol
596     @param port - port number
597     @param vfr_id - VRF ID
598 */
599 autoreply define nat44_del_session {
600   u32 client_index;
601   u32 context;
602   u8 is_in;
603   u8 address[4];
604   u8 protocol;
605   u16 port;
606   u32 vrf_id;
607 };
608
609
610 /*
611  * Deterministic NAT (CGN) APIs
612  */
613
614 /** \brief Add/delete NAT deterministic mapping
615     @param client_index - opaque cookie to identify the sender
616     @param context - sender context, to match reply w/ request
617     @param is_add - 1 if add, 0 if delete
618     @param is_nat44 - 1 if NAT44
619     @param in_addr - inside IP address
620     @param in_plen - inside IP address prefix length
621     @param out_addr - outside IPv4 address
622     @param out_addr - outside IPv4 address prefix length
623 */
624 autoreply define nat_det_add_del_map {
625   u32 client_index;
626   u32 context;
627   u8 is_add;
628   u8 is_nat44;
629   u8 addr_only;
630   u8 in_addr[16];
631   u8 in_plen;
632   u8 out_addr[4];
633   u8 out_plen;
634 };
635
636 /** \brief Get outside address and port range from inside address
637     @param client_index - opaque cookie to identify the sender
638     @param context - sender context, to match reply w/ request
639     @param is_nat44 - 1 if NAT44
640     @param in_addr - inside IP address
641 */
642 define nat_det_forward {
643   u32 client_index;
644   u32 context;
645   u8 is_nat44;
646   u8 in_addr[16];
647 };
648
649 /** \brief Get outside address and port range from inside address
650     @param context - sender context, to match reply w/ request
651     @param retval - return code
652     @param out_port_lo - outside port range start
653     @param out_port_hi - outside port range end
654     @param out_addr - outside IPv4 address
655 */
656 define nat_det_forward_reply {
657   u32 context;
658   i32 retval;
659   u16 out_port_lo;
660   u16 out_port_hi;
661   u8 out_addr[4];
662 };
663
664 /** \brief Get inside address from outside address and port
665     @param client_index - opaque cookie to identify the sender
666     @param context - sender context, to match reply w/ request
667     @param out_port - outside port
668     @param out_addr - outside IPv4 address
669 */
670 define nat_det_reverse {
671   u32 client_index;
672   u32 context;
673   u16 out_port;
674   u8 out_addr[4];
675 };
676
677 /** \brief Get inside address from outside address and port reply
678     @param context - sender context, to match reply w/ request
679     @param retval - return code
680     @param is_nat44 - 1 if NAT44
681     @param in_addr - inside IP address
682 */
683 define nat_det_reverse_reply {
684   u32 context;
685   i32 retval;
686   u8 is_nat44;
687   u8 in_addr[16];
688 };
689
690 /** \brief Dump NAT deterministic mappings
691     @param client_index - opaque cookie to identify the sender
692     @param context - sender context, to match reply w/ request
693 */
694 define nat_det_map_dump {
695   u32 client_index;
696   u32 context;
697 };
698
699 /** \brief NAT users response
700     @param context - sender context, to match reply w/ request
701     @param is_nat44 - 1 if NAT44
702     @param in_addr - inside IP address
703     @param in_plen - inside IP address prefix length
704     @param out_addr - outside IPv4 address
705     @param out_plen - outside IPv4 address prefix length
706     @param sharing_ratio - outside to inside address sharing ratio
707     @param ports_per_host - number of ports available to a host
708     @param ses_num - number of sessions belonging to this mapping
709 */
710 define nat_det_map_details {
711   u32 context;
712   u8 is_nat44;
713   u8 in_addr[16];
714   u8 in_plen;
715   u8 out_addr[4];
716   u8 out_plen;
717   u32 sharing_ratio;
718   u16 ports_per_host;
719   u32 ses_num;
720 };
721
722 /** \brief Set values of timeouts for deterministic NAT (seconds, 0 = default)
723     @param client_index - opaque cookie to identify the sender
724     @param context - sender context, to match reply w/ request
725     @param udp - UDP timeout (default 300sec)
726     @param tcp_established - TCP established timeout (default 7440sec)
727     @param tcp_transitory - TCP transitory timeout (default 240sec)
728     @param icmp - ICMP timeout (default 60sec)
729 */
730 autoreply define nat_det_set_timeouts {
731   u32 client_index;
732   u32 context;
733   u32 udp;
734   u32 tcp_established;
735   u32 tcp_transitory;
736   u32 icmp;
737 };
738
739 /** \brief Get values of timeouts for deterministic NAT (seconds)
740     @param client_index - opaque cookie to identify the sender
741     @param context - sender context, to match reply w/ request
742 */
743 define nat_det_get_timeouts {
744   u32 client_index;
745   u32 context;
746 };
747
748 /** \brief Get values of timeouts for deterministic NAT reply
749     @param context - sender context, to match reply w/ request
750     @param retval - return code
751     @param udp - UDP timeout (default 300sec)
752     @param tcp_established - TCP established timeout (default 7440sec)
753     @param tcp_transitory - TCP transitory timeout (default 240sec)
754     @param icmp - ICMP timeout (default 60sec)
755 */
756 define nat_det_get_timeouts_reply {
757   u32 context;
758   i32 retval;
759   u32 udp;
760   u32 tcp_established;
761   u32 tcp_transitory;
762   u32 icmp;
763 };
764
765 /** \brief Close deterministic NAT session by outside address and port
766     @param client_index - opaque cookie to identify the sender
767     @param context - sender context, to match reply w/ request
768     @param out_addr - outside IPv4 address
769     @param out_port - outside port
770     @param ext_addr - external host IPv4 address
771     @param ext_port - external host port
772 */
773 autoreply define nat_det_close_session_out {
774   u32 client_index;
775   u32 context;
776   u8 out_addr[4];
777   u16 out_port;
778   u8 ext_addr[4];
779   u16 ext_port;
780 };
781
782 /** \brief Close deterministic NAT session by inside address and port
783     @param client_index - opaque cookie to identify the sender
784     @param context - sender context, to match reply w/ request
785     @param is_nat44 - 1 if NAT44
786     @param in_addr - inside IP address
787     @param in_port - inside port
788     @param ext_addr - external host IP address
789     @param ext_port - external host port
790 */
791 autoreply define nat_det_close_session_in {
792   u32 client_index;
793   u32 context;
794   u8 is_nat44;
795   u8 in_addr[16];
796   u16 in_port;
797   u8 ext_addr[16];
798   u16 ext_port;
799 };
800
801 /** \brief Dump determinstic NAT sessions
802     @param client_index - opaque cookie to identify the sender
803     @param context - sender context, to match reply w/ request
804     @param is_nat44 - 1 if NAT44
805     @param user_addr - address of an inside user whose sessions to dump
806 */
807 define nat_det_session_dump {
808   u32 client_index;
809   u32 context;
810   u8 is_nat44;
811   u8 user_addr[16];
812 };
813
814 /** \brief Deterministic NAT sessions reply
815     @param context - sender context, to match reply w/ request
816     @param in_port - inside port
817     @param ext_addr - external host address
818     @param ext_port - external host port
819     @param out_port - outside NAT port
820     @param state - session state
821     @param expire - session expiration timestamp
822 */
823 define nat_det_session_details {
824   u32 client_index;
825   u32 context;
826   u16 in_port;
827   u8 ext_addr[4];
828   u16 ext_port;
829   u16 out_port;
830   u8 state;
831   u32 expire;
832 };
833
834 /*
835  * NAT64 APIs
836  */
837
838 /** \brief Add/delete address range to NAT64 pool
839     @param client_index - opaque cookie to identify the sender
840     @param context - sender context, to match reply w/ request
841     @param start_addr - start address of the range
842     @param end_addr - end address of the range
843     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
844     @param is_add - 1 if add, 0 if delete
845 */
846 autoreply define nat64_add_del_pool_addr_range {
847   u32 client_index;
848   u32 context;
849   u8 start_addr[4];
850   u8 end_addr[4];
851   u32 vrf_id;
852   u8 is_add;
853 };
854
855 /** \brief Dump NAT64 pool addresses
856     @param client_index - opaque cookie to identify the sender
857     @param context - sender context, to match reply w/ request
858 */
859 define nat64_pool_addr_dump {
860   u32 client_index;
861   u32 context;
862 };
863
864 /** \brief NAT64 pool address details response
865     @param context - sender context, to match reply w/ request
866     @param address - IPv4 address
867     @param vfr_id - VRF id of tenant, ~0 means independent of VRF
868 */
869 define nat64_pool_addr_details {
870   u32 context;
871   u8 address[4];
872   u32 vrf_id;
873 };
874
875 /** \brief Enable/disable NAT64 feature on the interface
876     @param client_index - opaque cookie to identify the sender
877     @param context - sender context, to match reply w/ request
878     @param sw_if_index - index of the interface
879     @param is_inside - 1 if inside, 0 if outside
880     @param is_add - 1 if add, 0 if delete
881 */
882 autoreply define nat64_add_del_interface {
883   u32 client_index;
884   u32 context;
885   u32 sw_if_index;
886   u8 is_inside;
887   u8 is_add;
888 };
889
890 /** \brief Dump interfaces with NAT64 feature
891     @param client_index - opaque cookie to identify the sender
892     @param context - sender context, to match reply w/ request
893 */
894 define nat64_interface_dump {
895   u32 client_index;
896   u32 context;
897 };
898
899 /** \brief NAT64 interface details response
900     @param context - sender context, to match reply w/ request
901     @param is_inside - 1 if inside, 0 if outside
902     @param sw_if_index - index of the interface
903 */
904 define nat64_interface_details {
905   u32 context;
906   u8 is_inside;
907   u32 sw_if_index;
908 };
909
910 /** \brief Add/delete NAT64 static BIB entry
911     @param client_index - opaque cookie to identify the sender
912     @param context - sender context, to match reply w/ request
913     @param i_addr - inside IPv6 address
914     @param o_addr - outside IPv4 address
915     @param i_port - inside port number
916     @param o_port - outside port number
917     @param vrf_id - VRF id of tenant
918     @param proto - protocol number
919     @param is_add - 1 if add, 0 if delete
920 */
921  autoreply define nat64_add_del_static_bib {
922   u32 client_index;
923   u32 context;
924   u8 i_addr[16];
925   u8 o_addr[4];
926   u16 i_port;
927   u16 o_port;
928   u32 vrf_id;
929   u8 proto;
930   u8 is_add;
931 };
932
933 /** \brief Dump NAT64 BIB
934     @param client_index - opaque cookie to identify the sender
935     @param context - sender context, to match reply w/ request
936     @param proto - protocol of the BIB: 255 - all BIBs
937                                         6 - TCP BIB
938                                         17 - UDP BIB
939                                         1/58 - ICMP BIB
940                                         otherwise - "unknown" protocol BIB
941 */
942 define nat64_bib_dump {
943   u32 client_index;
944   u32 context;
945   u8 proto;
946 };
947
948 /** \brief NAT64 BIB details response
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_static - 1 if static BIB entry, 0 if dynamic
957     @param ses_num - number of sessions associated with the BIB entry
958 */
959 define nat64_bib_details {
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_static;
968   u32 ses_num;
969 };
970
971 /** \brief Set values of timeouts for NAT64 (seconds, 0 = default)
972     @param client_index - opaque cookie to identify the sender
973     @param context - sender context, to match reply w/ request
974     @param udp - UDP timeout (default 300sec)
975     @param icmp - ICMP timeout (default 60sec)
976     @param tcp_trans - TCP transitory timeout (default 240sec)
977     @param tcp_est - TCP established timeout (default 7440sec)
978     @param tcp_incoming_syn - TCP incoming SYN timeout (default 6sec)
979 */
980 autoreply define nat64_set_timeouts {
981   u32 client_index;
982   u32 context;
983   u32 udp;
984   u32 icmp;
985   u32 tcp_trans;
986   u32 tcp_est;
987   u32 tcp_incoming_syn;
988 };
989
990 /** \brief Get values of timeouts for NAT64 (seconds)
991     @param client_index - opaque cookie to identify the sender
992     @param context - sender context, to match reply w/ request
993 */
994 define nat64_get_timeouts {
995   u32 client_index;
996   u32 context;
997 };
998
999 /** \brief Get values of timeouts for NAT64 reply
1000     @param context - sender context, to match reply w/ request
1001     @param retval - return code
1002     @param udp - UDP timeout
1003     @param icmp - ICMP timeout
1004     @param tcp_trans - TCP transitory timeout
1005     @param tcp_est - TCP established timeout
1006     @param tcp_incoming_syn - TCP incoming SYN timeout
1007 */
1008 define nat64_get_timeouts_reply {
1009   u32 context;
1010   i32 retval;
1011   u32 udp;
1012   u32 icmp;
1013   u32 tcp_trans;
1014   u32 tcp_est;
1015   u32 tcp_incoming_syn;
1016 };
1017
1018 /** \brief Dump NAT64 session table
1019     @param client_index - opaque cookie to identify the sender
1020     @param context - sender context, to match reply w/ request
1021     @param proto - protocol of the session table: 255 - all STs
1022                                                   6 - TCP ST
1023                                                   17 - UDP ST
1024                                                   1/58 - ICMP ST
1025                                                   otherwise - "unknown" proto ST
1026 */
1027 define nat64_st_dump {
1028   u32 client_index;
1029   u32 context;
1030   u8 proto;
1031 };
1032
1033 /** \brief NAT64 session table details response
1034     @param context - sender context, to match reply w/ request
1035     @param il_addr - inside IPv6 address of the local host
1036     @param ol_addr - outside IPv4 address of the local host
1037     @param il_port - inside port number id of the local host/inside ICMP id
1038     @param ol_port - outside port number of the local host/outside ICMP id
1039     @param il_addr - inside IPv6 address of the remote host
1040     @param ol_addr - outside IPv4 address of the remote host
1041     @param l_port - port number of the remote host (not used for ICMP)
1042     @param vrf_id - VRF id of tenant
1043     @param proto - protocol number
1044 */
1045 define nat64_st_details {
1046   u32 context;
1047   u8 il_addr[16];
1048   u8 ol_addr[4];
1049   u16 il_port;
1050   u16 ol_port;
1051   u8 ir_addr[16];
1052   u8 or_addr[4];
1053   u16 r_port;
1054   u32 vrf_id;
1055   u8 proto;
1056 };
1057
1058 /** \brief Add/del NAT64 prefix
1059     @param client_index - opaque cookie to identify the sender
1060     @param context - sender context, to match reply w/ request
1061     @param prefix - NAT64 prefix
1062     @param prefix - NAT64 prefix length
1063     @param vrf_id - VRF id of tenant
1064     @param is_add - 1 if add, 0 if delete
1065 */
1066 autoreply define nat64_add_del_prefix {
1067   u32 client_index;
1068   u32 context;
1069   u8 prefix[16];
1070   u8 prefix_len;
1071   u32 vrf_id;
1072   u8 is_add;
1073 };
1074
1075 /** \brief Dump NAT64 prefix
1076     @param client_index - opaque cookie to identify the sender
1077     @param context - sender context, to match reply w/ request
1078 */
1079 define nat64_prefix_dump {
1080   u32 client_index;
1081   u32 context;
1082 };
1083
1084 /** \brief Dump NAT64 prefix details response
1085     @param context - sender context, to match reply w/ request
1086     @param prefix - NAT64 prefix
1087     @param prefix - NAT64 prefix length
1088     @param vrf_id - VRF id of tenant
1089 */
1090 define nat64_prefix_details {
1091   u32 context;
1092   u8 prefix[16];
1093   u8 prefix_len;
1094   u32 vrf_id;
1095 };
1096
1097 /** \brief Add/delete NAT64 pool address from specific interfce
1098     @param client_index - opaque cookie to identify the sender
1099     @param context - sender context, to match reply w/ request
1100     @param is_add - 1 if add, 0 if delete
1101     @param sw_if_index - software index of the interface
1102 */
1103 autoreply define nat64_add_del_interface_addr {
1104   u32 client_index;
1105   u32 context;
1106   u8 is_add;
1107   u8 is_inside;
1108   u32 sw_if_index;
1109 };
1110
1111
1112 /*
1113  * DS-Lite APIs
1114  */
1115
1116 /** \brief Add/delete address range to DS-Lite pool
1117     @param client_index - opaque cookie to identify the sender
1118     @param context - sender context, to match reply w/ request
1119     @param start_addr - start address of the range
1120     @param end_addr - end address of the range
1121     @param is_add - 1 if add, 0 if delete
1122 */
1123 autoreply define dslite_add_del_pool_addr_range {
1124   u32 client_index;
1125   u32 context;
1126   u8 start_addr[4];
1127   u8 end_addr[4];
1128   u8 is_add;
1129 };
1130
1131 autoreply define dslite_set_aftr_addr {
1132   u32 client_index;
1133   u32 context;
1134   u8 ip4_addr[4];
1135   u8 ip6_addr[16];
1136 };