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