diff options
Diffstat (limited to 'filter')
-rw-r--r-- | filter/config.Y | 12 | ||||
-rw-r--r-- | filter/filter.c | 3 | ||||
-rw-r--r-- | filter/filter.h | 4 |
3 files changed, 15 insertions, 4 deletions
diff --git a/filter/config.Y b/filter/config.Y index c1e74531..51e7a8cc 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -426,7 +426,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN, %type <x> term block cmds cmds_int cmd function_body constant constructor print_one print_list var_list var_listn function_call symbol bgp_path_expr %type <fda> dynamic_attr %type <fsa> static_attr -%type <f> filter filter_body where_filter +%type <f> filter filter_body where_filter lua_call %type <i> type break_command ec_kind %type <i32> cnum %type <e> pair_item ec_item lc_item set_item switch_item set_items switch_items switch_body @@ -1064,6 +1064,16 @@ cmd: | BT_ASSERT '(' get_cf_position term get_cf_position ')' ';' { $$ = assert_done($4, $3 + 1, $5 - 1); } ; +lua_call: + LUA constant { + $$ = cfg_alloc(sizeof(struct filter)); + $$->name = NULL; + $$->root = f_new_inst(); + $$->root->code = P('L','C'); + $$->root->a1.p = $2; + $$->root->next = NULL; + } + get_cf_position: { $$ = cf_text; diff --git a/filter/filter.c b/filter/filter.c index 7f3979f3..a13d5cc8 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -1580,8 +1580,7 @@ interpret(struct f_inst *what) if (v1.type != T_STRING) runtime("Lua code should be a string argument"); - res.type = T_RETURN; - res.val.i = filter_lua_chunk(v1.val.s, f_rte, f_old_rta, f_tmp_attrs, f_pool); + res = filter_lua_chunk(v1.val.s, f_rte, f_old_rta, f_tmp_attrs, f_pool); break; default: diff --git a/filter/filter.h b/filter/filter.h index a4eb2913..c08f8a48 100644 --- a/filter/filter.h +++ b/filter/filter.h @@ -284,6 +284,8 @@ struct f_trie }; #define NEW_F_VAL struct f_val * val; val = cfg_alloc(sizeof(struct f_val)); +#define F_VAL(_type, where, value) ((struct f_val) { .type = (_type), .val.where = (value) }) +#define F_VAL_VOID ((struct f_val) { .type = T_VOID }) #define FF_SILENT 2 /* Silent filter execution */ @@ -308,6 +310,6 @@ struct f_bt_test_suite { extern void (*bt_assert_hook)(int result, struct f_inst *assert); /* Lua */ -int filter_lua_chunk(const char *chunk, struct rte **e, struct rta *a, struct ea_list **ea, struct linpool *lp); +struct f_val filter_lua_chunk(const char *chunk, struct rte **e, struct rta *a, struct ea_list **ea, struct linpool *lp); #endif |