From 7ea5b00f42bd3d1fdafb0be349e3ebbcdf3ea466 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 8 Oct 2009 15:23:24 +0100 Subject: First and last accessors to as_paths. --- filter/filter.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'filter/filter.c') diff --git a/filter/filter.c b/filter/filter.c index 8c0c4ab..7bcf383 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -353,6 +353,7 @@ interpret(struct f_inst *what) struct f_val v1, v2, res; unsigned u1, u2; int i; + u32 as; res.type = T_VOID; if (!what) @@ -727,6 +728,26 @@ interpret(struct f_inst *what) default: bug( "Unknown prefix to conversion" ); } break; + case P('a','f'): /* Get first ASN from AS PATH */ + ONEARG; + if (v1.type != T_PATH) + runtime( "AS Path expected" ); + + as = 0; + as_path_get_last(v1.val.ad, &as); /* really last */ + res.type = T_INT; + res.val.i = as; + break; + case P('a','l'): /* Get last ASN from AS PATH */ + ONEARG; + if (v1.type != T_PATH) + runtime( "AS path expected" ); + + as = 0; + as_path_get_first(v1.val.ad, &as); /* really first */ + res.type = T_INT; + res.val.i = as; + break; case 'r': ONEARG; res = v1; -- cgit v1.2.3