FD.io VPP  v17.04.2-2-ga8f93f8
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 define snat_add_address_range {
36  u8 first_ip_address[16];
37  u8 last_ip_address[16];
40 };
41 
42 /** \brief Add S-NAT address range reply
43  @param context - sender context, to match reply w/ request
44  @param retval - return code
45 */
46 define snat_add_address_range_reply {
49 };
50 
51 /** \brief Dump S-NAT addresses
52  @param client_index - opaque cookie to identify the sender
53  @param context - sender context, to match reply w/ request
54 */
55 define snat_address_dump {
58 };
59 
60 /** \brief S-NAT address details response
61  @param context - sender context, to match reply w/ request
62  @param is_ip4 - 1 if address type is IPv4
63  @param ip_address - IP address
64  @param vrf_id - VRF id of tenant, ~0 means independent of VRF
65 */
66 define snat_address_details {
69  u8 ip_address[16];
71 };
72 
73 /** \brief Enable/disable S-NAT feature on the interface
74  @param client_index - opaque cookie to identify the sender
75  @param context - sender context, to match reply w/ request
76  @param is_add - 1 if add, 0 if delete
77  @param is_inside - 1 if inside, 0 if outside
78  @param sw_if_index - software index of the interface
79 */
80 define snat_interface_add_del_feature {
86 };
87 
88 /** \brief Enable/disable S-NAT feature on the interface reply
89  @param context - sender context, to match reply w/ request
90  @param retval - return code
91 */
92 define snat_interface_add_del_feature_reply {
95 };
96 
97 /** \brief Dump interfaces with S-NAT feature
98  @param client_index - opaque cookie to identify the sender
99  @param context - sender context, to match reply w/ request
100 */
101 define snat_interface_dump {
104 };
105 
106 /** \brief S-NAT interface details response
107  @param context - sender context, to match reply w/ request
108  @param is_inside - 1 if inside, 0 if outside
109  @param sw_if_index - software index of the interface
110 */
111 define snat_interface_details {
115 };
116 
117 /** \brief Add/delete S-NAT static mapping
118  @param client_index - opaque cookie to identify the sender
119  @param context - sender context, to match reply w/ request
120  @param is_add - 1 if add, 0 if delete
121  @param is_ip4 - 1 if address type is IPv4
122  @param addr_only - 1 if address only mapping
123  @param local_ip_address - local IP address
124  @param external_ip_address - external IP address
125  @param protocol - IP protocol
126  @param local_port - local port number
127  @param external_port - external port number
128  @param external_sw_if_index - external interface (if set
129  external_ip_address is ignored)
130  @param vfr_id - VRF ID
131 */
138  u8 local_ip_address[16];
139  u8 external_ip_address[16];
145 };
146 
147 /** \brief Add/delete S-NAT static mapping reply
148  @param context - sender context, to match reply w/ request
149  @param retval - return code
150 */
151 define snat_add_static_mapping_reply {
154 };
155 
156 /** \brief Dump S-NAT static mappings
157  @param client_index - opaque cookie to identify the sender
158  @param context - sender context, to match reply w/ request
159 */
160 define snat_static_mapping_dump {
163 };
164 
165 /** \brief S-NAT static mapping details response
166  @param context - sender context, to match reply w/ request
167  @param is_ip4 - 1 if address type is IPv4
168  @param addr_only - 1 if address only mapping
169  @param local_ip_address - local IP address
170  @param external_ip_address - external IP address
171  @param protocol - IP protocol
172  @param local_port - local port number
173  @param external_port - external port number
174  @param external_sw_if_index - external interface
175  @param vfr_id - VRF ID
176 */
177 define snat_static_mapping_details {
181  u8 local_ip_address[16];
182  u8 external_ip_address[16];
188 };
189 
190 /** \brief Control ping from client to api server request
191  @param client_index - opaque cookie to identify the sender
192  @param context - sender context, to match reply w/ request
193 */
194 define snat_control_ping
195 {
198 };
199 
200 /** \brief Control ping from the client to the server response
201  @param client_index - opaque cookie to identify the sender
202  @param context - sender context, to match reply w/ request
203  @param retval - return code for the request
204  @param vpe_pid - the pid of the vpe, returned by the server
205 */
206 define snat_control_ping_reply
207 {
212 };
213 
214 /** \brief Show S-NAT plugin startup config
215  @param client_index - opaque cookie to identify the sender
216  @param context - sender context, to match reply w/ request
217 */
218 define snat_show_config
219 {
222 };
223 
224 /** \brief Show S-NAT plugin startup config reply
225  @param context - sender context, to match reply w/ request
226  @param retval - return code for the request
227  @param static_mapping_only - if 1 dynamic translations disabled
228  @param static_mapping_connection_tracking - if 1 create session data
229  @param deterministic - if 1 deterministic mapping
230  @param translation_buckets - number of translation hash buckets
231  @param translation_memory_size - translation hash memory size
232  @param user_buckets - number of user hash buckets
233  @param user_memory_size - user hash memory size
234  @param max_translations_per_user - maximum number of translations per user
235  @param outside_vrf_id - outside VRF id
236  @param inside_vrf_id - default inside VRF id
237 */
238 define snat_show_config_reply
239 {
252 };
253 
254 /** \brief Set S-NAT workers
255  @param client_index - opaque cookie to identify the sender
256  @param context - sender context, to match reply w/ request
257  @param worker_mask - S-NAT workers mask
258 */
263 };
264 
265 /** \brief Set S-NAT workers reply
266  @param context - sender context, to match reply w/ request
267  @param retval - return code
268 */
269 define snat_set_workers_reply {
272 };
273 
274 /** \brief Dump S-NAT workers
275  @param client_index - opaque cookie to identify the sender
276  @param context - sender context, to match reply w/ request
277 */
278 define snat_worker_dump {
281 };
282 
283 /** \brief S-NAT workers details response
284  @param context - sender context, to match reply w/ request
285  @param worker_index - worker index
286  @param lcore_id - lcore ID
287  @param name - worker name
288 */
289 define snat_worker_details {
293  u8 name[64];
294 };
295 
296 /** \brief Add/delete S-NAT pool address from specific interfce
297  @param client_index - opaque cookie to identify the sender
298  @param context - sender context, to match reply w/ request
299  @param is_add - 1 if add, 0 if delete
300  @param sw_if_index - software index of the interface
301 */
302 define snat_add_del_interface_addr {
308 };
309 
310 /** \brief Add/delete S-NAT pool address from specific interfce reply
311  @param context - sender context, to match reply w/ request
312  @param retval - return code
313 */
314 define snat_add_del_interface_addr_reply {
317 };
318 
319 /** \brief Dump S-NAT pool addresses interfaces
320  @param client_index - opaque cookie to identify the sender
321  @param context - sender context, to match reply w/ request
322 */
323 define snat_interface_addr_dump {
326 };
327 
328 /** \brief S-NAT pool addresses interfaces details response
329  @param context - sender context, to match reply w/ request
330  @param sw_if_index - software index of the interface
331 */
332 define snat_interface_addr_details {
335 };
336 
337 /** \brief Enable/disable S-NAT IPFIX logging
338  @param client_index - opaque cookie to identify the sender
339  @param context - sender context, to match reply w/ request
340  @param domain_id - observation domain ID
341  @param src_port - source port number
342  @param enable - 1 if enable, 0 if disable
343 */
344 define snat_ipfix_enable_disable {
350 };
351 
352 /** \brief Enable/disable S-NAT IPFIX logging reply
353  @param context - sender context, to match reply w/ request
354  @param retval - return code
355 */
356 define snat_ipfix_enable_disable_reply {
359 };
360 
361 /** \brief Dump S-NAT users
362  @param client_index - opaque cookie to identify the sender
363  @param context - sender context, to match reply w/ request
364 */
365 define snat_user_dump {
368 };
369 
370 /** \brief S-NAT users response
371  @param context - sender context, to match reply w/ request
372  @vrf_id - VRF ID
373  @param is_ip4 - 1 if address type is IPv4
374  @param ip_adress - IP address
375  @param nsessions - number of dynamic sessions
376  @param nstaticsessions - number of static sessions
377 */
378 define snat_user_details {
382  u8 ip_address[16];
385 };
386 
387 /** \brief S-NAT user's sessions
388  @param client_index - opaque cookie to identify the sender
389  @param context - sender context, to match reply w/ request
390  @param is_ip4 - 1 if address type is IPv4
391  @param user_ip - IP address of the user to dump
392  @param vrf_id - VRF_ID
393 */
394 define snat_user_session_dump {
398  u8 ip_address[16];
400 };
401 
402 /** \brief S-NAT user's sessions response
403  @param context - sender context, to match reply w/ request
404  @param is_ip4 - 1 if address type is IPv4
405  @param outside_ip_address - outside IP address
406  @param outside_port - outside port
407  @param inside_ip_address - inside IP address
408  @param inside_port - inside port
409  @param protocol - protocol
410  @param is_static - 1 if session is static
411  @param last_heard - last heard timer
412  @param total_bytes - count of bytes sent through session
413  @param total_pkts - count of pakets sent through session
414 */
415 define snat_user_session_details {
418  u8 outside_ip_address[16];
420  u8 inside_ip_address[16];
427 };
428 
429 /** \brief Add/delete S-NAT deterministic mapping
430  @param client_index - opaque cookie to identify the sender
431  @param context - sender context, to match reply w/ request
432  @param is_add - 1 if add, 0 if delete
433  @param is_ip4 - 1 if address type is IPv4
434  @param in_addr - inside IP address
435  @param in_plen - inside IP address prefix length
436  @param out_addr - outside IP address
437  @param out_addr - outside IP address prefix length
438 */
439 define snat_add_det_map {
445  u8 in_addr[16];
447  u8 out_addr[16];
449 };
450 
451 /** \brief Add/delete S-NAT deterministic mapping reply
452  @param context - sender context, to match reply w/ request
453  @param retval - return code
454 */
455 define snat_add_det_map_reply {
458 };
459 
460 /** \brief Get outside address and port range from inside address
461  @param client_index - opaque cookie to identify the sender
462  @param context - sender context, to match reply w/ request
463  @param is_ip4 - 1 if address type is IPv4
464  @param in_addr - inside IP address
465 */
470  u8 in_addr[16];
471 };
472 
473 /** \brief Get outside address and port range from inside address
474  @param context - sender context, to match reply w/ request
475  @param retval - return code
476  @param out_port_lo - outside port range start
477  @param out_port_hi - outside port range end
478  @param is_ip4 - 1 if address type is IPv4
479  @param out_addr - outside IP address
480 */
481 define snat_det_forward_reply {
487  u8 out_addr[16];
488 };
489 
490 /** \brief Get inside address from outside address and port
491  @param client_index - opaque cookie to identify the sender
492  @param context - sender context, to match reply w/ request
493  @param out_port - outside port
494  @param is_ip4 - 1 if address type is IPv4
495  @param out_addr - outside IP address
496 */
502  u8 out_addr[16];
503 };
504 
505 /** \brief Get inside address from outside address and port reply
506  @param context - sender context, to match reply w/ request
507  @param retval - return code
508  @param is_ip4 - 1 if address type is IPv4
509  @param in_addr - inside IP address
510 */
511 define snat_det_reverse_reply {
515  u8 in_addr[16];
516 };
517 
518 /** \brief Dump S-NAT deterministic mappings
519  @param client_index - opaque cookie to identify the sender
520  @param context - sender context, to match reply w/ request
521 */
522 define snat_det_map_dump {
525 };
526 
527 /** \brief S-NAT users response
528  @param context - sender context, to match reply w/ request
529  @param is_ip4 - 1 if address type is IPv4
530  @param in_addr - inside IP address
531  @param in_plen - inside IP address prefix length
532  @param out_addr - outside IP address
533  @param out_plen - outside IP address prefix length
534  @param sharing_ratio - outside to inside address sharing ratio
535  @param ports_per_host - number of ports available to a host
536  @param ses_num - number of sessions belonging to this mapping
537 */
538 define snat_det_map_details {
541  u8 in_addr[16];
543  u8 out_addr[16];
548 };
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:89
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:74
int i32
Definition: types.h:81
unsigned long u64
Definition: types.h:89
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:254
unsigned int u32
Definition: types.h:88
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
static int snat_set_workers(uword *bitmap)
Definition: snat.c:726