1999-01-16 00:49:17 +08:00
|
|
|
/*
|
1999-03-17 22:29:39 +08:00
|
|
|
* BIRD Internet Routing Daemon -- Filters
|
1999-01-16 00:49:17 +08:00
|
|
|
*
|
1999-03-17 22:29:39 +08:00
|
|
|
* (c) 1999 Pavel Machek <pavel@ucw.cz>
|
2019-01-21 16:17:54 +08:00
|
|
|
* (c) 2018--2019 Maria Matejka <mq@jmq.cz>
|
1999-01-16 00:49:17 +08: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 20:11:08 +08:00
|
|
|
#include "lib/ip.h"
|
2019-01-21 16:17:54 +08:00
|
|
|
#include "lib/macro.h"
|
2008-10-27 05:45:09 +08:00
|
|
|
#include "nest/route.h"
|
2000-04-17 19:20:00 +08:00
|
|
|
#include "nest/attrs.h"
|
1999-01-16 00:49:17 +08:00
|
|
|
|
2019-01-21 16:17:54 +08: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,
|
|
|
|
F_QUITBIRD,
|
|
|
|
};
|
|
|
|
|
2019-02-08 04:25:38 +08:00
|
|
|
struct f_val;
|
2018-12-27 21:26:11 +08:00
|
|
|
|
|
|
|
/* The filter encapsulating structure to be pointed-to from outside */
|
2019-02-08 04:25:38 +08:00
|
|
|
struct f_line;
|
1999-03-17 22:29:39 +08:00
|
|
|
struct filter {
|
|
|
|
char *name;
|
2018-12-27 21:26:11 +08:00
|
|
|
struct f_line *root;
|
|
|
|
};
|
|
|
|
|
1999-08-04 03:31:11 +08:00
|
|
|
struct rte;
|
|
|
|
|
2018-12-27 21:26:11 +08:00
|
|
|
enum filter_return f_run(const struct filter *filter, struct rte **rte, struct linpool *tmp_pool, int flags);
|
|
|
|
enum filter_return f_eval_rte(const struct f_line *expr, struct rte **rte, struct linpool *tmp_pool);
|
|
|
|
enum filter_return f_eval(const struct f_line *expr, struct linpool *tmp_pool, struct f_val *pres);
|
|
|
|
uint f_eval_int(const struct f_line *expr);
|
2009-08-28 01:01:04 +08:00
|
|
|
|
1999-04-06 04:10:31 +08:00
|
|
|
char *filter_name(struct filter *filter);
|
2000-01-17 01:49:32 +08:00
|
|
|
int filter_same(struct filter *new, struct filter *old);
|
2018-12-27 21:26:11 +08:00
|
|
|
int f_same(const struct f_line *f1, const struct f_line *f2);
|
|
|
|
|
|
|
|
int val_compare(const struct f_val *v1, const struct f_val *v2);
|
2000-02-01 01:44:22 +08:00
|
|
|
|
2018-12-27 21:26:11 +08:00
|
|
|
void val_format(const struct f_val *v, buffer *buf);
|
1999-04-07 20:11:08 +08:00
|
|
|
|
1999-04-06 04:10:31 +08:00
|
|
|
#define FILTER_ACCEPT NULL
|
|
|
|
#define FILTER_REJECT ((void *) 1)
|
2018-01-16 11:14:49 +08:00
|
|
|
#define FILTER_UNDEF ((void *) 2) /* Used in BGP */
|
1999-04-06 04:10:31 +08:00
|
|
|
|
2018-01-16 23:20:01 +08:00
|
|
|
#define FF_SILENT 2 /* Silent filter execution */
|
2000-03-29 17:02:00 +08:00
|
|
|
|
2018-11-22 03:37:11 +08: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-16 00:49:17 +08:00
|
|
|
#endif
|