diff options
Diffstat (limited to 'nest/a-path.c')
-rw-r--r-- | nest/a-path.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/nest/a-path.c b/nest/a-path.c index 0ea3e7b2..0c467551 100644 --- a/nest/a-path.c +++ b/nest/a-path.c @@ -103,6 +103,34 @@ as_path_getlen(struct adata *path) return res; } +int +as_path_get_first(struct adata *path) +{ + int res = -1; + u8 *p = path->data; + u8 *q = p+path->length; + int len; + + while (p<q) + { + switch (*p++) + { + case AS_PATH_SET: + if (len = *p++) + res = get_u16(p); + p += 2*len; + break; + case AS_PATH_SEQUENCE: + if (len = *p++) + res = get_u16(p+2*(len-1)); + p += 2*len; + break; + default: bug("as_path_get_first: Invalid path segment"); + } + } + return res; +} + #define MASK_PLUS do { mask = mask->next; if (!mask) return next == q; \ asterisk = (mask->val == PM_ANY); \ if (asterisk) { mask = mask->next; if (!mask) { return 1; } } \ |