]>
Commit | Line | Data |
---|---|---|
b9d70dc8 | 1 | /* |
e0f2e42f | 2 | * BIRD Internet Routing Daemon -- Filters |
b9d70dc8 | 3 | * |
e0f2e42f | 4 | * (c) 1999 Pavel Machek <pavel@ucw.cz> |
9b46748d | 5 | * (c) 2018--2019 Maria Matejka <mq@jmq.cz> |
b9d70dc8 PM |
6 | * |
7 | * Can be freely distributed and used under the terms of the GNU GPL. | |
8 | */ | |
9 | ||
10 | #ifndef _BIRD_FILT_H_ | |
11 | #define _BIRD_FILT_H_ | |
12 | ||
13 | #include "lib/resource.h" | |
23b1539b | 14 | #include "lib/ip.h" |
9b46748d | 15 | #include "lib/macro.h" |
4847a894 | 16 | #include "nest/route.h" |
159fa4ce | 17 | #include "nest/attrs.h" |
b9d70dc8 | 18 | |
9b46748d MM |
19 | /* Possible return values of filter execution */ |
20 | enum filter_return { | |
21 | F_NOP = 0, | |
22 | F_NONL, | |
23 | F_RETURN, | |
24 | F_ACCEPT, /* Need to preserve ordering: accepts < rejects! */ | |
25 | F_REJECT, | |
26 | F_ERROR, | |
27 | F_QUITBIRD, | |
28 | }; | |
29 | ||
de12cd18 MM |
30 | static inline const char *filter_return_str(const enum filter_return fret) { |
31 | switch (fret) { | |
32 | #define FRS(x) case x: return #x | |
33 | FRS(F_NOP); | |
34 | FRS(F_NONL); | |
35 | FRS(F_RETURN); | |
36 | FRS(F_ACCEPT); | |
37 | FRS(F_REJECT); | |
38 | FRS(F_ERROR); | |
39 | FRS(F_QUITBIRD); | |
40 | #undef FRS | |
41 | default: bug("This shall not happen"); | |
42 | } | |
43 | } | |
44 | ||
8bdb05ed | 45 | struct f_val; |
4c553c5a MM |
46 | |
47 | /* The filter encapsulating structure to be pointed-to from outside */ | |
8bdb05ed | 48 | struct f_line; |
e0f2e42f | 49 | struct filter { |
f249d0b8 | 50 | struct symbol *sym; |
0b39b1cb | 51 | const struct f_line *root; |
4c553c5a MM |
52 | }; |
53 | ||
9a706f32 MM |
54 | struct rte; |
55 | ||
4c553c5a MM |
56 | enum filter_return f_run(const struct filter *filter, struct rte **rte, struct linpool *tmp_pool, int flags); |
57 | enum filter_return f_eval_rte(const struct f_line *expr, struct rte **rte, struct linpool *tmp_pool); | |
4c553c5a | 58 | uint f_eval_int(const struct f_line *expr); |
52893045 | 59 | enum filter_return f_eval_buf(const struct f_line *expr, struct linpool *tmp_pool, buffer *buf); |
05198c12 | 60 | |
0b39b1cb MM |
61 | const char *filter_name(const struct filter *filter); |
62 | int filter_same(const struct filter *new, const struct filter *old); | |
4c553c5a MM |
63 | int f_same(const struct f_line *f1, const struct f_line *f2); |
64 | ||
87c82334 | 65 | void filter_commit(struct config *new, struct config *old); |
f249d0b8 | 66 | |
84ac62d3 MM |
67 | void filters_dump_all(void); |
68 | ||
63a381db | 69 | #define FILTER_ACCEPT NULL |
84ac62d3 MM |
70 | #define FILTER_REJECT ((struct filter *) 1) |
71 | #define FILTER_UNDEF ((struct filter *) 2) /* Used in BGP */ | |
63a381db | 72 | |
b9405791 | 73 | #define FF_SILENT 2 /* Silent filter execution */ |
0a06a9b8 | 74 | |
265419a3 MM |
75 | /* Custom route attributes */ |
76 | struct custom_attribute { | |
77 | resource r; | |
78 | struct f_dynamic_attr *fda; | |
79 | const char *name; | |
80 | }; | |
81 | ||
82 | struct custom_attribute *ca_lookup(pool *p, const char *name, int ea_type); | |
83 | ||
b9d70dc8 | 84 | #endif |