summaryrefslogtreecommitdiffstats
path: root/filter
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>1999-11-18 14:21:52 +0100
committerPavel Machek <pavel@ucw.cz>1999-11-18 14:21:52 +0100
commit346a12c2109b99d907e7ebeb3560992e92a6c26b (patch)
treece2fcca13ca95999ef3fe94e1b61a20c1b627d71 /filter
parent4364b47e48ddedb841e8ec8db25c8b4fa878a911 (diff)
downloadbird-346a12c2109b99d907e7ebeb3560992e92a6c26b.tar
bird-346a12c2109b99d907e7ebeb3560992e92a6c26b.zip
You can now print enum.
Diffstat (limited to 'filter')
-rw-r--r--filter/config.Y18
-rw-r--r--filter/filter.c1
-rw-r--r--filter/test.conf5
3 files changed, 10 insertions, 14 deletions
diff --git a/filter/config.Y b/filter/config.Y
index 5d84b92..540a85d 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -9,6 +9,8 @@
FIXME: whole system of paths, path ~ string, path.prepend(), path.originate
FIXME: create community lists
FIXME: write access to dynamic attributes.
+ FIXME: '! =' should not be permitted. Ze `!=' by nemelo byt totez jako `! =' Nadefinujes si pres %token novy token a do cf-lex.l pridas nove pravidlo, ktere jej rozpoznava. Napriklad != return NEQ;
+
*/
CF_HDR
@@ -29,7 +31,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, CONST,
INT, BOOL, IP, PREFIX, PAIR, SET, STRING,
IF, THEN, ELSE, CASE,
TRUE, FALSE,
- RTA, FROM, GW, NET, MASK, RIP_METRIC, RIP_TAG,
+ RTA, FROM, GW, NET, MASK, RIP_METRIC, RIP_TAG, SOURCE,
LEN,
DEFINED,
IMPOSSIBLE,
@@ -261,13 +263,6 @@ term:
| SYM {
$$ = f_new_inst();
switch ($1->class) {
- case 0: /* This should better be an enum */
- $$->code = 'c';
- $$->a1.i = $1->aux;
- if (($$->a1.i < T_ENUM_LO) || ($$->a1.i > T_ENUM_HI))
- cf_error("You used symbol and it was not enum.\n");
- $$->a2.i = (int) $1->aux2;
- break;
case SYM_VARIABLE | T_INT:
case SYM_VARIABLE | T_PAIR:
case SYM_VARIABLE | T_PREFIX:
@@ -280,10 +275,11 @@ term:
}
}
- | RTA '.' FROM { $$ = f_new_inst(); $$->code = 'a'; $$->a1.i = T_IP; $$->a2.i = OFFSETOF(struct rta, from); }
+ | RTA '.' FROM { $$ = f_new_inst(); $$->code = 'a'; $$->a1.i = T_IP; $$->a2.i = OFFSETOF(struct rta, from); }
- | RTA '.' GW { $$ = f_new_inst(); $$->code = 'a'; $$->a1.i = T_IP; $$->a2.i = OFFSETOF(struct rta, gw); }
- | RTA '.' NET { $$ = f_new_inst(); $$->code = 'a'; $$->a1.i = T_PREFIX; $$->a2.i = 0x12345678; }
+ | RTA '.' GW { $$ = f_new_inst(); $$->code = 'a'; $$->a1.i = T_IP; $$->a2.i = OFFSETOF(struct rta, gw); }
+ | RTA '.' NET { $$ = f_new_inst(); $$->code = 'a'; $$->a1.i = T_PREFIX; $$->a2.i = 0x12345678; }
+ | RTA '.' SOURCE { $$ = f_new_inst(); $$->code = 'a'; $$->a1.i = T_ENUM_RTS; $$->a2.i = OFFSETOF(struct rta, gw); }
| RTA '.' any_dynamic { $$ = $3; $$->code = 'ea'; }
diff --git a/filter/filter.c b/filter/filter.c
index 0dc4b21..a26b9e6 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -152,6 +152,7 @@ val_print(struct f_val v)
case T_PREFIX: PRINTF( "%I/%d", v.val.px.ip, v.val.px.len ); break;
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;
default: PRINTF( "[unknown type %x]", v.type );
}
printf( buf );
diff --git a/filter/test.conf b/filter/test.conf
index 6f102a8..97aaf8f 100644
--- a/filter/test.conf
+++ b/filter/test.conf
@@ -13,8 +13,7 @@ int local1;
int local2;
int i;
{
- print "Ok";
- print "Function callme called arguments " arg1 " and " arg2;
+ printn "Function callme called arguments " arg1 " and " arg2 ":";
i = arg2;
case arg1 {
@@ -47,7 +46,7 @@ ip p;
p = 127.1.2.3;
print "Testing mask : 127.0.0.0 = " p.mask(8);
print "Testing pairs: (1,2) = " (1,2);
-#
+ print "Testing enums: " RTS_DUMMY " " RTS_STATIC;
print "What will this do? " [ 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 5 ];