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