]> git.ipfire.org Git - thirdparty/bird.git/blame - filter/filter.h
Filter: Remove quitbird command
[thirdparty/bird.git] / filter / filter.h
CommitLineData
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 */
20enum 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,
9b46748d
MM
27};
28
de12cd18
MM
29static 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);
de12cd18
MM
38#undef FRS
39 default: bug("This shall not happen");
40 }
41}
42
8bdb05ed 43struct f_val;
4c553c5a
MM
44
45/* The filter encapsulating structure to be pointed-to from outside */
8bdb05ed 46struct f_line;
e0f2e42f 47struct filter {
f249d0b8 48 struct symbol *sym;
0b39b1cb 49 const struct f_line *root;
4c553c5a
MM
50};
51
9a706f32
MM
52struct rte;
53
4c553c5a
MM
54enum filter_return f_run(const struct filter *filter, struct rte **rte, struct linpool *tmp_pool, int flags);
55enum filter_return f_eval_rte(const struct f_line *expr, struct rte **rte, struct linpool *tmp_pool);
4c553c5a 56uint f_eval_int(const struct f_line *expr);
52893045 57enum filter_return f_eval_buf(const struct f_line *expr, struct linpool *tmp_pool, buffer *buf);
05198c12 58
0b39b1cb
MM
59const char *filter_name(const struct filter *filter);
60int filter_same(const struct filter *new, const struct filter *old);
4c553c5a
MM
61int f_same(const struct f_line *f1, const struct f_line *f2);
62
87c82334 63void filter_commit(struct config *new, struct config *old);
f249d0b8 64
84ac62d3
MM
65void filters_dump_all(void);
66
63a381db 67#define FILTER_ACCEPT NULL
84ac62d3
MM
68#define FILTER_REJECT ((struct filter *) 1)
69#define FILTER_UNDEF ((struct filter *) 2) /* Used in BGP */
63a381db 70
b9405791 71#define FF_SILENT 2 /* Silent filter execution */
0a06a9b8 72
265419a3
MM
73/* Custom route attributes */
74struct custom_attribute {
75 resource r;
76 struct f_dynamic_attr *fda;
77 const char *name;
78};
79
80struct custom_attribute *ca_lookup(pool *p, const char *name, int ea_type);
81
b9d70dc8 82#endif