diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2013-07-09 23:27:10 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2013-07-09 23:27:10 +0200 |
commit | cc31b75a8fd7949533c12db2c3e9d67eeaf46d10 (patch) | |
tree | 33ce8dbfd3279b121cd70cca13b315d9ecc07a57 /nest | |
parent | c01a94663cc18f53fd741c5d44387eead9ca88af (diff) |
Implements 'bgppath ~ int set' filter op.
Diffstat (limited to 'nest')
-rw-r--r-- | nest/a-path.c | 23 | ||||
-rw-r--r-- | nest/attrs.h | 3 |
2 files changed, 26 insertions, 0 deletions
diff --git a/nest/a-path.c b/nest/a-path.c index 63ac402e..712e77a3 100644 --- a/nest/a-path.c +++ b/nest/a-path.c @@ -264,6 +264,29 @@ as_path_is_member(struct adata *path, u32 as) return 0; } +int +as_path_match_set(struct adata *path, struct f_tree *set) +{ + u8 *p = path->data; + u8 *q = p+path->length; + int i, n; + + while (p<q) + { + n = p[1]; + p += 2; + for (i=0; i<n; i++) + { + struct f_val v = {T_INT, .val.i = get_as(p)}; + if (find_tree(set, v)) + return 1; + p += BS; + } + } + + return 0; +} + struct pm_pos { diff --git a/nest/attrs.h b/nest/attrs.h index 42f81a10..12f2fcf4 100644 --- a/nest/attrs.h +++ b/nest/attrs.h @@ -25,6 +25,8 @@ * to 16bit slot (like in 16bit AS_PATH). See RFC 4893 for details */ +struct f_tree; + struct adata *as_path_prepend(struct linpool *pool, struct adata *olda, u32 as); int as_path_convert_to_old(struct adata *path, byte *dst, int *new_used); int as_path_convert_to_new(struct adata *path, byte *dst, int req_as); @@ -34,6 +36,7 @@ int as_path_getlen_int(struct adata *path, int bs); int as_path_get_first(struct adata *path, u32 *orig_as); int as_path_get_last(struct adata *path, u32 *last_as); int as_path_is_member(struct adata *path, u32 as); +int as_path_match_set(struct adata *path, struct f_tree *set); #define PM_ASN 0 #define PM_QUESTION 1 |