]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP_PATH masks now actually work as data type.
authorPavel Machek <pavel@ucw.cz>
Wed, 12 Apr 2000 12:10:37 +0000 (12:10 +0000)
committerPavel Machek <pavel@ucw.cz>
Wed, 12 Apr 2000 12:10:37 +0000 (12:10 +0000)
filter/config.Y
filter/filter.c
filter/filter.h
filter/test.conf

index e17245dfc4b4163293b71c8e3171bca15ad88d0c..b0562974bf689a73cb1136d5aa1b70aea1692eff 100644 (file)
@@ -24,7 +24,7 @@ mnozina cisel ASu. Na cestach nadefinuji nasledujici operace:
 
 Filtry by mely podporovat:
 
-        - operator pridani AS k ceste [bgp_path_prepend]
+        - operator pridani AS k ceste [bgppath_prepend]
         - matchovani na pritomnost podposloupnosti v ceste (pricemz vyskytne-li
           se tam mnozina, tak si ji lze predstavit prerovnanou v libovolnem
           poradi)
@@ -65,7 +65,7 @@ CF_DECLS
 
 CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
        ACCEPT, REJECT, ERROR, QUITBIRD,
-       INT, BOOL, IP, PREFIX, PAIR, SET, STRING,
+       INT, BOOL, IP, PREFIX, PAIR, SET, STRING, BGP_PATH,
        IF, THEN, ELSE, CASE,
        TRUE, FALSE,
        FROM, GW, NET, MASK, SOURCE,
@@ -84,6 +84,8 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
 %type <e> set_item set_items switch_body
 %type <v> set_atom prefix prefix_s ipa
 %type <s> decls declsn one_decl function_params 
+%type <h> bgp_path
+%type <i> bgp_one
 
 CF_GRAMMAR
 
@@ -104,6 +106,7 @@ type:
  | PREFIX { $$ = T_PREFIX; }
  | PAIR { $$ = T_PAIR; }
  | STRING { $$ = T_STRING; }
+ | BGP_PATH { $$ = T_PATH; }
  | type SET { 
        switch ($1) {
          default:
@@ -305,6 +308,15 @@ switch_body: /* EMPTY */ { $$ = NULL; }
 
 /* CONST '(' expr ')' { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_INT; $$->a2.i = $3; } */
 
+bgp_one:
+   NUM { $$ = $1; }
+ ;
+
+bgp_path: 
+   bgp_one          { $$ = cfg_alloc(sizeof(struct f_path)); $$->next = NULL; $$->val  = $1; }
+ | bgp_one bgp_path { $$ = cfg_alloc(sizeof(struct f_path)); $$->next = $2;   $$->val  = $1; }
+ ;
+
 constant:
    NUM    { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_INT;  $$->a2.i = $1; }
  | TRUE   { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_BOOL; $$->a2.i = 1;  }
@@ -315,6 +327,7 @@ constant:
  | prefix_s {NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
  | '[' set_items ']' { DBG( "We've got a set here..." ); $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_SET; $$->a2.p = build_tree($2); DBG( "ook\n" ); }
  | ENUM          { $$ = f_new_inst(); $$->code = 'c'; $$->aux = $1 >> 16; $$->a2.i = $1 & 0xffff; }
+ | '/' bgp_path '/' { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_PATH; $$->a2.p = $2; }
  ;
 
 /*
@@ -371,6 +384,7 @@ term:
        case SYM_VARIABLE | T_PAIR:
        case SYM_VARIABLE | T_PREFIX:
        case SYM_VARIABLE | T_IP:
+       case SYM_VARIABLE | T_PATH:
         $$->code = 'C';
         $$->a1.p = $1->aux2;
         break;
@@ -401,7 +415,6 @@ term:
 /* Paths */
  | term '.' APPEND '(' term ')' { }
 /* | term '.' LEN { }  Hmm, this would colide with ip.len. What to do with that? */
- | term '.' MATCH '(' term ')' { }
 
 /* function_call is inlined here */
  | SYM '(' var_list ')' {
index f3f8c2379e611f653669464980ae5c433f29aebe..9788edb65f25bd2d8851be52d4462c1617e5e9f6 100644 (file)
@@ -133,6 +133,7 @@ val_print(struct f_val v)
   case T_PAIR: PRINTF( "(%d,%d)", v.val.i >> 16, v.val.i & 0xffff ); break;
   case T_SET: tree_print( v.val.t ); PRINTF( "\n" ); break;
   case T_ENUM: PRINTF( "(enum %x)%d", v.type, v.val.i ); break;
+  case T_PATH: debug( "(path " ); { struct f_path *p = v.val.s; while (p) { debug("%d ", p->val); p=p->next; } debug(")" ); } break;
   default: PRINTF( "[unknown type %x]", v.type );
 #undef PRINTF
   }
@@ -248,6 +249,7 @@ interpret(struct f_inst *what)
     case T_IP: 
     case T_PREFIX: 
     case T_PAIR: 
+    case T_PATH:
       if (sym->class != (SYM_VARIABLE | v2.type))
        runtime( "Variable of bad type" );
       * (struct f_val *) sym->aux2 = v2; 
index a6868f976f892280aa10187ddb4969d5716989f2..ecfd88d708edc6752c5acaaf2835428ae1207fb0 100644 (file)
@@ -50,6 +50,11 @@ struct f_val {
   } val;
 };
 
+struct f_path {
+  struct f_path *next;
+  int val;
+};
+
 struct filter {
   char *name;
   struct f_inst *root;
@@ -110,6 +115,7 @@ void val_print(struct f_val v);
 #define T_IP 0x20
 #define T_PREFIX 0x21
 #define T_STRING 0x22
+#define T_PATH 0x23    /* BGP path */
 
 #define T_RETURN 0x40
 #define T_SET 0x80
index 1677cd2fb93185a1ae8c5b1e5887dc61172227f5..cc62cd17c07e8171bf1ce38b23aeac73385e3918 100644 (file)
@@ -29,6 +29,14 @@ function fifteen()
        return 15;
 }
 
+function paths()
+bgp_path p;
+{
+       print "Testing paths";
+       p = / 1 2 3 4 /;
+       print p;
+}
+
 function startup() 
 int i;
 prefix px;
@@ -73,6 +81,8 @@ ip p;
        i = fifteen();
        print "Testing function calls: 15 = ", i;
 
+       paths();
+
        print "done";
        quitbird;
 #      print "*** FAIL: this is unreachable";