]> git.ipfire.org Git - thirdparty/bird.git/blob - filter/filter.h
Filter: Remove quitbird command
[thirdparty/bird.git] / filter / filter.h
1 /*
2 * BIRD Internet Routing Daemon -- Filters
3 *
4 * (c) 1999 Pavel Machek <pavel@ucw.cz>
5 * (c) 2018--2019 Maria Matejka <mq@jmq.cz>
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"
14 #include "lib/ip.h"
15 #include "lib/macro.h"
16 #include "nest/route.h"
17 #include "nest/attrs.h"
18
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 };
28
29 static inline const char *filter_return_str(const enum filter_return fret) {
30 switch (fret) {
31 #define FRS(x) case x: return #x
32 FRS(F_NOP);
33 FRS(F_NONL);
34 FRS(F_RETURN);
35 FRS(F_ACCEPT);
36 FRS(F_REJECT);
37 FRS(F_ERROR);
38 #undef FRS
39 default: bug("This shall not happen");
40 }
41 }
42
43 struct f_val;
44
45 /* The filter encapsulating structure to be pointed-to from outside */
46 struct f_line;
47 struct filter {
48 struct symbol *sym;
49 const struct f_line *root;
50 };
51
52 struct rte;
53
54 enum filter_return f_run(const struct filter *filter, struct rte **rte, struct linpool *tmp_pool, int flags);
55 enum filter_return f_eval_rte(const struct f_line *expr, struct rte **rte, struct linpool *tmp_pool);
56 uint f_eval_int(const struct f_line *expr);
57 enum filter_return f_eval_buf(const struct f_line *expr, struct linpool *tmp_pool, buffer *buf);
58
59 const char *filter_name(const struct filter *filter);
60 int filter_same(const struct filter *new, const struct filter *old);
61 int f_same(const struct f_line *f1, const struct f_line *f2);
62
63 void filter_commit(struct config *new, struct config *old);
64
65 void filters_dump_all(void);
66
67 #define FILTER_ACCEPT NULL
68 #define FILTER_REJECT ((struct filter *) 1)
69 #define FILTER_UNDEF ((struct filter *) 2) /* Used in BGP */
70
71 #define FF_SILENT 2 /* Silent filter execution */
72
73 /* Custom route attributes */
74 struct custom_attribute {
75 resource r;
76 struct f_dynamic_attr *fda;
77 const char *name;
78 };
79
80 struct custom_attribute *ca_lookup(pool *p, const char *name, int ea_type);
81
82 #endif