mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
TMP
This commit is contained in:
parent
0fbd598a9c
commit
a36fc2b2cd
@ -163,6 +163,7 @@ struct bytestring {
|
|||||||
#define SYM_FILTER 4
|
#define SYM_FILTER 4
|
||||||
#define SYM_TABLE 5
|
#define SYM_TABLE 5
|
||||||
#define SYM_ATTRIBUTE 6
|
#define SYM_ATTRIBUTE 6
|
||||||
|
#define SYM_VOLATILE 7
|
||||||
|
|
||||||
#define SYM_VARIABLE 0x100 /* 0x100-0x1ff are variable types */
|
#define SYM_VARIABLE 0x100 /* 0x100-0x1ff are variable types */
|
||||||
#define SYM_VARIABLE_RANGE SYM_VARIABLE ... (SYM_VARIABLE | 0xff)
|
#define SYM_VARIABLE_RANGE SYM_VARIABLE ... (SYM_VARIABLE | 0xff)
|
||||||
|
@ -12,6 +12,7 @@ CF_HDR
|
|||||||
|
|
||||||
#include "filter/f-inst.h"
|
#include "filter/f-inst.h"
|
||||||
#include "filter/data.h"
|
#include "filter/data.h"
|
||||||
|
#include "nest/volatile.h"
|
||||||
|
|
||||||
CF_DEFINES
|
CF_DEFINES
|
||||||
|
|
||||||
@ -366,16 +367,35 @@ conf: definition ;
|
|||||||
definition:
|
definition:
|
||||||
DEFINE symbol '=' term ';' {
|
DEFINE symbol '=' term ';' {
|
||||||
struct f_line *line = f_linearize($4, 1);
|
struct f_line *line = f_linearize($4, 1);
|
||||||
|
int volat = 0;
|
||||||
struct filter_iterator fit;
|
struct filter_iterator fit;
|
||||||
FILTER_ITERATE_INIT(&fit,
|
FILTER_ITERATE_INIT(&fit, line, new_config->pool);
|
||||||
if
|
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);
|
||||||
|
|
||||||
struct f_val val;
|
if (volat)
|
||||||
if (f_eval(, &val) > F_RETURN) cf_error("Runtime error");
|
cf_define_symbol($2, SYM_VOLATILE, volat, f_volatile_term(line));
|
||||||
cf_define_symbol($2, SYM_CONSTANT | val.type, val, lp_val_copy(cfg_mem, &val));
|
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 ';' {
|
| 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));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -820,12 +840,9 @@ symbol_value: symbol_known
|
|||||||
case SYM_ATTRIBUTE:
|
case SYM_ATTRIBUTE:
|
||||||
$$ = f_new_inst(FI_EA_GET, $1->attribute);
|
$$ = f_new_inst(FI_EA_GET, $1->attribute);
|
||||||
break;
|
break;
|
||||||
case SYM_COUNTER:
|
case SYM_VOLATILE:
|
||||||
$$ = f_new_inst(FI_COUNTER, $1);
|
$$ = f_copy_inst($1->volat->inst);
|
||||||
break;
|
break;
|
||||||
case SYM_COUNTER_TERM:
|
|
||||||
$$ = f_new_inst(FI_COUNTER_TERM, $1);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
cf_error("Can't get value of symbol %s", $1->name);
|
cf_error("Can't get value of symbol %s", $1->name);
|
||||||
}
|
}
|
||||||
|
@ -542,13 +542,14 @@
|
|||||||
RESULT_VAL(fstk->vstk[curline.vbase + sym->offset]);
|
RESULT_VAL(fstk->vstk[curline.vbase + sym->offset]);
|
||||||
}
|
}
|
||||||
|
|
||||||
INST(FI_COUNTER, 0, 1) {
|
INST(FI_VOLATILE_ROUTE_COUNTER, 0, 1) {
|
||||||
SYMBOL;
|
FID_MEMBER(struct volatile_route_counter_config *, vrcc, vrcc->vc.sym->flags & SYM_FLAG_SAME, "count route %p", item->vrcc);
|
||||||
|
|
||||||
NEVER_CONSTANT;
|
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;
|
SYMBOL;
|
||||||
NEVER_CONSTANT;
|
NEVER_CONSTANT;
|
||||||
|
|
||||||
|
@ -29,6 +29,15 @@ enum f_instruction_flags {
|
|||||||
#include "filter/inst-gen.h"
|
#include "filter/inst-gen.h"
|
||||||
|
|
||||||
#define f_new_inst(...) MACRO_CONCAT_AFTER(f_new_inst_, MACRO_FIRST(__VA_ARGS__))(__VA_ARGS__)
|
#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 */
|
/* Convert the instruction back to the enum name */
|
||||||
const char *f_instruction_name_(enum f_instruction_code fi);
|
const char *f_instruction_name_(enum f_instruction_code fi);
|
||||||
@ -94,6 +103,8 @@ void f_add_lines(const struct f_line_item *what, struct filter_iterator *fit);
|
|||||||
|
|
||||||
|
|
||||||
struct filter *f_new_where(struct f_inst *);
|
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)
|
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 }; }
|
{ 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 f_inst *f_generate_roa_check(struct rtable_config *table, struct f_inst *prefix, struct f_inst *asn);
|
||||||
|
@ -666,6 +666,8 @@ void rt_show(struct rt_show_data *);
|
|||||||
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_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 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 */
|
/* Value of table definition mode in struct rt_show_data */
|
||||||
#define RSD_TDB_DEFAULT 0 /* no table specified */
|
#define RSD_TDB_DEFAULT 0 /* no table specified */
|
||||||
#define RSD_TDB_INDIRECT 0 /* show route ... protocol P ... */
|
#define RSD_TDB_INDIRECT 0 /* show route ... protocol P ... */
|
||||||
|
Loading…
Reference in New Issue
Block a user