#define P(a,b) ((a<<8) | b)
-struct f_inst *startup_func = NULL, *test1_func, *test2_func;
-
#define CMP_ERROR 999
static int
return res.val.i;
}
-void
-filters_postconfig(void)
+int
+f_eval_int(struct f_inst *expr)
{
struct f_val res;
-#if 1
- if (!i_same(test1_func, test2_func))
- bug("i_same does not work");
-#endif
- if (startup_func) {
- debug( "Launching startup function...\n" );
- f_pool = lp_new(&root_pool, 1024);
- res = interpret(startup_func);
- if (res.type == F_ERROR)
- die( "Startup function resulted in error." );
- debug( "done\n" );
- }
-}
+ f_flags = 0;
+ f_tmp_attrs = NULL;
+ f_rte = NULL;
+ f_rte_old = NULL;
+ f_rta_copy = NULL;
+ f_pool = cfg_mem;
+ res = interpret(expr);
+ if (res.type != T_INT)
+ cf_error("Integer expression expected");
+ return res.val.i;
+}
/**
* filter_same - compare two filters
#define arg1 a1.p
#define arg2 a2.p
-struct prefix {
+struct f_prefix {
ip_addr ip;
int len;
#define LEN_MASK 0xff
union {
int i;
/* ip_addr ip; Folded into prefix */
- struct prefix px;
+ struct f_prefix px;
char *s;
struct f_tree *t;
struct adata *ad;
struct f_inst *root;
};
-void filters_postconfig(void);
struct f_inst *f_new_inst(void);
struct f_inst *f_new_dynamic_attr(int type, int f_type, int code); /* Type as core knows it, type as filters know it, and code of dynamic attribute */
struct f_tree *f_new_tree(void);
struct rte;
int f_run(struct filter *filter, struct rte **rte, struct ea_list **tmp_attrs, struct linpool *tmp_pool, int flags);
+int f_eval_int(struct f_inst *expr);
char *filter_name(struct filter *filter);
int filter_same(struct filter *new, struct filter *old);