FD.io VPP  v17.07.01-10-g3be13f0
Vector Packet Processing
snat.api
Go to the documentation of this file.
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  * @file snat.api
17  * @brief VPP control-plane API messages.
18  *
19  * This file defines VPP control-plane API messages which are generally
20  * called through a shared memory interface.
21  */
22 
23 /** \brief Add/del S-NAT address range
24  @param client_index - opaque cookie to identify the sender
25  @param context - sender context, to match reply w/ request
26  @param is_ip4 - 1 if address type is IPv4
27  @param first_ip_address - first IP address
28  @param last_ip_address - last IP address
29  @param vrf_id - VRF id of tenant, ~0 means independent of VRF
30  @param is_add - 1 if add, 0 if delete
31 */
32 autoreply define snat_add_address_range {
36  u8 first_ip_address[16];
37  u8 last_ip_address[16];
40 };
41 
42 /** \brief Dump S-NAT addresses
43  @param client_index - opaque cookie to identify the sender
44  @param context - sender context, to match reply w/ request
45 */
46 define snat_address_dump {
49 };
50 
51 /** \brief S-NAT address details response
52  @param context - sender context, to match reply w/ request
53  @param is_ip4 - 1 if address type is IPv4
54  @param ip_address - IP address
55  @param vrf_id - VRF id of tenant, ~0 means independent of VRF
56 */
57 define snat_address_details {
60  u8 ip_address[16];
62 };
63 
64 /** \brief Enable/disable S-NAT feature on the interface
65  @param client_index - opaque cookie to identify the sender
66  @param context - sender context, to match reply w/ request
67  @param is_add - 1 if add, 0 if delete
68  @param is_inside - 1 if inside, 0 if outside
69  @param sw_if_index - software index of the interface
70 */
71 autoreply define snat_interface_add_del_feature {
77 };
78 
79 /** \brief Dump interfaces with S-NAT feature
80  @param client_index - opaque cookie to identify the sender
81  @param context - sender context, to match reply w/ request
82 */
83 define snat_interface_dump {
86 };
87 
88 /** \brief S-NAT interface details response
89  @param context - sender context, to match reply w/ request
90  @param is_inside - 1 if inside, 0 if outside
91  @param sw_if_index - software index of the interface
92 */
93 define snat_interface_details {
97 };
98 
99 /** \brief Add/delete S-NAT static mapping
100  @param client_index - opaque cookie to identify the sender
101  @param context - sender context, to match reply w/ request
102  @param is_add - 1 if add, 0 if delete
103  @param is_ip4 - 1 if address type is IPv4
104  @param addr_only - 1 if address only mapping
105  @param local_ip_address - local IP address
106  @param external_ip_address - external IP address
107  @param protocol - IP protocol
108  @param local_port - local port number
109  @param external_port - external port number
110  @param external_sw_if_index - external interface (if set
111  external_ip_address is ignored, ~0 means not
112  used)
113  @param vfr_id - VRF ID
114 */
115 autoreply define snat_add_static_mapping {
121  u8 local_ip_address[16];
122  u8 external_ip_address[16];
128 };
129 
130 /** \brief Dump S-NAT static mappings
131  @param client_index - opaque cookie to identify the sender
132  @param context - sender context, to match reply w/ request
133 */
134 define snat_static_mapping_dump {
137 };
138 
139 /** \brief S-NAT static mapping details response
140  @param context - sender context, to match reply w/ request
141  @param is_ip4 - 1 if address type is IPv4
142  @param addr_only - 1 if address only mapping
143  @param local_ip_address - local IP address
144  @param external_ip_address - external IP address
145  @param protocol - IP protocol
146  @param local_port - local port number
147  @param external_port - external port number
148  @param external_sw_if_index - external interface
149  @param vfr_id - VRF ID
150 */
151 define snat_static_mapping_details {
155  u8 local_ip_address[16];
156  u8 external_ip_address[16];
162 };
163 
164 /** \brief Control ping from client to api server request
165  @param client_index - opaque cookie to identify the sender
166  @param context - sender context, to match reply w/ request
167 */
168 define snat_control_ping
169 {
172 };
173 
174 /** \brief Control ping from the client to the server response
175  @param client_index - opaque cookie to identify the sender
176  @param context - sender context, to match reply w/ request
177  @param retval - return code for the request
178  @param vpe_pid - the pid of the vpe, returned by the server
179 */
180 define snat_control_ping_reply
181 {
186 };
187 
188 /** \brief Show S-NAT plugin startup config
189  @param client_index - opaque cookie to identify the sender
190  @param context - sender context, to match reply w/ request
191 */
192 define snat_show_config
193 {
196 };
197 
198 /** \brief Show S-NAT plugin startup config reply
199  @param context - sender context, to match reply w/ request
200  @param retval - return code for the request
201  @param static_mapping_only - if 1 dynamic translations disabled
202  @param static_mapping_connection_tracking - if 1 create session data
203  @param deterministic - if 1 deterministic mapping
204  @param translation_buckets - number of translation hash buckets
205  @param translation_memory_size - translation hash memory size
206  @param user_buckets - number of user hash buckets
207  @param user_memory_size - user hash memory size
208  @param max_translations_per_user - maximum number of translations per user
209  @param outside_vrf_id - outside VRF id
210  @param inside_vrf_id - default inside VRF id
211 */
212 define snat_show_config_reply
213 {
226 };
227 
228 /** \brief Set S-NAT workers
229  @param client_index - opaque cookie to identify the sender
230  @param context - sender context, to match reply w/ request
231  @param worker_mask - S-NAT workers mask
232 */
233 autoreply define snat_set_workers {
237 };
238 
239 /** \brief Dump S-NAT workers
240  @param client_index - opaque cookie to identify the sender
241  @param context - sender context, to match reply w/ request
242 */
243 define snat_worker_dump {
246 };
247 
248 /** \brief S-NAT workers details response
249  @param context - sender context, to match reply w/ request
250  @param worker_index - worker index
251  @param lcore_id - lcore ID
252  @param name - worker name
253 */
254 define snat_worker_details {
258  u8 name[64];
259 };
260 
261 /** \brief Add/delete S-NAT pool address from specific interfce
262  @param client_index - opaque cookie to identify the sender
263  @param context - sender context, to match reply w/ request
264  @param is_add - 1 if add, 0 if delete
265  @param sw_if_index - software index of the interface
266 */
267 autoreply define snat_add_del_interface_addr {
273 };
274 
275 /** \brief Dump S-NAT pool addresses interfaces
276  @param client_index - opaque cookie to identify the sender
277  @param context - sender context, to match reply w/ request
278 */
279 define snat_interface_addr_dump {
282 };
283 
284 /** \brief S-NAT pool addresses interfaces details response
285  @param context - sender context, to match reply w/ request
286  @param sw_if_index - software index of the interface
287 */
288 define snat_interface_addr_details {
291 };
292 
293 /** \brief Enable/disable S-NAT IPFIX logging
294  @param client_index - opaque cookie to identify the sender
295  @param context - sender context, to match reply w/ request
296  @param domain_id - observation domain ID
297  @param src_port - source port number
298  @param enable - 1 if enable, 0 if disable
299 */
300 autoreply define snat_ipfix_enable_disable {
306 };
307 
308 /** \brief Dump S-NAT users
309  @param client_index - opaque cookie to identify the sender
310  @param context - sender context, to match reply w/ request
311 */
312 define snat_user_dump {
315 };
316 
317 /** \brief S-NAT users response
318  @param context - sender context, to match reply w/ request
319  @vrf_id - VRF ID
320  @param is_ip4 - 1 if address type is IPv4
321  @param ip_adress - IP address
322  @param nsessions - number of dynamic sessions
323  @param nstaticsessions - number of static sessions
324 */
325 define snat_user_details {
329  u8 ip_address[16];
332 };
333 
334 /** \brief S-NAT user's sessions
335  @param client_index - opaque cookie to identify the sender
336  @param context - sender context, to match reply w/ request
337  @param is_ip4 - 1 if address type is IPv4
338  @param user_ip - IP address of the user to dump
339  @param vrf_id - VRF_ID
340 */
341 define snat_user_session_dump {
345  u8 ip_address[16];
347 };
348 
349 /** \brief S-NAT user's sessions response
350  @param context - sender context, to match reply w/ request
351  @param is_ip4 - 1 if address type is IPv4
352  @param outside_ip_address - outside IP address
353  @param outside_port - outside port
354  @param inside_ip_address - inside IP address
355  @param inside_port - inside port
356  @param protocol - protocol
357  @param is_static - 1 if session is static
358  @param last_heard - last heard timer
359  @param total_bytes - count of bytes sent through session
360  @param total_pkts - count of pakets sent through session
361 */
362 define snat_user_session_details {
365  u8 outside_ip_address[16];
367  u8 inside_ip_address[16];
374 };
375 
376 /** \brief Add/delete S-NAT deterministic mapping
377  @param client_index - opaque cookie to identify the sender
378  @param context - sender context, to match reply w/ request
379  @param is_add - 1 if add, 0 if delete
380  @param is_ip4 - 1 if address type is IPv4
381  @param in_addr - inside IP address
382  @param in_plen - inside IP address prefix length
383  @param out_addr - outside IP address
384  @param out_addr - outside IP address prefix length
385 */
386 autoreply define snat_add_det_map {
392  u8 in_addr[16];
394  u8 out_addr[16];
396 };
397 
398 /** \brief Get outside address and port range from inside address
399  @param client_index - opaque cookie to identify the sender
400  @param context - sender context, to match reply w/ request
401  @param is_ip4 - 1 if address type is IPv4
402  @param in_addr - inside IP address
403 */
408  u8 in_addr[16];
409 };
410 
411 /** \brief Get outside address and port range from inside address
412  @param context - sender context, to match reply w/ request
413  @param retval - return code
414  @param out_port_lo - outside port range start
415  @param out_port_hi - outside port range end
416  @param is_ip4 - 1 if address type is IPv4
417  @param out_addr - outside IP address
418 */
419 define snat_det_forward_reply {
425  u8 out_addr[16];
426 };
427 
428 /** \brief Get inside address from outside address and port
429  @param client_index - opaque cookie to identify the sender
430  @param context - sender context, to match reply w/ request
431  @param out_port - outside port
432  @param is_ip4 - 1 if address type is IPv4
433  @param out_addr - outside IP address
434 */
440  u8 out_addr[16];
441 };
442 
443 /** \brief Get inside address from outside address and port reply
444  @param context - sender context, to match reply w/ request
445  @param retval - return code
446  @param is_ip4 - 1 if address type is IPv4
447  @param in_addr - inside IP address
448 */
449 define snat_det_reverse_reply {
453  u8 in_addr[16];
454 };
455 
456 /** \brief Dump S-NAT deterministic mappings
457  @param client_index - opaque cookie to identify the sender
458  @param context - sender context, to match reply w/ request
459 */
460 define snat_det_map_dump {
463 };
464 
465 /** \brief S-NAT users response
466  @param context - sender context, to match reply w/ request
467  @param is_ip4 - 1 if address type is IPv4
468  @param in_addr - inside IP address
469  @param in_plen - inside IP address prefix length
470  @param out_addr - outside IP address
471  @param out_plen - outside IP address prefix length
472  @param sharing_ratio - outside to inside address sharing ratio
473  @param ports_per_host - number of ports available to a host
474  @param ses_num - number of sessions belonging to this mapping
475 */
476 define snat_det_map_details {
479  u8 in_addr[16];
481  u8 out_addr[16];
486 };
487 
488 /** \brief Set values of timeouts for deterministic NAT (seconds, 0 = default)
489  @param client_index - opaque cookie to identify the sender
490  @param context - sender context, to match reply w/ request
491  @param udp - UDP timeout (default 300sec)
492  @param tcp_established - TCP established timeout (default 7440sec)
493  @param tcp_transitory - TCP transitory timeout (default 240sec)
494  @param icmp - ICMP timeout (default 60sec)
495 */
496 autoreply define snat_det_set_timeouts {
503 };
504 
505 /** \brief Get values of timeouts for deterministic NAT (seconds)
506  @param client_index - opaque cookie to identify the sender
507  @param context - sender context, to match reply w/ request
508 */
509 define snat_det_get_timeouts {
512 };
513 
514 /** \brief Get values of timeouts for deterministic NAT reply
515  @param context - sender context, to match reply w/ request
516  @param retval - return code
517  @param udp - UDP timeout (default 300sec)
518  @param tcp_established - TCP established timeout (default 7440sec)
519  @param tcp_transitory - TCP transitory timeout (default 240sec)
520  @param icmp - ICMP timeout (default 60sec)
521 */
522 define snat_det_get_timeouts_reply {
529 };
530 
531 /** \brief Close CGNAT session by outside address and port
532  @param client_index - opaque cookie to identify the sender
533  @param context - sender context, to match reply w/ request
534  @param is_ip4 - 1 if address type is IPv4
535  @param out_addr - outside IP address
536  @param out_port - outside port
537  @param ext_addr - external host address
538  @param ext_port - external host port
539 */
540 autoreply define snat_det_close_session_out {
544  u8 out_addr[16];
546  u8 ext_addr[16];
548 };
549 
550 /** \brief Close CGNAT session by inside address and port
551  @param client_index - opaque cookie to identify the sender
552  @param context - sender context, to match reply w/ request
553  @param is_ip4 - 1 if address type is IPv4
554  @param in_addr - inside IP address
555  @param in_port - inside port
556  @param ext_addr - external host address
557  @param ext_port - external host port
558 */
559 autoreply define snat_det_close_session_in {
563  u8 in_addr[16];
565  u8 ext_addr[16];
567 };
568 
569 /** \brief Dump S-NAT deterministic sessions
570  @param client_index - opaque cookie to identify the sender
571  @param context - sender context, to match reply w/ request
572  @param is_ip4 - 1 if address type is IPv4
573  @param user_addr - address of an inside user whose sessions to dump
574 */
575 define snat_det_session_dump {
579  u8 user_addr[16];
580 };
581 
582 /** \brief S-NAT deterministic sessions reply
583  @param context - sender context, to match reply w/ request
584  @param is_ip4 - 1 if address type is IPv4
585  @param in_port - inside port
586  @param ext_addr - external host address
587  @param ext_port - external host port
588  @param out_port - outside NAT port
589  @param state - session state
590  @param expire - session expiration timestamp
591 */
592 define snat_det_session_details {
597  u8 ext_addr[16];
602 };
603 
604 /** \brief Add/delete address range to NAT64 pool
605  @param client_index - opaque cookie to identify the sender
606  @param context - sender context, to match reply w/ request
607  @param start_addr - start address of the range
608  @param end_addr - end address of the range
609  @param vrf_id - VRF id of tenant, ~0 means independent of VRF
610  @param is_add - 1 if add, 0 if delete
611 */
612 autoreply define nat64_add_del_pool_addr_range {
615  u8 start_addr[4];
616  u8 end_addr[4];
619 };
620 
621 /** \brief Dump NAT64 pool addresses
622  @param client_index - opaque cookie to identify the sender
623  @param context - sender context, to match reply w/ request
624 */
625 define nat64_pool_addr_dump {
628 };
629 
630 /** \brief NAT64 pool address details response
631  @param context - sender context, to match reply w/ request
632  @param address - IPv4 address
633  @param vfr_id - VRF id of tenant, ~0 means independent of VRF
634 */
635 define nat64_pool_addr_details {
637  u8 address[4];
639 };
640 
641 /** \brief Enable/disable NAT64 feature on the interface
642  @param client_index - opaque cookie to identify the sender
643  @param context - sender context, to match reply w/ request
644  @param sw_if_index - index of the interface
645  @param is_inside - 1 if inside, 0 if outside
646  @param is_add - 1 if add, 0 if delete
647 */
648 autoreply define nat64_add_del_interface {
654 };
655 
656 /** \brief Dump interfaces with NAT64 feature
657  @param client_index - opaque cookie to identify the sender
658  @param context - sender context, to match reply w/ request
659 */
660 define nat64_interface_dump {
663 };
664 
665 /** \brief NAT64 interface details response
666  @param context - sender context, to match reply w/ request
667  @param is_inside - 1 if inside, 0 if outside
668  @param sw_if_index - index of the interface
669 */
670 define nat64_interface_details {
674 };
675 
676 /** \brief Add/delete NAT64 static BIB entry
677  @param client_index - opaque cookie to identify the sender
678  @param context - sender context, to match reply w/ request
679  @param i_addr - inside IPv6 address
680  @param o_addr - outside IPv4 address
681  @param i_port - inside port number
682  @param o_port - outside port number
683  @param vrf_id - VRF id of tenant
684  @param proto - protocol number
685  @param is_add - 1 if add, 0 if delete
686 */
687  autoreply define nat64_add_del_static_bib {
690  u8 i_addr[16];
691  u8 o_addr[4];
697 };
698 
699 /** \brief Dump NAT64 BIB
700  @param client_index - opaque cookie to identify the sender
701  @param context - sender context, to match reply w/ request
702  @param proto - protocol of the BIB
703 */
704 define nat64_bib_dump {
708 };
709 
710 /** \brief NAT64 BIB details response
711  @param context - sender context, to match reply w/ request
712  @param i_addr - inside IPv6 address
713  @param o_addr - outside IPv4 address
714  @param i_port - inside port number
715  @param o_port - outside port number
716  @param vrf_id - VRF id of tenant
717  @param proto - protocol number
718  @param is_static - 1 if static BIB entry, 0 if dynamic
719  @param ses_num - number of sessions associated with the BIB entry
720 */
721 define nat64_bib_details {
723  u8 i_addr[16];
724  u8 o_addr[4];
731 };
732 
733 /** \brief Set values of timeouts for NAT64 (seconds, 0 = default)
734  @param client_index - opaque cookie to identify the sender
735  @param context - sender context, to match reply w/ request
736  @param udp - UDP timeout (default 300sec)
737  @param icmp - ICMP timeout (default 60sec)
738  @param tcp_trans - TCP transitory timeout (default 240sec)
739  @param tcp_est - TCP established timeout (default 7440sec)
740  @param tcp_incoming_syn - TCP incoming SYN timeout (default 6sec)
741 */
742 autoreply define nat64_set_timeouts {
750 };
751 
752 /** \brief Get values of timeouts for NAT64 (seconds)
753  @param client_index - opaque cookie to identify the sender
754  @param context - sender context, to match reply w/ request
755 */
756 define nat64_get_timeouts {
759 };
760 
761 /** \brief Get values of timeouts for NAT64 reply
762  @param context - sender context, to match reply w/ request
763  @param retval - return code
764  @param udp - UDP timeout
765  @param icmp - ICMP timeout
766  @param tcp_trans - TCP transitory timeout
767  @param tcp_est - TCP established timeout
768  @param tcp_incoming_syn - TCP incoming SYN timeout
769 */
770 define nat64_get_timeouts_reply {
778 };
779 
780 /** \brief Dump NAT64 session table
781  @param client_index - opaque cookie to identify the sender
782  @param context - sender context, to match reply w/ request
783  @param proto - protocol of the session table
784 */
785 define nat64_st_dump {
789 };
790 
791 /** \brief NAT64 session table details response
792  @param context - sender context, to match reply w/ request
793  @param il_addr - inside IPv6 address of the local host
794  @param ol_addr - outside IPv4 address of the local host
795  @param il_port - inside port number id of the local host/inside ICMP id
796  @param ol_port - outside port number of the local host/outside ICMP id
797  @param il_addr - inside IPv6 address of the remote host
798  @param ol_addr - outside IPv4 address of the remote host
799  @param l_port - port number of the remote host (not used for ICMP)
800  @param vrf_id - VRF id of tenant
801  @param proto - protocol number
802 */
803 define nat64_st_details {
805  u8 il_addr[16];
806  u8 ol_addr[4];
809  u8 ir_addr[16];
810  u8 or_addr[4];
814 };
815 
816 /** \brief Add/del NAT64 prefix
817  @param client_index - opaque cookie to identify the sender
818  @param context - sender context, to match reply w/ request
819  @param prefix - NAT64 prefix
820  @param prefix - NAT64 prefix length
821  @param vrf_id - VRF id of tenant
822  @param is_add - 1 if add, 0 if delete
823 */
824 autoreply define nat64_add_del_prefix {
827  u8 prefix[16];
831 };
832 
833 /** \brief Dump NAT64 prefix
834  @param client_index - opaque cookie to identify the sender
835  @param context - sender context, to match reply w/ request
836 */
837 define nat64_prefix_dump {
840 };
841 
842 /** \brief Dump NAT64 prefix details response
843  @param context - sender context, to match reply w/ request
844  @param prefix - NAT64 prefix
845  @param prefix - NAT64 prefix length
846  @param vrf_id - VRF id of tenant
847 */
848 define nat64_prefix_details {
850  u8 prefix[16];
853 };
int nat64_add_del_interface(u32 sw_if_index, u8 is_inside, u8 is_add)
Enable/disable NAT64 feature on the interface.
Definition: nat64.c:159
static void snat_det_reverse(snat_det_map_t *dm, ip4_address_t *out_addr, u16 out_port, ip4_address_t *in_addr)
Definition: snat_det.h:90
static void snat_det_forward(snat_det_map_t *dm, ip4_address_t *in_addr, ip4_address_t *out_addr, u16 *lo_port)
Definition: snat_det.h:75
int i32
Definition: types.h:81
unsigned long u64
Definition: types.h:89
int nat64_add_del_prefix(ip6_address_t *prefix, u8 plen, u32 vrf_id, u8 is_add)
Add/delete NAT64 prefix.
Definition: nat64.c:611
int snat_set_workers(uword *bitmap)
Definition: snat.c:695
int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, u16 l_port, u16 e_port, u32 vrf_id, int addr_only, u32 sw_if_index, snat_protocol_t proto, int is_add)
Add static mapping.
Definition: snat.c:223
unsigned int u32
Definition: types.h:88
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56