acl-plugin: add the support for dumping the ethertype whitelist (VPP-1163)
[vpp.git] / src / plugins / acl / acl.api
1 /* Hey Emacs use -*- mode: C -*- */
2 /*
3  * Copyright (c) 2016 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /** \file
18     This file defines the vpp control-plane API messages
19     used to control the ACL plugin
20 */
21
22 option version = "1.0.0";
23
24 /** \brief Get the plugin version
25     @param client_index - opaque cookie to identify the sender
26     @param context - sender context, to match reply w/ request
27 */
28
29 define acl_plugin_get_version
30 {
31   u32 client_index;
32   u32 context;
33 };
34
35 /** \brief Reply to get the plugin version
36     @param context - returned sender context, to match reply w/ request
37     @param major - Incremented every time a known breaking behavior change is introduced
38     @param minor - Incremented with small changes, may be used to avoid buggy versions
39 */
40
41 define acl_plugin_get_version_reply
42 {
43   u32 context;
44   u32 major;
45   u32 minor;
46 };
47
48 /** \brief Control ping from client to api server request
49     @param client_index - opaque cookie to identify the sender
50     @param context - sender context, to match reply w/ request
51 */
52 define acl_plugin_control_ping
53 {
54   u32 client_index;
55   u32 context;
56 };
57
58 /** \brief Control ping from the client to the server response
59     @param client_index - opaque cookie to identify the sender
60     @param context - sender context, to match reply w/ request
61     @param retval - return code for the request
62     @param vpe_pid - the pid of the vpe, returned by the server
63 */
64 define acl_plugin_control_ping_reply
65 {
66   u32 context;
67   i32 retval;
68   u32 client_index;
69   u32 vpe_pid;
70 };
71
72 /** \brief Access List Rule entry
73     @param is_permit - deny (0), permit (1), or permit+reflect(2) action on this rule.
74     @param is_ipv6   - IP addresses in this rule are IPv6 (1) or IPv4 (0)
75     @param src_ip_addr - Source prefix value
76     @param src_ip_prefix_len - Source prefix length
77     @param dst_ip_addr - Destination prefix value
78     @param dst_ip_prefix_len - Destination prefix length
79     @param proto - L4 protocol (http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml)
80     @param srcport_or_icmptype_first - beginning of source port or ICMP4/6 type range
81     @param srcport_or_icmptype_last - end of source port or ICMP4/6 type range
82     @param dstport_or_icmpcode_first - beginning of destination port or ICMP4/6 code range
83     @param dstport_or_icmpcode_last - end of destination port or ICMP4/6 code range
84     @param tcp_flags_mask - if proto==6, match masked TCP flags with this value
85     @param tcp_flags_value - if proto==6, mask to AND the TCP flags in the packet with
86 */
87
88 typeonly manual_print define acl_rule
89 {
90   u8 is_permit;
91   u8 is_ipv6;
92   u8 src_ip_addr[16];
93   u8 src_ip_prefix_len;
94   u8 dst_ip_addr[16];
95   u8 dst_ip_prefix_len;
96 /*
97  * L4 protocol. IANA number. 1 = ICMP, 58 = ICMPv6, 6 = TCP, 17 = UDP.
98  * 0 => ignore L4 and ignore the ports/tcpflags when matching.
99  */
100   u8 proto;
101 /*
102  * If the L4 protocol is TCP or UDP, the below
103  * hold ranges of ports, else if the L4 is ICMP/ICMPv6
104  * they hold ranges of ICMP(v6) types/codes.
105  *
106  * Ranges are inclusive, i.e. to match "any" TCP/UDP port,
107  * use first=0,last=65535. For ICMP(v6),
108  * use first=0,last=255.
109  */
110   u16 srcport_or_icmptype_first;
111   u16 srcport_or_icmptype_last;
112   u16 dstport_or_icmpcode_first;
113   u16 dstport_or_icmpcode_last;
114 /*
115  * for proto = 6, this matches if the
116  * TCP flags in the packet, ANDed with tcp_flags_mask,
117  * is equal to tcp_flags_value.
118  */
119   u8 tcp_flags_mask;
120   u8 tcp_flags_value;
121 };
122
123 /** \brief MACIP Access List Rule entry
124     @param is_permit - deny (0), permit (1) action on this rule.
125     @param is_ipv6   - IP addresses in this rule are IPv6 (1) or IPv4 (0)
126     @param src_mac - match masked source MAC address against this value
127     @param src_mac_mask - AND source MAC address with this value before matching
128     @param src_ip_addr - Source prefix value
129     @param src_ip_prefix_len - Source prefix length
130 */
131
132 typeonly manual_print define macip_acl_rule
133 {
134   u8 is_permit;
135   u8 is_ipv6;
136 /*
137  * The source mac of the packet ANDed with src_mac_mask.
138  * The source ip[46] address in the packet is matched
139  * against src_ip_addr, with src_ip_prefix_len set to 0.
140  *
141  * For better performance, minimize the number of
142  * (src_mac_mask, src_ip_prefix_len) combinations
143  * in a MACIP ACL.
144  */
145   u8 src_mac[6];
146   u8 src_mac_mask[6];
147   u8 src_ip_addr[16];
148   u8 src_ip_prefix_len;
149 };
150
151 /** \brief Replace an existing ACL in-place or create a new ACL
152     @param client_index - opaque cookie to identify the sender
153     @param context - sender context, to match reply w/ request
154     @param acl_index - an existing ACL entry (0..0xfffffffe) to replace, or 0xffffffff to make new ACL
155     @param tag - a string value stored along with the ACL, for descriptive purposes
156     @param count - number of ACL rules
157     @r - Rules for this access-list
158 */
159
160 manual_print manual_endian define acl_add_replace
161 {
162   u32 client_index;
163   u32 context;
164   u32 acl_index; /* ~0 to add, existing ACL# to replace */
165   u8 tag[64]; /* What gets in here gets out in the corresponding tag field when dumping the ACLs. */
166   u32 count;
167   vl_api_acl_rule_t r[count];
168 };
169
170 /** \brief Reply to add/replace ACL
171     @param context - returned sender context, to match reply w/ request
172     @param acl_index - index of the updated or newly created ACL
173     @param retval 0 - no error
174 */
175
176 define acl_add_replace_reply
177 {
178   u32 context;
179   u32 acl_index;
180   i32 retval;
181 };
182
183 /** \brief Delete an ACL
184     @param client_index - opaque cookie to identify the sender
185     @param context - sender context, to match reply w/ request
186     @param acl_index - ACL index to delete
187 */
188
189 autoreply manual_print define acl_del
190 {
191   u32 client_index;
192   u32 context;
193   u32 acl_index;
194 };
195
196 /* acl_interface_add_del(_reply) to be deprecated in lieu of acl_interface_set_acl_list */
197 /** \brief Use acl_interface_set_acl_list instead
198     Append/remove an ACL index to/from the list of ACLs checked for an interface
199     @param client_index - opaque cookie to identify the sender
200     @param context - sender context, to match reply w/ request
201     @param is_add - add or delete the ACL index from the list
202     @param is_input - check the ACL on input (1) or output (0)
203     @param sw_if_index - the interface to alter the list of ACLs on
204     @param acl_index - index of ACL for the operation
205 */
206
207 autoreply manual_print define acl_interface_add_del
208 {
209   u32 client_index;
210   u32 context;
211   u8 is_add;
212 /*
213  * is_input = 0 => ACL applied on interface egress
214  * is_input = 1 => ACL applied on interface ingress
215  */
216   u8 is_input;
217   u32 sw_if_index;
218   u32 acl_index;
219 };
220
221 /** \brief Set the vector of input/output ACLs checked for an interface
222     @param client_index - opaque cookie to identify the sender
223     @param context - sender context, to match reply w/ request
224     @param sw_if_index - the interface to alter the list of ACLs on
225     @param count - total number of ACL indices in the vector
226     @param n_input - this many first elements correspond to input ACLs, the rest - output
227     @param acls - vector of ACL indices
228 */
229
230 autoreply manual_print define acl_interface_set_acl_list
231 {
232   u32 client_index;
233   u32 context;
234   u32 sw_if_index;
235   u8 count;
236   u8 n_input; /* First n_input ACLs are set as a list of input ACLs, the rest are applied as output */
237   u32 acls[count];
238 };
239
240 /** \brief Reply to set the ACL list on an interface
241     @param context - returned sender context, to match reply w/ request
242     @param retval 0 - no error
243 */
244
245 /** \brief Dump the specific ACL contents or all of the ACLs' contents
246     @param client_index - opaque cookie to identify the sender
247     @param context - sender context, to match reply w/ request
248     @param acl_index - ACL index to dump, ~0 to dump all ACLs
249 */
250
251 define acl_dump
252 {
253   u32 client_index;
254   u32 context;
255   u32 acl_index; /* ~0 for all ACLs */
256 };
257
258 /** \brief Details about a single ACL contents
259     @param context - returned sender context, to match reply w/ request
260     @param acl_index - ACL index whose contents are being sent in this message
261     @param tag - Descriptive tag value which was supplied at ACL creation
262     @param count - Number of rules in this ACL
263     @param r - Array of rules within this ACL
264 */
265
266 manual_endian manual_print define acl_details
267 {
268   u32 context;
269   u32 acl_index;
270   u8 tag[64]; /* Same blob that was supplied to us when creating the ACL, one hopes. */
271   u32 count;
272   vl_api_acl_rule_t r[count];
273 };
274
275 /** \brief Dump the list(s) of ACL applied to specific or all interfaces
276     @param client_index - opaque cookie to identify the sender
277     @param context - sender context, to match reply w/ request
278     @param sw_if_index - interface to dump the ACL list for
279 */
280
281 define acl_interface_list_dump
282 {
283   u32 client_index;
284   u32 context;
285   u32 sw_if_index; /* ~0 for all interfaces */
286 };
287
288 /** \brief Details about a single ACL contents
289     @param context - returned sender context, to match reply w/ request
290     @param sw_if_index - interface for which the list of ACLs is applied
291     @param count - total length of acl indices vector
292     @param n_input - this many of indices in the beginning are input ACLs, the rest - output
293     @param acls - the vector of ACL indices
294 */
295
296 define acl_interface_list_details
297 {
298   u32 context;
299   u32 sw_if_index;
300   u8 count;
301   u8 n_input;
302   u32 acls[count];
303 };
304
305 /** \brief Add a MACIP ACL
306     @param client_index - opaque cookie to identify the sender
307     @param context - sender context, to match reply w/ request
308     @param tag - descriptive value for this MACIP ACL
309     @param count - number of rules in this MACIP ACL
310     @param r - vector of MACIP ACL rules
311 */
312
313 manual_endian manual_print define macip_acl_add
314 {
315   u32 client_index;
316   u32 context;
317   u8 tag[64];
318   u32 count;
319   vl_api_macip_acl_rule_t r[count];
320 };
321
322 /** \brief Reply to add MACIP ACL
323     @param context - returned sender context, to match reply w/ request
324     @param acl_index - index of the newly created MACIP ACL
325     @param retval 0 - no error
326 */
327
328 define macip_acl_add_reply
329 {
330   u32 context;
331   u32 acl_index;
332   i32 retval;
333 };
334
335 /** \brief Add/Replace a MACIP ACL
336     @param client_index - opaque cookie to identify the sender
337     @param context - sender context, to match reply w/ request
338     @param acl_index - an existing MACIP ACL entry (0..0xfffffffe) to replace, or 0xffffffff to make new MACIP ACL
339     @param tag - descriptive value for this MACIP ACL
340     @param count - number of rules in this MACIP ACL
341     @param r - vector of MACIP ACL rules
342 */
343
344 manual_endian manual_print define macip_acl_add_replace
345 {
346   u32 client_index;
347   u32 context;
348   u32 acl_index; /* ~0 to add, existing MACIP ACL# to replace */
349   u8 tag[64];
350   u32 count;
351   vl_api_macip_acl_rule_t r[count];
352 };
353
354 /** \brief Reply to add/replace MACIP ACL
355     @param context - returned sender context, to match reply w/ request
356     @param acl_index - index of the newly created MACIP ACL
357     @param retval 0 - no error
358 */
359
360 define macip_acl_add_replace_reply
361 {
362   u32 context;
363   u32 acl_index;
364   i32 retval;
365 };
366
367 /** \brief Delete a MACIP ACL
368     @param client_index - opaque cookie to identify the sender
369     @param context - sender context, to match reply w/ request
370     @param acl_index - MACIP ACL index to delete
371 */
372
373 autoreply manual_print define macip_acl_del
374 {
375   u32 client_index;
376   u32 context;
377   u32 acl_index;
378 };
379
380 /** \brief Add or delete a MACIP ACL to/from interface
381     @param client_index - opaque cookie to identify the sender
382     @param context - sender context, to match reply w/ request
383     @param is_add - add (1) or delete (0) MACIP ACL from being used on an interface
384     @param sw_if_index - interface to apply the action to
385     @param acl_index - MACIP ACL index
386 */
387
388 autoreply manual_print define macip_acl_interface_add_del
389 {
390   u32 client_index;
391   u32 context;
392   u8 is_add;
393   /* MACIP ACLs are always input */
394   u32 sw_if_index;
395   u32 acl_index;
396 };
397
398 /** \brief Dump one or all defined MACIP ACLs
399     @param client_index - opaque cookie to identify the sender
400     @param context - sender context, to match reply w/ request
401     @param acl_index - MACIP ACL index or ~0 to dump all MACIP ACLs
402 */
403
404 define macip_acl_dump
405 {
406   u32 client_index;
407   u32 context;
408   u32 acl_index; /* ~0 for all ACLs */
409 };
410
411 /** \brief Details about one MACIP ACL
412     @param context - returned sender context, to match reply w/ request
413     @param acl_index - index of this MACIP ACL
414     @param tag - descriptive tag which was supplied during the creation
415     @param count - length of the vector of MACIP ACL rules
416     @param r - rules comprising this MACIP ACL
417 */
418
419 manual_endian manual_print define macip_acl_details
420 {
421   u32 context;
422   u32 acl_index;
423   u8 tag[64];
424   u32 count;
425   vl_api_macip_acl_rule_t r[count];
426 };
427
428 /** \brief Get the vector of MACIP ACL IDs applied to the interfaces
429     @param client_index - opaque cookie to identify the sender
430     @param context - sender context, to match reply w/ request
431 */
432
433 define macip_acl_interface_get
434 {
435   u32 client_index;
436   u32 context;
437 };
438
439 /** \brief Reply with the vector of MACIP ACLs by sw_if_index
440     @param context - returned sender context, to match reply w/ request
441     @param count - total number of elements in the vector
442     @param acls - the vector of active MACIP ACL indices per sw_if_index
443 */
444
445 define macip_acl_interface_get_reply
446 {
447   u32 context;
448   u32 count;
449   u32 acls[count];
450 };
451
452 /** \brief Dump the list(s) of MACIP ACLs applied to specific or all interfaces
453     @param client_index - opaque cookie to identify the sender
454     @param context - sender context, to match reply w/ request
455     @param sw_if_index - interface to dump the MACIP ACL list for
456 */
457
458 define macip_acl_interface_list_dump
459 {
460   u32 client_index;
461   u32 context;
462   u32 sw_if_index; /* ~0 for all interfaces */
463 };
464
465 /** \brief Details about a single MACIP ACL contents
466     @param context - returned sender context, to match reply w/ request
467     @param sw_if_index - interface for which the list of MACIP ACLs is applied
468     @param count - total length of acl indices vector
469     @param acls - the vector of MACIP ACL indices
470 */
471
472 define macip_acl_interface_list_details
473 {
474   u32 context;
475   u32 sw_if_index;
476   u8 count;
477   u32 acls[count];
478 };
479
480 /** \brief Set the ethertype whitelists on an interface. Takes effect when applying ACLs on the interface, so must be given prior.
481     @param client_index - opaque cookie to identify the sender
482     @param context - sender context, to match reply w/ request
483     @param sw_if_index - the interface to alter the list of ACLs on
484     @param count - total number of whitelisted ethertypes in the vector
485     @param n_input - this many first elements correspond to input whitelisted ethertypes, the rest - output
486     @param whitelist - vector of whitelisted ethertypes
487 */
488
489 autoreply manual_print define acl_interface_set_etype_whitelist
490 {
491   u32 client_index;
492   u32 context;
493   u32 sw_if_index;
494   u8 count; /* Total number of ethertypes in the whitelist */
495   u8 n_input; /* first n_input ethertypes are input, the rest - output */
496   u16 whitelist[count];
497 };
498
499 /** \brief Dump the list(s) of Ethertype whitelists applied to specific or all interfaces
500     @param client_index - opaque cookie to identify the sender
501     @param context - sender context, to match reply w/ request
502     @param sw_if_index - interface to dump the ethertype whitelist for
503 */
504
505 define acl_interface_etype_whitelist_dump
506 {
507   u32 client_index;
508   u32 context;
509   u32 sw_if_index; /* ~0 for all interfaces */
510 };
511
512 /** \brief Details about ethertype whitelist on a single interface
513     @param context - returned sender context, to match reply w/ request
514     @param sw_if_index - interface for which the list of MACIP ACLs is applied
515     @param count - total number of whitelisted ethertypes in the vector
516     @param n_input - this many first elements correspond to input whitelisted ethertypes, the rest - output
517     @param whitelist - vector of whitelisted ethertypes
518 */
519
520 define acl_interface_etype_whitelist_details
521 {
522   u32 context;
523   u32 sw_if_index;
524   u8 count;
525   u8 n_input; /* first n_input ethertypes are input, the rest - output */
526   u16 whitelist[count];
527 };
528