nat: nat44-ed cleanup & fixes
[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 Set TCP MSS rewriting configuration
202     @param client_index - opaque cookie to identify the sender
203     @param context - sender context, to match reply w/ request
204     @param mss_value - MSS value to be used for MSS rewriting
205     @param enable - if true enable MSS rewriting feature else disable
206 */
207 autoreply define nat_set_mss_clamping {
208   u32 client_index;
209   u32 context;
210   u16 mss_value;
211   bool enable;
212 };
213
214 /** \brief Get TCP MSS rewriting configuration
215     @param client_index - opaque cookie to identify the sender
216     @param context - sender context, to match reply w/ request
217 */
218 define nat_get_mss_clamping {
219   u32 client_index;
220   u32 context;
221 };
222
223 /** \brief Get TCP MSS rewriting configuration reply
224     @param context - sender context, to match reply w/ request
225     @param retval - return code
226     @param mss_value - MSS value to be used for MSS rewriting
227     @param enable - if true enable MSS rewriting feature else disable
228 */
229 define nat_get_mss_clamping_reply {
230   u32 context;
231   i32 retval;
232   u16 mss_value;
233   bool enable;
234 };
235
236 /** \brief Set NAT handoff frame queue options
237     @param client_index - opaque cookie to identify the sender
238     @param context - sender context, to match reply w/ request
239     @param frame_queue_nelts - number of worker handoff frame queue elements
240 */
241 autoreply define nat44_ed_set_fq_options {
242   u32 client_index;
243   u32 context;
244   u32 frame_queue_nelts;
245 };
246
247 /** \brief Show NAT handoff frame queue options
248     @param client_index - opaque cookie to identify the sender
249     @param context - sender context, to match reply w/ request
250 */
251 define nat44_ed_show_fq_options
252 {
253   u32 client_index;
254   u32 context;
255 };
256
257 /** \brief Show NAT handoff frame queue options reply
258     @param context - sender context, to match reply w/ request
259     @param retval - return code for the request
260     @param frame_queue_nelts - number of worker handoff frame queue elements
261 */
262 define nat44_ed_show_fq_options_reply
263 {
264   u32 context;
265   i32 retval;
266   u32 frame_queue_nelts;
267 };
268
269 /** \brief Add/delete NAT44 pool address from specific interfce
270     @param client_index - opaque cookie to identify the sender
271     @param context - sender context, to match reply w/ request
272     @param is_add - true if add, false if delete
273     @param sw_if_index - software index of the interface
274     @param flags - flag NAT_TWICE_NAT if NAT address range for external hosts
275 */
276 autoreply define nat44_add_del_interface_addr {
277   u32 client_index;
278   u32 context;
279   bool is_add;
280   vl_api_interface_index_t sw_if_index;
281   vl_api_nat_config_flags_t flags;
282 };
283
284 /** \brief Dump NAT44 pool addresses interfaces
285     @param client_index - opaque cookie to identify the sender
286     @param context - sender context, to match reply w/ request
287 */
288 define nat44_interface_addr_dump {
289   u32 client_index;
290   u32 context;
291 };
292
293 /** \brief NAT44 pool addresses interfaces details response
294     @param context - sender context, to match reply w/ request
295     @param sw_if_index - software index of the interface
296     @param flags - flag NAT_TWICE_NAT if NAT address range for external hosts
297
298 */
299 define nat44_interface_addr_details {
300   u32 context;
301   vl_api_interface_index_t sw_if_index;
302   vl_api_nat_config_flags_t flags;
303 };
304
305 /** \brief Add/del NAT44 address range
306     @param client_index - opaque cookie to identify the sender
307     @param context - sender context, to match reply w/ request
308     @param first_ip_address - first IPv4 address
309     @param last_ip_address - last IPv4 address
310     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
311     @param is_add - true if add, false if delete
312     @param flags - flag NAT_IS_TWICE_NAT if NAT address range for external hosts
313
314 */
315 autoreply define nat44_add_del_address_range {
316   u32 client_index;
317   u32 context;
318   vl_api_ip4_address_t first_ip_address;
319   vl_api_ip4_address_t last_ip_address;
320   u32 vrf_id;
321   bool is_add;
322   vl_api_nat_config_flags_t flags;
323 };
324
325 /** \brief Dump NAT44 addresses
326     @param client_index - opaque cookie to identify the sender
327     @param context - sender context, to match reply w/ request
328 */
329 define nat44_address_dump {
330   u32 client_index;
331   u32 context;
332 };
333
334 /** \brief NAT44 address details response
335     @param context - sender context, to match reply w/ request
336     @param ip_address - IPv4 address
337     @param flags - flag NAT_IS_TWICE_NAT if NAT address range for external hosts
338     @param vrf_id - VRF id of tenant, ~0 means independent of VRF
339 */
340 define nat44_address_details {
341   u32 context;
342   vl_api_ip4_address_t ip_address;
343   vl_api_nat_config_flags_t flags;
344   u32 vrf_id;
345 };
346
347 /** \brief Enable/disable NAT44 feature on the interface
348     @param client_index - opaque cookie to identify the sender
349     @param context - sender context, to match reply w/ request
350     @param is_add - true if add, false if delete
351     @param flags - flag NAT_IS_INSIDE if interface is inside else
352                    interface is outside
353     @param sw_if_index - software index of the interface
354 */
355 autoreply define nat44_interface_add_del_feature {
356   u32 client_index;
357   u32 context;
358   bool is_add;
359   vl_api_nat_config_flags_t flags;
360   vl_api_interface_index_t sw_if_index;
361 };
362
363 /** \brief Dump interfaces with NAT44 feature
364     @param client_index - opaque cookie to identify the sender
365     @param context - sender context, to match reply w/ request
366 */
367 define nat44_interface_dump {
368   u32 client_index;
369   u32 context;
370 };
371
372 /** \brief NAT44 interface details response
373     @param context - sender context, to match reply w/ request
374     @param sw_if_index - software index of the interface
375     @param flags - flag NAT_IS_INSIDE if interface is inside,
376                    flag NAT_IS_OUTSIDE if interface is outside
377                    and if both flags are set the interface is
378                    both inside and outside
379 */
380 define nat44_interface_details {
381   u32 context;
382   vl_api_nat_config_flags_t flags;
383   vl_api_interface_index_t sw_if_index;
384 };
385
386 /** \brief add/del NAT output interface (postrouting
387            in2out translation)
388     @param client_index - opaque cookie to identify the sender
389     @param context - sender context, to match reply w/ request
390     @param is_add - true if add, false if delete
391     @param sw_if_index - software index of the interface
392 */
393 autoendian autoreply define nat44_ed_add_del_output_interface {
394   u32 client_index;
395   u32 context;
396   bool is_add;
397   vl_api_interface_index_t sw_if_index;
398 };
399
400 service {
401   rpc nat44_ed_output_interface_get returns nat44_ed_output_interface_get_reply
402     stream nat44_ed_output_interface_details;
403 };
404
405 define nat44_ed_output_interface_get
406 {
407   u32 client_index;
408   u32 context;
409   u32 cursor;
410 };
411
412 define nat44_ed_output_interface_get_reply
413 {
414   u32 context;
415   i32 retval;
416   u32 cursor;
417 };
418
419 define nat44_ed_output_interface_details
420 {
421   u32 context;
422   vl_api_interface_index_t sw_if_index;
423 };
424
425 /** \brief Add/delete NAT44 static mapping
426     @param client_index - opaque cookie to identify the sender
427     @param context - sender context, to match reply w/ request
428     @param is_add - true if add, false if delete
429     @param flags - flag NAT_IS_ADDR_ONLY if address only mapping,
430                    flag nat_is_twice_nat if nat address range for external hosts,
431                    flag NAT_IS_SELF_TWICE_NAT if translate external host address
432                    and port whenever external host address equals local
433                    address of internal host,
434                    flag NAT_IS_OUT2IN_ONLY if rule match only out2in direction
435     @param local_ip_address - local IPv4 address
436     @param external_ip_address - external IPv4 address
437     @param protocol - IP protocol, used only if addr_only=0
438     @param local_port - local port number, used only if addr_only=0
439     @param external_port - external port number, used only if addr_only=0
440     @param external_sw_if_index - external interface (if set
441                                   external_ip_address is ignored, ~0 means not
442                                   used)
443     @param vfr_id - VRF ID
444     @param tag - opaque string tag
445 */
446 autoreply define nat44_add_del_static_mapping {
447   u32 client_index;
448   u32 context;
449   bool is_add;
450   vl_api_nat_config_flags_t flags;
451   vl_api_ip4_address_t local_ip_address;
452   vl_api_ip4_address_t external_ip_address;
453   u8 protocol;
454   u16 local_port;
455   u16 external_port;
456   vl_api_interface_index_t external_sw_if_index;
457   u32 vrf_id;
458   string tag[64];
459 };
460
461 /** \brief Add/delete NAT44 static mapping
462     @param client_index - opaque cookie to identify the sender
463     @param context - sender context, to match reply w/ request
464     @param is_add - true if add, false if delete
465     @param match_pool - true if use specific pool_ip_address
466     @param flags - flag NAT_IS_ADDR_ONLY if address only mapping,
467                    flag nat_is_twice_nat if nat address range for external hosts,
468                    flag NAT_IS_SELF_TWICE_NAT if translate external host address
469                    and port whenever external host address equals local
470                    address of internal host,
471                    flag NAT_IS_OUT2IN_ONLY if rule match only out2in direction
472     @param pool_ip_address - pool IPv4 address to match with pool
473     @param local_ip_address - local IPv4 address
474     @param external_ip_address - external IPv4 address
475     @param protocol - IP protocol, used only if addr_only=0
476     @param local_port - local port number, used only if addr_only=0
477     @param external_port - external port number, used only if addr_only=0
478     @param external_sw_if_index - external interface (if set
479                                   external_ip_address is ignored, ~0 means not
480                                   used)
481     @param vfr_id - VRF ID
482     @param tag - opaque string tag
483 */
484 autoreply define nat44_add_del_static_mapping_v2 {
485   u32 client_index;
486   u32 context;
487   bool is_add;
488   bool match_pool;
489   vl_api_nat_config_flags_t flags;
490   vl_api_ip4_address_t pool_ip_address;
491   vl_api_ip4_address_t local_ip_address;
492   vl_api_ip4_address_t external_ip_address;
493   u8 protocol;
494   u16 local_port;
495   u16 external_port;
496   vl_api_interface_index_t external_sw_if_index;
497   u32 vrf_id;
498   string tag[64];
499 };
500
501 /** \brief Dump NAT44 static mappings
502     @param client_index - opaque cookie to identify the sender
503     @param context - sender context, to match reply w/ request
504 */
505 define nat44_static_mapping_dump {
506   u32 client_index;
507   u32 context;
508 };
509
510 /** \brief NAT44 static mapping details response
511     @param context - sender context, to match reply w/ request
512     @param flags - flag NAT_ADDR_ONLY if address only mapping,
513                    flag NAT_TWICE_NAT if NAT address range for external hosts,
514                    flag NAT_SELF_TWICE_NAT if translate external host address
515                    and port whenever external host address equals local
516                    address of internal host,
517                    flag NAT_OUT2IN_ONLY if rule match only out2in direction
518     @param local_ip_address - local IPv4 address
519     @param external_ip_address - external IPv4 address
520     @param protocol - IP protocol, valid only if no NAT_ADDR_ONLY flag
521     @param local_port - local port number, valid only if no NAT_ADDR_ONLY flag
522     @param external_port - external port number, valid only if no NAT_ADDR_ONLY flag
523     @param external_sw_if_index - external interface
524     @param vfr_id - VRF ID
525     @param tag - opaque string tag
526 */
527 define nat44_static_mapping_details {
528   u32 context;
529   vl_api_nat_config_flags_t flags;
530   vl_api_ip4_address_t local_ip_address;
531   vl_api_ip4_address_t external_ip_address;
532   u8 protocol;
533   u16 local_port;
534   u16 external_port;
535   vl_api_interface_index_t external_sw_if_index;
536   u32 vrf_id;
537   string tag[64];
538 };
539
540 /** \brief Add/delete NAT44 identity mapping
541     @param client_index - opaque cookie to identify the sender
542     @param context - sender context, to match reply w/ request
543     @param is_add - true if add, false if delete
544     @param flags - flag NAT_ADDR_ONLY if address only mapping
545     @param ip_address - IPv4 address
546     @param protocol - IP protocol
547     @param port - port number
548     @param sw_if_index - interface (if set ip_address is ignored, ~0 means not
549                                     used)
550     @param vfr_id - VRF ID (if ~0 use default VRF)
551     @param tag - opaque string tag
552 */
553 autoreply define nat44_add_del_identity_mapping {
554   u32 client_index;
555   u32 context;
556   bool is_add;
557   vl_api_nat_config_flags_t flags;
558   vl_api_ip4_address_t ip_address;
559   u8 protocol;
560   u16 port;
561   vl_api_interface_index_t sw_if_index;
562   u32 vrf_id;
563   string tag[64];
564 };
565
566 /** \brief Dump NAT44 identity mappings
567     @param client_index - opaque cookie to identify the sender
568     @param context - sender context, to match reply w/ request
569 */
570 define nat44_identity_mapping_dump {
571   u32 client_index;
572   u32 context;
573 };
574
575 /** \brief NAT44 identity mapping details response
576     @param context - sender context, to match reply w/ request
577     @param flags - flag NAT_ADDR_ONLY if address only mapping
578     @param ip_address - IPv4 address
579     @param protocol - IP protocol
580     @param port - port number
581     @param sw_if_index - interface
582     @param vfr_id - VRF ID
583     @param tag - opaque string tag
584 */
585 define nat44_identity_mapping_details {
586   u32 context;
587   vl_api_nat_config_flags_t flags;
588   vl_api_ip4_address_t ip_address;
589   u8 protocol;
590   u16 port;
591   vl_api_interface_index_t sw_if_index;
592   u32 vrf_id;
593   string tag[64];
594 };
595
596 /** \brief NAT44 load-balancing address and port pair
597     @param addr - IPv4 address of the internal node
598     @param port - L4 port number of the internal node
599     @param probability - probability of the internal node to be randomly matched
600     @param vrf_id - VRF id
601 */
602 typedef nat44_lb_addr_port {
603   vl_api_ip4_address_t addr;
604   u16 port;
605   u8 probability;
606   u32 vrf_id;
607 };
608
609 /** \brief Add/delete NAT44 load-balancing static mapping rule
610     @param client_index - opaque cookie to identify the sender
611     @param context - sender context, to match reply w/ request
612     @param is_add - true if add, false if delete
613     @param flags - flag NAT_TWICE_NAT if NAT address range for external hosts,
614                    flag NAT_SELF_TWICE_NAT if translate external host address
615                    and port whenever external host address equals local
616                    address of internal host,
617                    flag NAT_OUT2IN_ONLY if rule match only out2in direction
618     @param external_addr - external IPv4 address of the service
619     @param external_port - external L4 port number of the service
620     @param protocol - IP protocol number of the service
621     @param affinity - if 0 disabled, otherwise client IP affinity sticky time
622                       in seconds
623     @param local_num - number of local network nodes
624     @param locals - local network nodes
625     @param tag - opaque string tag
626 */
627 autoreply define nat44_add_del_lb_static_mapping {
628   u32 client_index;
629   u32 context;
630   bool is_add;
631   vl_api_nat_config_flags_t flags;
632   vl_api_ip4_address_t external_addr;
633   u16 external_port;
634   u8 protocol;
635   u32 affinity;
636   string tag[64];
637   u32 local_num;
638   vl_api_nat44_lb_addr_port_t locals[local_num];
639 };
640
641 /** \brief Add/delete NAT44 load-balancing static mapping rule backend
642     @param client_index - opaque cookie to identify the sender
643     @param context - sender context, to match reply w/ request
644     @param is_add - true if add, false if delete
645     @param external_addr - external IPv4 address of the service
646     @param external_port - external L4 port number of the service
647     @param protocol - IP protocol number of the service
648     @param local - local network node
649 */
650 autoreply define nat44_lb_static_mapping_add_del_local {
651   u32 client_index;
652   u32 context;
653   bool is_add;
654   vl_api_ip4_address_t external_addr;
655   u16 external_port;
656   u8 protocol;
657   vl_api_nat44_lb_addr_port_t local;
658 };
659
660 /** \brief Dump NAT44 load-balancing static mapping rules
661     @param client_index - opaque cookie to identify the sender
662     @param context - sender context, to match reply w/ request
663 */
664 define nat44_lb_static_mapping_dump {
665   u32 client_index;
666   u32 context;
667 };
668
669 /** \brief NAT44 load-balancing static mapping rule details response
670     @param context - sender context, to match reply w/ request
671     @param external_addr - external IPv4 address of the service
672     @param external_port - external L4 port number of the service
673     @param protocol - IP protocol number of the service
674     @param flags - flag NAT_TWICE_NAT if NAT address range for external hosts,
675                    flag NAT_SELF_TWICE_NAT if translate external host address
676                    and port whenever external host address equals local
677                    address of internal host,
678                    flag NAT_OUT2IN_ONLY if rule match only out2in direction
679     @param affinity - if 0 disabled, otherwise client IP affinity sticky time
680                       in seconds
681     @param local_num - number of local network nodes
682     @param locals - local network nodes
683     @param tag - opaque string tag
684 */
685 define nat44_lb_static_mapping_details {
686   u32 context;
687   vl_api_ip4_address_t external_addr;
688   u16 external_port;
689   u8 protocol;
690   vl_api_nat_config_flags_t flags;
691   u32 affinity;
692   string tag[64];
693   u32 local_num;
694   vl_api_nat44_lb_addr_port_t locals[local_num];
695 };
696
697 /** \brief Delete NAT44 session
698     @param client_index - opaque cookie to identify the sender
699     @param context - sender context, to match reply w/ request
700     @param ip_address - IPv4 address
701     @param protocol - IP protocol
702     @param port - port number
703     @param vfr_id - VRF ID
704     @param flags - flag NAT_IS_INSIDE if interface is inside or
705                    interface is outside,
706                    flag NAT_IS_EXT_HOST_VALID if external host address and
707                    port are valid
708     @param ext_host_address - external host IPv4 address
709     @param ext_host_port - external host port
710 */
711 autoreply define nat44_del_session {
712   u32 client_index;
713   u32 context;
714   vl_api_ip4_address_t address;
715   u8 protocol;
716   u16 port;
717   u32 vrf_id;
718   vl_api_nat_config_flags_t flags;
719   vl_api_ip4_address_t ext_host_address;
720   u16 ext_host_port;
721 };
722
723 /** \brief Dump NAT44 users
724     @param client_index - opaque cookie to identify the sender
725     @param context - sender context, to match reply w/ request
726 */
727 define nat44_user_dump {
728   u32 client_index;
729   u32 context;
730 };
731
732 /** \brief NAT44 users response
733     @param context - sender context, to match reply w/ request
734     @vrf_id - VRF ID
735     @param ip_address - IPv4 address
736     @param nsessions - number of dynamic sessions
737     @param nstaticsessions - number of static sessions
738 */
739 define nat44_user_details {
740   u32 context;
741   u32 vrf_id;
742   vl_api_ip4_address_t ip_address;
743   u32 nsessions;
744   u32 nstaticsessions;
745 };
746
747 /** \brief NAT44 user's sessions
748     @param client_index - opaque cookie to identify the sender
749     @param context - sender context, to match reply w/ request
750     @param ip_address - IPv4 address of the user to dump
751     @param vrf_id - VRF_ID
752 */
753 define nat44_user_session_dump {
754   u32 client_index;
755   u32 context;
756   vl_api_ip4_address_t ip_address;
757   u32 vrf_id;
758 };
759
760 /** \brief NAT44 user's sessions response
761     @param context - sender context, to match reply w/ request
762     @param outside_ip_address - outside IPv4 address
763     @param outside_port - outside port
764     @param inside_ip_address - inside IPv4 address
765     @param inside_port - inside port
766     @param protocol - protocol
767     @param flags - flag NAT_IS_STATIC if session is static,
768                    flag NAT_IS_TWICE_NAT if session is twice-nat,
769                    flag NAT_IS_EXT_HOST_VALID if external host address
770                    and port are valid
771     @param last_heard - last heard timer
772     @param total_bytes - count of bytes sent through session
773     @param total_pkts - count of pakets sent through session
774     @param ext_host_address - external host IPv4 address
775     @param ext_host_port - external host port
776     @param ext_host_nat_address - post-NAT external host IPv4 address (valid
777                                   only if twice-nat session)
778     @param ext_host_nat_port - post-NAT external host port (valid only if
779                                twice-nat session)
780 */
781 define nat44_user_session_details {
782   u32 context;
783   vl_api_ip4_address_t outside_ip_address;
784   u16 outside_port;
785   vl_api_ip4_address_t inside_ip_address;
786   u16 inside_port;
787   u16 protocol;
788   vl_api_nat_config_flags_t flags;
789   u64 last_heard;
790   u64 total_bytes;
791   u32 total_pkts;
792   vl_api_ip4_address_t ext_host_address;
793   u16 ext_host_port;
794   vl_api_ip4_address_t ext_host_nat_address;
795   u16 ext_host_nat_port;
796 };
797
798 /** \brief NAT44 user's sessions
799     @param client_index - opaque cookie to identify the sender
800     @param context - sender context, to match reply w/ request
801     @param ip_address - IPv4 address of the user to dump
802     @param vrf_id - VRF_ID
803 */
804 define nat44_user_session_v2_dump {
805   u32 client_index;
806   u32 context;
807   vl_api_ip4_address_t ip_address;
808   u32 vrf_id;
809 };
810
811 /** \brief NAT44 user's sessions response
812     @param context - sender context, to match reply w/ request
813     @param outside_ip_address - outside IPv4 address
814     @param outside_port - outside port
815     @param inside_ip_address - inside IPv4 address
816     @param inside_port - inside port
817     @param protocol - protocol
818     @param flags - flag NAT_IS_STATIC if session is static,
819                    flag NAT_IS_TWICE_NAT if session is twice-nat,
820                    flag NAT_IS_EXT_HOST_VALID if external host address
821                    and port are valid
822     @param last_heard - last heard timer
823     @param total_bytes - count of bytes sent through session
824     @param total_pkts - count of pakets sent through session
825     @param ext_host_address - external host IPv4 address
826     @param ext_host_port - external host port
827     @param ext_host_nat_address - post-NAT external host IPv4 address (valid
828                                   only if twice-nat session)
829     @param ext_host_nat_port - post-NAT external host port (valid only if
830                                twice-nat session)
831     @param is_timed_out - true, if session is timed out, and false, if session
832                           is active
833 */
834 define nat44_user_session_v2_details {
835   u32 context;
836   vl_api_ip4_address_t outside_ip_address;
837   u16 outside_port;
838   vl_api_ip4_address_t inside_ip_address;
839   u16 inside_port;
840   u16 protocol;
841   vl_api_nat_config_flags_t flags;
842   u64 last_heard;
843   u64 total_bytes;
844   u32 total_pkts;
845   vl_api_ip4_address_t ext_host_address;
846   u16 ext_host_port;
847   vl_api_ip4_address_t ext_host_nat_address;
848   u16 ext_host_nat_port;
849   bool is_timed_out;
850 };
851
852 // DEPRECATED, obsolete messages completely unsupported
853
854 /** \brief Del NAT44 user
855     @param client_index - opaque cookie to identify the sender
856     @param context - sender context, to match reply w/ request
857     @param ip_address - IPv4 address
858     @param fib_index - FIB index
859 */
860 autoreply define nat44_del_user {
861   option deprecated;
862   u32 client_index;
863   u32 context;
864   vl_api_ip4_address_t ip_address;
865   u32 fib_index;
866 };
867
868 /** \brief Set address and port assignment algorithm
869     @param client_index - opaque cookie to identify the sender
870     @param context - sender context, to match reply w/ request
871     @param alg - address and port assignment algorithm:
872                  0 - default, 1 - MAP-E, 2 - port range
873                  (see nat_addr_and_port_alloc_alg_t in nat.h)
874     @param psid_offset - number of offset bits (valid only for MAP-E alg)
875     @param psid_length - length of PSID (valid only for MAP-E alg)
876     @param psid - Port Set Identifier (PSID) value (valid only for MAP-E alg)
877     @param start_port - beginning of the port range
878     @param end_port - end of the port range
879 */
880 autoreply define nat_set_addr_and_port_alloc_alg {
881   option deprecated;
882   u32 client_index;
883   u32 context;
884   u8 alg;
885   u8 psid_offset;
886   u8 psid_length;
887   u16 psid;
888   u16 start_port;
889   u16 end_port;
890 };
891
892 /** \brief Get address and port assignment algorithm
893     @param client_index - opaque cookie to identify the sender
894     @param context - sender context, to match reply w/ request
895 */
896 define nat_get_addr_and_port_alloc_alg {
897   option deprecated;
898   u32 client_index;
899   u32 context;
900 };
901
902 /** \brief Get address and port assignment algorithm reply
903     @param context - sender context, to match reply w/ request
904     @param retval - return code
905     @param alg - address and port assignment algorithm:
906                  0 - default, 1 - MAP-E, 2 - port range
907                  (see nat_addr_and_port_alloc_alg_t in nat.h)
908     @param psid_offset - number of offset bits (valid only for MAP-E alg)
909     @param psid_length - length of PSID (valid only for MAP-E alg)
910     @param psid - Port Set Identifier (PSID) value (valid only for MAP-E alg)
911     @param start_port - beginning of the port range
912     @param end_port - end of the port range
913 */
914 define nat_get_addr_and_port_alloc_alg_reply {
915   option deprecated;
916   u32 context;
917   i32 retval;
918   u8 alg;
919   u8 psid_offset;
920   u8 psid_length;
921   u16 psid;
922   u16 start_port;
923   u16 end_port;
924 };
925
926 /** \brief Set HA listener (local settings)
927     @param client_index - opaque cookie to identify the sender
928     @param context - sender context, to match reply w/ request
929     @param ip_address - local IP4 address
930     @param port - local UDP port number
931     @param path_mtu - path MTU between local and failover
932 */
933 autoreply define nat_ha_set_listener {
934   option deprecated;
935   u32 client_index;
936   u32 context;
937   vl_api_ip4_address_t ip_address;
938   u16 port;
939   u32 path_mtu;
940 };
941
942 /** \brief Set HA failover (remote settings)
943     @param client_index - opaque cookie to identify the sender
944     @param context - sender context, to match reply w/ request
945     @param ip_address - failover IP4 address
946     @param port - failvoer UDP port number
947     @param session_refresh_interval - number of seconds after which to send
948                                       session counters refresh
949 */
950 autoreply define nat_ha_set_failover {
951   option deprecated;
952   u32 client_index;
953   u32 context;
954   vl_api_ip4_address_t ip_address;
955   u16 port;
956   u32 session_refresh_interval;
957 };
958
959 /** \brief Get HA listener/local configuration
960     @param client_index - opaque cookie to identify the sender
961     @param context - sender context, to match reply w/ request
962 */
963 define nat_ha_get_listener {
964   option deprecated;
965   u32 client_index;
966   u32 context;
967 };
968
969 /** \brief Get HA listener/local configuration reply
970     @param context - sender context, to match reply w/ request
971     @param retval - return code
972     @param ip_address - local IP4 address
973     @param port - local UDP port number
974     @param path_mtu - Path MTU between local and failover
975 */
976 define nat_ha_get_listener_reply {
977   option deprecated;
978   u32 context;
979   i32 retval;
980   vl_api_ip4_address_t ip_address;
981   u16 port;
982   u32 path_mtu;
983 };
984
985 /** \brief Get HA failover/remote settings
986     @param client_index - opaque cookie to identify the sender
987     @param context - sender context, to match reply w/ request
988 */
989 define nat_ha_get_failover {
990   option deprecated;
991   u32 client_index;
992   u32 context;
993 };
994
995 /** \brief Get HA failover/remote settings reply
996     @param context - sender context, to match reply w/ request
997     @param retval - return code
998     @param ip_address - failover IP4 address
999     @param port - failvoer UDP port number
1000     @param session_refresh_interval - number of seconds after which to send
1001                                       session counters refresh
1002 */
1003 define nat_ha_get_failover_reply {
1004   option deprecated;
1005   u32 context;
1006   i32 retval;
1007   vl_api_ip4_address_t ip_address;
1008   u16 port;
1009   u32 session_refresh_interval;
1010 };
1011
1012 /** \brief Flush the current HA data (for testing)
1013     @param client_index - opaque cookie to identify the sender
1014     @param context - sender context, to match reply w/ request
1015 */
1016 autoreply define nat_ha_flush {
1017   option deprecated;
1018   u32 client_index;
1019   u32 context;
1020 };
1021
1022 /** \brief Resync HA (resend existing sessions to new failover)
1023     @param client_index - opaque cookie to identify the sender
1024     @param context - sender context, to match reply w/ request
1025     @param want_resync_event - resync completed event sent to the sender via
1026                                nat_ha_resync_completed_event API message if
1027                                non-zero
1028     @param pid - sender's pid
1029 */
1030 autoreply define nat_ha_resync
1031 {
1032   option deprecated;
1033   u32 client_index;
1034   u32 context;
1035   u8 want_resync_event;
1036   u32 pid;
1037 };
1038
1039 /** \brief Tell client about a HA resync completion event
1040     @param client_index - opaque cookie to identify the sender
1041     @param pid - client pid registered to receive notification
1042     @param missed_count - number of missed (not ACKed) messages
1043 */
1044 define nat_ha_resync_completed_event
1045 {
1046   option deprecated;
1047   u32 client_index;
1048   u32 pid;
1049   u32 missed_count;
1050 };
1051
1052 service {
1053   rpc nat_ha_resync returns nat_ha_resync_reply events nat_ha_resync_completed_event;
1054 };