diff options
author | Pavel Tvrdik <pawel.tvrdik@gmail.com> | 2016-06-29 12:08:28 +0200 |
---|---|---|
committer | Jan Moskyto Matejka <mq@ucw.cz> | 2016-12-07 09:35:24 +0100 |
commit | 69ae5784509d51ee928c99b8b066f68a166bfe18 (patch) | |
tree | 21a0187736347359839f929305414cf6a0fad2b0 /filter | |
parent | f6e8e141df63cd86e344ca659637f23d638d47a2 (diff) |
Add `.asn' operator to all ROA prefixes in filters
Example:
bird> eval (1.2.0.0/16 max 20 as 1234).asn
1234
Todo: Should be described in user docs
Diffstat (limited to 'filter')
-rw-r--r-- | filter/config.Y | 3 | ||||
-rw-r--r-- | filter/filter.c | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/filter/config.Y b/filter/config.Y index 3e70a63e..6783ea10 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -278,7 +278,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN, TRUE, FALSE, RT, RO, UNKNOWN, GENERIC, FROM, GW, NET, MASK, PROTO, SOURCE, SCOPE, CAST, DEST, IFNAME, IFINDEX, PREFERENCE, - ROA_CHECK, + ROA_CHECK, ASN, LEN, DEFINED, ADD, DELETE, CONTAINS, RESET, @@ -740,6 +740,7 @@ term: | term '.' IP { $$ = f_new_inst(); $$->code = P('c','p'); $$->a1.p = $1; $$->aux = T_IP; } | term '.' LEN { $$ = f_new_inst(); $$->code = 'L'; $$->a1.p = $1; } + | term '.' ASN { $$ = f_new_inst(); $$->code = P('R','a'); $$->a1.p = $1; } | term '.' MASK '(' term ')' { $$ = f_new_inst(); $$->code = P('i','M'); $$->a1.p = $1; $$->a2.p = $5; } | term '.' FIRST { $$ = f_new_inst(); $$->code = P('a','f'); $$->a1.p = $1; } | term '.' LAST { $$ = f_new_inst(); $$->code = P('a','l'); $$->a1.p = $1; } diff --git a/filter/filter.c b/filter/filter.c index 47c5e63d..ba1ba753 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -1029,6 +1029,16 @@ interpret(struct f_inst *what) default: runtime( "Prefix, path, clist or eclist expected" ); } break; + case P('R','a'): /* Get ROA ASN */ + ONEARG; + if (v1.type != T_NET || !net_is_roa(v1.val.net)) + runtime( "ROA expected" ); + + res.type = T_INT; + res.val.i = (v1.val.net->type == NET_ROA4) ? + ((net_addr_roa4 *) v1.val.net)->asn : + ((net_addr_roa6 *) v1.val.net)->asn; + break; case P('c','p'): /* Convert prefix to ... */ ONEARG; if (v1.type != T_NET) |