summaryrefslogtreecommitdiff
path: root/nest/a-path.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2016-02-16 17:33:58 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2016-02-16 17:33:58 +0100
commit9c9cc35c0273f8bcae10fb8b546d199514b2bbc5 (patch)
tree060b7ebe4012294ee4468a47cb4e73e3f6b1f0c1 /nest/a-path.c
parentc2106b674ca632f7c0bffd7cab4b1940f74d353c (diff)
Filter: Implement last_nonaggregated operator on bgp_path
Diffstat (limited to 'nest/a-path.c')
-rw-r--r--nest/a-path.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/nest/a-path.c b/nest/a-path.c
index c9c5aefb..32e2d27e 100644
--- a/nest/a-path.c
+++ b/nest/a-path.c
@@ -220,7 +220,7 @@ as_path_get_last(struct adata *path, u32 *orig_as)
p += BS * len;
}
break;
- default: bug("as_path_get_first: Invalid path segment");
+ default: bug("Invalid path segment");
}
}
@@ -229,6 +229,35 @@ as_path_get_last(struct adata *path, u32 *orig_as)
return found;
}
+u32
+as_path_get_last_nonaggregated(struct adata *path)
+{
+ u8 *p = path->data;
+ u8 *q = p+path->length;
+ u32 res = 0;
+ int len;
+
+ while (p<q)
+ {
+ switch (*p++)
+ {
+ case AS_PATH_SET:
+ return res;
+
+ case AS_PATH_SEQUENCE:
+ if (len = *p++)
+ res = get_as(p + BS * (len - 1));
+ p += BS * len;
+ break;
+
+ default: bug("Invalid path segment");
+ }
+ }
+
+ return res;
+}
+
+
int
as_path_get_first(struct adata *path, u32 *last_as)
{