"autoreply" flag: autogenerate standard xxx_reply_t messages
[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 autoreply 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 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 {
47   u32 client_index;
48   u32 context;
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 {
58   u32 context;
59   u8 is_ip4;
60   u8 ip_address[16];
61   u32 vrf_id;
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 {
72   u32 client_index;
73   u32 context;
74   u8 is_add;
75   u8 is_inside;
76   u32 sw_if_index;
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 {
84   u32 client_index;
85   u32 context;
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 {
94   u32 context;
95   u8 is_inside;
96   u32 sw_if_index;
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 {
116   u32 client_index;
117   u32 context;
118   u8 is_add;
119   u8 is_ip4;
120   u8 addr_only;
121   u8 local_ip_address[16];
122   u8 external_ip_address[16];
123   u8 protocol;
124   u16 local_port;
125   u16 external_port;
126   u32 external_sw_if_index;
127   u32 vrf_id;
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 {
135   u32 client_index;
136   u32 context;
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 {
152   u32 context;
153   u8 is_ip4;
154   u8 addr_only;
155   u8 local_ip_address[16];
156   u8 external_ip_address[16];
157   u8 protocol;
158   u16 local_port;
159   u16 external_port;
160   u32 external_sw_if_index;
161   u32 vrf_id;
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 {
170   u32 client_index;
171   u32 context;
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 {
182   u32 context;
183   i32 retval;
184   u32 client_index;
185   u32 vpe_pid;
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 {
194   u32 client_index;
195   u32 context;
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 {
214   u32 context;
215   i32 retval;
216   u8 static_mapping_only;
217   u8 static_mapping_connection_tracking;
218   u8 deterministic;
219   u32 translation_buckets;
220   u32 translation_memory_size;
221   u32 user_buckets;
222   u32 user_memory_size;
223   u32 max_translations_per_user;
224   u32 outside_vrf_id;
225   u32 inside_vrf_id;
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 {
234   u32 client_index;
235   u32 context;
236   u64 worker_mask;
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 {
244   u32 client_index;
245   u32 context;
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 {
255   u32 context;
256   u32 worker_index;
257   u32 lcore_id;
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 {
268   u32 client_index;
269   u32 context;
270   u8 is_add;
271   u8 is_inside;
272   u32 sw_if_index;
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 {
280   u32 client_index;
281   u32 context;
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 {
289   u32 context;
290   u32 sw_if_index;
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 {
301   u32 client_index;
302   u32 context;
303   u32 domain_id;
304   u16 src_port;
305   u8 enable;
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 {
313   u32 client_index;
314   u32 context;
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 {
326   u32 context;
327   u32 vrf_id;
328   u8 is_ip4;
329   u8 ip_address[16];
330   u32 nsessions;
331   u32 nstaticsessions;
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 {
342   u32 client_index;
343   u32 context;
344   u8 is_ip4;
345   u8 ip_address[16];
346   u32 vrf_id;
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 {
363   u32 context;
364   u8 is_ip4;
365   u8 outside_ip_address[16];
366   u16 outside_port;
367   u8 inside_ip_address[16];
368   u16 inside_port;
369   u16 protocol;
370   u8 is_static;
371   u64 last_heard;
372   u64 total_bytes;
373   u32 total_pkts;
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 {
387   u32 client_index;
388   u32 context;
389   u8 is_add;
390   u8 is_ip4;
391   u8 addr_only;
392   u8 in_addr[16];
393   u8 in_plen;
394   u8 out_addr[16];
395   u8 out_plen;
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 */
404 define snat_det_forward {
405   u32 client_index;
406   u32 context;
407   u8 is_ip4;
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 {
420   u32 context;
421   i32 retval;
422   u16 out_port_lo;
423   u16 out_port_hi;
424   u8 is_ip4;
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 */
435 define snat_det_reverse {
436   u32 client_index;
437   u32 context;
438   u16 out_port;
439   u8 is_ip4;
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 {
450   u32 context;
451   i32 retval;
452   u8 is_ip4;
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 {
461   u32 client_index;
462   u32 context;
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 {
477   u32 context;
478   u8 is_ip4;
479   u8 in_addr[16];
480   u8 in_plen;
481   u8 out_addr[16];
482   u8 out_plen;
483   u32 sharing_ratio;
484   u16 ports_per_host;
485   u32 ses_num;
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 {
497   u32 client_index;
498   u32 context;
499   u32 udp;
500   u32 tcp_established;
501   u32 tcp_transitory;
502   u32 icmp;
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 {
510   u32 client_index;
511   u32 context;
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 {
523   u32 context;
524   i32 retval;
525   u32 udp;
526   u32 tcp_established;
527   u32 tcp_transitory;
528   u32 icmp;
529 };