]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
2 | * Route filtering function. | |
3 | * Copyright (C) 1998 Kunihiro Ishiguro | |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published | |
9 | * by the Free Software Foundation; either version 2, or (at your | |
10 | * option) any later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
896014f4 DL |
17 | * You should have received a copy of the GNU General Public License along |
18 | * with this program; see the file COPYING; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 20 | */ |
21 | ||
22 | #ifndef _ZEBRA_FILTER_H | |
23 | #define _ZEBRA_FILTER_H | |
24 | ||
25 | #include "if.h" | |
4cf24501 | 26 | #include "prefix.h" |
718e3744 | 27 | |
5e244469 RW |
28 | #ifdef __cplusplus |
29 | extern "C" { | |
30 | #endif | |
31 | ||
45a8eba9 RW |
32 | /* Maximum ACL name length */ |
33 | #define ACL_NAMSIZ 128 | |
34 | ||
0ed507dd RZ |
35 | /** Cisco host wildcard mask. */ |
36 | #define CISCO_HOST_WILDCARD_MASK "0.0.0.0" | |
37 | /** Cisco host wildcard binary mask. */ | |
38 | #define CISCO_BIN_HOST_WILDCARD_MASK INADDR_ANY | |
39 | ||
40 | /** Cisco any wildcard mask. */ | |
41 | #define CISCO_ANY_WILDCARD_MASK "255.255.255.255" | |
42 | /** Cisco binary any wildcard mask. */ | |
43 | #define CISCO_BIN_ANY_WILDCARD_MASK INADDR_NONE | |
44 | ||
039f3a34 DS |
45 | /* Filter direction. */ |
46 | #define FILTER_IN 0 | |
47 | #define FILTER_OUT 1 | |
48 | #define FILTER_MAX 2 | |
49 | ||
718e3744 | 50 | /* Filter type is made by `permit', `deny' and `dynamic'. */ |
d62a17ae | 51 | enum filter_type { FILTER_DENY, FILTER_PERMIT, FILTER_DYNAMIC }; |
718e3744 | 52 | |
d62a17ae | 53 | enum access_type { ACCESS_TYPE_STRING, ACCESS_TYPE_NUMBER }; |
718e3744 | 54 | |
4cf24501 RZ |
55 | struct filter_cisco { |
56 | /* Cisco access-list */ | |
57 | int extended; | |
58 | struct in_addr addr; | |
59 | struct in_addr addr_mask; | |
60 | struct in_addr mask; | |
61 | struct in_addr mask_mask; | |
62 | }; | |
63 | ||
64 | struct filter_zebra { | |
65 | /* If this filter is "exact" match then this flag is set. */ | |
66 | int exact; | |
67 | ||
68 | /* Prefix information. */ | |
69 | struct prefix prefix; | |
70 | }; | |
71 | ||
72 | /* Forward declaration of access-list struct. */ | |
73 | struct access_list; | |
74 | ||
75 | /* Filter element of access list */ | |
76 | struct filter { | |
77 | /* For doubly linked list. */ | |
78 | struct filter *next; | |
79 | struct filter *prev; | |
80 | ||
81 | /* Parent access-list pointer. */ | |
82 | struct access_list *acl; | |
83 | ||
84 | /* Filter type information. */ | |
85 | enum filter_type type; | |
86 | ||
87 | /* Sequence number */ | |
88 | int64_t seq; | |
89 | ||
90 | /* Cisco access-list */ | |
91 | int cisco; | |
92 | ||
93 | union { | |
94 | struct filter_cisco cfilter; | |
95 | struct filter_zebra zfilter; | |
96 | } u; | |
97 | }; | |
98 | ||
718e3744 | 99 | /* Access list */ |
d62a17ae | 100 | struct access_list { |
101 | char *name; | |
102 | char *remark; | |
718e3744 | 103 | |
d62a17ae | 104 | struct access_master *master; |
718e3744 | 105 | |
d62a17ae | 106 | enum access_type type; |
718e3744 | 107 | |
d62a17ae | 108 | struct access_list *next; |
109 | struct access_list *prev; | |
718e3744 | 110 | |
d62a17ae | 111 | struct filter *head; |
112 | struct filter *tail; | |
718e3744 | 113 | }; |
114 | ||
4cf24501 RZ |
115 | /* List of access_list. */ |
116 | struct access_list_list { | |
117 | struct access_list *head; | |
118 | struct access_list *tail; | |
119 | }; | |
120 | ||
121 | /* Master structure of access_list. */ | |
122 | struct access_master { | |
123 | /* List of access_list which name is number. */ | |
124 | struct access_list_list num; | |
125 | ||
126 | /* List of access_list which name is string. */ | |
127 | struct access_list_list str; | |
128 | ||
129 | /* Hook function which is executed when new access_list is added. */ | |
130 | void (*add_hook)(struct access_list *); | |
131 | ||
132 | /* Hook function which is executed when access_list is deleted. */ | |
133 | void (*delete_hook)(struct access_list *); | |
134 | }; | |
135 | ||
136 | ||
718e3744 | 137 | /* Prototypes for access-list. */ |
d62a17ae | 138 | extern void access_list_init(void); |
139 | extern void access_list_reset(void); | |
140 | extern void access_list_add_hook(void (*func)(struct access_list *)); | |
141 | extern void access_list_delete_hook(void (*func)(struct access_list *)); | |
142 | extern struct access_list *access_list_lookup(afi_t, const char *); | |
123214ef MS |
143 | extern enum filter_type access_list_apply(struct access_list *access, |
144 | const void *object); | |
718e3744 | 145 | |
4cf24501 RZ |
146 | struct access_list *access_list_get(afi_t afi, const char *name); |
147 | void access_list_delete(struct access_list *access); | |
148 | struct filter *filter_new(void); | |
149 | void access_list_filter_add(struct access_list *access, | |
150 | struct filter *filter); | |
151 | void access_list_filter_delete(struct access_list *access, | |
152 | struct filter *filter); | |
153 | int64_t filter_new_seq_get(struct access_list *access); | |
154 | struct filter *filter_lookup_cisco(struct access_list *access, | |
155 | struct filter *mnew); | |
156 | struct filter *filter_lookup_zebra(struct access_list *access, | |
157 | struct filter *mnew); | |
158 | ||
c2aab693 RZ |
159 | extern const struct frr_yang_module_info frr_filter_info; |
160 | ||
be96651c RZ |
161 | |
162 | /* filter_nb.c */ | |
163 | enum yang_access_list_type { | |
164 | YALT_IPV4 = 0, | |
165 | YALT_IPV6 = 1, | |
166 | YALT_MAC = 2, | |
167 | }; | |
168 | ||
169 | enum yang_prefix_list_type { | |
170 | YPLT_IPV4 = 0, | |
171 | YPLT_IPV6 = 1, | |
172 | }; | |
173 | ||
174 | enum yang_prefix_list_action { | |
175 | YPLA_DENY = 0, | |
176 | YPLA_PERMIT = 1, | |
177 | }; | |
178 | ||
1d3c4b66 RZ |
179 | /* filter_cli.c */ |
180 | struct lyd_node; | |
181 | struct vty; | |
182 | ||
1d3c4b66 RZ |
183 | extern void access_list_show(struct vty *vty, struct lyd_node *dnode, |
184 | bool show_defaults); | |
185 | extern void access_list_remark_show(struct vty *vty, struct lyd_node *dnode, | |
186 | bool show_defaults); | |
187 | extern void prefix_list_show(struct vty *vty, struct lyd_node *dnode, | |
188 | bool show_defaults); | |
189 | extern void prefix_list_remark_show(struct vty *vty, struct lyd_node *dnode, | |
190 | bool show_defaults); | |
191 | ||
b62578bd RZ |
192 | void filter_cli_init(void); |
193 | ||
5e244469 RW |
194 | #ifdef __cplusplus |
195 | } | |
196 | #endif | |
197 | ||
718e3744 | 198 | #endif /* _ZEBRA_FILTER_H */ |