summaryrefslogtreecommitdiffstats
path: root/filter/filter.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2008-11-14 14:50:37 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2008-11-14 14:50:37 +0100
commite29fa06ece1bf9f9a47f224db797df940556136e (patch)
tree10775979f654be43a67c072e225879d3f42973d9 /filter/filter.c
parentaebe06b40ce730a88cc8a3121be1944b3ddf5765 (diff)
downloadbird-e29fa06ece1bf9f9a47f224db797df940556136e.tar
bird-e29fa06ece1bf9f9a47f224db797df940556136e.zip
New read-only route attribute 'proto' added. It returns a string
representing a name of the protocol that originated the route. Strings can be compared using = or matched using ~. Routes can be filtered, for example: show route where proto ~ "bgp1*"
Diffstat (limited to 'filter/filter.c')
-rw-r--r--filter/filter.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/filter/filter.c b/filter/filter.c
index 6f85c06..bdc6f08 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -137,6 +137,8 @@ val_compare(struct f_val v1, struct f_val v2)
return 0;
case T_PATH_MASK:
return pm_path_compare(v1.val.path_mask, v2.val.path_mask);
+ case T_STRING:
+ return strcmp(v1.val.s, v2.val.s);
default:
debug( "Compare of unkown entities: %x\n", v1.type );
return CMP_ERROR;
@@ -153,6 +155,8 @@ val_simple_in_range(struct f_val v1, struct f_val v2)
return as_path_match(v1.val.ad, v2.val.path_mask);
if ((v1.type == T_PAIR) && (v2.type == T_CLIST))
return int_set_contains(v2.val.ad, v1.val.i);
+ if ((v1.type == T_STRING) && (v2.type == T_STRING))
+ return patmatch(v2.val.s, v1.val.s);
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))));
@@ -497,6 +501,9 @@ interpret(struct f_inst *what)
case T_ENUM:
res.val.i = * ((char *) rta + what->a2.i);
break;
+ case T_STRING: /* Warning: this is a special case for proto attribute */
+ res.val.s = rta->proto->name;
+ break;
case T_PREFIX: /* Warning: this works only for prefix of network */
{
res.val.px.ip = (*f_rte)->net->n.prefix;