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