diff options
author | Pavel Machek <pavel@ucw.cz> | 2000-04-17 13:06:39 +0200 |
---|---|---|
committer | Pavel Machek <pavel@ucw.cz> | 2000-04-17 13:06:39 +0200 |
commit | 684c6f5a0e134426159be7dbd514271aea9f4d3d (patch) | |
tree | 0e5acd2b882f7e05365d6e50a3a6fcc2f41ed974 /nest | |
parent | ecd25633bdc3e491a0eca44c63c158eeff388f13 (diff) | |
download | bird-684c6f5a0e134426159be7dbd514271aea9f4d3d.tar bird-684c6f5a0e134426159be7dbd514271aea9f4d3d.zip |
Path_getlen moved to nest and length was made callable from filters.
Diffstat (limited to 'nest')
-rw-r--r-- | nest/a-path.c | 18 | ||||
-rw-r--r-- | nest/attrs.h | 7 |
2 files changed, 22 insertions, 3 deletions
diff --git a/nest/a-path.c b/nest/a-path.c index ca39e29..d808bc9 100644 --- a/nest/a-path.c +++ b/nest/a-path.c @@ -81,3 +81,21 @@ as_path_format(struct adata *path, byte *buf, unsigned int size) } *buf = 0; } + +int +as_path_getlen(struct adata *path) +{ + int res = 0; + u8 *p = path->data; + u8 *q = p+path->length; + int len; + + while (p<q) { + switch (*p++) { + case 1: len = *p++; res++; p += 2*len; break; + case 2: len = *p++; res+=len; p += 2*len; break; + default: bug("This should not be in path"); + } + } + return res; +} diff --git a/nest/attrs.h b/nest/attrs.h index fc960fb..67ec52d 100644 --- a/nest/attrs.h +++ b/nest/attrs.h @@ -11,12 +11,13 @@ /* a-path.c */ -struct adata *as_path_prepend(struct linpool *pool, struct adata *olda, int as); -void as_path_format(struct adata *path, byte *buf, unsigned int size); - #define AS_PATH_SET 1 /* Types of path segments */ #define AS_PATH_SEQUENCE 2 +struct adata *as_path_prepend(struct linpool *pool, struct adata *olda, int as); +void as_path_format(struct adata *path, byte *buf, unsigned int size); +int as_path_getlen(struct adata *path); + /* a-set.c */ void int_set_format(struct adata *set, byte *buf, unsigned int size); |