9689f5f9dfc335bc097588b77f506aa25bbff0ea
[vpp.git] / src / plugins / snat / snat.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  * @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 {
33   u32 client_index;
34   u32 context;
35   u8 is_ip4;
36   u8 first_ip_address[16];
37   u8 last_ip_address[16];
38   u32 vrf_id;
39   u8 is_add;
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 {
47   u32 context;
48   i32 retval;
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 {
56   u32 client_index;
57   u32 context;
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 {
67   u32 context;
68   u8 is_ip4;
69   u8 ip_address[16];
70   u32 vrf_id;
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 {
81   u32 client_index;
82   u32 context;
83   u8 is_add;
84   u8 is_inside;
85   u32 sw_if_index;
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 {
93   u32 context;
94   i32 retval;
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 {
102   u32 client_index;
103   u32 context;
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 {
112   u32 context;
113   u8 is_inside;
114   u32 sw_if_index;
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, ~0 means not
130                                   used)
131     @param vfr_id - VRF ID
132 */
133 define snat_add_static_mapping {
134   u32 client_index;
135   u32 context;
136   u8 is_add;
137   u8 is_ip4;
138   u8 addr_only;
139   u8 local_ip_address[16];
140   u8 external_ip_address[16];
141   u8 protocol;
142   u16 local_port;
143   u16 external_port;
144   u32 external_sw_if_index;
145   u32 vrf_id;
146 };
147
148 /** \brief Add/delete S-NAT static mapping reply
149     @param context - sender context, to match reply w/ request
150     @param retval - return code
151 */
152 define snat_add_static_mapping_reply {
153   u32 context;
154   i32 retval;
155 };
156
157 /** \brief Dump S-NAT static mappings
158     @param client_index - opaque cookie to identify the sender
159     @param context - sender context, to match reply w/ request
160 */
161 define snat_static_mapping_dump {
162   u32 client_index;
163   u32 context;
164 };
165
166 /** \brief S-NAT static mapping details response
167     @param context - sender context, to match reply w/ request
168     @param is_ip4 - 1 if address type is IPv4
169     @param addr_only - 1 if address only mapping
170     @param local_ip_address - local IP address
171     @param external_ip_address - external IP address
172     @param protocol - IP protocol
173     @param local_port - local port number
174     @param external_port - external port number
175     @param external_sw_if_index - external interface
176     @param vfr_id - VRF ID
177 */
178 define snat_static_mapping_details {
179   u32 context;
180   u8 is_ip4;
181   u8 addr_only;
182   u8 local_ip_address[16];
183   u8 external_ip_address[16];
184   u8 protocol;
185   u16 local_port;
186   u16 external_port;
187   u32 external_sw_if_index;
188   u32 vrf_id;
189 };
190
191 /** \brief Control ping from client to api server request
192     @param client_index - opaque cookie to identify the sender
193     @param context - sender context, to match reply w/ request
194 */
195 define snat_control_ping
196 {
197   u32 client_index;
198   u32 context;
199 };
200
201 /** \brief Control ping from the client to the server response
202     @param client_index - opaque cookie to identify the sender
203     @param context - sender context, to match reply w/ request
204     @param retval - return code for the request
205     @param vpe_pid - the pid of the vpe, returned by the server
206 */
207 define snat_control_ping_reply
208 {
209   u32 context;
210   i32 retval;
211   u32 client_index;
212   u32 vpe_pid;
213 };
214
215 /** \brief Show S-NAT plugin startup config
216     @param client_index - opaque cookie to identify the sender
217     @param context - sender context, to match reply w/ request
218 */
219 define snat_show_config
220 {
221   u32 client_index;
222   u32 context;
223 };
224
225 /** \brief Show S-NAT plugin startup config reply
226     @param context - sender context, to match reply w/ request
227     @param retval - return code for the request
228     @param static_mapping_only - if 1 dynamic translations disabled
229     @param static_mapping_connection_tracking - if 1 create session data
230     @param deterministic - if 1 deterministic mapping
231     @param translation_buckets - number of translation hash buckets
232     @param translation_memory_size - translation hash memory size
233     @param user_buckets - number of user hash buckets
234     @param user_memory_size - user hash memory size
235     @param max_translations_per_user - maximum number of translations per user
236     @param outside_vrf_id - outside VRF id
237     @param inside_vrf_id - default inside VRF id
238 */
239 define snat_show_config_reply
240 {
241   u32 context;
242   i32 retval;
243   u8 static_mapping_only;
244   u8 static_mapping_connection_tracking;
245   u8 deterministic;
246   u32 translation_buckets;
247   u32 translation_memory_size;
248   u32 user_buckets;
249   u32 user_memory_size;
250   u32 max_translations_per_user;
251   u32 outside_vrf_id;
252   u32 inside_vrf_id;
253 };
254
255 /** \brief Set S-NAT workers
256     @param client_index - opaque cookie to identify the sender
257     @param context - sender context, to match reply w/ request
258     @param worker_mask - S-NAT workers mask
259 */
260 define snat_set_workers {
261   u32 client_index;
262   u32 context;
263   u64 worker_mask;
264 };
265
266 /** \brief Set S-NAT workers reply
267     @param context - sender context, to match reply w/ request
268     @param retval - return code
269 */
270 define snat_set_workers_reply {
271   u32 context;
272   i32 retval;
273 };
274
275 /** \brief Dump S-NAT workers
276     @param client_index - opaque cookie to identify the sender
277     @param context - sender context, to match reply w/ request
278 */
279 define snat_worker_dump {
280   u32 client_index;
281   u32 context;
282 };
283
284 /** \brief S-NAT workers details response
285     @param context - sender context, to match reply w/ request
286     @param worker_index - worker index
287     @param lcore_id - lcore ID
288     @param name - worker name
289 */
290 define snat_worker_details {
291   u32 context;
292   u32 worker_index;
293   u32 lcore_id;
294   u8 name[64];
295 };
296
297 /** \brief Add/delete S-NAT pool address from specific interfce
298     @param client_index - opaque cookie to identify the sender
299     @param context - sender context, to match reply w/ request
300     @param is_add - 1 if add, 0 if delete
301     @param sw_if_index - software index of the interface
302 */
303 define snat_add_del_interface_addr {
304   u32 client_index;
305   u32 context;
306   u8 is_add;
307   u8 is_inside;
308   u32 sw_if_index;
309 };
310
311 /** \brief Add/delete S-NAT pool address from specific interfce reply
312     @param context - sender context, to match reply w/ request
313     @param retval - return code
314 */
315 define snat_add_del_interface_addr_reply {
316   u32 context;
317   i32 retval;
318 };
319
320 /** \brief Dump S-NAT pool addresses interfaces
321     @param client_index - opaque cookie to identify the sender
322     @param context - sender context, to match reply w/ request
323 */
324 define snat_interface_addr_dump {
325   u32 client_index;
326   u32 context;
327 };
328
329 /** \brief S-NAT pool addresses interfaces details response
330     @param context - sender context, to match reply w/ request
331     @param sw_if_index - software index of the interface
332 */
333 define snat_interface_addr_details {
334   u32 context;
335   u32 sw_if_index;
336 };
337
338 /** \brief Enable/disable S-NAT IPFIX logging
339     @param client_index - opaque cookie to identify the sender
340     @param context - sender context, to match reply w/ request
341     @param domain_id - observation domain ID
342     @param src_port - source port number
343     @param enable - 1 if enable, 0 if disable
344 */
345 define snat_ipfix_enable_disable {
346   u32 client_index;
347   u32 context;
348   u32 domain_id;
349   u16 src_port;
350   u8 enable;
351 };
352
353 /** \brief Enable/disable S-NAT IPFIX logging reply
354     @param context - sender context, to match reply w/ request
355     @param retval - return code
356 */
357 define snat_ipfix_enable_disable_reply {
358   u32 context;
359   i32 retval;
360 };
361
362 /** \brief Dump S-NAT users
363     @param client_index - opaque cookie to identify the sender
364     @param context - sender context, to match reply w/ request
365 */
366 define snat_user_dump {
367   u32 client_index;
368   u32 context;
369 };
370
371 /** \brief S-NAT users response
372     @param context - sender context, to match reply w/ request
373     @vrf_id - VRF ID
374     @param is_ip4 - 1 if address type is IPv4
375     @param ip_adress - IP address
376     @param nsessions - number of dynamic sessions
377     @param nstaticsessions - number of static sessions
378 */
379 define snat_user_details {
380   u32 context;
381   u32 vrf_id;
382   u8 is_ip4;
383   u8 ip_address[16];
384   u32 nsessions;
385   u32 nstaticsessions;
386 };
387
388 /** \brief S-NAT user's sessions
389     @param client_index - opaque cookie to identify the sender
390     @param context - sender context, to match reply w/ request
391     @param is_ip4 - 1 if address type is IPv4
392     @param user_ip - IP address of the user to dump
393     @param vrf_id - VRF_ID
394 */
395 define snat_user_session_dump {
396   u32 client_index;
397   u32 context;
398   u8 is_ip4;
399   u8 ip_address[16];
400   u32 vrf_id;
401 };
402
403 /** \brief S-NAT user's sessions response
404     @param context - sender context, to match reply w/ request
405     @param is_ip4 - 1 if address type is IPv4
406     @param outside_ip_address - outside IP address
407     @param outside_port - outside port
408     @param inside_ip_address - inside IP address
409     @param inside_port - inside port
410     @param protocol - protocol
411     @param is_static - 1 if session is static
412     @param last_heard - last heard timer
413     @param total_bytes - count of bytes sent through session
414     @param total_pkts - count of pakets sent through session
415 */
416 define snat_user_session_details {
417   u32 context;
418   u8 is_ip4;
419   u8 outside_ip_address[16];
420   u16 outside_port;
421   u8 inside_ip_address[16];
422   u16 inside_port;
423   u16 protocol;
424   u8 is_static;
425   u64 last_heard;
426   u64 total_bytes;
427   u32 total_pkts;
428 };
429
430 /** \brief Add/delete S-NAT deterministic mapping
431     @param client_index - opaque cookie to identify the sender
432     @param context - sender context, to match reply w/ request
433     @param is_add - 1 if add, 0 if delete
434     @param is_ip4 - 1 if address type is IPv4
435     @param in_addr - inside IP address
436     @param in_plen - inside IP address prefix length
437     @param out_addr - outside IP address
438     @param out_addr - outside IP address prefix length
439 */
440 define snat_add_det_map {
441   u32 client_index;
442   u32 context;
443   u8 is_add;
444   u8 is_ip4;
445   u8 addr_only;
446   u8 in_addr[16];
447   u8 in_plen;
448   u8 out_addr[16];
449   u8 out_plen;
450 };
451
452 /** \brief Add/delete S-NAT deterministic mapping reply
453     @param context - sender context, to match reply w/ request
454     @param retval - return code
455 */
456 define snat_add_det_map_reply {
457   u32 context;
458   i32 retval;
459 };
460
461 /** \brief Get outside address and port range from inside address
462     @param client_index - opaque cookie to identify the sender
463     @param context - sender context, to match reply w/ request
464     @param is_ip4 - 1 if address type is IPv4
465     @param in_addr - inside IP address
466 */
467 define snat_det_forward {
468   u32 client_index;
469   u32 context;
470   u8 is_ip4;
471   u8 in_addr[16];
472 };
473
474 /** \brief Get outside address and port range from inside address
475     @param context - sender context, to match reply w/ request
476     @param retval - return code
477     @param out_port_lo - outside port range start
478     @param out_port_hi - outside port range end
479     @param is_ip4 - 1 if address type is IPv4
480     @param out_addr - outside IP address
481 */
482 define snat_det_forward_reply {
483   u32 context;
484   i32 retval;
485   u16 out_port_lo;
486   u16 out_port_hi;
487   u8 is_ip4;
488   u8 out_addr[16];
489 };
490
491 /** \brief Get inside address from outside address and port
492     @param client_index - opaque cookie to identify the sender
493     @param context - sender context, to match reply w/ request
494     @param out_port - outside port
495     @param is_ip4 - 1 if address type is IPv4
496     @param out_addr - outside IP address
497 */
498 define snat_det_reverse {
499   u32 client_index;
500   u32 context;
501   u16 out_port;
502   u8 is_ip4;
503   u8 out_addr[16];
504 };
505
506 /** \brief Get inside address from outside address and port reply
507     @param context - sender context, to match reply w/ request
508     @param retval - return code
509     @param is_ip4 - 1 if address type is IPv4
510     @param in_addr - inside IP address
511 */
512 define snat_det_reverse_reply {
513   u32 context;
514   i32 retval;
515   u8 is_ip4;
516   u8 in_addr[16];
517 };
518
519 /** \brief Dump S-NAT deterministic mappings
520     @param client_index - opaque cookie to identify the sender
521     @param context - sender context, to match reply w/ request
522 */
523 define snat_det_map_dump {
524   u32 client_index;
525   u32 context;
526 };
527
528 /** \brief S-NAT users response
529     @param context - sender context, to match reply w/ request
530     @param is_ip4 - 1 if address type is IPv4
531     @param in_addr - inside IP address
532     @param in_plen - inside IP address prefix length
533     @param out_addr - outside IP address
534     @param out_plen - outside IP address prefix length
535     @param sharing_ratio - outside to inside address sharing ratio
536     @param ports_per_host - number of ports available to a host
537     @param ses_num - number of sessions belonging to this mapping
538 */
539 define snat_det_map_details {
540   u32 context;
541   u8 is_ip4;
542   u8 in_addr[16];
543   u8 in_plen;
544   u8 out_addr[16];
545   u8 out_plen;
546   u32 sharing_ratio;
547   u16 ports_per_host;
548   u32 ses_num;
549 };
550
551 /** \brief Set values of timeouts for deterministic NAT (seconds, 0 = default)
552     @param client_index - opaque cookie to identify the sender
553     @param context - sender context, to match reply w/ request
554     @param udp - UDP timeout (default 300sec)
555     @param tcp_established - TCP established timeout (default 7440sec)
556     @param tcp_transitory - TCP transitory timeout (default 240sec)
557     @param icmp - ICMP timeout (default 60sec)
558 */
559 define snat_det_set_timeouts {
560   u32 client_index;
561   u32 context;
562   u32 udp;
563   u32 tcp_established;
564   u32 tcp_transitory;
565   u32 icmp;
566 };
567
568 /** \brief Set values of timeouts for deterministic NAT reply
569     @param context - sender context, to match reply w/ request
570     @param retval - return code
571 */
572 define snat_det_set_timeouts_reply {
573   u32 context;
574   i32 retval;
575 };
576
577 /** \brief Get values of timeouts for deterministic NAT (seconds)
578     @param client_index - opaque cookie to identify the sender
579     @param context - sender context, to match reply w/ request
580 */
581 define snat_det_get_timeouts {
582   u32 client_index;
583   u32 context;
584 };
585
586 /** \brief Get values of timeouts for deterministic NAT reply
587     @param context - sender context, to match reply w/ request
588     @param retval - return code
589     @param udp - UDP timeout (default 300sec)
590     @param tcp_established - TCP established timeout (default 7440sec)
591     @param tcp_transitory - TCP transitory timeout (default 240sec)
592     @param icmp - ICMP timeout (default 60sec)
593 */
594 define snat_det_get_timeouts_reply {
595   u32 context;
596   i32 retval;
597   u32 udp;
598   u32 tcp_established;
599   u32 tcp_transitory;
600   u32 icmp;
601 };