mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
17f91f9e6e
Changes in internal API: * Every route attribute must be defined as struct ea_class somewhere. * Registration of route attributes known at startup must be done by ea_register_init() from protocol build functions. * Every attribute has now its symbol registered in a global symbol table defined as SYM_ATTRIBUTE * All attribute ID's are dynamically allocated. * Attribute value custom formatting hook is defined in the ea_class. * Attribute names are the same for display and filters, always prefixed by protocol name. Also added some unit testing code for filters with route attributes.
74 lines
1.8 KiB
C
74 lines
1.8 KiB
C
/*
|
|
* BIRD Internet Routing Daemon -- Filters
|
|
*
|
|
* (c) 1999 Pavel Machek <pavel@ucw.cz>
|
|
* (c) 2018--2019 Maria Matejka <mq@jmq.cz>
|
|
*
|
|
* 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"
|
|
#include "lib/ip.h"
|
|
#include "lib/macro.h"
|
|
#include "nest/rt.h"
|
|
#include "lib/attrs.h"
|
|
|
|
/* 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,
|
|
};
|
|
|
|
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");
|
|
}
|
|
}
|
|
|
|
struct f_val;
|
|
|
|
/* The filter encapsulating structure to be pointed-to from outside */
|
|
struct f_line;
|
|
struct filter {
|
|
struct symbol *sym;
|
|
const struct f_line *root;
|
|
};
|
|
|
|
struct rte;
|
|
|
|
enum filter_return f_run(const struct filter *filter, struct rte **rte, int flags);
|
|
enum filter_return f_eval_rte(const struct f_line *expr, struct rte **rte);
|
|
uint f_eval_int(const struct f_line *expr);
|
|
enum filter_return f_eval_buf(const struct f_line *expr, buffer *buf);
|
|
|
|
const char *filter_name(const struct filter *filter);
|
|
int filter_same(const struct filter *new, const struct filter *old);
|
|
int f_same(const struct f_line *f1, const struct f_line *f2);
|
|
|
|
void filter_commit(struct config *new, struct config *old);
|
|
|
|
void filters_dump_all(void);
|
|
|
|
#define FILTER_ACCEPT NULL
|
|
#define FILTER_REJECT ((struct filter *) 1)
|
|
#define FILTER_UNDEF ((struct filter *) 2) /* Used in BGP */
|
|
|
|
#define FF_SILENT 2 /* Silent filter execution */
|
|
|
|
#endif
|