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