Add setting of tenant VRF id for SNAT addresses (VPP-641)
[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)
130     @param vfr_id - VRF ID
131 */
132 define snat_add_static_mapping {
133   u32 client_index;
134   u32 context;
135   u8 is_add;
136   u8 is_ip4;
137   u8 addr_only;
138   u8 local_ip_address[16];
139   u8 external_ip_address[16];
140   u8 protocol;
141   u16 local_port;
142   u16 external_port;
143   u32 external_sw_if_index;
144   u32 vrf_id;
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 {
152   u32 context;
153   i32 retval;
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 {
161   u32 client_index;
162   u32 context;
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 {
178   u32 context;
179   u8 is_ip4;
180   u8 addr_only;
181   u8 local_ip_address[16];
182   u8 external_ip_address[16];
183   u8 protocol;
184   u16 local_port;
185   u16 external_port;
186   u32 external_sw_if_index;
187   u32 vrf_id;
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 {
196   u32 client_index;
197   u32 context;
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 {
208   u32 context;
209   i32 retval;
210   u32 client_index;
211   u32 vpe_pid;
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 {
220   u32 client_index;
221   u32 context;
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 translation_buckets - number of translation hash buckets
230     @param translation_memory_size - translation hash memory size
231     @param user_buckets - number of user hash buckets
232     @param user_memory_size - user hash memory size
233     @param max_translations_per_user - maximum number of translations per user
234     @param outside_vrf_id - outside VRF id
235     @param inside_vrf_id - default inside VRF id
236 */
237 define snat_show_config_reply
238 {
239   u32 context;
240   i32 retval;
241   u8 static_mapping_only;
242   u8 static_mapping_connection_tracking;
243   u32 translation_buckets;
244   u32 translation_memory_size;
245   u32 user_buckets;
246   u32 user_memory_size;
247   u32 max_translations_per_user;
248   u32 outside_vrf_id;
249   u32 inside_vrf_id;
250 };
251
252 /** \brief Set S-NAT workers
253     @param client_index - opaque cookie to identify the sender
254     @param context - sender context, to match reply w/ request
255     @param worker_mask - S-NAT workers mask
256 */
257 define snat_set_workers {
258   u32 client_index;
259   u32 context;
260   u64 worker_mask;
261 };
262
263 /** \brief Set S-NAT workers reply
264     @param context - sender context, to match reply w/ request
265     @param retval - return code
266 */
267 define snat_set_workers_reply {
268   u32 context;
269   i32 retval;
270 };
271
272 /** \brief Dump S-NAT workers
273     @param client_index - opaque cookie to identify the sender
274     @param context - sender context, to match reply w/ request
275 */
276 define snat_worker_dump {
277   u32 client_index;
278   u32 context;
279 };
280
281 /** \brief S-NAT workers details response
282     @param context - sender context, to match reply w/ request
283     @param worker_index - worker index
284     @param lcore_id - lcore ID
285     @param name - worker name
286 */
287 define snat_worker_details {
288   u32 context;
289   u32 worker_index;
290   u32 lcore_id;
291   u8 name[64];
292 };
293
294 /** \brief Add/delete S-NAT pool address from specific interfce
295     @param client_index - opaque cookie to identify the sender
296     @param context - sender context, to match reply w/ request
297     @param is_add - 1 if add, 0 if delete
298     @param sw_if_index - software index of the interface
299 */
300 define snat_add_del_interface_addr {
301   u32 client_index;
302   u32 context;
303   u8 is_add;
304   u8 is_inside;
305   u32 sw_if_index;
306 };
307
308 /** \brief Add/delete S-NAT pool address from specific interfce reply
309     @param context - sender context, to match reply w/ request
310     @param retval - return code
311 */
312 define snat_add_del_interface_addr_reply {
313   u32 context;
314   i32 retval;
315 };
316
317 /** \brief Dump S-NAT pool addresses interfaces
318     @param client_index - opaque cookie to identify the sender
319     @param context - sender context, to match reply w/ request
320 */
321 define snat_interface_addr_dump {
322   u32 client_index;
323   u32 context;
324 };
325
326 /** \brief S-NAT pool addresses interfaces details response
327     @param context - sender context, to match reply w/ request
328     @param sw_if_index - software index of the interface
329 */
330 define snat_interface_addr_details {
331   u32 context;
332   u32 sw_if_index;
333 };
334
335 /** \brief Enable/disable S-NAT IPFIX logging
336     @param client_index - opaque cookie to identify the sender
337     @param context - sender context, to match reply w/ request
338     @param domain_id - observation domain ID
339     @param src_port - source port number
340     @param enable - 1 if enable, 0 if disable
341 */
342 define snat_ipfix_enable_disable {
343   u32 client_index;
344   u32 context;
345   u32 domain_id;
346   u16 src_port;
347   u8 enable;
348 };
349
350 /** \brief Enable/disable S-NAT IPFIX logging reply
351     @param context - sender context, to match reply w/ request
352     @param retval - return code
353 */
354 define snat_ipfix_enable_disable_reply {
355   u32 context;
356   i32 retval;
357 };
358
359 /** \brief Dump S-NAT users
360     @param client_index - opaque cookie to identify the sender
361     @param context - sender context, to match reply w/ request
362 */
363 define snat_user_dump {
364   u32 client_index;
365   u32 context;
366 };
367
368 /** \brief S-NAT users response
369     @param context - sender context, to match reply w/ request
370     @vrf_id - VRF ID
371     @param is_ip4 - 1 if address type is IPv4
372     @param ip_adress - IP address
373     @param nsessions - number of dynamic sessions
374     @param nstaticsessions - number of static sessions
375 */
376 define snat_user_details {
377   u32 context;
378   u32 vrf_id;
379   u8 is_ip4;
380   u8 ip_address[16];
381   u32 nsessions;
382   u32 nstaticsessions;
383 };
384
385 /** \brief S-NAT user's sessions
386     @param client_index - opaque cookie to identify the sender
387     @param context - sender context, to match reply w/ request
388     @param user_ip - IP address of the user to dump
389     @param vrf_id - VRF_ID
390 */
391 define snat_user_session_dump {
392   u32 client_index;
393   u32 context;
394   u8 ip_address[16];
395   u32 vrf_id;
396 };
397
398 /** \brief S-NAT user's sessions response
399     @param context - sender context, to match reply w/ request
400     @param is_ip4 - 1 if address type is IPv4
401     @param outside_ip_address - outside IP address
402     @param outside_port - outside port
403     @param inside_ip_address - inside IP address
404     @param inside_port - inside port
405     @param protocol - protocol
406     @param is_static - 1 if session is static
407     @param last_heard - last heard timer
408     @param total_bytes - count of bytes sent through session
409     @param total_pkts - count of pakets sent through session
410 */
411 define snat_user_session_details {
412   u32 context;
413   u8 is_ip4;
414   u8 outside_ip_address[16];
415   u16 outside_port;
416   u8 inside_ip_address[16];
417   u16 inside_port;
418   u16 protocol;
419   u8 is_static;
420   u64 last_heard;
421   u64 total_bytes;
422   u32 total_pkts;
423 };