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