NAT44: LB NAT - local backends in multiple VRFs (VPP-1345)
[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 option version = "3.0.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, used only if addr_only=0
347     @param local_port - local port number, used only if addr_only=0
348     @param external_port - external port number, used only if addr_only=0
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 self_twice_nat - if 1 translate external host address and port
356                             whenever external host address equals
357                             local address of internal host
358     @param out2in_only - if 1 rule match only out2in direction
359     @param tag - opaque string tag
360 */
361 autoreply define nat44_add_del_static_mapping {
362   u32 client_index;
363   u32 context;
364   u8 is_add;
365   u8 addr_only;
366   u8 local_ip_address[4];
367   u8 external_ip_address[4];
368   u8 protocol;
369   u16 local_port;
370   u16 external_port;
371   u32 external_sw_if_index;
372   u32 vrf_id;
373   u8 twice_nat;
374   u8 self_twice_nat;
375   u8 out2in_only;
376   u8 tag[64];
377 };
378
379 /** \brief Dump NAT44 static mappings
380     @param client_index - opaque cookie to identify the sender
381     @param context - sender context, to match reply w/ request
382 */
383 define nat44_static_mapping_dump {
384   u32 client_index;
385   u32 context;
386 };
387
388 /** \brief NAT44 static mapping details response
389     @param context - sender context, to match reply w/ request
390     @param addr_only - 1 if address only mapping
391     @param local_ip_address - local IPv4 address
392     @param external_ip_address - external IPv4 address
393     @param protocol - IP protocol, valid only if addr_only=0
394     @param local_port - local port number, valid only if addr_only=0
395     @param external_port - external port number, valid only if addr_only=0
396     @param external_sw_if_index - external interface
397     @param vfr_id - VRF ID
398     @param twice_nat - if 1 translate external host address and port
399     @param self_twice_nat - if 1 translate external host address and port
400                             whenever external host address equals
401                             local address of internal host
402     @param out2in_only - if 1 rule match only out2in direction
403     @param tag - opaque string tag
404 */
405 define nat44_static_mapping_details {
406   u32 context;
407   u8 addr_only;
408   u8 local_ip_address[4];
409   u8 external_ip_address[4];
410   u8 protocol;
411   u16 local_port;
412   u16 external_port;
413   u32 external_sw_if_index;
414   u32 vrf_id;
415   u8 twice_nat;
416   u8 self_twice_nat;
417   u8 out2in_only;
418   u8 tag[64];
419 };
420
421 /** \brief Add/delete NAT44 identity mapping
422     @param client_index - opaque cookie to identify the sender
423     @param context - sender context, to match reply w/ request
424     @param is_add - 1 if add, 0 if delete
425     @param addr_only - 1 if address only mapping
426     @param ip_address - IPv4 address
427     @param protocol - IP protocol
428     @param port - port number
429     @param sw_if_index - interface (if set ip_address is ignored, ~0 means not
430                                     used)
431     @param vfr_id - VRF ID (if ~0 use default VRF)
432     @param tag - opaque string tag
433 */
434 autoreply define nat44_add_del_identity_mapping {
435   u32 client_index;
436   u32 context;
437   u8 is_add;
438   u8 addr_only;
439   u8 ip_address[4];
440   u8 protocol;
441   u16 port;
442   u32 sw_if_index;
443   u32 vrf_id;
444   u8 tag[64];
445 };
446
447 /** \brief Dump NAT44 identity mappings
448     @param client_index - opaque cookie to identify the sender
449     @param context - sender context, to match reply w/ request
450 */
451 define nat44_identity_mapping_dump {
452   u32 client_index;
453   u32 context;
454 };
455
456 /** \brief NAT44 identity mapping details response
457     @param context - sender context, to match reply w/ request
458     @param addr_only - 1 if address only mapping
459     @param ip_address - IPv4 address
460     @param protocol - IP protocol
461     @param port - port number
462     @param sw_if_index - interface
463     @param vfr_id - VRF ID
464     @param tag - opaque string tag
465 */
466 define nat44_identity_mapping_details {
467   u32 context;
468   u8 addr_only;
469   u8 ip_address[4];
470   u8 protocol;
471   u16 port;
472   u32 sw_if_index;
473   u32 vrf_id;
474   u8 tag[64];
475 };
476
477 /** \brief Add/delete NAT44 pool address from specific interfce
478     @param client_index - opaque cookie to identify the sender
479     @param context - sender context, to match reply w/ request
480     @param is_add - 1 if add, 0 if delete
481     @param twice_nat - twice NAT address for extenal hosts
482     @param sw_if_index - software index of the interface
483 */
484 autoreply define nat44_add_del_interface_addr {
485   u32 client_index;
486   u32 context;
487   u8 is_add;
488   u8 twice_nat;
489   u32 sw_if_index;
490 };
491
492 /** \brief Dump NAT44 pool addresses interfaces
493     @param client_index - opaque cookie to identify the sender
494     @param context - sender context, to match reply w/ request
495 */
496 define nat44_interface_addr_dump {
497   u32 client_index;
498   u32 context;
499 };
500
501 /** \brief NAT44 pool addresses interfaces details response
502     @param context - sender context, to match reply w/ request
503     @param sw_if_index - software index of the interface
504     @param twice_nat - twice NAT address for extenal hosts
505 */
506 define nat44_interface_addr_details {
507   u32 context;
508   u32 sw_if_index;
509   u8 twice_nat;
510 };
511
512 /** \brief Dump NAT44 users
513     @param client_index - opaque cookie to identify the sender
514     @param context - sender context, to match reply w/ request
515 */
516 define nat44_user_dump {
517   u32 client_index;
518   u32 context;
519 };
520
521 /** \brief NAT44 users response
522     @param context - sender context, to match reply w/ request
523     @vrf_id - VRF ID
524     @param ip_adress - IPv4 address
525     @param nsessions - number of dynamic sessions
526     @param nstaticsessions - number of static sessions
527 */
528 define nat44_user_details {
529   u32 context;
530   u32 vrf_id;
531   u8 ip_address[4];
532   u32 nsessions;
533   u32 nstaticsessions;
534 };
535
536 /** \brief NAT44 user's sessions
537     @param client_index - opaque cookie to identify the sender
538     @param context - sender context, to match reply w/ request
539     @param is_ip4 - 1 if address type is IPv4
540     @param user_ip - IP address of the user to dump
541     @param vrf_id - VRF_ID
542 */
543 define nat44_user_session_dump {
544   u32 client_index;
545   u32 context;
546   u8 ip_address[4];
547   u32 vrf_id;
548 };
549
550 /** \brief NAT44 user's sessions response
551     @param context - sender context, to match reply w/ request
552     @param outside_ip_address - outside IPv4 address
553     @param outside_port - outside port
554     @param inside_ip_address - inside IPv4 address
555     @param inside_port - inside port
556     @param protocol - protocol
557     @param is_static - 1 if session is static
558     @param last_heard - last heard timer
559     @param total_bytes - count of bytes sent through session
560     @param total_pkts - count of pakets sent through session
561     @param is_twicenat - 1 if session is twice-nat
562     @param ext_host_valid - 1 if external host address and port are valid
563     @param ext_host_address - external host IPv4 address
564     @param ext_host_port - external host port
565     @param ext_host_nat_address - post-NAT external host IPv4 address (valid
566                                   only if twice-nat session)
567     @param ext_host_nat_port - post-NAT external host port (valid only if
568                                twice-nat session)
569 */
570 define nat44_user_session_details {
571   u32 context;
572   u8 outside_ip_address[4];
573   u16 outside_port;
574   u8 inside_ip_address[4];
575   u16 inside_port;
576   u16 protocol;
577   u8 is_static;
578   u64 last_heard;
579   u64 total_bytes;
580   u32 total_pkts;
581   u8 is_twicenat;
582   u8 ext_host_valid;
583   u8 ext_host_address[4];
584   u16 ext_host_port;
585   u8 ext_host_nat_address[4];
586   u16 ext_host_nat_port;
587 };
588
589 /** \brief NAT44 load-balancing address and port pair
590     @param addr - IPv4 address of the internal node
591     @param port - L4 port number of the internal node
592     @param probability - probability of the internal node to be randomly matched
593 */
594 typeonly manual_endian define nat44_lb_addr_port {
595   u8 addr[4];
596   u16 port;
597   u8 probability;
598   u32 vrf_id;
599 };
600
601 /** \brief Add/delete NAT44 load-balancing static mapping rule
602     @param client_index - opaque cookie to identify the sender
603     @param context - sender context, to match reply w/ request
604     @param is_add - 1 if add, 0 if delete
605     @param external_addr - external IPv4 address of the service
606     @param external_port - external L4 port number of the service
607     @param protocol - IP protocol number of the service
608     @param twice_nat - if 1 translate external host address and port
609     @param self_twice_nat - if 1 translate external host address and port
610                             whenever external host address equals
611                             local address of internal host
612     @param out2in_only - if 1 rule match only out2in direction
613     @param tag - opaque string tag
614     @param local_num - number of local network nodes
615     @param locals - local network nodes
616 */
617 autoreply manual_endian define nat44_add_del_lb_static_mapping {
618   u32 client_index;
619   u32 context;
620   u8 is_add;
621   u8 external_addr[4];
622   u16 external_port;
623   u8 protocol;
624   u8 twice_nat;
625   u8 self_twice_nat;
626   u8 out2in_only;
627   u8 tag[64];
628   u8 local_num;
629   vl_api_nat44_lb_addr_port_t locals[local_num];
630 };
631
632 /** \brief Dump NAT44 load-balancing static mapping rules
633     @param client_index - opaque cookie to identify the sender
634     @param context - sender context, to match reply w/ request
635 */
636 define nat44_lb_static_mapping_dump {
637   u32 client_index;
638   u32 context;
639 };
640
641 /** \brief NAT44 load-balancing static mapping rule details response
642     @param context - sender context, to match reply w/ request
643     @param is_add - 1 if add, 0 if delete
644     @param external_addr - external IPv4 address of the service
645     @param external_port - external L4 port number of the service
646     @param protocol - IP protocol number of the service
647     @param twice_nat - if 1 translate external host address and port
648     @param self_twice_nat - if 1 translate external host address and port
649                             whenever external host address equals
650                             local address of internal host
651     @param out2in_only - if 1 rule match only out2in direction
652     @param tag - opaque string tag
653     @param local_num - number of local network nodes
654     @param locals - local network nodes
655 */
656 manual_endian define nat44_lb_static_mapping_details {
657   u32 context;
658   u8 external_addr[4];
659   u16 external_port;
660   u8 protocol;
661   u8 twice_nat;
662   u8 self_twice_nat;
663   u8 out2in_only;
664   u8 tag[64];
665   u8 local_num;
666   vl_api_nat44_lb_addr_port_t locals[local_num];
667 };
668
669 /** \brief Delete NAT44 session
670     @param client_index - opaque cookie to identify the sender
671     @param context - sender context, to match reply w/ request
672     @param is_in - 1 if inside network addres and port pari, 0 if outside
673     @param ip_address - IPv4 address
674     @param protocol - IP protocol
675     @param port - port number
676     @param vfr_id - VRF ID
677     @param ext_host_valid - 1 if external host address and port are valid
678     @param ext_host_address - external host IPv4 address
679     @param ext_host_port - external host port
680 */
681 autoreply define nat44_del_session {
682   u32 client_index;
683   u32 context;
684   u8 is_in;
685   u8 address[4];
686   u8 protocol;
687   u16 port;
688   u32 vrf_id;
689   u8 ext_host_valid;
690   u8 ext_host_address[4];
691   u16 ext_host_port;
692 };
693
694 /** \brief Enable/disable forwarding for NAT44
695     Forward packets which don't match existing translation
696     or static mapping instead of dropping them.
697     @param client_index - opaque cookie to identify the sender
698     @param context - sender context, to match reply w/ request
699     @param enable - 0 for enable, 1 for disable
700 */
701 autoreply define nat44_forwarding_enable_disable {
702   u32 client_index;
703   u32 context;
704   u8 enable;
705 };
706
707 /** \brief Check if forwarding is enabled or disabled
708     @param client_index - opaque cookie to identify the sender
709     @param context - sender context, to match reply w/ request
710 */
711 define nat44_forwarding_is_enabled {
712   u32 client_index;
713   u32 context;
714 };
715
716 /** \brief Response to check if forwarding is enabled or disabled
717     @param context - sender context, to match reply w/ request
718     @param enabled - 1 if enabled, 0 if disabled
719 */
720 define nat44_forwarding_is_enabled_reply {
721   u32 context;
722   u8 enabled;
723 };
724
725
726 /*
727  * Deterministic NAT (CGN) APIs
728  */
729
730 /** \brief Add/delete NAT deterministic mapping
731     @param client_index - opaque cookie to identify the sender
732     @param context - sender context, to match reply w/ request
733     @param is_add - 1 if add, 0 if delete
734     @param is_nat44 - 1 if NAT44
735     @param in_addr - inside IP address
736     @param in_plen - inside IP address prefix length
737     @param out_addr - outside IPv4 address
738     @param out_addr - outside IPv4 address prefix length
739 */
740 autoreply define nat_det_add_del_map {
741   u32 client_index;
742   u32 context;
743   u8 is_add;
744   u8 is_nat44;
745   u8 addr_only;
746   u8 in_addr[16];
747   u8 in_plen;
748   u8 out_addr[4];
749   u8 out_plen;
750 };
751
752 /** \brief Get outside address and port range from inside address
753     @param client_index - opaque cookie to identify the sender
754     @param context - sender context, to match reply w/ request
755     @param is_nat44 - 1 if NAT44
756     @param in_addr - inside IP address
757 */
758 define nat_det_forward {
759   u32 client_index;
760   u32 context;
761   u8 is_nat44;
762   u8 in_addr[16];
763 };
764
765 /** \brief Get outside address and port range from inside address
766     @param context - sender context, to match reply w/ request
767     @param retval - return code
768     @param out_port_lo - outside port range start
769     @param out_port_hi - outside port range end
770     @param out_addr - outside IPv4 address
771 */
772 define nat_det_forward_reply {
773   u32 context;
774   i32 retval;
775   u16 out_port_lo;
776   u16 out_port_hi;
777   u8 out_addr[4];
778 };
779
780 /** \brief Get inside address from outside address and port
781     @param client_index - opaque cookie to identify the sender
782     @param context - sender context, to match reply w/ request
783     @param out_port - outside port
784     @param out_addr - outside IPv4 address
785 */
786 define nat_det_reverse {
787   u32 client_index;
788   u32 context;
789   u16 out_port;
790   u8 out_addr[4];
791 };
792
793 /** \brief Get inside address from outside address and port reply
794     @param context - sender context, to match reply w/ request
795     @param retval - return code
796     @param is_nat44 - 1 if NAT44
797     @param in_addr - inside IP address
798 */
799 define nat_det_reverse_reply {
800   u32 context;
801   i32 retval;
802   u8 is_nat44;
803   u8 in_addr[16];
804 };
805
806 /** \brief Dump NAT deterministic mappings
807     @param client_index - opaque cookie to identify the sender
808     @param context - sender context, to match reply w/ request
809 */
810 define nat_det_map_dump {
811   u32 client_index;
812   u32 context;
813 };
814
815 /** \brief NAT users response
816     @param context - sender context, to match reply w/ request
817     @param is_nat44 - 1 if NAT44
818     @param in_addr - inside IP address
819     @param in_plen - inside IP address prefix length
820     @param out_addr - outside IPv4 address
821     @param out_plen - outside IPv4 address prefix length
822     @param sharing_ratio - outside to inside address sharing ratio
823     @param ports_per_host - number of ports available to a host
824     @param ses_num - number of sessions belonging to this mapping
825 */
826 define nat_det_map_details {
827   u32 context;
828   u8 is_nat44;
829   u8 in_addr[16];
830   u8 in_plen;
831   u8 out_addr[4];
832   u8 out_plen;
833   u32 sharing_ratio;
834   u16 ports_per_host;
835   u32 ses_num;
836 };
837
838 /** \brief Set values of timeouts for deterministic NAT (seconds, 0 = default)
839     @param client_index - opaque cookie to identify the sender
840     @param context - sender context, to match reply w/ request
841     @param udp - UDP timeout (default 300sec)
842     @param tcp_established - TCP established timeout (default 7440sec)
843     @param tcp_transitory - TCP transitory timeout (default 240sec)
844     @param icmp - ICMP timeout (default 60sec)
845 */
846 autoreply define nat_det_set_timeouts {
847   u32 client_index;
848   u32 context;
849   u32 udp;
850   u32 tcp_established;
851   u32 tcp_transitory;
852   u32 icmp;
853 };
854
855 /** \brief Get values of timeouts for deterministic NAT (seconds)
856     @param client_index - opaque cookie to identify the sender
857     @param context - sender context, to match reply w/ request
858 */
859 define nat_det_get_timeouts {
860   u32 client_index;
861   u32 context;
862 };
863
864 /** \brief Get values of timeouts for deterministic NAT reply
865     @param context - sender context, to match reply w/ request
866     @param retval - return code
867     @param udp - UDP timeout (default 300sec)
868     @param tcp_established - TCP established timeout (default 7440sec)
869     @param tcp_transitory - TCP transitory timeout (default 240sec)
870     @param icmp - ICMP timeout (default 60sec)
871 */
872 define nat_det_get_timeouts_reply {
873   u32 context;
874   i32 retval;
875   u32 udp;
876   u32 tcp_established;
877   u32 tcp_transitory;
878   u32 icmp;
879 };
880
881 /** \brief Close deterministic NAT session by outside address and port
882     @param client_index - opaque cookie to identify the sender
883     @param context - sender context, to match reply w/ request
884     @param out_addr - outside IPv4 address
885     @param out_port - outside port
886     @param ext_addr - external host IPv4 address
887     @param ext_port - external host port
888 */
889 autoreply define nat_det_close_session_out {
890   u32 client_index;
891   u32 context;
892   u8 out_addr[4];
893   u16 out_port;
894   u8 ext_addr[4];
895   u16 ext_port;
896 };
897
898 /** \brief Close deterministic NAT session by inside address and port
899     @param client_index - opaque cookie to identify the sender
900     @param context - sender context, to match reply w/ request
901     @param is_nat44 - 1 if NAT44
902     @param in_addr - inside IP address
903     @param in_port - inside port
904     @param ext_addr - external host IP address
905     @param ext_port - external host port
906 */
907 autoreply define nat_det_close_session_in {
908   u32 client_index;
909   u32 context;
910   u8 is_nat44;
911   u8 in_addr[16];
912   u16 in_port;
913   u8 ext_addr[16];
914   u16 ext_port;
915 };
916
917 /** \brief Dump determinstic NAT sessions
918     @param client_index - opaque cookie to identify the sender
919     @param context - sender context, to match reply w/ request
920     @param is_nat44 - 1 if NAT44
921     @param user_addr - address of an inside user whose sessions to dump
922 */
923 define nat_det_session_dump {
924   u32 client_index;
925   u32 context;
926   u8 is_nat44;
927   u8 user_addr[16];
928 };
929
930 /** \brief Deterministic NAT sessions reply
931     @param context - sender context, to match reply w/ request
932     @param in_port - inside port
933     @param ext_addr - external host address
934     @param ext_port - external host port
935     @param out_port - outside NAT port
936     @param state - session state
937     @param expire - session expiration timestamp
938 */
939 define nat_det_session_details {
940   u32 client_index;
941   u32 context;
942   u16 in_port;
943   u8 ext_addr[4];
944   u16 ext_port;
945   u16 out_port;
946   u8 state;
947   u32 expire;
948 };
949
950 /*
951  * NAT64 APIs
952  */
953
954 /** \brief Add/delete address range to NAT64 pool
955     @param client_index - opaque cookie to identify the sender
956     @param context - sender context, to match reply w/ request
957     @param start_addr - start address of the range
958     @param end_addr - end address of the range
959     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
960     @param is_add - 1 if add, 0 if delete
961 */
962 autoreply define nat64_add_del_pool_addr_range {
963   u32 client_index;
964   u32 context;
965   u8 start_addr[4];
966   u8 end_addr[4];
967   u32 vrf_id;
968   u8 is_add;
969 };
970
971 /** \brief Dump NAT64 pool addresses
972     @param client_index - opaque cookie to identify the sender
973     @param context - sender context, to match reply w/ request
974 */
975 define nat64_pool_addr_dump {
976   u32 client_index;
977   u32 context;
978 };
979
980 /** \brief NAT64 pool address details response
981     @param context - sender context, to match reply w/ request
982     @param address - IPv4 address
983     @param vfr_id - VRF id of tenant, ~0 means independent of VRF
984 */
985 define nat64_pool_addr_details {
986   u32 context;
987   u8 address[4];
988   u32 vrf_id;
989 };
990
991 /** \brief Enable/disable NAT64 feature on the interface
992     @param client_index - opaque cookie to identify the sender
993     @param context - sender context, to match reply w/ request
994     @param sw_if_index - index of the interface
995     @param is_inside - 1 if inside, 0 if outside
996     @param is_add - 1 if add, 0 if delete
997 */
998 autoreply define nat64_add_del_interface {
999   u32 client_index;
1000   u32 context;
1001   u32 sw_if_index;
1002   u8 is_inside;
1003   u8 is_add;
1004 };
1005
1006 /** \brief Dump interfaces with NAT64 feature
1007     @param client_index - opaque cookie to identify the sender
1008     @param context - sender context, to match reply w/ request
1009 */
1010 define nat64_interface_dump {
1011   u32 client_index;
1012   u32 context;
1013 };
1014
1015 /** \brief NAT64 interface details response
1016     @param context - sender context, to match reply w/ request
1017     @param is_inside - 1 if inside, 0 if outside
1018     @param sw_if_index - index of the interface
1019 */
1020 define nat64_interface_details {
1021   u32 context;
1022   u8 is_inside;
1023   u32 sw_if_index;
1024 };
1025
1026 /** \brief Add/delete NAT64 static BIB entry
1027     @param client_index - opaque cookie to identify the sender
1028     @param context - sender context, to match reply w/ request
1029     @param i_addr - inside IPv6 address
1030     @param o_addr - outside IPv4 address
1031     @param i_port - inside port number
1032     @param o_port - outside port number
1033     @param vrf_id - VRF id of tenant
1034     @param proto - protocol number
1035     @param is_add - 1 if add, 0 if delete
1036 */
1037  autoreply define nat64_add_del_static_bib {
1038   u32 client_index;
1039   u32 context;
1040   u8 i_addr[16];
1041   u8 o_addr[4];
1042   u16 i_port;
1043   u16 o_port;
1044   u32 vrf_id;
1045   u8 proto;
1046   u8 is_add;
1047 };
1048
1049 /** \brief Dump NAT64 BIB
1050     @param client_index - opaque cookie to identify the sender
1051     @param context - sender context, to match reply w/ request
1052     @param proto - protocol of the BIB: 255 - all BIBs
1053                                         6 - TCP BIB
1054                                         17 - UDP BIB
1055                                         1/58 - ICMP BIB
1056                                         otherwise - "unknown" protocol BIB
1057 */
1058 define nat64_bib_dump {
1059   u32 client_index;
1060   u32 context;
1061   u8 proto;
1062 };
1063
1064 /** \brief NAT64 BIB details response
1065     @param context - sender context, to match reply w/ request
1066     @param i_addr - inside IPv6 address
1067     @param o_addr - outside IPv4 address
1068     @param i_port - inside port number
1069     @param o_port - outside port number
1070     @param vrf_id - VRF id of tenant
1071     @param proto - protocol number
1072     @param is_static - 1 if static BIB entry, 0 if dynamic
1073     @param ses_num - number of sessions associated with the BIB entry
1074 */
1075 define nat64_bib_details {
1076   u32 context;
1077   u8 i_addr[16];
1078   u8 o_addr[4];
1079   u16 i_port;
1080   u16 o_port;
1081   u32 vrf_id;
1082   u8 proto;
1083   u8 is_static;
1084   u32 ses_num;
1085 };
1086
1087 /** \brief Set values of timeouts for NAT64 (seconds, 0 = default)
1088     @param client_index - opaque cookie to identify the sender
1089     @param context - sender context, to match reply w/ request
1090     @param udp - UDP timeout (default 300sec)
1091     @param icmp - ICMP timeout (default 60sec)
1092     @param tcp_trans - TCP transitory timeout (default 240sec)
1093     @param tcp_est - TCP established timeout (default 7440sec)
1094     @param tcp_incoming_syn - TCP incoming SYN timeout (default 6sec)
1095 */
1096 autoreply define nat64_set_timeouts {
1097   u32 client_index;
1098   u32 context;
1099   u32 udp;
1100   u32 icmp;
1101   u32 tcp_trans;
1102   u32 tcp_est;
1103   u32 tcp_incoming_syn;
1104 };
1105
1106 /** \brief Get values of timeouts for NAT64 (seconds)
1107     @param client_index - opaque cookie to identify the sender
1108     @param context - sender context, to match reply w/ request
1109 */
1110 define nat64_get_timeouts {
1111   u32 client_index;
1112   u32 context;
1113 };
1114
1115 /** \brief Get values of timeouts for NAT64 reply
1116     @param context - sender context, to match reply w/ request
1117     @param retval - return code
1118     @param udp - UDP timeout
1119     @param icmp - ICMP timeout
1120     @param tcp_trans - TCP transitory timeout
1121     @param tcp_est - TCP established timeout
1122     @param tcp_incoming_syn - TCP incoming SYN timeout
1123 */
1124 define nat64_get_timeouts_reply {
1125   u32 context;
1126   i32 retval;
1127   u32 udp;
1128   u32 icmp;
1129   u32 tcp_trans;
1130   u32 tcp_est;
1131   u32 tcp_incoming_syn;
1132 };
1133
1134 /** \brief Dump NAT64 session table
1135     @param client_index - opaque cookie to identify the sender
1136     @param context - sender context, to match reply w/ request
1137     @param proto - protocol of the session table: 255 - all STs
1138                                                   6 - TCP ST
1139                                                   17 - UDP ST
1140                                                   1/58 - ICMP ST
1141                                                   otherwise - "unknown" proto ST
1142 */
1143 define nat64_st_dump {
1144   u32 client_index;
1145   u32 context;
1146   u8 proto;
1147 };
1148
1149 /** \brief NAT64 session table details response
1150     @param context - sender context, to match reply w/ request
1151     @param il_addr - inside IPv6 address of the local host
1152     @param ol_addr - outside IPv4 address of the local host
1153     @param il_port - inside port number id of the local host/inside ICMP id
1154     @param ol_port - outside port number of the local host/outside ICMP id
1155     @param il_addr - inside IPv6 address of the remote host
1156     @param ol_addr - outside IPv4 address of the remote host
1157     @param l_port - port number of the remote host (not used for ICMP)
1158     @param vrf_id - VRF id of tenant
1159     @param proto - protocol number
1160 */
1161 define nat64_st_details {
1162   u32 context;
1163   u8 il_addr[16];
1164   u8 ol_addr[4];
1165   u16 il_port;
1166   u16 ol_port;
1167   u8 ir_addr[16];
1168   u8 or_addr[4];
1169   u16 r_port;
1170   u32 vrf_id;
1171   u8 proto;
1172 };
1173
1174 /** \brief Add/del NAT64 prefix
1175     @param client_index - opaque cookie to identify the sender
1176     @param context - sender context, to match reply w/ request
1177     @param prefix - NAT64 prefix
1178     @param prefix - NAT64 prefix length
1179     @param vrf_id - VRF id of tenant
1180     @param is_add - 1 if add, 0 if delete
1181 */
1182 autoreply define nat64_add_del_prefix {
1183   u32 client_index;
1184   u32 context;
1185   u8 prefix[16];
1186   u8 prefix_len;
1187   u32 vrf_id;
1188   u8 is_add;
1189 };
1190
1191 /** \brief Dump NAT64 prefix
1192     @param client_index - opaque cookie to identify the sender
1193     @param context - sender context, to match reply w/ request
1194 */
1195 define nat64_prefix_dump {
1196   u32 client_index;
1197   u32 context;
1198 };
1199
1200 /** \brief Dump NAT64 prefix details response
1201     @param context - sender context, to match reply w/ request
1202     @param prefix - NAT64 prefix
1203     @param prefix - NAT64 prefix length
1204     @param vrf_id - VRF id of tenant
1205 */
1206 define nat64_prefix_details {
1207   u32 context;
1208   u8 prefix[16];
1209   u8 prefix_len;
1210   u32 vrf_id;
1211 };
1212
1213 /** \brief Add/delete NAT64 pool address from specific interfce
1214     @param client_index - opaque cookie to identify the sender
1215     @param context - sender context, to match reply w/ request
1216     @param is_add - 1 if add, 0 if delete
1217     @param sw_if_index - software index of the interface
1218 */
1219 autoreply define nat64_add_del_interface_addr {
1220   u32 client_index;
1221   u32 context;
1222   u8 is_add;
1223   u8 is_inside;
1224   u32 sw_if_index;
1225 };
1226
1227
1228 /*
1229  * DS-Lite APIs
1230  */
1231
1232 /** \brief Add/delete address range to DS-Lite pool
1233     @param client_index - opaque cookie to identify the sender
1234     @param context - sender context, to match reply w/ request
1235     @param start_addr - start address of the range
1236     @param end_addr - end address of the range
1237     @param is_add - 1 if add, 0 if delete
1238 */
1239 autoreply define dslite_add_del_pool_addr_range {
1240   u32 client_index;
1241   u32 context;
1242   u8 start_addr[4];
1243   u8 end_addr[4];
1244   u8 is_add;
1245 };
1246
1247 /** \brief Dump DS-Lite addresses
1248     @param client_index - opaque cookie to identify the sender
1249     @param context - sender context, to match reply w/ request
1250 */
1251 define dslite_address_dump {
1252   u32 client_index;
1253   u32 context;
1254 };
1255
1256 /** \brief DS-Lite address details response
1257     @param context - sender context, to match reply w/ request
1258     @param ip_address - IPv4 address
1259 */
1260 define dslite_address_details {
1261   u32 context;
1262   u8 ip_address[4];
1263 };
1264
1265 /** \brief Set AFTR IPv6 and IPv4 addresses
1266     @param client_index - opaque cookie to identify the sender
1267     @param context - sender context, to match reply w/ request
1268     @param ip4_addr - IPv4 address
1269     @param ip6_addr - IP64 address
1270 */
1271 autoreply define dslite_set_aftr_addr {
1272   u32 client_index;
1273   u32 context;
1274   u8 ip4_addr[4];
1275   u8 ip6_addr[16];
1276 };
1277
1278 /** \brief Get AFTR IPv6 and IPv4 addresses
1279     @param client_index - opaque cookie to identify the sender
1280     @param context - sender context, to match reply w/ request
1281 */
1282 define dslite_get_aftr_addr {
1283   u32 client_index;
1284   u32 context;
1285 };
1286
1287 /** \brief Response to get AFTR IPv6 and IPv4 addresses
1288     @param context - sender context, to match reply w/ request
1289     @param retval - return code
1290     @param ip4_addr - IPv4 address
1291     @param ip6_addr - IP64 address
1292 */
1293 define dslite_get_aftr_addr_reply {
1294   u32 context;
1295   i32 retval;
1296   u8 ip4_addr[4];
1297   u8 ip6_addr[16];
1298 };
1299
1300 /** \brief Set B4 IPv6 and IPv4 addresses
1301     @param client_index - opaque cookie to identify the sender
1302     @param context - sender context, to match reply w/ request
1303     @param ip4_addr - IPv4 address
1304     @param ip6_addr - IP64 address
1305 */
1306 autoreply define dslite_set_b4_addr {
1307   u32 client_index;
1308   u32 context;
1309   u8 ip4_addr[4];
1310   u8 ip6_addr[16];
1311 };
1312
1313 /** \brief Get B4 IPv6 and IPv4 addresses
1314     @param client_index - opaque cookie to identify the sender
1315     @param context - sender context, to match reply w/ request
1316 */
1317 define dslite_get_b4_addr {
1318   u32 client_index;
1319   u32 context;
1320 };
1321
1322 /** \brief Response to get B4 IPv6 and IPv4 addresses
1323     @param context - sender context, to match reply w/ request
1324     @param retval - return code
1325     @param ip4_addr - IPv4 address
1326     @param ip6_addr - IP64 address
1327 */
1328 define dslite_get_b4_addr_reply {
1329   u32 context;
1330   i32 retval;
1331   u8 ip4_addr[4];
1332   u8 ip6_addr[16];
1333 };
1334
1335 /*
1336  * NAT66 APIs
1337  */
1338 /** \brief Enable/disable NAT66 feature on the interface
1339     @param client_index - opaque cookie to identify the sender
1340     @param context - sender context, to match reply w/ request
1341     @param is_add - 1 if add, 0 if delete
1342     @param is_inside - 1 if inside, 0 if outside
1343     @param sw_if_index - software index of the interface
1344 */
1345 autoreply define nat66_add_del_interface {
1346   u32 client_index;
1347   u32 context;
1348   u8 is_add;
1349   u8 is_inside;
1350   u32 sw_if_index;
1351 };
1352
1353 /** \brief Dump interfaces with NAT66 feature
1354     @param client_index - opaque cookie to identify the sender
1355     @param context - sender context, to match reply w/ request
1356 */
1357 define nat66_interface_dump {
1358   u32 client_index;
1359   u32 context;
1360 };
1361
1362 /** \brief NAT66 interface details response
1363     @param context - sender context, to match reply w/ request
1364     @param is_inside - 1 if inside, 0 if outside
1365     @param sw_if_index - software index of the interface
1366 */
1367 define nat66_interface_details {
1368   u32 context;
1369   u8 is_inside;
1370   u32 sw_if_index;
1371 };
1372
1373 /** \brief Add/delete 1:1 NAT66
1374     @param client_index - opaque cookie to identify the sender
1375     @param context - sender context, to match reply w/ request
1376     @param is_add - 1 if add, 0 if delete
1377     @param local_ip_address - local IPv6 address
1378     @param external_ip_address - external IPv6 address
1379     @param vrf_id - VRF id of tenant
1380 */
1381 autoreply define nat66_add_del_static_mapping {
1382   u32 client_index;
1383   u32 context;
1384   u8 is_add;
1385   u8 local_ip_address[16];
1386   u8 external_ip_address[16];
1387   u32 vrf_id;
1388 };
1389
1390 /** \brief Dump NAT66 static mappings
1391     @param client_index - opaque cookie to identify the sender
1392     @param context - sender context, to match reply w/ request
1393 */
1394 define nat66_static_mapping_dump {
1395   u32 client_index;
1396   u32 context;
1397 };
1398
1399 /** \brief NAT66 static mapping details response
1400     @param context - sender context, to match reply w/ request
1401     @param local_ip_address - local IPv6 address
1402     @param external_ip_address - external IPv6 address
1403     @param vrf_id - VRF id of tenant
1404     @param total_bytes - count of bytes sent through static mapping
1405     @param total_pkts - count of pakets sent through static mapping
1406 */
1407 define nat66_static_mapping_details {
1408   u32 context;
1409   u8 local_ip_address[16];
1410   u8 external_ip_address[16];
1411   u32 vrf_id;
1412   u64 total_bytes;
1413   u64 total_pkts;
1414 };