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"
|
2023-10-29 15:25:01 +00:00
|
|
|
#include "nest/route.h"
|
2022-03-31 17:22:07 +00:00
|
|
|
#include "lib/attrs.h"
|
2023-08-24 02:45:55 +00:00
|
|
|
#include "filter/data.h"
|
2023-10-13 11:36:47 +00:00
|
|
|
#include "conf/conf.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;
|
|
|
|
|
2022-05-30 14:41:15 +00:00
|
|
|
enum filter_return f_run(const struct filter *filter, struct rte *rte, int flags);
|
2023-10-31 09:28:01 +00:00
|
|
|
enum filter_return f_run_args(const struct filter *filter, struct rte *rte, uint argc, const struct f_val *argv, int flags);
|
2023-10-31 15:54:58 +00:00
|
|
|
enum filter_return f_eval_rte(const struct f_line *expr, struct rte *rte, uint argc, const struct f_val *argv, uint resc, struct f_val *resv);
|
2022-04-10 16:55:15 +00:00
|
|
|
enum filter_return f_eval_buf(const struct f_line *expr, buffer *buf);
|
2009-08-27 17:01:04 +00:00
|
|
|
|
2023-10-13 11:36:47 +00:00
|
|
|
struct f_val cf_eval_tmp(const struct f_inst *inst, int type);
|
|
|
|
static inline struct f_val *cf_eval(const struct f_inst *inst, int type)
|
|
|
|
{
|
|
|
|
struct f_val val = cf_eval_tmp(inst, type);
|
|
|
|
return lp_val_copy(cfg_mem, &val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint cf_eval_int(const struct f_inst *inst) { return cf_eval_tmp(inst, T_INT).val.i; };
|
2023-08-24 02:45:55 +00:00
|
|
|
|
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);
|
|
|
|
|
2024-06-13 13:49:56 +00:00
|
|
|
void filter_preconfig(struct config *new);
|
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
|
|
|
|
2024-11-14 19:43:35 +00:00
|
|
|
void filters_dump_all(struct dump_request *);
|
2019-07-03 06:13:07 +00:00
|
|
|
|
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
|
|
|
|
1999-01-15 16:49:17 +00:00
|
|
|
#endif
|