#define SYM_FILTER 4
#define SYM_TABLE 5
#define SYM_ATTRIBUTE 6
+#define SYM_VOLATILE 7
#define SYM_VARIABLE 0x100 /* 0x100-0x1ff are variable types */
#define SYM_VARIABLE_RANGE SYM_VARIABLE ... (SYM_VARIABLE | 0xff)
#include "filter/f-inst.h"
#include "filter/data.h"
+#include "nest/volatile.h"
CF_DEFINES
definition:
DEFINE symbol '=' term ';' {
struct f_line *line = f_linearize($4, 1);
+ int volat = 0;
struct filter_iterator fit;
- FILTER_ITERATE_INIT(&fit,
- if
-
- struct f_val val;
- if (f_eval(, &val) > F_RETURN) cf_error("Runtime error");
- cf_define_symbol($2, SYM_CONSTANT | val.type, val, lp_val_copy(cfg_mem, &val));
+ FILTER_ITERATE_INIT(&fit, line, new_config->pool);
+ FILTER_ITERATE(&fit, fi)
+ {
+ switch (fi->fi_code)
+ {
+ case FI_VOLATILE_ROUTE_COUNTER:
+ case FI_VOLATILE_TERM:
+ volat = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ FILTER_ITERATE_END;
+ FILTER_ITERATE_CLEANUP(&fit);
+
+ if (volat)
+ cf_define_symbol($2, SYM_VOLATILE, volat, f_volatile_term(line));
+ else
+ {
+ struct f_val val;
+ if (f_eval(line, &val) > F_RETURN) cf_error("Runtime error");
+ cf_define_symbol($2, SYM_CONSTANT | val.type, val, lp_val_copy(cfg_mem, &val));
+ }
}
| DEFINE symbol '=' COUNT ROUTE r_args ';' {
- cf_define_symbol($2, SYM_VOLATILE, volat, f_volatile_counter($6));
+ cf_define_symbol($2, SYM_VOLATILE, volat, rt_volatile_route_counter($6));
}
;
case SYM_ATTRIBUTE:
$$ = f_new_inst(FI_EA_GET, $1->attribute);
break;
- case SYM_COUNTER:
- $$ = f_new_inst(FI_COUNTER, $1);
- break;
- case SYM_COUNTER_TERM:
- $$ = f_new_inst(FI_COUNTER_TERM, $1);
- break;
+ case SYM_VOLATILE:
+ $$ = f_copy_inst($1->volat->inst);
+ break;
default:
cf_error("Can't get value of symbol %s", $1->name);
}
RESULT_VAL(fstk->vstk[curline.vbase + sym->offset]);
}
- INST(FI_COUNTER, 0, 1) {
- SYMBOL;
+ INST(FI_VOLATILE_ROUTE_COUNTER, 0, 1) {
+ FID_MEMBER(struct volatile_route_counter_config *, vrcc, vrcc->vc.sym->flags & SYM_FLAG_SAME, "count route %p", item->vrcc);
+
NEVER_CONSTANT;
- RESULT(T_INT, i, stats_get_counter(sym));
+ RESULT(T_INT, i, vrcc->counter_pub);
}
- INST(FI_COUNTER_TERM, 0, 1) {
+ INST(FI_VOLATILE_TERM, 0, 1) {
SYMBOL;
NEVER_CONSTANT;
#include "filter/inst-gen.h"
#define f_new_inst(...) MACRO_CONCAT_AFTER(f_new_inst_, MACRO_FIRST(__VA_ARGS__))(__VA_ARGS__)
+static inline struct f_inst *
+f_copy_inst(struct f_inst *i)
+{
+ ASSERT_DIE(i->next == NULL);
+ struct f_inst *ii = tmp_allocz(sizeof *ii);
+ memcpy(ii, i, sizeof *ii);
+ ii->lineno = ifs->lino;
+ return ii;
+}
/* Convert the instruction back to the enum name */
const char *f_instruction_name_(enum f_instruction_code fi);
struct filter *f_new_where(struct f_inst *);
+struct volatile_config *f_volatile_term(const struct f_line *);
+
static inline struct f_static_attr f_new_static_attr(btype type, int code, int readonly)
{ return (struct f_static_attr) { .type = type, .sa_code = code, .readonly = readonly }; }
struct f_inst *f_generate_roa_check(struct rtable_config *table, struct f_inst *prefix, struct f_inst *asn);
struct rt_show_data_rtable * rt_show_add_exporter(struct rt_show_data *d, struct rt_exporter *t, const char *name);
struct rt_show_data_rtable * rt_show_add_table(struct rt_show_data *d, rtable *t);
+struct volatile_config *rt_volatile_route_counter(struct rt_show_data *);
+
/* Value of table definition mode in struct rt_show_data */
#define RSD_TDB_DEFAULT 0 /* no table specified */
#define RSD_TDB_INDIRECT 0 /* show route ... protocol P ... */