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