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