1999-01-15 16:49:17 +00:00
|
|
|
/*
|
1999-03-17 14:29:39 +00:00
|
|
|
* BIRD Internet Routing Daemon -- Filters
|
1999-01-15 16:49:17 +00:00
|
|
|
*
|
1999-03-17 14:29:39 +00:00
|
|
|
* (c) 1999 Pavel Machek <pavel@ucw.cz>
|
2019-01-21 08:17:54 +00:00
|
|
|
* (c) 2018--2019 Maria Matejka <mq@jmq.cz>
|
1999-01-15 16:49:17 +00:00
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BIRD_FILT_H_
|
|
|
|
#define _BIRD_FILT_H_
|
|
|
|
|
|
|
|
#include "lib/resource.h"
|
1999-04-07 12:11:08 +00:00
|
|
|
#include "lib/ip.h"
|
2019-01-21 08:17:54 +00:00
|
|
|
#include "lib/macro.h"
|
2008-10-26 21:45:09 +00:00
|
|
|
#include "nest/route.h"
|
2000-04-17 11:20:00 +00:00
|
|
|
#include "nest/attrs.h"
|
2023-08-24 02:45:55 +00:00
|
|
|
#include "filter/data.h"
|
1999-01-15 16:49:17 +00:00
|
|
|
|
2019-01-21 08:17:54 +00:00
|
|
|
/* Possible return values of filter execution */
|
|
|
|
enum filter_return {
|
|
|
|
F_NOP = 0,
|
|
|
|
F_NONL,
|
|
|
|
F_RETURN,
|
|
|
|
F_ACCEPT, /* Need to preserve ordering: accepts < rejects! */
|
|
|
|
F_REJECT,
|
|
|
|
F_ERROR,
|
|
|
|
};
|
|
|
|
|
2019-02-12 13:16:28 +00:00
|
|
|
static inline const char *filter_return_str(const enum filter_return fret) {
|
|
|
|
switch (fret) {
|
|
|
|
#define FRS(x) case x: return #x
|
|
|
|
FRS(F_NOP);
|
|
|
|
FRS(F_NONL);
|
|
|
|
FRS(F_RETURN);
|
|
|
|
FRS(F_ACCEPT);
|
|
|
|
FRS(F_REJECT);
|
|
|
|
FRS(F_ERROR);
|
|
|
|
#undef FRS
|
|
|
|
default: bug("This shall not happen");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-27 13:26:11 +00:00
|
|
|
/* The filter encapsulating structure to be pointed-to from outside */
|
2023-08-24 02:45:55 +00:00
|
|
|
struct f_inst;
|
2019-02-07 20:25:38 +00:00
|
|
|
struct f_line;
|
1999-03-17 14:29:39 +00:00
|
|
|
struct filter {
|
2019-02-26 15:44:24 +00:00
|
|
|
struct symbol *sym;
|
2019-02-15 12:53:17 +00:00
|
|
|
const struct f_line *root;
|
2018-12-27 13:26:11 +00:00
|
|
|
};
|
|
|
|
|
1999-08-03 19:31:11 +00:00
|
|
|
struct rte;
|
|
|
|
|
2018-12-27 13:26:11 +00:00
|
|
|
enum filter_return f_run(const struct filter *filter, struct rte **rte, struct linpool *tmp_pool, int flags);
|
2023-06-21 11:15:07 +00:00
|
|
|
enum filter_return f_run_args(const struct filter *filter, struct rte **rte, struct linpool *tmp_pool, uint argc, const struct f_val *argv, int flags);
|
|
|
|
enum filter_return f_eval_rte(const struct f_line *expr, struct rte **rte, struct linpool *tmp_pool, uint argc, const struct f_val *argv, struct f_val *pres);
|
2019-02-11 16:12:48 +00:00
|
|
|
enum filter_return f_eval_buf(const struct f_line *expr, struct linpool *tmp_pool, buffer *buf);
|
2009-08-27 17:01:04 +00:00
|
|
|
|
2023-08-24 02:45:55 +00:00
|
|
|
struct f_val cf_eval(const struct f_inst *inst, int type);
|
|
|
|
static inline uint cf_eval_int(const struct f_inst *inst) { return cf_eval(inst, T_INT).val.i; };
|
|
|
|
|
2019-02-15 12:53:17 +00:00
|
|
|
const char *filter_name(const struct filter *filter);
|
|
|
|
int filter_same(const struct filter *new, const struct filter *old);
|
2018-12-27 13:26:11 +00:00
|
|
|
int f_same(const struct f_line *f1, const struct f_line *f2);
|
|
|
|
|
2019-06-13 12:24:48 +00:00
|
|
|
void filter_commit(struct config *new, struct config *old);
|
2019-02-26 15:44:24 +00:00
|
|
|
|
2019-07-03 06:13:07 +00:00
|
|
|
void filters_dump_all(void);
|
|
|
|
|
1999-04-05 20:10:31 +00:00
|
|
|
#define FILTER_ACCEPT NULL
|
2019-07-03 06:13:07 +00:00
|
|
|
#define FILTER_REJECT ((struct filter *) 1)
|
|
|
|
#define FILTER_UNDEF ((struct filter *) 2) /* Used in BGP */
|
1999-04-05 20:10:31 +00:00
|
|
|
|
2018-01-16 15:20:01 +00:00
|
|
|
#define FF_SILENT 2 /* Silent filter execution */
|
2000-03-29 09:02:00 +00:00
|
|
|
|
2018-11-21 19:37:11 +00:00
|
|
|
/* Custom route attributes */
|
|
|
|
struct custom_attribute {
|
|
|
|
resource r;
|
|
|
|
struct f_dynamic_attr *fda;
|
|
|
|
const char *name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct custom_attribute *ca_lookup(pool *p, const char *name, int ea_type);
|
|
|
|
|
1999-01-15 16:49:17 +00:00
|
|
|
#endif
|