summaryrefslogtreecommitdiffstats
path: root/filter/filter.c
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2000-04-12 15:31:39 +0200
committerPavel Machek <pavel@ucw.cz>2000-04-12 15:31:39 +0200
commit10a53608860724c47596948f2fd426d4eca8224d (patch)
treeac3bfd9e753e16d0ae61de59adfbf9745276b749 /filter/filter.c
parent775063494694d247b340bb1145e509e31af27802 (diff)
downloadbird-10a53608860724c47596948f2fd426d4eca8224d.tar
bird-10a53608860724c47596948f2fd426d4eca8224d.zip
Filters now know type path. It is possible to declare variable of type
path, but it is not possible to write constant of type path. It should be possible to print paths and match them.
Diffstat (limited to 'filter/filter.c')
-rw-r--r--filter/filter.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/filter/filter.c b/filter/filter.c
index 2da2a28..a2d827a 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -60,6 +60,9 @@ val_compare(struct f_val v1, struct f_val v2)
int
val_simple_in_range(struct f_val v1, struct f_val v2)
{
+ if ((v1.type == T_PATH) && (v2.type == T_PATH_MASK))
+ return path_match(&v1.val.ad->data, v1.val.ad->length, v2.val.path_mask);
+
if ((v1.type == T_IP) && (v2.type == T_PREFIX))
return !(ipa_compare(ipa_and(v2.val.px.ip, ipa_mkmask(v2.val.px.len)), ipa_and(v1.val.px.ip, ipa_mkmask(v2.val.px.len))));
@@ -133,6 +136,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: PRINTF( "%s", path_format(&v.val.ad->data, v.val.ad->length)); break;
case T_PATH_MASK: debug( "(path " ); { struct f_path_mask *p = v.val.s; while (p) { debug("%d ", p->val); p=p->next; } debug(")" ); } break;
default: PRINTF( "[unknown type %x]", v.type );
#undef PRINTF
@@ -341,11 +345,14 @@ interpret(struct f_inst *what)
res.type = T_VOID;
break;
}
- res.type = what->aux;
+ res.type = what->aux; /* FIXME: should check type? */
switch (what->a1.i) {
case T_INT:
res.val.i = e->u.data;
break;
+ case T_PATH:
+ res.val.ad = e->u.ptr;
+ break;
}
}
break;
@@ -369,6 +376,11 @@ interpret(struct f_inst *what)
runtime( "Setting int attribute to non-int value" );
l->attrs[0].u.data = v1.val.i;
break;
+ case EAF_TYPE_AS_PATH:
+ if (v1.type != T_PATH)
+ runtime( "Setting path attribute to non-path value" );
+ l->attrs[0].u.ptr = v1.val.ad;
+ break;
case EAF_TYPE_UNDEF:
if (v1.type != T_VOID)
runtime( "Setting void attribute to non-void value" );