Annotation of embedaddon/bird2/filter/filter.h, revision 1.1.1.1
1.1 misho 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: F_QUITBIRD,
28: };
29:
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:
45: struct f_val;
46:
47: /* The filter encapsulating structure to be pointed-to from outside */
48: struct f_line;
49: struct filter {
50: struct symbol *sym;
51: const struct f_line *root;
52: };
53:
54: struct rte;
55:
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);
58: uint f_eval_int(const struct f_line *expr);
59: enum filter_return f_eval_buf(const struct f_line *expr, struct linpool *tmp_pool, buffer *buf);
60:
61: const char *filter_name(const struct filter *filter);
62: int filter_same(const struct filter *new, const struct filter *old);
63: int f_same(const struct f_line *f1, const struct f_line *f2);
64:
65: void filter_commit(struct config *new, struct config *old);
66:
67: void filters_dump_all(void);
68:
69: #define FILTER_ACCEPT NULL
70: #define FILTER_REJECT ((struct filter *) 1)
71: #define FILTER_UNDEF ((struct filter *) 2) /* Used in BGP */
72:
73: #define FF_SILENT 2 /* Silent filter execution */
74:
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:
84: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>