ip: add classifier-based ACLs support on ip punt
[vpp.git] / src / vnet / classify / in_out_acl.h
1 /*
2  * Copyright (c) 2015 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 #ifndef __included_vnet_in_out_acl_h__
17 #define __included_vnet_in_out_acl_h__
18
19 #include <vlib/vlib.h>
20 #include <vnet/vnet.h>
21 #include <vnet/classify/vnet_classify.h>
22
23 typedef enum
24 {
25   ACL_NEXT_INDEX_DENY,
26   ACL_NEXT_INDEX_N_NEXT,
27 } acl_next_index_t;
28
29 typedef enum
30 {
31   IN_OUT_ACL_TABLE_IP4,
32   IN_OUT_ACL_TABLE_IP6,
33   IN_OUT_ACL_TABLE_L2,
34   IN_OUT_ACL_TABLE_IP4_PUNT,
35   IN_OUT_ACL_TABLE_IP6_PUNT,
36   IN_OUT_ACL_N_TABLES,
37 } in_out_acl_table_id_t;
38
39 typedef enum
40 {
41   IN_OUT_ACL_INPUT_TABLE_GROUP,
42   IN_OUT_ACL_OUTPUT_TABLE_GROUP,
43   IN_OUT_ACL_N_TABLE_GROUPS
44 } in_out_acl_table_group_id_t;
45
46 typedef struct
47 {
48
49   /* classifier table vectors */
50   u32
51     * classify_table_index_by_sw_if_index[IN_OUT_ACL_N_TABLE_GROUPS]
52     [IN_OUT_ACL_N_TABLES];
53
54   /* convenience variables */
55   vlib_main_t *vlib_main;
56   vnet_main_t *vnet_main;
57   vnet_classify_main_t *vnet_classify_main;
58     vnet_config_main_t
59     * vnet_config_main[IN_OUT_ACL_N_TABLE_GROUPS][IN_OUT_ACL_N_TABLES];
60 } in_out_acl_main_t;
61
62 extern in_out_acl_main_t in_out_acl_main;
63
64 int vnet_set_in_out_acl_intfc (vlib_main_t *vm, u32 sw_if_index,
65                                u32 ip4_table_index, u32 ip6_table_index,
66                                u32 l2_table_index, u32 ip4_punt_table_index,
67                                u32 ip6_punt_table_index, u32 is_add,
68                                u32 is_output);
69
70 int vnet_set_input_acl_intfc (vlib_main_t *vm, u32 sw_if_index,
71                               u32 ip4_table_index, u32 ip6_table_index,
72                               u32 l2_table_index, u32 is_add);
73
74 int vnet_set_output_acl_intfc (vlib_main_t * vm, u32 sw_if_index,
75                                u32 ip4_table_index,
76                                u32 ip6_table_index,
77                                u32 l2_table_index, u32 is_add);
78
79 #endif /* __included_vnet_in_out_acl_h__ */
80
81 /*
82  * fd.io coding-style-patch-verification: ON
83  *
84  * Local Variables:
85  * eval: (c-set-style "gnu")
86  * End:
87  */