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