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