SNAT: Port allocation per protocol
[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 is_add - 1 if add, 0 if delete
30 */
31 define snat_add_address_range {
32   u32 client_index;
33   u32 context;
34   u8 is_ip4;
35   u8 first_ip_address[16];
36   u8 last_ip_address[16];
37   u8 is_add;
38 };
39
40 /** \brief Add S-NAT address range reply
41     @param context - sender context, to match reply w/ request
42     @param retval - return code
43 */
44 define snat_add_address_range_reply {
45   u32 context;
46   i32 retval;
47 };
48
49 /** \brief Dump S-NAT addresses
50     @param client_index - opaque cookie to identify the sender
51     @param context - sender context, to match reply w/ request
52 */
53 define snat_address_dump {
54   u32 client_index;
55   u32 context;
56 };
57
58 /** \brief S-NAT address details response
59     @param context - sender context, to match reply w/ request
60     @param is_ip4 - 1 if address type is IPv4
61     @param ip_address - IP address
62 */
63 define snat_address_details {
64   u32 context;
65   u8 is_ip4;
66   u8 ip_address[16];
67 };
68
69 /** \brief Enable/disable S-NAT feature on the interface
70     @param client_index - opaque cookie to identify the sender
71     @param context - sender context, to match reply w/ request
72     @param is_add - 1 if add, 0 if delete
73     @param is_inside - 1 if inside, 0 if outside
74     @param sw_if_index - software index of the interface
75 */
76 define snat_interface_add_del_feature {
77   u32 client_index;
78   u32 context;
79   u8 is_add;
80   u8 is_inside;
81   u32 sw_if_index;
82 };
83
84 /** \brief Enable/disable S-NAT feature on the interface reply
85     @param context - sender context, to match reply w/ request
86     @param retval - return code
87 */
88 define snat_interface_add_del_feature_reply {
89   u32 context;
90   i32 retval;
91 };
92
93 /** \brief Dump interfaces with S-NAT feature
94     @param client_index - opaque cookie to identify the sender
95     @param context - sender context, to match reply w/ request
96 */
97 define snat_interface_dump {
98   u32 client_index;
99   u32 context;
100 };
101
102 /** \brief S-NAT interface details response
103     @param context - sender context, to match reply w/ request
104     @param is_inside - 1 if inside, 0 if outside
105     @param sw_if_index - software index of the interface
106 */
107 define snat_interface_details {
108   u32 context;
109   u8 is_inside;
110   u32 sw_if_index;
111 };
112
113 /** \brief Add/delete S-NAT static mapping
114     @param client_index - opaque cookie to identify the sender
115     @param context - sender context, to match reply w/ request
116     @param is_add - 1 if add, 0 if delete
117     @param is_ip4 - 1 if address type is IPv4
118     @param addr_only - 1 if address only mapping
119     @param local_ip_address - local IP address
120     @param external_ip_address - external IP address
121     @param protocol - IP protocol
122     @param local_port - local port number
123     @param external_port - external port number
124     @param external_sw_if_index - external interface (if set
125                                   external_ip_address is ignored)
126     @param vfr_id - VRF ID
127 */
128 define snat_add_static_mapping {
129   u32 client_index;
130   u32 context;
131   u8 is_add;
132   u8 is_ip4;
133   u8 addr_only;
134   u8 local_ip_address[16];
135   u8 external_ip_address[16];
136   u8 protocol;
137   u16 local_port;
138   u16 external_port;
139   u32 external_sw_if_index;
140   u32 vrf_id;
141 };
142
143 /** \brief Add/delete S-NAT static mapping reply
144     @param context - sender context, to match reply w/ request
145     @param retval - return code
146 */
147 define snat_add_static_mapping_reply {
148   u32 context;
149   i32 retval;
150 };
151
152 /** \brief Dump S-NAT static mappings
153     @param client_index - opaque cookie to identify the sender
154     @param context - sender context, to match reply w/ request
155 */
156 define snat_static_mapping_dump {
157   u32 client_index;
158   u32 context;
159 };
160
161 /** \brief S-NAT static mapping details response
162     @param context - sender context, to match reply w/ request
163     @param is_ip4 - 1 if address type is IPv4
164     @param addr_only - 1 if address only mapping
165     @param local_ip_address - local IP address
166     @param external_ip_address - external IP address
167     @param protocol - IP protocol
168     @param local_port - local port number
169     @param external_port - external port number
170     @param vfr_id - VRF ID
171 */
172 define snat_static_mapping_details {
173   u32 context;
174   u8 is_ip4;
175   u8 addr_only;
176   u8 local_ip_address[16];
177   u8 external_ip_address[16];
178   u8 protocol;
179   u16 local_port;
180   u16 external_port;
181   u32 vrf_id;
182 };
183
184 /** \brief Control ping from client to api server request
185     @param client_index - opaque cookie to identify the sender
186     @param context - sender context, to match reply w/ request
187 */
188 define snat_control_ping
189 {
190   u32 client_index;
191   u32 context;
192 };
193
194 /** \brief Control ping from the client to the server response
195     @param client_index - opaque cookie to identify the sender
196     @param context - sender context, to match reply w/ request
197     @param retval - return code for the request
198     @param vpe_pid - the pid of the vpe, returned by the server
199 */
200 define snat_control_ping_reply
201 {
202   u32 context;
203   i32 retval;
204   u32 client_index;
205   u32 vpe_pid;
206 };
207
208 /** \brief Show S-NAT plugin startup config
209     @param client_index - opaque cookie to identify the sender
210     @param context - sender context, to match reply w/ request
211 */
212 define snat_show_config
213 {
214   u32 client_index;
215   u32 context;
216 };
217
218 /** \brief Show S-NAT plugin startup config reply
219     @param context - sender context, to match reply w/ request
220     @param retval - return code for the request
221     @param static_mapping_only - if 1 dynamic translations disabled
222     @param static_mapping_connection_tracking - if 1 create session data
223     @param translation_buckets - number of translation hash buckets
224     @param translation_memory_size - translation hash memory size
225     @param user_buckets - number of user hash buckets
226     @param user_memory_size - user hash memory size
227     @param max_translations_per_user - maximum number of translations per user
228     @param outside_vrf_id - outside VRF id
229     @param inside_vrf_id - default inside VRF id
230 */
231 define snat_show_config_reply
232 {
233   u32 context;
234   i32 retval;
235   u8 static_mapping_only;
236   u8 static_mapping_connection_tracking;
237   u32 translation_buckets;
238   u32 translation_memory_size;
239   u32 user_buckets;
240   u32 user_memory_size;
241   u32 max_translations_per_user;
242   u32 outside_vrf_id;
243   u32 inside_vrf_id;
244 };
245
246 /** \brief Set S-NAT workers
247     @param client_index - opaque cookie to identify the sender
248     @param context - sender context, to match reply w/ request
249     @param worker_mask - S-NAT workers mask
250 */
251 define snat_set_workers {
252   u32 client_index;
253   u32 context;
254   u64 worker_mask;
255 };
256
257 /** \brief Set S-NAT workers reply
258     @param context - sender context, to match reply w/ request
259     @param retval - return code
260 */
261 define snat_set_workers_reply {
262   u32 context;
263   i32 retval;
264 };
265
266 /** \brief Dump S-NAT workers
267     @param client_index - opaque cookie to identify the sender
268     @param context - sender context, to match reply w/ request
269 */
270 define snat_worker_dump {
271   u32 client_index;
272   u32 context;
273 };
274
275 /** \brief S-NAT workers details response
276     @param context - sender context, to match reply w/ request
277     @param worker_index - worker index
278     @param lcore_id - lcore ID
279     @param name - worker name
280 */
281 define snat_worker_details {
282   u32 context;
283   u32 worker_index;
284   u32 lcore_id;
285   u8 name[64];
286 };
287
288 /** \brief Add/delete S-NAT pool address from specific interfce
289     @param client_index - opaque cookie to identify the sender
290     @param context - sender context, to match reply w/ request
291     @param is_add - 1 if add, 0 if delete
292     @param sw_if_index - software index of the interface
293 */
294 define snat_add_del_interface_addr {
295   u32 client_index;
296   u32 context;
297   u8 is_add;
298   u8 is_inside;
299   u32 sw_if_index;
300 };
301
302 /** \brief Add/delete S-NAT pool address from specific interfce reply
303     @param context - sender context, to match reply w/ request
304     @param retval - return code
305 */
306 define snat_add_del_interface_addr_reply {
307   u32 context;
308   i32 retval;
309 };
310
311 /** \brief Dump S-NAT pool addresses interfaces
312     @param client_index - opaque cookie to identify the sender
313     @param context - sender context, to match reply w/ request
314 */
315 define snat_interface_addr_dump {
316   u32 client_index;
317   u32 context;
318 };
319
320 /** \brief S-NAT pool addresses interfaces details response
321     @param context - sender context, to match reply w/ request
322     @param sw_if_index - software index of the interface
323 */
324 define snat_interface_addr_details {
325   u32 context;
326   u32 sw_if_index;
327 };
328
329 /** \brief Enable/disable S-NAT IPFIX logging
330     @param client_index - opaque cookie to identify the sender
331     @param context - sender context, to match reply w/ request
332     @param domain_id - observation domain ID
333     @param src_port - source port number
334     @param enable - 1 if enable, 0 if disable
335 */
336 define snat_ipfix_enable_disable {
337   u32 client_index;
338   u32 context;
339   u32 domain_id;
340   u16 src_port;
341   u8 enable;
342 };
343
344 /** \brief Enable/disable S-NAT IPFIX logging reply
345     @param context - sender context, to match reply w/ request
346     @param retval - return code
347 */
348 define snat_ipfix_enable_disable_reply {
349   u32 context;
350   i32 retval;
351 };