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