From 430da60fa29196cf8715e09e1d81c7ea0b672f05 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 2 Dec 1999 14:04:44 +0000 Subject: Implemented `show route where ' command. Pavel, please check my addition to filter/config.Y. --- TODO | 1 - filter/config.Y | 28 ++++++++++++++++++++++++++-- nest/config.Y | 6 ++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index e80d1b3..34dd1dc 100644 --- a/TODO +++ b/TODO @@ -50,7 +50,6 @@ shutdown # order system shutdown configure [] debug # dump debugging information to log show # show everything you know about symbol - route [] [table ] [filter ( | { })] [where ] [all] <-- WHERE rip ??? [] ospf ??? [] static ??? [] diff --git a/filter/config.Y b/filter/config.Y index 05a0f2d..5369468 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -34,13 +34,13 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, CONST, UNSET, LEN, DEFINED, IMPOSSIBLE, - FILTER) + FILTER, WHERE) %nonassoc THEN %nonassoc ELSE %type term block cmds cmd function_body constant print_one print_list var_list var_listn any_dynamic -%type filter filter_body +%type filter filter_body where_filter %type type break_command pair %type set_item set_items switch_body %type set_atom prefix prefix_s ipa @@ -124,6 +124,30 @@ filter: | filter_body ; +where_filter: + WHERE term { + /* Construct 'IF term THEN ACCEPT; REJECT;' */ + struct filter *f = cfg_alloc(sizeof(struct filter)); + struct f_inst *i, *acc, *rej; + acc = f_new_inst(); /* ACCEPT */ + acc->code = 'p,'; + acc->a1.p = NULL; + acc->a2.i = F_ACCEPT; + rej = f_new_inst(); /* REJECT */ + rej->code = 'p,'; + rej->a1.p = NULL; + rej->a2.i = F_REJECT; + i = f_new_inst(); /* IF */ + i->code = '?'; + i->a1.p = $2; + i->a2.p = acc; + i->next = rej; + f->name = NULL; + f->root = i; + $$ = f; + } + ; + function_params: '(' declsn ')' { printf( "Have function parameters\n" ); $$=$2; } | '(' ')' { $$=NULL; } diff --git a/nest/config.Y b/nest/config.Y index 89177a7..01d34fa 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -237,8 +237,14 @@ r_args: } | r_args FILTER filter { $$ = $1; + if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice"); $$->filter = $3; } + | r_args where_filter { + $$ = $1; + if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice"); + $$->filter = $2; + } | r_args ALL { $$ = $1; $$->verbose = 1; -- cgit v1.2.3