nat: fix type in api message
[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 = "5.2.0";
17 import "vnet/ip/ip_types.api";
18 import "vnet/interface_types.api";
19 import "plugins/nat/nat_types.api";
20
21 /**
22  * @file nat.api
23  * @brief VPP control-plane API messages.
24  *
25  * This file defines VPP control-plane API messages which are generally
26  * called through a shared memory interface.
27  */
28
29 /*
30  * Common NAT plugin APIs
31  */
32
33 /** \brief Control ping from client to api server request
34     @param client_index - opaque cookie to identify the sender
35     @param context - sender context, to match reply w/ request
36 */
37 define nat_control_ping
38 {
39   u32 client_index;
40   u32 context;
41 };
42
43 /** \brief Control ping from the client to the server response
44     @param client_index - opaque cookie to identify the sender
45     @param context - sender context, to match reply w/ request
46     @param retval - return code for the request
47     @param vpe_pid - the pid of the vpe, returned by the server
48 */
49 define nat_control_ping_reply
50 {
51   u32 context;
52   i32 retval;
53   u32 client_index;
54   u32 vpe_pid;
55 };
56
57 /** \brief Show NAT plugin startup config
58     @param client_index - opaque cookie to identify the sender
59     @param context - sender context, to match reply w/ request
60 */
61 define nat_show_config
62 {
63   option deprecated;
64   u32 client_index;
65   u32 context;
66 };
67
68 /** \brief DEPRECATED: Show NAT plugin startup config reply
69     @param context - sender context, to match reply w/ request
70     @param retval - return code for the request
71     @param static_mapping_only - if true dynamic translations disabled
72     @param static_mapping_connection_tracking - if true create session data
73     @param deterministic - if true deterministic mapping
74     @param endpoint_dependent - if true endpoint-dependent mode
75     @param out2in_dpo - if true out2in dpo mode
76     @param dslite_ce - if true DS-Lite is CE/B4 element, if false AFTR elemet
77     @param translation_buckets - number of translation hash buckets
78     @param translation_memory_size - translation hash memory size
79     @param user_buckets - number of user hash buckets
80     @param user_memory_size - user hash memory size
81     @param max_translations_per_user - maximum number of translations per user
82     @param outside_vrf_id - outside VRF id
83     @param inside_vrf_id - default inside VRF id
84     @param nat64_bib_buckets - number of NAT64 BIB hash buckets
85     @param nat64_bib_memory_size - memory size of NAT64 BIB hash
86     @param nat64_st_buckets - number of NAT64 session table hash buckets
87     @param nat64_st_memory_size - memory size of NAT64 session table hash
88 */
89 define nat_show_config_reply
90 {
91   u32 context;
92   i32 retval;
93   bool static_mapping_only;
94   bool static_mapping_connection_tracking;
95   bool deterministic;
96   bool endpoint_dependent;
97   bool out2in_dpo;
98   bool dslite_ce;
99   u32 translation_buckets;
100   u32 translation_memory_size;
101   u32 user_buckets;
102   u64 user_memory_size;
103   u32 max_translations_per_user;
104   u32 outside_vrf_id;
105   u32 inside_vrf_id;
106   u32 nat64_bib_buckets;
107   u64 nat64_bib_memory_size;
108   u32 nat64_st_buckets;
109   u64 nat64_st_memory_size;
110 };
111
112 /** \brief Show NAT plugin startup config
113     @param client_index - opaque cookie to identify the sender
114     @param context - sender context, to match reply w/ request
115 */
116 define nat_show_config_2
117 {
118   u32 client_index;
119   u32 context;
120 };
121
122 /** \brief Show NAT plugin startup config reply
123     @param context - sender context, to match reply w/ request
124     @param retval - return code for the request
125     @param static_mapping_only - if true dynamic translations disabled
126     @param static_mapping_connection_tracking - if true create session data
127     @param deterministic - if true deterministic mapping
128     @param endpoint_dependent - if true endpoint-dependent mode
129     @param out2in_dpo - if true out2in dpo mode
130     @param dslite_ce - if true DS-Lite is CE/B4 element, if false AFTR elemet
131     @param translation_buckets - number of translation hash buckets
132     @param translation_memory_size - translation hash memory size
133     @param user_buckets - number of user hash buckets
134     @param user_memory_size - user hash memory size
135     @param max_translations_per_user - maximum number of translations per user
136     @param outside_vrf_id - outside VRF id
137     @param inside_vrf_id - default inside VRF id
138     @param nat64_bib_buckets - number of NAT64 BIB hash buckets
139     @param nat64_bib_memory_size - memory size of NAT64 BIB hash
140     @param nat64_st_buckets - number of NAT64 session table hash buckets
141     @param nat64_st_memory_size - memory size of NAT64 session table hash
142     @param max_translations_per_thread - max translations per worker thread
143     @param max_users_per_thread - max users per worker thread
144 */
145 define nat_show_config_2_reply
146 {
147   u32 context;
148   i32 retval;
149   bool static_mapping_only;
150   bool static_mapping_connection_tracking;
151   bool deterministic;
152   bool endpoint_dependent;
153   bool out2in_dpo;
154   bool dslite_ce;
155   u32 translation_buckets;
156   u64 translation_memory_size;
157   u32 user_buckets;
158   u64 user_memory_size;
159   u32 max_translations_per_user;
160   u32 outside_vrf_id;
161   u32 inside_vrf_id;
162   u32 nat64_bib_buckets;
163   u64 nat64_bib_memory_size;
164   u32 nat64_st_buckets;
165   u64 nat64_st_memory_size;
166   u32 max_translations_per_thread;
167   u32 max_users_per_thread;
168 };
169
170 enum nat_log_level : u8
171 {
172   NAT_LOG_NONE = 0x00,
173   NAT_LOG_ERROR = 0x01,
174   NAT_LOG_WARNING = 0x02,
175   NAT_LOG_NOTICE = 0x03,
176   NAT_LOG_INFO = 0x04,
177   NAT_LOG_DEBUG = 0x05,
178 };
179
180 /** \brief Run nat44 garbage collection
181     @param client_index - opaque cookie to identify the sender
182     @param context - sender context, to match reply w/ request
183 */
184 autoreply define nat44_session_cleanup {
185   u32 client_index;
186   u32 context;
187 };
188
189 /** \brief NAT44 set session limit
190     @param client_index - opaque cookie to identify the sender
191     @param context - sender context, to match reply w/ request
192     @param session_limit - session limit
193     @param vrf_id - vrf id
194 */
195 autoreply define nat44_set_session_limit {
196   u32 client_index;
197   u32 context;
198   u32 session_limit;
199   u32 vrf_id;
200 };
201
202 /** \brief Set NAT logging level
203     @param client_index - opaque cookie to identify the sender
204     @param context - sender context, to match reply w/ request
205     @param log_level - logging level
206 */
207 autoreply define nat_set_log_level {
208   u32 client_index;
209   u32 context;
210   vl_api_nat_log_level_t log_level;
211 };
212
213 /** \brief Set NAT workers
214     @param client_index - opaque cookie to identify the sender
215     @param context - sender context, to match reply w/ request
216     @param worker_mask - NAT workers mask
217 */
218 autoreply define nat_set_workers {
219   u32 client_index;
220   u32 context;
221   u64 worker_mask;
222 };
223
224 /** \brief Dump NAT workers
225     @param client_index - opaque cookie to identify the sender
226     @param context - sender context, to match reply w/ request
227 */
228 define nat_worker_dump {
229   u32 client_index;
230   u32 context;
231 };
232
233 /** \brief NAT workers details response
234     @param context - sender context, to match reply w/ request
235     @param worker_index - worker index
236     @param lcore_id - lcore ID
237     @param name - worker name
238 */
239 define nat_worker_details {
240   u32 context;
241   u32 worker_index;
242   u32 lcore_id;
243   string name[64];
244 };
245
246 /** \brief Enable/disable NAT IPFIX logging
247     @param client_index - opaque cookie to identify the sender
248     @param context - sender context, to match reply w/ request
249     @param domain_id - observation domain ID
250     @param src_port - source port number
251     @param enable - true if enable, false if disable
252 */
253 autoreply define nat_ipfix_enable_disable {
254   u32 client_index;
255   u32 context;
256   u32 domain_id;
257   u16 src_port;
258   bool enable;
259 };
260
261 /** \brief Set values of timeouts for NAT sessions (seconds)
262     @param client_index - opaque cookie to identify the sender
263     @param context - sender context, to match reply w/ request
264     @param udp - UDP timeout (default 300sec)
265     @param tcp_established - TCP established timeout (default 7440sec)
266     @param tcp_transitory - TCP transitory timeout (default 240sec)
267     @param icmp - ICMP timeout (default 60sec)
268 */
269 autoreply define nat_set_timeouts {
270   u32 client_index;
271   u32 context;
272   u32 udp;
273   u32 tcp_established;
274   u32 tcp_transitory;
275   u32 icmp;
276 };
277
278 /** \brief Get values of timeouts for NAT sessions (seconds)
279     @param client_index - opaque cookie to identify the sender
280     @param context - sender context, to match reply w/ request
281 */
282 define nat_get_timeouts {
283   u32 client_index;
284   u32 context;
285 };
286
287 /** \brief Get values of timeouts for NAT sessions reply
288     @param context - sender context, to match reply w/ request
289     @param retval - return code
290     @param udp - UDP timeout
291     @param tcp_established - TCP established timeout
292     @param tcp_transitory - TCP transitory timeout
293     @param icmp - ICMP timeout
294 */
295 define nat_get_timeouts_reply {
296   u32 context;
297   i32 retval;
298   u32 udp;
299   u32 tcp_established;
300   u32 tcp_transitory;
301   u32 icmp;
302 };
303
304 /** \brief Set address and port assignment algorithm
305     @param client_index - opaque cookie to identify the sender
306     @param context - sender context, to match reply w/ request
307     @param alg - address and port assignment algorithm:
308                  0 - default, 1 - MAP-E, 2 - port range
309                  (see nat_addr_and_port_alloc_alg_t in nat.h)
310     @param psid_offset - number of offset bits (valid only for MAP-E alg)
311     @param psid_length - length of PSID (valid only for MAP-E alg)
312     @param psid - Port Set Identifier (PSID) value (valid only for MAP-E alg)
313     @param start_port - beginning of the port range
314     @param end_port - end of the port range
315 */
316 autoreply define nat_set_addr_and_port_alloc_alg {
317   u32 client_index;
318   u32 context;
319   u8 alg;
320   u8 psid_offset;
321   u8 psid_length;
322   u16 psid;
323   u16 start_port;
324   u16 end_port;
325 };
326
327 /** \brief Get address and port assignment algorithm
328     @param client_index - opaque cookie to identify the sender
329     @param context - sender context, to match reply w/ request
330 */
331 define nat_get_addr_and_port_alloc_alg {
332   u32 client_index;
333   u32 context;
334 };
335
336 /** \brief Get address and port assignment algorithm reply
337     @param context - sender context, to match reply w/ request
338     @param retval - return code
339     @param alg - address and port assignment algorithm:
340                  0 - default, 1 - MAP-E, 2 - port range
341                  (see nat_addr_and_port_alloc_alg_t in nat.h)
342     @param psid_offset - number of offset bits (valid only for MAP-E alg)
343     @param psid_length - length of PSID (valid only for MAP-E alg)
344     @param psid - Port Set Identifier (PSID) value (valid only for MAP-E alg)
345     @param start_port - beginning of the port range
346     @param end_port - end of the port range
347 */
348 define nat_get_addr_and_port_alloc_alg_reply {
349   u32 context;
350   i32 retval;
351   u8 alg;
352   u8 psid_offset;
353   u8 psid_length;
354   u16 psid;
355   u16 start_port;
356   u16 end_port;
357 };
358
359 /** \brief Set TCP MSS rewriting configuration
360     @param client_index - opaque cookie to identify the sender
361     @param context - sender context, to match reply w/ request
362     @param mss_value - MSS value to be used for MSS rewriting
363     @param enable - if true enable MSS rewriting feature else disable
364 */
365 autoreply define nat_set_mss_clamping {
366   u32 client_index;
367   u32 context;
368   u16 mss_value;
369   bool enable;
370 };
371
372 /** \brief Get TCP MSS rewriting configuration
373     @param client_index - opaque cookie to identify the sender
374     @param context - sender context, to match reply w/ request
375 */
376 define nat_get_mss_clamping {
377   u32 client_index;
378   u32 context;
379 };
380
381 /** \brief Get TCP MSS rewriting configuration reply
382     @param context - sender context, to match reply w/ request
383     @param retval - return code
384     @param mss_value - MSS value to be used for MSS rewriting
385     @param enable - if true enable MSS rewriting feature else disable
386 */
387 define nat_get_mss_clamping_reply {
388   u32 context;
389   i32 retval;
390   u16 mss_value;
391   bool enable;
392 };
393
394 /** \brief Set HA listener (local settings)
395     @param client_index - opaque cookie to identify the sender
396     @param context - sender context, to match reply w/ request
397     @param ip_address - local IP4 address
398     @param port - local UDP port number
399     @param path_mtu - path MTU between local and failover
400 */
401 autoreply define nat_ha_set_listener {
402   u32 client_index;
403   u32 context;
404   vl_api_ip4_address_t ip_address;
405   u16 port;
406   u32 path_mtu;
407 };
408
409 /** \brief Set HA failover (remote settings)
410     @param client_index - opaque cookie to identify the sender
411     @param context - sender context, to match reply w/ request
412     @param ip_address - failover IP4 address
413     @param port - failvoer UDP port number
414     @param session_refresh_interval - number of seconds after which to send
415                                       session counters refresh
416 */
417 autoreply define nat_ha_set_failover {
418   u32 client_index;
419   u32 context;
420   vl_api_ip4_address_t ip_address;
421   u16 port;
422   u32 session_refresh_interval;
423 };
424
425 /** \brief Get HA listener/local configuration
426     @param client_index - opaque cookie to identify the sender
427     @param context - sender context, to match reply w/ request
428 */
429 define nat_ha_get_listener {
430   u32 client_index;
431   u32 context;
432 };
433
434 /** \brief Get HA listener/local configuration reply
435     @param context - sender context, to match reply w/ request
436     @param retval - return code
437     @param ip_address - local IP4 address
438     @param port - local UDP port number
439     @param path_mtu - Path MTU between local and failover
440 */
441 define nat_ha_get_listener_reply {
442   u32 context;
443   i32 retval;
444   vl_api_ip4_address_t ip_address;
445   u16 port;
446   u32 path_mtu;
447 };
448
449 /** \brief Get HA failover/remote settings
450     @param client_index - opaque cookie to identify the sender
451     @param context - sender context, to match reply w/ request
452 */
453 define nat_ha_get_failover {
454   u32 client_index;
455   u32 context;
456 };
457
458 /** \brief Get HA failover/remote settings reply
459     @param context - sender context, to match reply w/ request
460     @param retval - return code
461     @param ip_address - failover IP4 address
462     @param port - failvoer UDP port number
463     @param session_refresh_interval - number of seconds after which to send
464                                       session counters refresh
465 */
466 define nat_ha_get_failover_reply {
467   u32 context;
468   i32 retval;
469   vl_api_ip4_address_t ip_address;
470   u16 port;
471   u32 session_refresh_interval;
472 };
473
474 /** \brief Flush the current HA data (for testing)
475     @param client_index - opaque cookie to identify the sender
476     @param context - sender context, to match reply w/ request
477 */
478 autoreply define nat_ha_flush {
479   u32 client_index;
480   u32 context;
481 };
482
483 /** \brief Resync HA (resend existing sessions to new failover)
484     @param client_index - opaque cookie to identify the sender
485     @param context - sender context, to match reply w/ request
486     @param want_resync_event - resync completed event sent to the sender via
487                                nat_ha_resync_completed_event API message if
488                                non-zero
489     @param pid - sender's pid
490 */
491 autoreply define nat_ha_resync
492 {
493   u32 client_index;
494   u32 context;
495   u8 want_resync_event;
496   u32 pid;
497 };
498
499 /** \brief Tell client about a HA resync completion event
500     @param client_index - opaque cookie to identify the sender
501     @param pid - client pid registered to receive notification
502     @param missed_count - number of missed (not ACKed) messages
503 */
504 define nat_ha_resync_completed_event
505 {
506   u32 client_index;
507   u32 pid;
508   u32 missed_count;
509 };
510
511 service {
512   rpc nat_ha_resync returns nat_ha_resync_reply events nat_ha_resync_completed_event;
513 };
514
515 /*
516  * NAT44 APIs
517  */
518
519 /** \brief Del NAT44 user
520     @param client_index - opaque cookie to identify the sender
521     @param context - sender context, to match reply w/ request
522     @param ip_address - IPv4 address
523     @param fib_index - FIB index
524 */
525 autoreply define nat44_del_user {
526   u32 client_index;
527   u32 context;
528   vl_api_ip4_address_t ip_address;
529   u32 fib_index;
530 };
531
532 /** \brief Add/del NAT44 address range
533     @param client_index - opaque cookie to identify the sender
534     @param context - sender context, to match reply w/ request
535     @param first_ip_address - first IPv4 address
536     @param last_ip_address - last IPv4 address
537     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
538     @param is_add - true if add, false if delete
539     @param flags - flag NAT_IS_TWICE_NAT if NAT address range for external hosts
540
541 */
542 autoreply define nat44_add_del_address_range {
543   u32 client_index;
544   u32 context;
545   vl_api_ip4_address_t first_ip_address;
546   vl_api_ip4_address_t last_ip_address;
547   u32 vrf_id;
548   bool is_add;
549   vl_api_nat_config_flags_t flags;
550 };
551
552 /** \brief Dump NAT44 addresses
553     @param client_index - opaque cookie to identify the sender
554     @param context - sender context, to match reply w/ request
555 */
556 define nat44_address_dump {
557   u32 client_index;
558   u32 context;
559 };
560
561 /** \brief NAT44 address details response
562     @param context - sender context, to match reply w/ request
563     @param ip_address - IPv4 address
564     @param flags - flag NAT_IS_TWICE_NAT if NAT address range for external hosts
565     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
566 */
567 define nat44_address_details {
568   u32 context;
569   vl_api_ip4_address_t ip_address;
570   vl_api_nat_config_flags_t flags;
571   u32 vrf_id;
572 };
573
574 /** \brief Enable/disable NAT44 feature on the interface
575     @param client_index - opaque cookie to identify the sender
576     @param context - sender context, to match reply w/ request
577     @param is_add - true if add, false if delete
578     @param flags - flag NAT_IS_INSIDE if interface is inside else
579                    interface is outside
580     @param sw_if_index - software index of the interface
581 */
582 autoreply define nat44_interface_add_del_feature {
583   u32 client_index;
584   u32 context;
585   bool is_add;
586   vl_api_nat_config_flags_t flags;
587   vl_api_interface_index_t sw_if_index;
588 };
589
590 /** \brief Dump interfaces with NAT44 feature
591     @param client_index - opaque cookie to identify the sender
592     @param context - sender context, to match reply w/ request
593 */
594 define nat44_interface_dump {
595   u32 client_index;
596   u32 context;
597 };
598
599 /** \brief NAT44 interface details response
600     @param context - sender context, to match reply w/ request
601     @param sw_if_index - software index of the interface
602     @param flags - flag NAT_IS_INSIDE if interface is inside,
603                    flag NAT_IS_OUTSIDE if interface is outside
604                    and if both flags are set the interface is
605                    both inside and outside
606 */
607 define nat44_interface_details {
608   u32 context;
609   vl_api_nat_config_flags_t flags;
610   vl_api_interface_index_t sw_if_index;
611 };
612
613 /** \brief Enable/disbale NAT44 as an interface output feature (postrouting
614            in2out translation)
615     @param client_index - opaque cookie to identify the sender
616     @param context - sender context, to match reply w/ request
617     @param is_add - true if add, false if delete
618     @param flags - flag NAT_IS_INSIDE if interface is inside else
619                    interface is outside
620     @param sw_if_index - software index of the interface
621 */
622 autoreply define nat44_interface_add_del_output_feature {
623   u32 client_index;
624   u32 context;
625   bool is_add;
626   vl_api_nat_config_flags_t flags;
627   vl_api_interface_index_t sw_if_index;
628 };
629
630 /** \brief Dump interfaces with NAT44 output feature
631     @param client_index - opaque cookie to identify the sender
632     @param context - sender context, to match reply w/ request
633 */
634 define nat44_interface_output_feature_dump {
635   u32 client_index;
636   u32 context;
637 };
638
639 /** \brief NAT44 interface with output feature details response
640     @param context - sender context, to match reply w/ request
641     @param flags - flag NAT_IS_INSIDE if interface is inside else
642                    interface is outside
643     @param sw_if_index - software index of the interface
644 */
645 define nat44_interface_output_feature_details {
646   u32 context;
647   vl_api_nat_config_flags_t flags;
648   vl_api_interface_index_t sw_if_index;
649 };
650
651 /** \brief Add/delete NAT44 static mapping
652     @param client_index - opaque cookie to identify the sender
653     @param context - sender context, to match reply w/ request
654     @param is_add - true if add, false if delete
655     @param flags - flag NAT_IS_ADDR_ONLY if address only mapping,
656                    flag nat_is_twice_nat if nat address range for external hosts,
657                    flag NAT_IS_SELF_TWICE_NAT if translate external host address
658                    and port whenever external host address equals local
659                    address of internal host,
660                    flag NAT_IS_OUT2IN_ONLY if rule match only out2in direction
661     @param local_ip_address - local IPv4 address
662     @param external_ip_address - external IPv4 address
663     @param protocol - IP protocol, used only if addr_only=0
664     @param local_port - local port number, used only if addr_only=0
665     @param external_port - external port number, used only if addr_only=0
666     @param external_sw_if_index - external interface (if set
667                                   external_ip_address is ignored, ~0 means not
668                                   used)
669     @param vfr_id - VRF ID
670     @param tag - opaque string tag
671 */
672 autoreply define nat44_add_del_static_mapping {
673   u32 client_index;
674   u32 context;
675   bool is_add;
676   vl_api_nat_config_flags_t flags;
677   vl_api_ip4_address_t local_ip_address;
678   vl_api_ip4_address_t external_ip_address;
679   u8 protocol;
680   u16 local_port;
681   u16 external_port;
682   vl_api_interface_index_t external_sw_if_index;
683   u32 vrf_id;
684   string tag[64];
685 };
686
687 /** \brief Dump NAT44 static mappings
688     @param client_index - opaque cookie to identify the sender
689     @param context - sender context, to match reply w/ request
690 */
691 define nat44_static_mapping_dump {
692   u32 client_index;
693   u32 context;
694 };
695
696 /** \brief NAT44 static mapping details response
697     @param context - sender context, to match reply w/ request
698     @param flags - flag NAT_ADDR_ONLY if address only mapping,
699                    flag NAT_TWICE_NAT if NAT address range for external hosts,
700                    flag NAT_SELF_TWICE_NAT if translate external host address
701                    and port whenever external host address equals local
702                    address of internal host,
703                    flag NAT_OUT2IN_ONLY if rule match only out2in direction
704     @param local_ip_address - local IPv4 address
705     @param external_ip_address - external IPv4 address
706     @param protocol - IP protocol, valid only if no NAT_ADDR_ONLY flag
707     @param local_port - local port number, valid only if no NAT_ADDR_ONLY flag
708     @param external_port - external port number, valid only if no NAT_ADDR_ONLY flag
709     @param external_sw_if_index - external interface
710     @param vfr_id - VRF ID
711     @param tag - opaque string tag
712 */
713 define nat44_static_mapping_details {
714   u32 context;
715   vl_api_nat_config_flags_t flags;
716   vl_api_ip4_address_t local_ip_address;
717   vl_api_ip4_address_t external_ip_address;
718   u8 protocol;
719   u16 local_port;
720   u16 external_port;
721   vl_api_interface_index_t external_sw_if_index;
722   u32 vrf_id;
723   string tag[64];
724 };
725
726 /** \brief Add/delete NAT44 identity mapping
727     @param client_index - opaque cookie to identify the sender
728     @param context - sender context, to match reply w/ request
729     @param is_add - true if add, false if delete
730     @param flags - flag NAT_ADDR_ONLY if address only mapping
731     @param ip_address - IPv4 address
732     @param protocol - IP protocol
733     @param port - port number
734     @param sw_if_index - interface (if set ip_address is ignored, ~0 means not
735                                     used)
736     @param vfr_id - VRF ID (if ~0 use default VRF)
737     @param tag - opaque string tag
738 */
739 autoreply define nat44_add_del_identity_mapping {
740   u32 client_index;
741   u32 context;
742   bool is_add;
743   vl_api_nat_config_flags_t flags;
744   vl_api_ip4_address_t ip_address;
745   u8 protocol;
746   u16 port;
747   vl_api_interface_index_t sw_if_index;
748   u32 vrf_id;
749   string tag[64];
750 };
751
752 /** \brief Dump NAT44 identity mappings
753     @param client_index - opaque cookie to identify the sender
754     @param context - sender context, to match reply w/ request
755 */
756 define nat44_identity_mapping_dump {
757   u32 client_index;
758   u32 context;
759 };
760
761 /** \brief NAT44 identity mapping details response
762     @param context - sender context, to match reply w/ request
763     @param flags - flag NAT_ADDR_ONLY if address only mapping
764     @param ip_address - IPv4 address
765     @param protocol - IP protocol
766     @param port - port number
767     @param sw_if_index - interface
768     @param vfr_id - VRF ID
769     @param tag - opaque string tag
770 */
771 define nat44_identity_mapping_details {
772   u32 context;
773   vl_api_nat_config_flags_t flags;
774   vl_api_ip4_address_t ip_address;
775   u8 protocol;
776   u16 port;
777   vl_api_interface_index_t sw_if_index;
778   u32 vrf_id;
779   string tag[64];
780 };
781
782 /** \brief Add/delete NAT44 pool address from specific interfce
783     @param client_index - opaque cookie to identify the sender
784     @param context - sender context, to match reply w/ request
785     @param is_add - true if add, false if delete
786     @param sw_if_index - software index of the interface
787     @param flags - flag NAT_TWICE_NAT if NAT address range for external hosts
788 */
789 autoreply define nat44_add_del_interface_addr {
790   u32 client_index;
791   u32 context;
792   bool is_add;
793   vl_api_interface_index_t sw_if_index;
794   vl_api_nat_config_flags_t flags;
795 };
796
797 /** \brief Dump NAT44 pool addresses interfaces
798     @param client_index - opaque cookie to identify the sender
799     @param context - sender context, to match reply w/ request
800 */
801 define nat44_interface_addr_dump {
802   u32 client_index;
803   u32 context;
804 };
805
806 /** \brief NAT44 pool addresses interfaces details response
807     @param context - sender context, to match reply w/ request
808     @param sw_if_index - software index of the interface
809     @param flags - flag NAT_TWICE_NAT if NAT address range for external hosts
810
811 */
812 define nat44_interface_addr_details {
813   u32 context;
814   vl_api_interface_index_t sw_if_index;
815   vl_api_nat_config_flags_t flags;
816 };
817
818 /** \brief Dump NAT44 users
819     @param client_index - opaque cookie to identify the sender
820     @param context - sender context, to match reply w/ request
821 */
822 define nat44_user_dump {
823   u32 client_index;
824   u32 context;
825 };
826
827 /** \brief NAT44 users response
828     @param context - sender context, to match reply w/ request
829     @vrf_id - VRF ID
830     @param ip_address - IPv4 address
831     @param nsessions - number of dynamic sessions
832     @param nstaticsessions - number of static sessions
833 */
834 define nat44_user_details {
835   u32 context;
836   u32 vrf_id;
837   vl_api_ip4_address_t ip_address;
838   u32 nsessions;
839   u32 nstaticsessions;
840 };
841
842 /** \brief NAT44 user's sessions
843     @param client_index - opaque cookie to identify the sender
844     @param context - sender context, to match reply w/ request
845     @param ip_address - IPv4 address of the user to dump
846     @param vrf_id - VRF_ID
847 */
848 define nat44_user_session_dump {
849   u32 client_index;
850   u32 context;
851   vl_api_ip4_address_t ip_address;
852   u32 vrf_id;
853 };
854
855 /** \brief NAT44 user's sessions response
856     @param context - sender context, to match reply w/ request
857     @param outside_ip_address - outside IPv4 address
858     @param outside_port - outside port
859     @param inside_ip_address - inside IPv4 address
860     @param inside_port - inside port
861     @param protocol - protocol
862     @param flags - flag NAT_IS_STATIC if session is static,
863                    flag NAT_IS_TWICE_NAT if session is twice-nat,
864                    flag NAT_IS_EXT_HOST_VALID if external host address
865                    and port are valid
866     @param last_heard - last heard timer
867     @param total_bytes - count of bytes sent through session
868     @param total_pkts - count of pakets sent through session
869     @param ext_host_address - external host IPv4 address
870     @param ext_host_port - external host port
871     @param ext_host_nat_address - post-NAT external host IPv4 address (valid
872                                   only if twice-nat session)
873     @param ext_host_nat_port - post-NAT external host port (valid only if
874                                twice-nat session)
875 */
876 define nat44_user_session_details {
877   u32 context;
878   vl_api_ip4_address_t outside_ip_address;
879   u16 outside_port;
880   vl_api_ip4_address_t inside_ip_address;
881   u16 inside_port;
882   u16 protocol;
883   vl_api_nat_config_flags_t flags;
884   u64 last_heard;
885   u64 total_bytes;
886   u32 total_pkts;
887   vl_api_ip4_address_t ext_host_address;
888   u16 ext_host_port;
889   vl_api_ip4_address_t ext_host_nat_address;
890   u16 ext_host_nat_port;
891 };
892
893 /** \brief NAT44 load-balancing address and port pair
894     @param addr - IPv4 address of the internal node
895     @param port - L4 port number of the internal node
896     @param probability - probability of the internal node to be randomly matched
897     @param vrf_id - VRF id
898 */
899 typedef nat44_lb_addr_port {
900   vl_api_ip4_address_t addr;
901   u16 port;
902   u8 probability;
903   u32 vrf_id;
904 };
905
906 /** \brief Add/delete NAT44 load-balancing static mapping rule
907     @param client_index - opaque cookie to identify the sender
908     @param context - sender context, to match reply w/ request
909     @param is_add - true if add, false if delete
910     @param flags - flag NAT_TWICE_NAT if NAT address range for external hosts,
911                    flag NAT_SELF_TWICE_NAT if translate external host address
912                    and port whenever external host address equals local
913                    address of internal host,
914                    flag NAT_OUT2IN_ONLY if rule match only out2in direction
915     @param external_addr - external IPv4 address of the service
916     @param external_port - external L4 port number of the service
917     @param protocol - IP protocol number of the service
918     @param affinity - if 0 disabled, otherwise client IP affinity sticky time
919                       in seconds
920     @param local_num - number of local network nodes
921     @param locals - local network nodes
922     @param tag - opaque string tag
923 */
924 autoreply manual_endian define nat44_add_del_lb_static_mapping {
925   u32 client_index;
926   u32 context;
927   bool is_add;
928   vl_api_nat_config_flags_t flags;
929   vl_api_ip4_address_t external_addr;
930   u16 external_port;
931   u8 protocol;
932   u32 affinity;
933   string tag[64];
934   u32 local_num;
935   vl_api_nat44_lb_addr_port_t locals[local_num];
936 };
937
938 /** \brief Add/delete NAT44 load-balancing static mapping rule backend
939     @param client_index - opaque cookie to identify the sender
940     @param context - sender context, to match reply w/ request
941     @param is_add - true if add, false if delete
942     @param external_addr - external IPv4 address of the service
943     @param external_port - external L4 port number of the service
944     @param protocol - IP protocol number of the service
945     @param local - local network node
946 */
947 autoreply define nat44_lb_static_mapping_add_del_local {
948   u32 client_index;
949   u32 context;
950   bool is_add;
951   vl_api_ip4_address_t external_addr;
952   u16 external_port;
953   u8 protocol;
954   vl_api_nat44_lb_addr_port_t local;
955 };
956
957 /** \brief Dump NAT44 load-balancing static mapping rules
958     @param client_index - opaque cookie to identify the sender
959     @param context - sender context, to match reply w/ request
960 */
961 define nat44_lb_static_mapping_dump {
962   u32 client_index;
963   u32 context;
964 };
965
966 /** \brief NAT44 load-balancing static mapping rule details response
967     @param context - sender context, to match reply w/ request
968     @param external_addr - external IPv4 address of the service
969     @param external_port - external L4 port number of the service
970     @param protocol - IP protocol number of the service
971     @param flags - flag NAT_TWICE_NAT if NAT address range for external hosts,
972                    flag NAT_SELF_TWICE_NAT if translate external host address
973                    and port whenever external host address equals local
974                    address of internal host,
975                    flag NAT_OUT2IN_ONLY if rule match only out2in direction
976     @param affinity - if 0 disabled, otherwise client IP affinity sticky time
977                       in seconds
978     @param local_num - number of local network nodes
979     @param locals - local network nodes
980     @param tag - opaque string tag
981 */
982 manual_endian define nat44_lb_static_mapping_details {
983   u32 context;
984   vl_api_ip4_address_t external_addr;
985   u16 external_port;
986   u8 protocol;
987   vl_api_nat_config_flags_t flags;
988   u32 affinity;
989   string tag[64];
990   u32 local_num;
991   vl_api_nat44_lb_addr_port_t locals[local_num];
992 };
993
994 /** \brief Delete NAT44 session
995     @param client_index - opaque cookie to identify the sender
996     @param context - sender context, to match reply w/ request
997     @param ip_address - IPv4 address
998     @param protocol - IP protocol
999     @param port - port number
1000     @param vfr_id - VRF ID
1001     @param flags - flag NAT_IS_INSIDE if interface is inside or
1002                    interface is outside,
1003                    flag NAT_IS_EXT_HOST_VALID if external host address and
1004                    port are valid
1005     @param ext_host_address - external host IPv4 address
1006     @param ext_host_port - external host port
1007 */
1008 autoreply define nat44_del_session {
1009   u32 client_index;
1010   u32 context;
1011   vl_api_ip4_address_t address;
1012   u8 protocol;
1013   u16 port;
1014   u32 vrf_id;
1015   vl_api_nat_config_flags_t flags;
1016   vl_api_ip4_address_t ext_host_address;
1017   u16 ext_host_port;
1018 };
1019
1020 /** \brief Enable/disable forwarding for NAT44
1021     Forward packets which don't match existing translation
1022     or static mapping instead of dropping them.
1023     @param client_index - opaque cookie to identify the sender
1024     @param context - sender context, to match reply w/ request
1025     @param enable - true for enable, false for disable
1026 */
1027 autoreply define nat44_forwarding_enable_disable {
1028   u32 client_index;
1029   u32 context;
1030   bool enable;
1031 };
1032
1033 /** \brief Check if forwarding is enabled or disabled
1034     @param client_index - opaque cookie to identify the sender
1035     @param context - sender context, to match reply w/ request
1036 */
1037 define nat44_forwarding_is_enabled {
1038   u32 client_index;
1039   u32 context;
1040 };
1041
1042 /** \brief Response to check if forwarding is enabled or disabled
1043     @param context - sender context, to match reply w/ request
1044     @param enabled - true if enabled, false if disabled
1045 */
1046 define nat44_forwarding_is_enabled_reply {
1047   u32 context;
1048   bool enabled;
1049 };
1050
1051 /*
1052  * NAT64 APIs
1053  */
1054
1055 /** \brief Add/delete address range to NAT64 pool
1056     @param client_index - opaque cookie to identify the sender
1057     @param context - sender context, to match reply w/ request
1058     @param start_addr - start IPv4 address of the range
1059     @param end_addr - end IPv4 address of the range
1060     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
1061     @param is_add - true if add, false if delete
1062 */
1063 autoreply define nat64_add_del_pool_addr_range {
1064   u32 client_index;
1065   u32 context;
1066   vl_api_ip4_address_t start_addr;
1067   vl_api_ip4_address_t end_addr;
1068   u32 vrf_id;
1069   bool is_add;
1070 };
1071
1072 /** \brief Dump NAT64 pool addresses
1073     @param client_index - opaque cookie to identify the sender
1074     @param context - sender context, to match reply w/ request
1075 */
1076 define nat64_pool_addr_dump {
1077   u32 client_index;
1078   u32 context;
1079 };
1080
1081 /** \brief NAT64 pool address details response
1082     @param context - sender context, to match reply w/ request
1083     @param address - IPv4 address
1084     @param vfr_id - VRF id of tenant, ~0 means independent of VRF
1085 */
1086 define nat64_pool_addr_details {
1087   u32 context;
1088   vl_api_ip4_address_t address;
1089   u32 vrf_id;
1090 };
1091
1092 /** \brief Enable/disable NAT64 feature on the interface
1093     @param client_index - opaque cookie to identify the sender
1094     @param context - sender context, to match reply w/ request
1095     @param is_add - true if add, false if delete
1096     @param flags - flag NAT_IS_INSIDE if interface is inside else
1097                    interface is outside
1098     @param sw_if_index - index of the interface
1099 */
1100 autoreply define nat64_add_del_interface {
1101   u32 client_index;
1102   u32 context;
1103   bool is_add;
1104   vl_api_nat_config_flags_t flags;
1105   vl_api_interface_index_t sw_if_index;
1106 };
1107
1108 /** \brief Dump interfaces with NAT64 feature
1109     @param client_index - opaque cookie to identify the sender
1110     @param context - sender context, to match reply w/ request
1111 */
1112 define nat64_interface_dump {
1113   u32 client_index;
1114   u32 context;
1115 };
1116
1117 /** \brief NAT64 interface details response
1118     @param context - sender context, to match reply w/ request
1119     @param flags - flag NAT_IS_INSIDE if interface is inside,
1120                    flag NAT_IS_OUTSIDE if interface is outside
1121                    and if both flags are set the interface is
1122                    both inside and outside
1123     @param sw_if_index - index of the interface
1124 */
1125 define nat64_interface_details {
1126   u32 context;
1127   vl_api_nat_config_flags_t flags;
1128   vl_api_interface_index_t sw_if_index;
1129 };
1130
1131 /** \brief Add/delete NAT64 static BIB entry
1132     @param client_index - opaque cookie to identify the sender
1133     @param context - sender context, to match reply w/ request
1134     @param i_addr - inside IPv6 address
1135     @param o_addr - outside IPv4 address
1136     @param i_port - inside port number
1137     @param o_port - outside port number
1138     @param vrf_id - VRF id of tenant
1139     @param proto - protocol number
1140     @param is_add - true if add, false if delete
1141 */
1142  autoreply define nat64_add_del_static_bib {
1143   u32 client_index;
1144   u32 context;
1145   vl_api_ip6_address_t i_addr;
1146   vl_api_ip4_address_t o_addr;
1147   u16 i_port;
1148   u16 o_port;
1149   u32 vrf_id;
1150   u8 proto;
1151   bool is_add;
1152 };
1153
1154 /** \brief Dump NAT64 BIB
1155     @param client_index - opaque cookie to identify the sender
1156     @param context - sender context, to match reply w/ request
1157     @param proto - protocol of the BIB: 255 - all BIBs
1158                                         6 - TCP BIB
1159                                         17 - UDP BIB
1160                                         1/58 - ICMP BIB
1161                                         otherwise - "unknown" protocol BIB
1162 */
1163 define nat64_bib_dump {
1164   u32 client_index;
1165   u32 context;
1166   u8 proto;
1167 };
1168
1169 /** \brief NAT64 BIB details response
1170     @param context - sender context, to match reply w/ request
1171     @param i_addr - inside IPv6 address
1172     @param o_addr - outside IPv4 address
1173     @param i_port - inside port number
1174     @param o_port - outside port number
1175     @param vrf_id - VRF id of tenant
1176     @param proto - protocol number
1177     @param flags - flag NAT_IS_STATIC if BIB entry is static 
1178                    or BIB entry is dynamic
1179     @param ses_num - number of sessions associated with the BIB entry
1180 */
1181 define nat64_bib_details {
1182   u32 context;
1183   vl_api_ip6_address_t i_addr;
1184   vl_api_ip4_address_t o_addr;
1185   u16 i_port;
1186   u16 o_port;
1187   u32 vrf_id;
1188   u8 proto;
1189   vl_api_nat_config_flags_t flags;
1190   u32 ses_num;
1191 };
1192
1193 /** \brief Dump NAT64 session table
1194     @param client_index - opaque cookie to identify the sender
1195     @param context - sender context, to match reply w/ request
1196     @param proto - protocol of the session table: 255 - all STs
1197                                                   6 - TCP ST
1198                                                   17 - UDP ST
1199                                                   1/58 - ICMP ST
1200                                                   otherwise - "unknown" proto ST
1201 */
1202 define nat64_st_dump {
1203   u32 client_index;
1204   u32 context;
1205   u8 proto;
1206 };
1207
1208 /** \brief NAT64 session table details response
1209     @param context - sender context, to match reply w/ request
1210     @param il_addr - inside IPv6 address of the local host
1211     @param ol_addr - outside IPv4 address of the local host
1212     @param il_port - inside port number id of the local host/inside ICMP id
1213     @param ol_port - outside port number of the local host/outside ICMP id
1214     @param ir_addr - inside IPv6 address of the remote host
1215     @param or_addr - outside IPv4 address of the remote host
1216     @param r_port - port number of the remote host (not used for ICMP)
1217     @param vrf_id - VRF id of tenant
1218     @param proto - protocol number
1219 */
1220 define nat64_st_details {
1221   u32 context;
1222   vl_api_ip6_address_t il_addr;
1223   vl_api_ip4_address_t ol_addr;
1224   u16 il_port;
1225   u16 ol_port;
1226   vl_api_ip6_address_t ir_addr;
1227   vl_api_ip4_address_t or_addr;
1228   u16 r_port;
1229   u32 vrf_id;
1230   u8 proto;
1231 };
1232
1233 /** \brief Add/del NAT64 prefix
1234     @param client_index - opaque cookie to identify the sender
1235     @param context - sender context, to match reply w/ request
1236     @param prefix - NAT64 prefix
1237     @param vrf_id - VRF id of tenant
1238     @param is_add - true if add, false if delete
1239 */
1240 autoreply define nat64_add_del_prefix {
1241   u32 client_index;
1242   u32 context;
1243   vl_api_ip6_prefix_t prefix;
1244   u32 vrf_id;
1245   bool is_add;
1246 };
1247
1248 /** \brief Dump NAT64 prefix
1249     @param client_index - opaque cookie to identify the sender
1250     @param context - sender context, to match reply w/ request
1251 */
1252 define nat64_prefix_dump {
1253   u32 client_index;
1254   u32 context;
1255 };
1256
1257 /** \brief Dump NAT64 prefix details response
1258     @param context - sender context, to match reply w/ request
1259     @param prefix - NAT64 prefix
1260     @param vrf_id - VRF id of tenant
1261 */
1262 define nat64_prefix_details {
1263   u32 context;
1264   vl_api_ip6_prefix_t prefix;
1265   u32 vrf_id;
1266 };
1267
1268 /** \brief Add/delete NAT64 pool address from specific interfce
1269     @param client_index - opaque cookie to identify the sender
1270     @param context - sender context, to match reply w/ request
1271     @param is_add - true if add, false if delete
1272     @param sw_if_index - software index of the interface
1273 */
1274 autoreply define nat64_add_del_interface_addr {
1275   u32 client_index;
1276   u32 context;
1277   bool is_add;
1278   vl_api_interface_index_t sw_if_index;
1279 };