Fix pretty-printing in "api trace custom-dump" (VPP-683)
[vpp.git] / plugins / acl-plugin / 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
23 /** \brief Get the plugin version
24     @param client_index - opaque cookie to identify the sender
25     @param context - sender context, to match reply w/ request
26 */
27
28 define acl_plugin_get_version
29 {
30   u32 client_index;
31   u32 context;
32 };
33
34 /** \brief Reply to get the plugin version
35     @param context - returned sender context, to match reply w/ request
36     @param major - Incremented every time a known breaking behavior change is introduced
37     @param minor - Incremented with small changes, may be used to avoid buggy versions
38 */
39
40 define acl_plugin_get_version_reply
41 {
42   u32 context;
43   u32 major;
44   u32 minor;
45 };
46
47 /** \brief Access List Rule entry
48     @param is_permit - deny (0), permit (1), or permit+reflect(2) action on this rule.
49     @param is_ipv6   - IP addresses in this rule are IPv6 (1) or IPv4 (0)
50     @param src_ip_addr - Source prefix value
51     @param src_ip_prefix_len - Source prefix length
52     @param dst_ip_addr - Destination prefix value
53     @param dst_ip_prefix_len - Destination prefix length
54     @param proto - L4 protocol (http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml)
55     @param srcport_or_icmptype_first - beginning of source port or ICMP4/6 type range
56     @param srcport_or_icmptype_last - end of source port or ICMP4/6 type range
57     @param dstport_or_icmpcode_first - beginning of destination port or ICMP4/6 code range
58     @param dstport_or_icmpcode_last - end of destination port or ICMP4/6 code range
59     @param tcp_flags_mask - if proto==6, match masked TCP flags with this value
60     @param tcp_flags_value - if proto==6, mask to AND the TCP flags in the packet with
61 */
62
63 typeonly manual_print manual_endian define acl_rule
64 {
65   u8 is_permit;
66   u8 is_ipv6;
67   u8 src_ip_addr[16];
68   u8 src_ip_prefix_len;
69   u8 dst_ip_addr[16];
70   u8 dst_ip_prefix_len;
71 /*
72  * L4 protocol. IANA number. 1 = ICMP, 58 = ICMPv6, 6 = TCP, 17 = UDP.
73  * 0 => ignore L4 and ignore the ports/tcpflags when matching.
74  */
75   u8 proto;
76 /*
77  * If the L4 protocol is TCP or UDP, the below
78  * hold ranges of ports, else if the L4 is ICMP/ICMPv6
79  * they hold ranges of ICMP(v6) types/codes.
80  *
81  * Ranges are inclusive, i.e. to match "any" TCP/UDP port,
82  * use first=0,last=65535. For ICMP(v6),
83  * use first=0,last=255.
84  */
85   u16 srcport_or_icmptype_first;
86   u16 srcport_or_icmptype_last;
87   u16 dstport_or_icmpcode_first;
88   u16 dstport_or_icmpcode_last;
89 /*
90  * for proto = 6, this matches if the
91  * TCP flags in the packet, ANDed with tcp_flags_mask,
92  * is equal to tcp_flags_value.
93  */
94   u8 tcp_flags_mask;
95   u8 tcp_flags_value;
96 };
97
98 /** \brief MACIP Access List Rule entry
99     @param is_permit - deny (0), permit (1) action on this rule.
100     @param is_ipv6   - IP addresses in this rule are IPv6 (1) or IPv4 (0)
101     @param src_mac - match masked source MAC address against this value
102     @param src_mac_mask - AND source MAC address with this value before matching
103     @param src_ip_addr - Source prefix value
104     @param src_ip_prefix_len - Source prefix length
105 */
106
107 typeonly manual_print manual_endian define macip_acl_rule
108 {
109   u8 is_permit;
110   u8 is_ipv6;
111 /*
112  * The source mac of the packet ANDed with src_mac_mask.
113  * The source ip[46] address in the packet is matched
114  * against src_ip_addr, with src_ip_prefix_len set to 0.
115  *
116  * For better performance, minimize the number of
117  * (src_mac_mask, src_ip_prefix_len) combinations
118  * in a MACIP ACL.
119  */
120   u8 src_mac[6];
121   u8 src_mac_mask[6];
122   u8 src_ip_addr[16];
123   u8 src_ip_prefix_len;
124 };
125
126 /** \brief Replace an existing ACL in-place or create a new ACL
127     @param client_index - opaque cookie to identify the sender
128     @param context - sender context, to match reply w/ request
129     @param acl_index - an existing ACL entry (0..0xfffffffe) to replace, or 0xffffffff to make new ACL
130     @param tag - a string value stored along with the ACL, for descriptive purposes
131     @param count - number of ACL rules
132     @r - Rules for this access-list
133 */
134
135 manual_print manual_endian define acl_add_replace
136 {
137   u32 client_index;
138   u32 context;
139   u32 acl_index; /* ~0 to add, existing ACL# to replace */
140   u8 tag[64]; /* What gets in here gets out in the corresponding tag field when dumping the ACLs. */
141   u32 count;
142   vl_api_acl_rule_t r[count];
143 };
144
145 /** \brief Reply to add/replace ACL
146     @param context - returned sender context, to match reply w/ request
147     @param acl_index - index of the updated or newly created ACL
148     @param retval 0 - no error
149 */
150
151 define acl_add_replace_reply
152 {
153   u32 context;
154   u32 acl_index;
155   i32 retval;
156 };
157
158 /** \brief Delete an ACL
159     @param client_index - opaque cookie to identify the sender
160     @param context - sender context, to match reply w/ request
161     @param acl_index - ACL index to delete
162 */
163
164 define acl_del
165 {
166   u32 client_index;
167   u32 context;
168   u32 acl_index;
169 };
170
171 /** \brief Reply to delete the ACL
172     @param context - returned sender context, to match reply w/ request
173     @param retval 0 - no error
174 */
175
176 define acl_del_reply
177 {
178   u32 context;
179   i32 retval;
180 };
181
182 /* acl_interface_add_del(_reply) to be deprecated in lieu of acl_interface_set_acl_list */
183 /** \brief Use acl_interface_set_acl_list instead
184     Append/remove an ACL index to/from the list of ACLs checked for an interface
185     @param client_index - opaque cookie to identify the sender
186     @param context - sender context, to match reply w/ request
187     @param is_add - add or delete the ACL index from the list
188     @param is_input - check the ACL on input (1) or output (0)
189     @param sw_if_index - the interface to alter the list of ACLs on
190     @param acl_index - index of ACL for the operation
191 */
192
193 define acl_interface_add_del
194 {
195   u32 client_index;
196   u32 context;
197   u8 is_add;
198 /*
199  * is_input = 0 => ACL applied on interface egress
200  * is_input = 1 => ACL applied on interface ingress
201  */
202   u8 is_input;
203   u32 sw_if_index;
204   u32 acl_index;
205 };
206
207 /** \brief Reply to alter the ACL list
208     @param context - returned sender context, to match reply w/ request
209     @param retval 0 - no error
210 */
211
212 define acl_interface_add_del_reply
213 {
214   u32 context;
215   i32 retval;
216 };
217
218 /** \brief Set the vector of input/output ACLs checked for an interface
219     @param client_index - opaque cookie to identify the sender
220     @param context - sender context, to match reply w/ request
221     @param sw_if_index - the interface to alter the list of ACLs on
222     @param count - total number of ACL indices in the vector
223     @param n_input - this many first elements correspond to input ACLs, the rest - output
224     @param acls - vector of ACL indices
225 */
226
227 manual_endian define acl_interface_set_acl_list
228 {
229   u32 client_index;
230   u32 context;
231   u32 sw_if_index;
232   u8 count;
233   u8 n_input; /* First n_input ACLs are set as a list of input ACLs, the rest are applied as output */
234   u32 acls[count];
235 };
236
237 /** \brief Reply to set the ACL list on an interface
238     @param context - returned sender context, to match reply w/ request
239     @param retval 0 - no error
240 */
241
242 define acl_interface_set_acl_list_reply
243 {
244   u32 context;
245   i32 retval;
246 };
247
248 /** \brief Dump the specific ACL contents or all of the ACLs' contents
249     @param client_index - opaque cookie to identify the sender
250     @param context - sender context, to match reply w/ request
251     @param acl_index - ACL index to dump, ~0 to dump all ACLs
252 */
253
254 define acl_dump
255 {
256   u32 client_index;
257   u32 context;
258   u32 acl_index; /* ~0 for all ACLs */
259 };
260
261 /** \brief Details about a single ACL contents
262     @param context - returned sender context, to match reply w/ request
263     @param acl_index - ACL index whose contents are being sent in this message
264     @param tag - Descriptive tag value which was supplied at ACL creation
265     @param count - Number of rules in this ACL
266     @param r - Array of rules within this ACL
267 */
268
269 manual_print manual_endian define acl_details
270 {
271   u32 context;
272   u32 acl_index;
273   u8 tag[64]; /* Same blob that was supplied to us when creating the ACL, one hopes. */
274   u32 count;
275   vl_api_acl_rule_t r[count];
276 };
277
278 /** \brief Dump the list(s) of ACL applied to specific or all interfaces
279     @param client_index - opaque cookie to identify the sender
280     @param context - sender context, to match reply w/ request
281     @param sw_if_index - interface to dump the ACL list for
282 */
283
284 define acl_interface_list_dump
285 {
286   u32 client_index;
287   u32 context;
288   u32 sw_if_index; /* ~0 for all interfaces */
289 };
290
291 /** \brief Details about a single ACL contents
292     @param context - returned sender context, to match reply w/ request
293     @param sw_if_index - interface for which the list of ACLs is applied
294     @param count - total length of acl indices vector
295     @param n_input - this many of indices in the beginning are input ACLs, the rest - output
296     @param acls - the vector of ACL indices
297 */
298
299 manual_endian define acl_interface_list_details
300 {
301   u32 context;
302   u32 sw_if_index;
303   u8 count;
304   u8 n_input;
305   u32 acls[count];
306 };
307
308 /** \brief Add a MACIP ACL
309     @param client_index - opaque cookie to identify the sender
310     @param context - sender context, to match reply w/ request
311     @param tag - descriptive value for this MACIP ACL
312     @param count - number of rules in this ACL
313     @param r - vector of MACIP ACL rules
314 */
315
316 manual_print manual_endian define macip_acl_add
317 {
318   u32 client_index;
319   u32 context;
320   u8 tag[64];
321   u32 count;
322   vl_api_macip_acl_rule_t r[count];
323 };
324
325 /** \brief Reply to add MACIP ACL
326     @param context - returned sender context, to match reply w/ request
327     @param acl_index - index of the newly created ACL
328     @param retval 0 - no error
329 */
330
331 define macip_acl_add_reply
332 {
333   u32 context;
334   u32 acl_index;
335   i32 retval;
336 };
337
338 /** \brief Delete a MACIP ACL
339     @param client_index - opaque cookie to identify the sender
340     @param context - sender context, to match reply w/ request
341     @param acl_index - MACIP ACL index to delete
342 */
343
344 define macip_acl_del
345 {
346   u32 client_index;
347   u32 context;
348   u32 acl_index;
349 };
350
351 /** \brief Reply to delete the MACIP ACL
352     @param context - returned sender context, to match reply w/ request
353     @param retval 0 - no error
354 */
355
356 define macip_acl_del_reply
357 {
358   u32 context;
359   i32 retval;
360 };
361
362 /** \brief Add or delete a MACIP ACL to/from interface
363     @param client_index - opaque cookie to identify the sender
364     @param context - sender context, to match reply w/ request
365     @param is_add - add (1) or delete (0) ACL from being used on an interface
366     @param sw_if_index - interface to apply the action to
367     @param acl_index - MACIP ACL index
368 */
369
370 define macip_acl_interface_add_del
371 {
372   u32 client_index;
373   u32 context;
374   u8 is_add;
375   /* macip ACLs are always input */
376   u32 sw_if_index;
377   u32 acl_index;
378 };
379
380 /** \brief Reply to apply/unapply  the MACIP ACL
381     @param context - returned sender context, to match reply w/ request
382     @param retval 0 - no error
383 */
384
385 define macip_acl_interface_add_del_reply
386 {
387   u32 context;
388   i32 retval;
389 };
390
391 /** \brief Dump one or all defined MACIP ACLs
392     @param client_index - opaque cookie to identify the sender
393     @param context - sender context, to match reply w/ request
394     @param acl_index - MACIP ACL index or ~0 to dump all ACLs
395 */
396
397 define macip_acl_dump
398 {
399   u32 client_index;
400   u32 context;
401   u32 acl_index; /* ~0 for all ACLs */
402 };
403
404 /** \brief Details about one MACIP ACL
405     @param context - returned sender context, to match reply w/ request
406     @param acl_index - index of this MACIP ACL
407     @param tag - descriptive tag which was supplied during the creation
408     @param count - length of the vector of MACIP ACL rules
409     @param r - rules comprising this ACL
410 */
411
412 manual_print manual_endian define macip_acl_details
413 {
414   u32 context;
415   u32 acl_index;
416   u8 tag[64];
417   u32 count;
418   vl_api_macip_acl_rule_t r[count];
419 };
420
421 /** \brief Get the vector of MACIP ACL IDs applied to the interfaces
422     @param client_index - opaque cookie to identify the sender
423     @param context - sender context, to match reply w/ request
424 */
425
426 define macip_acl_interface_get
427 {
428   u32 client_index;
429   u32 context;
430 };
431
432 /** \brief Reply with the vector of MACIP ACLs by sw_if_index
433     @param context - returned sender context, to match reply w/ request
434     @param count - total number of elements in the vector
435     @param acls - the vector of active MACACL indices per sw_if_index
436 */
437
438 define macip_acl_interface_get_reply
439 {
440   u32 context;
441   u32 count;
442   u32 acls[count];
443 };
444