acl: API cleanup
[vpp.git] / src / plugins / acl / acl_types.api
1 /* Hey Emacs use -*- mode: C -*- */
2 /*
3  * Copyright (c) 2016 Cisco and/or its affiliates.
4  * Copyright 2019 Vinci Consulting Corp.  All Rights Reserved.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 import "vnet/ip/ip_types.api";
19 import "vnet/ethernet/ethernet_types.api";
20
21 enum acl_action : u8
22 {
23   ACL_ACTION_API_DENY = 0,
24   ACL_ACTION_API_PERMIT = 1,
25   ACL_ACTION_API_PERMIT_REFLECT = 2,
26 };
27
28 /** \brief Access List Rule entry
29     @param is_permit - deny (0), permit (1), or permit+reflect(2) action on this rule.
30     @param src_prefix - Source prefix
31     @param dst_prefix - Destination prefix
32     @param proto - L4 protocol (http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml)
33     @param srcport_or_icmptype_first - beginning of source port or ICMP4/6 type range
34     @param srcport_or_icmptype_last - end of source port or ICMP4/6 type range
35     @param dstport_or_icmpcode_first - beginning of destination port or ICMP4/6 code range
36     @param dstport_or_icmpcode_last - end of destination port or ICMP4/6 code range
37     @param tcp_flags_mask - if proto==6, match masked TCP flags with this value
38     @param tcp_flags_value - if proto==6, mask to AND the TCP flags in the packet with
39 */
40
41 typedef acl_rule
42 {
43   vl_api_acl_action_t is_permit;
44   vl_api_prefix_t src_prefix;
45   vl_api_prefix_t dst_prefix;
46 /*
47  * L4 protocol. IANA number. 1 = ICMP, 58 = ICMPv6, 6 = TCP, 17 = UDP.
48  * 0 => ignore L4 and ignore the ports/tcpflags when matching.
49  */
50   vl_api_ip_proto_t proto;
51 /*
52  * If the L4 protocol is TCP or UDP, the below
53  * hold ranges of ports, else if the L4 is ICMP/ICMPv6
54  * they hold ranges of ICMP(v6) types/codes.
55  *
56  * Ranges are inclusive, i.e. to match "any" TCP/UDP port,
57  * use first=0,last=65535. For ICMP(v6),
58  * use first=0,last=255.
59  */
60   u16 srcport_or_icmptype_first;
61   u16 srcport_or_icmptype_last;
62   u16 dstport_or_icmpcode_first;
63   u16 dstport_or_icmpcode_last;
64 /*
65  * for proto = 6, this matches if the
66  * TCP flags in the packet, ANDed with tcp_flags_mask,
67  * is equal to tcp_flags_value.
68  */
69   u8 tcp_flags_mask;
70   u8 tcp_flags_value;
71 };
72
73
74 /** \brief MACIP Access List Rule entry
75     @param is_permit - deny (0), permit (1) action on this rule.
76     @param src_mac - match masked source MAC address against this value
77     @param src_mac_mask - AND source MAC address with this value before matching
78     @param src_prefix - Source prefix value
79 */
80
81 typedef macip_acl_rule
82 {
83   vl_api_acl_action_t is_permit;
84 /*
85  * The source mac of the packet ANDed with src_mac_mask.
86  * The source ip[46] address in the packet is matched
87  * against src_prefix set to 0.
88  *
89  * For better performance, minimize the number of
90  * (src_mac_mask, src_prefix.len) combinations
91  * in a MACIP ACL.
92  */
93   vl_api_mac_address_t src_mac;
94   vl_api_mac_address_t src_mac_mask;
95   vl_api_prefix_t src_prefix;
96 };