FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
nat.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 nat.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 /*
24  * Old "snat" APIs, will be deprecated after 17.10
25  */
26 
27 /** \brief Add/del NAT44 address range
28  @param client_index - opaque cookie to identify the sender
29  @param context - sender context, to match reply w/ request
30  @param is_ip4 - 1 if address type is IPv4
31  @param first_ip_address - first IP address
32  @param last_ip_address - last IP address
33  @param vrf_id - VRF id of tenant, ~0 means independent of VRF
34  @param is_add - 1 if add, 0 if delete
35 */
36 autoreply define snat_add_address_range {
40  u8 first_ip_address[16];
41  u8 last_ip_address[16];
44 };
45 
46 /** \brief Dump NAT44 addresses
47  @param client_index - opaque cookie to identify the sender
48  @param context - sender context, to match reply w/ request
49 */
50 define snat_address_dump {
53 };
54 
55 /** \brief NAT44 address details response
56  @param context - sender context, to match reply w/ request
57  @param is_ip4 - 1 if address type is IPv4
58  @param ip_address - IP address
59  @param vrf_id - VRF id of tenant, ~0 means independent of VRF
60 */
61 define snat_address_details {
64  u8 ip_address[16];
66 };
67 
68 /** \brief Enable/disable NAT44 feature on the interface
69  @param client_index - opaque cookie to identify the sender
70  @param context - sender context, to match reply w/ request
71  @param is_add - 1 if add, 0 if delete
72  @param is_inside - 1 if inside, 0 if outside
73  @param sw_if_index - software index of the interface
74 */
75 autoreply define snat_interface_add_del_feature {
81 };
82 
83 /** \brief Dump interfaces with NAT44 feature
84  @param client_index - opaque cookie to identify the sender
85  @param context - sender context, to match reply w/ request
86 */
87 define snat_interface_dump {
90 };
91 
92 /** \brief NAT44 interface details response
93  @param context - sender context, to match reply w/ request
94  @param is_inside - 1 if inside, 0 if outside
95  @param sw_if_index - software index of the interface
96 */
97 define snat_interface_details {
101 };
102 
103 /** \brief Enable/disbale NAT44 as an interface output feature (postrouting
104  in2out translation)
105  @param client_index - opaque cookie to identify the sender
106  @param context - sender context, to match reply w/ request
107  @param is_add - 1 if add, 0 if delete
108  @param is_inside - 1 if inside, 0 if outside
109  @param sw_if_index - software index of the interface
110 */
117 };
118 
119 /** \brief Dump interfaces with NAT44 output feature
120  @param client_index - opaque cookie to identify the sender
121  @param context - sender context, to match reply w/ request
122 */
123 define snat_interface_output_feature_dump {
126 };
127 
128 /** \brief NAT44 interface with output feature details response
129  @param context - sender context, to match reply w/ request
130  @param is_inside - 1 if inside, 0 if outside
131  @param sw_if_index - software index of the interface
132 */
133 define snat_interface_output_feature_details {
137 };
138 
139 /** \brief Add/delete NAT44 static mapping
140  @param client_index - opaque cookie to identify the sender
141  @param context - sender context, to match reply w/ request
142  @param is_add - 1 if add, 0 if delete
143  @param is_ip4 - 1 if address type is IPv4
144  @param addr_only - 1 if address only mapping
145  @param local_ip_address - local IP address
146  @param external_ip_address - external IP address
147  @param protocol - IP protocol
148  @param local_port - local port number
149  @param external_port - external port number
150  @param external_sw_if_index - external interface (if set
151  external_ip_address is ignored, ~0 means not
152  used)
153  @param vfr_id - VRF ID
154 */
155 autoreply define snat_add_static_mapping {
161  u8 local_ip_address[16];
162  u8 external_ip_address[16];
168 };
169 
170 /** \brief Dump NAT44 static mappings
171  @param client_index - opaque cookie to identify the sender
172  @param context - sender context, to match reply w/ request
173 */
174 define snat_static_mapping_dump {
177 };
178 
179 /** \brief NAT44 static mapping details response
180  @param context - sender context, to match reply w/ request
181  @param is_ip4 - 1 if address type is IPv4
182  @param addr_only - 1 if address only mapping
183  @param local_ip_address - local IP address
184  @param external_ip_address - external IP address
185  @param protocol - IP protocol
186  @param local_port - local port number
187  @param external_port - external port number
188  @param external_sw_if_index - external interface
189  @param vfr_id - VRF ID
190 */
191 define snat_static_mapping_details {
195  u8 local_ip_address[16];
196  u8 external_ip_address[16];
202 };
203 
204 /** \brief Control ping from client to api server request
205  @param client_index - opaque cookie to identify the sender
206  @param context - sender context, to match reply w/ request
207 */
208 define snat_control_ping
209 {
212 };
213 
214 /** \brief Control ping from the client to the server response
215  @param client_index - opaque cookie to identify the sender
216  @param context - sender context, to match reply w/ request
217  @param retval - return code for the request
218  @param vpe_pid - the pid of the vpe, returned by the server
219 */
220 define snat_control_ping_reply
221 {
226 };
227 
228 /** \brief Show NAT plugin startup config
229  @param client_index - opaque cookie to identify the sender
230  @param context - sender context, to match reply w/ request
231 */
232 define snat_show_config
233 {
236 };
237 
238 /** \brief Show NAT plugin startup config reply
239  @param context - sender context, to match reply w/ request
240  @param retval - return code for the request
241  @param static_mapping_only - if 1 dynamic translations disabled
242  @param static_mapping_connection_tracking - if 1 create session data
243  @param deterministic - if 1 deterministic mapping
244  @param translation_buckets - number of translation hash buckets
245  @param translation_memory_size - translation hash memory size
246  @param user_buckets - number of user hash buckets
247  @param user_memory_size - user hash memory size
248  @param max_translations_per_user - maximum number of translations per user
249  @param outside_vrf_id - outside VRF id
250  @param inside_vrf_id - default inside VRF id
251 */
252 define snat_show_config_reply
253 {
266 };
267 
268 /** \brief Set NAT workers
269  @param client_index - opaque cookie to identify the sender
270  @param context - sender context, to match reply w/ request
271  @param worker_mask - NAT workers mask
272 */
273 autoreply define snat_set_workers {
277 };
278 
279 /** \brief Dump NAT workers
280  @param client_index - opaque cookie to identify the sender
281  @param context - sender context, to match reply w/ request
282 */
283 define snat_worker_dump {
286 };
287 
288 /** \brief NAT workers details response
289  @param context - sender context, to match reply w/ request
290  @param worker_index - worker index
291  @param lcore_id - lcore ID
292  @param name - worker name
293 */
294 define snat_worker_details {
298  u8 name[64];
299 };
300 
301 /** \brief Add/delete NAT44 pool address from specific interfce
302  @param client_index - opaque cookie to identify the sender
303  @param context - sender context, to match reply w/ request
304  @param is_add - 1 if add, 0 if delete
305  @param sw_if_index - software index of the interface
306 */
307 autoreply define snat_add_del_interface_addr {
313 };
314 
315 /** \brief Dump NAT44 pool addresses interfaces
316  @param client_index - opaque cookie to identify the sender
317  @param context - sender context, to match reply w/ request
318 */
319 define snat_interface_addr_dump {
322 };
323 
324 /** \brief NAT44 pool addresses interfaces details response
325  @param context - sender context, to match reply w/ request
326  @param sw_if_index - software index of the interface
327 */
328 define snat_interface_addr_details {
331 };
332 
333 /** \brief Enable/disable NAT IPFIX logging
334  @param client_index - opaque cookie to identify the sender
335  @param context - sender context, to match reply w/ request
336  @param domain_id - observation domain ID
337  @param src_port - source port number
338  @param enable - 1 if enable, 0 if disable
339 */
340 autoreply define snat_ipfix_enable_disable {
346 };
347 
348 /** \brief Dump NAT44 users
349  @param client_index - opaque cookie to identify the sender
350  @param context - sender context, to match reply w/ request
351 */
352 define snat_user_dump {
355 };
356 
357 /** \brief NAT44 users response
358  @param context - sender context, to match reply w/ request
359  @vrf_id - VRF ID
360  @param is_ip4 - 1 if address type is IPv4
361  @param ip_adress - IP address
362  @param nsessions - number of dynamic sessions
363  @param nstaticsessions - number of static sessions
364 */
365 define snat_user_details {
369  u8 ip_address[16];
372 };
373 
374 /** \brief NAT44 user's sessions
375  @param client_index - opaque cookie to identify the sender
376  @param context - sender context, to match reply w/ request
377  @param is_ip4 - 1 if address type is IPv4
378  @param user_ip - IP address of the user to dump
379  @param vrf_id - VRF_ID
380 */
381 define snat_user_session_dump {
385  u8 ip_address[16];
387 };
388 
389 /** \brief NAT44 user's sessions response
390  @param context - sender context, to match reply w/ request
391  @param is_ip4 - 1 if address type is IPv4
392  @param outside_ip_address - outside IP address
393  @param outside_port - outside port
394  @param inside_ip_address - inside IP address
395  @param inside_port - inside port
396  @param protocol - protocol
397  @param is_static - 1 if session is static
398  @param last_heard - last heard timer
399  @param total_bytes - count of bytes sent through session
400  @param total_pkts - count of pakets sent through session
401 */
402 define snat_user_session_details {
405  u8 outside_ip_address[16];
407  u8 inside_ip_address[16];
414 };
415 
416 /** \brief Add/delete NAT deterministic mapping
417  @param client_index - opaque cookie to identify the sender
418  @param context - sender context, to match reply w/ request
419  @param is_add - 1 if add, 0 if delete
420  @param is_ip4 - 1 if address type is IPv4
421  @param in_addr - inside IP address
422  @param in_plen - inside IP address prefix length
423  @param out_addr - outside IP address
424  @param out_addr - outside IP address prefix length
425 */
426 autoreply define snat_add_det_map {
432  u8 in_addr[16];
434  u8 out_addr[16];
436 };
437 
438 /** \brief Get outside address and port range from inside address
439  @param client_index - opaque cookie to identify the sender
440  @param context - sender context, to match reply w/ request
441  @param is_ip4 - 1 if address type is IPv4
442  @param in_addr - inside IP address
443 */
448  u8 in_addr[16];
449 };
450 
451 /** \brief Get outside address and port range from inside address
452  @param context - sender context, to match reply w/ request
453  @param retval - return code
454  @param out_port_lo - outside port range start
455  @param out_port_hi - outside port range end
456  @param is_ip4 - 1 if address type is IPv4
457  @param out_addr - outside IP address
458 */
459 define snat_det_forward_reply {
465  u8 out_addr[16];
466 };
467 
468 /** \brief Get inside address from outside address and port
469  @param client_index - opaque cookie to identify the sender
470  @param context - sender context, to match reply w/ request
471  @param out_port - outside port
472  @param is_ip4 - 1 if address type is IPv4
473  @param out_addr - outside IP address
474 */
480  u8 out_addr[16];
481 };
482 
483 /** \brief Get inside address from outside address and port reply
484  @param context - sender context, to match reply w/ request
485  @param retval - return code
486  @param is_ip4 - 1 if address type is IPv4
487  @param in_addr - inside IP address
488 */
489 define snat_det_reverse_reply {
493  u8 in_addr[16];
494 };
495 
496 /** \brief Dump NAT deterministic mappings
497  @param client_index - opaque cookie to identify the sender
498  @param context - sender context, to match reply w/ request
499 */
500 define snat_det_map_dump {
503 };
504 
505 /** \brief NAT users response
506  @param context - sender context, to match reply w/ request
507  @param is_ip4 - 1 if address type is IPv4
508  @param in_addr - inside IP address
509  @param in_plen - inside IP address prefix length
510  @param out_addr - outside IP address
511  @param out_plen - outside IP address prefix length
512  @param sharing_ratio - outside to inside address sharing ratio
513  @param ports_per_host - number of ports available to a host
514  @param ses_num - number of sessions belonging to this mapping
515 */
516 define snat_det_map_details {
519  u8 in_addr[16];
521  u8 out_addr[16];
526 };
527 
528 /** \brief Set values of timeouts for deterministic NAT (seconds, 0 = default)
529  @param client_index - opaque cookie to identify the sender
530  @param context - sender context, to match reply w/ request
531  @param udp - UDP timeout (default 300sec)
532  @param tcp_established - TCP established timeout (default 7440sec)
533  @param tcp_transitory - TCP transitory timeout (default 240sec)
534  @param icmp - ICMP timeout (default 60sec)
535 */
536 autoreply define snat_det_set_timeouts {
543 };
544 
545 /** \brief Get values of timeouts for deterministic NAT (seconds)
546  @param client_index - opaque cookie to identify the sender
547  @param context - sender context, to match reply w/ request
548 */
549 define snat_det_get_timeouts {
552 };
553 
554 /** \brief Get values of timeouts for deterministic NAT reply
555  @param context - sender context, to match reply w/ request
556  @param retval - return code
557  @param udp - UDP timeout (default 300sec)
558  @param tcp_established - TCP established timeout (default 7440sec)
559  @param tcp_transitory - TCP transitory timeout (default 240sec)
560  @param icmp - ICMP timeout (default 60sec)
561 */
562 define snat_det_get_timeouts_reply {
569 };
570 
571 /** \brief Close deterministic NAT session by outside address and port
572  @param client_index - opaque cookie to identify the sender
573  @param context - sender context, to match reply w/ request
574  @param is_ip4 - 1 if address type is IPv4
575  @param out_addr - outside IP address
576  @param out_port - outside port
577  @param ext_addr - external host address
578  @param ext_port - external host port
579 */
580 autoreply define snat_det_close_session_out {
584  u8 out_addr[16];
586  u8 ext_addr[16];
588 };
589 
590 /** \brief Close deterministic NAT session by inside address and port
591  @param client_index - opaque cookie to identify the sender
592  @param context - sender context, to match reply w/ request
593  @param is_ip4 - 1 if address type is IPv4
594  @param in_addr - inside IP address
595  @param in_port - inside port
596  @param ext_addr - external host address
597  @param ext_port - external host port
598 */
599 autoreply define snat_det_close_session_in {
603  u8 in_addr[16];
605  u8 ext_addr[16];
607 };
608 
609 /** \brief Dump determinstic NAT sessions
610  @param client_index - opaque cookie to identify the sender
611  @param context - sender context, to match reply w/ request
612  @param is_ip4 - 1 if address type is IPv4
613  @param user_addr - address of an inside user whose sessions to dump
614 */
615 define snat_det_session_dump {
619  u8 user_addr[16];
620 };
621 
622 /** \brief Deterministic NAT sessions reply
623  @param context - sender context, to match reply w/ request
624  @param is_ip4 - 1 if address type is IPv4
625  @param in_port - inside port
626  @param ext_addr - external host address
627  @param ext_port - external host port
628  @param out_port - outside NAT port
629  @param state - session state
630  @param expire - session expiration timestamp
631 */
632 define snat_det_session_details {
637  u8 ext_addr[16];
642 };
643 
644 /*
645  * Common NAT plugin APIs
646  */
647 
648 /** \brief Control ping from client to api server request
649  @param client_index - opaque cookie to identify the sender
650  @param context - sender context, to match reply w/ request
651 */
652 define nat_control_ping
653 {
656 };
657 
658 /** \brief Control ping from the client to the server response
659  @param client_index - opaque cookie to identify the sender
660  @param context - sender context, to match reply w/ request
661  @param retval - return code for the request
662  @param vpe_pid - the pid of the vpe, returned by the server
663 */
664 define nat_control_ping_reply
665 {
670 };
671 
672 /** \brief Show NAT plugin startup config
673  @param client_index - opaque cookie to identify the sender
674  @param context - sender context, to match reply w/ request
675 */
676 define nat_show_config
677 {
680 };
681 
682 /** \brief Show NAT plugin startup config reply
683  @param context - sender context, to match reply w/ request
684  @param retval - return code for the request
685  @param static_mapping_only - if 1 dynamic translations disabled
686  @param static_mapping_connection_tracking - if 1 create session data
687  @param deterministic - if 1 deterministic mapping
688  @param translation_buckets - number of translation hash buckets
689  @param translation_memory_size - translation hash memory size
690  @param user_buckets - number of user hash buckets
691  @param user_memory_size - user hash memory size
692  @param max_translations_per_user - maximum number of translations per user
693  @param outside_vrf_id - outside VRF id
694  @param inside_vrf_id - default inside VRF id
695 */
696 define nat_show_config_reply
697 {
710 };
711 
712 /** \brief Set NAT workers
713  @param client_index - opaque cookie to identify the sender
714  @param context - sender context, to match reply w/ request
715  @param worker_mask - NAT workers mask
716 */
717 autoreply define nat_set_workers {
721 };
722 
723 /** \brief Dump NAT workers
724  @param client_index - opaque cookie to identify the sender
725  @param context - sender context, to match reply w/ request
726 */
727 define nat_worker_dump {
730 };
731 
732 /** \brief NAT workers details response
733  @param context - sender context, to match reply w/ request
734  @param worker_index - worker index
735  @param lcore_id - lcore ID
736  @param name - worker name
737 */
738 define nat_worker_details {
742  u8 name[64];
743 };
744 
745 /** \brief Enable/disable NAT IPFIX logging
746  @param client_index - opaque cookie to identify the sender
747  @param context - sender context, to match reply w/ request
748  @param domain_id - observation domain ID
749  @param src_port - source port number
750  @param enable - 1 if enable, 0 if disable
751 */
752 autoreply define nat_ipfix_enable_disable {
758 };
759 
760 /*
761  * NAT44 APIs
762  */
763 
764 /** \brief Add/del NAT44 address range
765  @param client_index - opaque cookie to identify the sender
766  @param context - sender context, to match reply w/ request
767  @param first_ip_address - first IPv4 address
768  @param last_ip_address - last IPv4 address
769  @param vrf_id - VRF id of tenant, ~0 means independent of VRF
770  @param is_add - 1 if add, 0 if delete
771 */
772 autoreply define nat44_add_del_address_range {
775  u8 first_ip_address[4];
776  u8 last_ip_address[4];
779 };
780 
781 /** \brief Dump NAT44 addresses
782  @param client_index - opaque cookie to identify the sender
783  @param context - sender context, to match reply w/ request
784 */
785 define nat44_address_dump {
788 };
789 
790 /** \brief NAT44 address details response
791  @param context - sender context, to match reply w/ request
792  @param ip_address - IPv4 address
793  @param vrf_id - VRF id of tenant, ~0 means independent of VRF
794 */
795 define nat44_address_details {
797  u8 ip_address[4];
799 };
800 
801 /** \brief Enable/disable NAT44 feature on the interface
802  @param client_index - opaque cookie to identify the sender
803  @param context - sender context, to match reply w/ request
804  @param is_add - 1 if add, 0 if delete
805  @param is_inside - 1 if inside, 0 if outside
806  @param sw_if_index - software index of the interface
807 */
808 autoreply define nat44_interface_add_del_feature {
814 };
815 
816 /** \brief Dump interfaces with NAT44 feature
817  @param client_index - opaque cookie to identify the sender
818  @param context - sender context, to match reply w/ request
819 */
820 define nat44_interface_dump {
823 };
824 
825 /** \brief NAT44 interface details response
826  @param context - sender context, to match reply w/ request
827  @param is_inside - 1 if inside, 0 if outside
828  @param sw_if_index - software index of the interface
829 */
830 define nat44_interface_details {
834 };
835 
836 /** \brief Enable/disbale NAT44 as an interface output feature (postrouting
837  in2out translation)
838  @param client_index - opaque cookie to identify the sender
839  @param context - sender context, to match reply w/ request
840  @param is_add - 1 if add, 0 if delete
841  @param is_inside - 1 if inside, 0 if outside
842  @param sw_if_index - software index of the interface
843 */
844 autoreply define nat44_interface_add_del_output_feature {
850 };
851 
852 /** \brief Dump interfaces with NAT44 output feature
853  @param client_index - opaque cookie to identify the sender
854  @param context - sender context, to match reply w/ request
855 */
856 define nat44_interface_output_feature_dump {
859 };
860 
861 /** \brief NAT44 interface with output feature details response
862  @param context - sender context, to match reply w/ request
863  @param is_inside - 1 if inside, 0 if outside
864  @param sw_if_index - software index of the interface
865 */
866 define nat44_interface_output_feature_details {
870 };
871 
872 /** \brief Add/delete NAT44 static mapping
873  @param client_index - opaque cookie to identify the sender
874  @param context - sender context, to match reply w/ request
875  @param is_add - 1 if add, 0 if delete
876  @param addr_only - 1 if address only mapping
877  @param local_ip_address - local IPv4 address
878  @param external_ip_address - external IPv4 address
879  @param protocol - IP protocol
880  @param local_port - local port number
881  @param external_port - external port number
882  @param external_sw_if_index - external interface (if set
883  external_ip_address is ignored, ~0 means not
884  used)
885  @param vfr_id - VRF ID
886 */
887 autoreply define nat44_add_del_static_mapping {
892  u8 local_ip_address[4];
893  u8 external_ip_address[4];
899 };
900 
901 /** \brief Dump NAT44 static mappings
902  @param client_index - opaque cookie to identify the sender
903  @param context - sender context, to match reply w/ request
904 */
905 define nat44_static_mapping_dump {
908 };
909 
910 /** \brief NAT44 static mapping details response
911  @param context - sender context, to match reply w/ request
912  @param addr_only - 1 if address only mapping
913  @param local_ip_address - local IPv4 address
914  @param external_ip_address - external IPv4 address
915  @param protocol - IP protocol
916  @param local_port - local port number
917  @param external_port - external port number
918  @param external_sw_if_index - external interface
919  @param vfr_id - VRF ID
920 */
921 define nat44_static_mapping_details {
924  u8 local_ip_address[4];
925  u8 external_ip_address[4];
931 };
932 
933 /** \brief Add/delete NAT44 pool address from specific interfce
934  @param client_index - opaque cookie to identify the sender
935  @param context - sender context, to match reply w/ request
936  @param is_add - 1 if add, 0 if delete
937  @param sw_if_index - software index of the interface
938 */
939 autoreply define nat44_add_del_interface_addr {
945 };
946 
947 /** \brief Dump NAT44 pool addresses interfaces
948  @param client_index - opaque cookie to identify the sender
949  @param context - sender context, to match reply w/ request
950 */
951 define nat44_interface_addr_dump {
954 };
955 
956 /** \brief NAT44 pool addresses interfaces details response
957  @param context - sender context, to match reply w/ request
958  @param sw_if_index - software index of the interface
959 */
960 define nat44_interface_addr_details {
963 };
964 
965 /** \brief Dump NAT44 users
966  @param client_index - opaque cookie to identify the sender
967  @param context - sender context, to match reply w/ request
968 */
969 define nat44_user_dump {
972 };
973 
974 /** \brief NAT44 users response
975  @param context - sender context, to match reply w/ request
976  @vrf_id - VRF ID
977  @param ip_adress - IPv4 address
978  @param nsessions - number of dynamic sessions
979  @param nstaticsessions - number of static sessions
980 */
981 define nat44_user_details {
984  u8 ip_address[4];
987 };
988 
989 /** \brief NAT44 user's sessions
990  @param client_index - opaque cookie to identify the sender
991  @param context - sender context, to match reply w/ request
992  @param is_ip4 - 1 if address type is IPv4
993  @param user_ip - IP address of the user to dump
994  @param vrf_id - VRF_ID
995 */
996 define nat44_user_session_dump {
999  u8 ip_address[4];
1001 };
1002 
1003 /** \brief NAT44 user's sessions response
1004  @param context - sender context, to match reply w/ request
1005  @param outside_ip_address - outside IPv4 address
1006  @param outside_port - outside port
1007  @param inside_ip_address - inside IPv4 address
1008  @param inside_port - inside port
1009  @param protocol - protocol
1010  @param is_static - 1 if session is static
1011  @param last_heard - last heard timer
1012  @param total_bytes - count of bytes sent through session
1013  @param total_pkts - count of pakets sent through session
1014 */
1015 define nat44_user_session_details {
1017  u8 outside_ip_address[4];
1019  u8 inside_ip_address[4];
1026 };
1027 
1028 typeonly manual_endian define nat44_lb_addr_port {
1029  u8 addr[4];
1032 };
1033 
1034 autoreply manual_endian define nat44_add_del_lb_static_mapping {
1038  u8 external_addr[4];
1043  vl_api_nat44_lb_addr_port_t locals[local_num];
1044 };
1045 
1046 define nat44_lb_static_mapping_dump {
1049 };
1050 
1051 manual_endian define nat44_lb_static_mapping_details {
1053  u8 external_addr[4];
1058  vl_api_nat44_lb_addr_port_t locals[local_num];
1059 };
1060 
1061 /*
1062  * Deterministic NAT (CGN) APIs
1063  */
1064 
1065 /** \brief Add/delete NAT deterministic mapping
1066  @param client_index - opaque cookie to identify the sender
1067  @param context - sender context, to match reply w/ request
1068  @param is_add - 1 if add, 0 if delete
1069  @param is_nat44 - 1 if NAT44
1070  @param in_addr - inside IP address
1071  @param in_plen - inside IP address prefix length
1072  @param out_addr - outside IPv4 address
1073  @param out_addr - outside IPv4 address prefix length
1074 */
1075 autoreply define nat_det_add_del_map {
1081  u8 in_addr[16];
1083  u8 out_addr[4];
1085 };
1086 
1087 /** \brief Get outside address and port range from inside address
1088  @param client_index - opaque cookie to identify the sender
1089  @param context - sender context, to match reply w/ request
1090  @param is_nat44 - 1 if NAT44
1091  @param in_addr - inside IP address
1092 */
1093 define nat_det_forward {
1097  u8 in_addr[16];
1098 };
1099 
1100 /** \brief Get outside address and port range from inside address
1101  @param context - sender context, to match reply w/ request
1102  @param retval - return code
1103  @param out_port_lo - outside port range start
1104  @param out_port_hi - outside port range end
1105  @param out_addr - outside IPv4 address
1106 */
1107 define nat_det_forward_reply {
1112  u8 out_addr[4];
1113 };
1114 
1115 /** \brief Get inside address from outside address and port
1116  @param client_index - opaque cookie to identify the sender
1117  @param context - sender context, to match reply w/ request
1118  @param out_port - outside port
1119  @param out_addr - outside IPv4 address
1120 */
1121 define nat_det_reverse {
1125  u8 out_addr[4];
1126 };
1127 
1128 /** \brief Get inside address from outside address and port reply
1129  @param context - sender context, to match reply w/ request
1130  @param retval - return code
1131  @param is_nat44 - 1 if NAT44
1132  @param in_addr - inside IP address
1133 */
1134 define nat_det_reverse_reply {
1138  u8 in_addr[16];
1139 };
1140 
1141 /** \brief Dump NAT deterministic mappings
1142  @param client_index - opaque cookie to identify the sender
1143  @param context - sender context, to match reply w/ request
1144 */
1145 define nat_det_map_dump {
1148 };
1149 
1150 /** \brief NAT users response
1151  @param context - sender context, to match reply w/ request
1152  @param is_nat44 - 1 if NAT44
1153  @param in_addr - inside IP address
1154  @param in_plen - inside IP address prefix length
1155  @param out_addr - outside IPv4 address
1156  @param out_plen - outside IPv4 address prefix length
1157  @param sharing_ratio - outside to inside address sharing ratio
1158  @param ports_per_host - number of ports available to a host
1159  @param ses_num - number of sessions belonging to this mapping
1160 */
1161 define nat_det_map_details {
1164  u8 in_addr[16];
1166  u8 out_addr[4];
1171 };
1172 
1173 /** \brief Set values of timeouts for deterministic NAT (seconds, 0 = default)
1174  @param client_index - opaque cookie to identify the sender
1175  @param context - sender context, to match reply w/ request
1176  @param udp - UDP timeout (default 300sec)
1177  @param tcp_established - TCP established timeout (default 7440sec)
1178  @param tcp_transitory - TCP transitory timeout (default 240sec)
1179  @param icmp - ICMP timeout (default 60sec)
1180 */
1181 autoreply define nat_det_set_timeouts {
1188 };
1189 
1190 /** \brief Get values of timeouts for deterministic NAT (seconds)
1191  @param client_index - opaque cookie to identify the sender
1192  @param context - sender context, to match reply w/ request
1193 */
1194 define nat_det_get_timeouts {
1197 };
1198 
1199 /** \brief Get values of timeouts for deterministic NAT reply
1200  @param context - sender context, to match reply w/ request
1201  @param retval - return code
1202  @param udp - UDP timeout (default 300sec)
1203  @param tcp_established - TCP established timeout (default 7440sec)
1204  @param tcp_transitory - TCP transitory timeout (default 240sec)
1205  @param icmp - ICMP timeout (default 60sec)
1206 */
1207 define nat_det_get_timeouts_reply {
1214 };
1215 
1216 /** \brief Close deterministic NAT session by outside address and port
1217  @param client_index - opaque cookie to identify the sender
1218  @param context - sender context, to match reply w/ request
1219  @param out_addr - outside IPv4 address
1220  @param out_port - outside port
1221  @param ext_addr - external host IPv4 address
1222  @param ext_port - external host port
1223 */
1224 autoreply define nat_det_close_session_out {
1227  u8 out_addr[4];
1229  u8 ext_addr[4];
1231 };
1232 
1233 /** \brief Close deterministic NAT session by inside address and port
1234  @param client_index - opaque cookie to identify the sender
1235  @param context - sender context, to match reply w/ request
1236  @param is_nat44 - 1 if NAT44
1237  @param in_addr - inside IP address
1238  @param in_port - inside port
1239  @param ext_addr - external host IP address
1240  @param ext_port - external host port
1241 */
1242 autoreply define nat_det_close_session_in {
1246  u8 in_addr[16];
1248  u8 ext_addr[16];
1250 };
1251 
1252 /** \brief Dump determinstic NAT sessions
1253  @param client_index - opaque cookie to identify the sender
1254  @param context - sender context, to match reply w/ request
1255  @param is_nat44 - 1 if NAT44
1256  @param user_addr - address of an inside user whose sessions to dump
1257 */
1258 define nat_det_session_dump {
1262  u8 user_addr[16];
1263 };
1264 
1265 /** \brief Deterministic NAT sessions reply
1266  @param context - sender context, to match reply w/ request
1267  @param in_port - inside port
1268  @param ext_addr - external host address
1269  @param ext_port - external host port
1270  @param out_port - outside NAT port
1271  @param state - session state
1272  @param expire - session expiration timestamp
1273 */
1274 define nat_det_session_details {
1278  u8 ext_addr[4];
1283 };
1284 
1285 /*
1286  * NAT64 APIs
1287  */
1288 
1289 /** \brief Add/delete address range to NAT64 pool
1290  @param client_index - opaque cookie to identify the sender
1291  @param context - sender context, to match reply w/ request
1292  @param start_addr - start address of the range
1293  @param end_addr - end address of the range
1294  @param vrf_id - VRF id of tenant, ~0 means independent of VRF
1295  @param is_add - 1 if add, 0 if delete
1296 */
1297 autoreply define nat64_add_del_pool_addr_range {
1300  u8 start_addr[4];
1301  u8 end_addr[4];
1304 };
1305 
1306 /** \brief Dump NAT64 pool addresses
1307  @param client_index - opaque cookie to identify the sender
1308  @param context - sender context, to match reply w/ request
1309 */
1310 define nat64_pool_addr_dump {
1313 };
1314 
1315 /** \brief NAT64 pool address details response
1316  @param context - sender context, to match reply w/ request
1317  @param address - IPv4 address
1318  @param vfr_id - VRF id of tenant, ~0 means independent of VRF
1319 */
1320 define nat64_pool_addr_details {
1322  u8 address[4];
1324 };
1325 
1326 /** \brief Enable/disable NAT64 feature on the interface
1327  @param client_index - opaque cookie to identify the sender
1328  @param context - sender context, to match reply w/ request
1329  @param sw_if_index - index of the interface
1330  @param is_inside - 1 if inside, 0 if outside
1331  @param is_add - 1 if add, 0 if delete
1332 */
1333 autoreply define nat64_add_del_interface {
1339 };
1340 
1341 /** \brief Dump interfaces with NAT64 feature
1342  @param client_index - opaque cookie to identify the sender
1343  @param context - sender context, to match reply w/ request
1344 */
1345 define nat64_interface_dump {
1348 };
1349 
1350 /** \brief NAT64 interface details response
1351  @param context - sender context, to match reply w/ request
1352  @param is_inside - 1 if inside, 0 if outside
1353  @param sw_if_index - index of the interface
1354 */
1355 define nat64_interface_details {
1359 };
1360 
1361 /** \brief Add/delete NAT64 static BIB entry
1362  @param client_index - opaque cookie to identify the sender
1363  @param context - sender context, to match reply w/ request
1364  @param i_addr - inside IPv6 address
1365  @param o_addr - outside IPv4 address
1366  @param i_port - inside port number
1367  @param o_port - outside port number
1368  @param vrf_id - VRF id of tenant
1369  @param proto - protocol number
1370  @param is_add - 1 if add, 0 if delete
1371 */
1372  autoreply define nat64_add_del_static_bib {
1375  u8 i_addr[16];
1376  u8 o_addr[4];
1382 };
1383 
1384 /** \brief Dump NAT64 BIB
1385  @param client_index - opaque cookie to identify the sender
1386  @param context - sender context, to match reply w/ request
1387  @param proto - protocol of the BIB: 255 - all BIBs
1388  6 - TCP BIB
1389  17 - UDP BIB
1390  1/58 - ICMP BIB
1391  otherwise - "unknown" protocol BIB
1392 */
1393 define nat64_bib_dump {
1397 };
1398 
1399 /** \brief NAT64 BIB details response
1400  @param context - sender context, to match reply w/ request
1401  @param i_addr - inside IPv6 address
1402  @param o_addr - outside IPv4 address
1403  @param i_port - inside port number
1404  @param o_port - outside port number
1405  @param vrf_id - VRF id of tenant
1406  @param proto - protocol number
1407  @param is_static - 1 if static BIB entry, 0 if dynamic
1408  @param ses_num - number of sessions associated with the BIB entry
1409 */
1410 define nat64_bib_details {
1412  u8 i_addr[16];
1413  u8 o_addr[4];
1420 };
1421 
1422 /** \brief Set values of timeouts for NAT64 (seconds, 0 = default)
1423  @param client_index - opaque cookie to identify the sender
1424  @param context - sender context, to match reply w/ request
1425  @param udp - UDP timeout (default 300sec)
1426  @param icmp - ICMP timeout (default 60sec)
1427  @param tcp_trans - TCP transitory timeout (default 240sec)
1428  @param tcp_est - TCP established timeout (default 7440sec)
1429  @param tcp_incoming_syn - TCP incoming SYN timeout (default 6sec)
1430 */
1431 autoreply define nat64_set_timeouts {
1439 };
1440 
1441 /** \brief Get values of timeouts for NAT64 (seconds)
1442  @param client_index - opaque cookie to identify the sender
1443  @param context - sender context, to match reply w/ request
1444 */
1445 define nat64_get_timeouts {
1448 };
1449 
1450 /** \brief Get values of timeouts for NAT64 reply
1451  @param context - sender context, to match reply w/ request
1452  @param retval - return code
1453  @param udp - UDP timeout
1454  @param icmp - ICMP timeout
1455  @param tcp_trans - TCP transitory timeout
1456  @param tcp_est - TCP established timeout
1457  @param tcp_incoming_syn - TCP incoming SYN timeout
1458 */
1459 define nat64_get_timeouts_reply {
1467 };
1468 
1469 /** \brief Dump NAT64 session table
1470  @param client_index - opaque cookie to identify the sender
1471  @param context - sender context, to match reply w/ request
1472  @param proto - protocol of the session table: 255 - all STs
1473  6 - TCP ST
1474  17 - UDP ST
1475  1/58 - ICMP ST
1476  otherwise - "unknown" proto ST
1477 */
1478 define nat64_st_dump {
1482 };
1483 
1484 /** \brief NAT64 session table details response
1485  @param context - sender context, to match reply w/ request
1486  @param il_addr - inside IPv6 address of the local host
1487  @param ol_addr - outside IPv4 address of the local host
1488  @param il_port - inside port number id of the local host/inside ICMP id
1489  @param ol_port - outside port number of the local host/outside ICMP id
1490  @param il_addr - inside IPv6 address of the remote host
1491  @param ol_addr - outside IPv4 address of the remote host
1492  @param l_port - port number of the remote host (not used for ICMP)
1493  @param vrf_id - VRF id of tenant
1494  @param proto - protocol number
1495 */
1496 define nat64_st_details {
1498  u8 il_addr[16];
1499  u8 ol_addr[4];
1502  u8 ir_addr[16];
1503  u8 or_addr[4];
1507 };
1508 
1509 /** \brief Add/del NAT64 prefix
1510  @param client_index - opaque cookie to identify the sender
1511  @param context - sender context, to match reply w/ request
1512  @param prefix - NAT64 prefix
1513  @param prefix - NAT64 prefix length
1514  @param vrf_id - VRF id of tenant
1515  @param is_add - 1 if add, 0 if delete
1516 */
1517 autoreply define nat64_add_del_prefix {
1520  u8 prefix[16];
1524 };
1525 
1526 /** \brief Dump NAT64 prefix
1527  @param client_index - opaque cookie to identify the sender
1528  @param context - sender context, to match reply w/ request
1529 */
1530 define nat64_prefix_dump {
1533 };
1534 
1535 /** \brief Dump NAT64 prefix details response
1536  @param context - sender context, to match reply w/ request
1537  @param prefix - NAT64 prefix
1538  @param prefix - NAT64 prefix length
1539  @param vrf_id - VRF id of tenant
1540 */
1541 define nat64_prefix_details {
1543  u8 prefix[16];
1546 };
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:166
static void snat_det_forward(snat_det_map_t *dm, ip4_address_t *in_addr, ip4_address_t *out_addr, u16 *lo_port)
Definition: nat_det.h:75
static void snat_det_reverse(snat_det_map_t *dm, ip4_address_t *out_addr, u16 out_port, ip4_address_t *in_addr)
Definition: nat_det.h:90
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:622
int snat_interface_add_del_output_feature(u32 sw_if_index, u8 is_inside, int is_del)
Definition: nat.c:1017
int nat44_add_del_lb_static_mapping(ip4_address_t e_addr, u16 e_port, snat_protocol_t proto, u32 vrf_id, nat44_lb_addr_port_t *locals, u8 is_add)
Definition: nat.c:582
unsigned int u32
Definition: types.h:88
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
int snat_set_workers(uword *bitmap)
Definition: nat.c:1102
vhost_vring_addr_t addr
Definition: vhost-user.h:83
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: nat.c:262