]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Implemented `show route where <condition>' command.
authorMartin Mares <mj@ucw.cz>
Thu, 2 Dec 1999 14:04:44 +0000 (14:04 +0000)
committerMartin Mares <mj@ucw.cz>
Thu, 2 Dec 1999 14:04:44 +0000 (14:04 +0000)
Pavel, please check my addition to filter/config.Y.

TODO
filter/config.Y
nest/config.Y

diff --git a/TODO b/TODO
index e80d1b3076147d2feff6860dfad9e74aca8541fc..34dd1dc1749458ea3fa8df840e1af93b87d8a896 100644 (file)
--- a/TODO
+++ b/TODO
@@ -50,7 +50,6 @@ shutdown                      # order system shutdown
 configure [<file>]
 debug  <what>                  # dump debugging information to log
 show   <name>                  # show everything you know about symbol <name>
-       route [<route>] [table <name>] [filter (<name> | { <inline> })] [where <condition>] [all]   <-- WHERE
        rip ??? [<name>]
        ospf ??? [<name>]
        static ??? [<name>]
index 05a0f2d2de6291d29a5283445655d5013fabb807..5369468cd235245dfdcfdc097ec8d5dc6cb8755b 100644 (file)
@@ -34,13 +34,13 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, CONST, UNSET,
        LEN,
        DEFINED,
        IMPOSSIBLE,
-       FILTER)
+       FILTER, WHERE)
 
 %nonassoc THEN
 %nonassoc ELSE
 
 %type <x> term block cmds cmd function_body constant print_one print_list var_list var_listn any_dynamic
-%type <f> filter filter_body
+%type <f> filter filter_body where_filter
 %type <i> type break_command pair
 %type <e> set_item set_items switch_body
 %type <v> 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; }
index 89177a7a745be462afe4ed9951d07f13024bd88a..01d34fa9668848319d78e78942e553aacd23e5f2 100644 (file)
@@ -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;