diff options
author | Martin Mares <mj@ucw.cz> | 2000-04-17 07:53:29 +0000 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2000-04-17 07:53:29 +0000 |
commit | c0668f36967ce651e452a476b786b7604038a556 (patch) | |
tree | 37ce9ac274e1badc32f0e7badc4d6e8dd2e78213 /nest | |
parent | ebff007f08965d83dba5840ee02171d09ac2598d (diff) |
Created nest/a-path.c and a-set.c which should contain general operations
on AS paths and community sets.
Moved as_path_prepend() there.
Pavel, please move the other functions as well.
Diffstat (limited to 'nest')
-rw-r--r-- | nest/Makefile | 3 | ||||
-rw-r--r-- | nest/a-path.c | 38 | ||||
-rw-r--r-- | nest/a-set.c | 12 | ||||
-rw-r--r-- | nest/attrs.h | 16 |
4 files changed, 68 insertions, 1 deletions
diff --git a/nest/Makefile b/nest/Makefile index 69afae1d..478a82b7 100644 --- a/nest/Makefile +++ b/nest/Makefile @@ -1,4 +1,5 @@ -source=rt-table.c rt-fib.c rt-attr.c proto.c iface.c rt-dev.c password.c cli.c locks.c cmds.c neighbor.c +source=rt-table.c rt-fib.c rt-attr.c proto.c iface.c rt-dev.c password.c cli.c locks.c cmds.c neighbor.c \ + a-path.c a-set.c root-rel=../ dir-name=nest diff --git a/nest/a-path.c b/nest/a-path.c new file mode 100644 index 00000000..557f29c2 --- /dev/null +++ b/nest/a-path.c @@ -0,0 +1,38 @@ +/* + * BIRD -- Path Operations + * + * (c) 2000 Martin Mares <mj@ucw.cz> + * (c) 2000 Pavel Machek <pavel@ucw.cz> + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#include "nest/bird.h" +#include "nest/route.h" +#include "lib/resource.h" +#include "lib/unaligned.h" + +struct adata * +as_path_prepend(struct linpool *pool, struct adata *olda, int as) +{ + struct adata *newa; + + if (olda->length && olda->data[0] == 2 && olda->data[1] < 255) /* Starting with sequence => just prepend the AS number */ + { + newa = lp_alloc(pool, sizeof(struct adata) + olda->length + 2); + newa->length = olda->length + 2; + newa->data[0] = 2; + newa->data[1] = olda->data[1] + 1; + memcpy(newa->data+4, olda->data+2, olda->length-2); + } + else /* Create new path segment */ + { + newa = lp_alloc(pool, sizeof(struct adata) + olda->length + 4); + newa->length = olda->length + 4; + newa->data[0] = 2; + newa->data[1] = 1; + memcpy(newa->data+4, olda->data, olda->length); + } + put_u16(newa->data+2, as); + return newa; +} diff --git a/nest/a-set.c b/nest/a-set.c new file mode 100644 index 00000000..7c7d6894 --- /dev/null +++ b/nest/a-set.c @@ -0,0 +1,12 @@ +/* + * BIRD -- Set/Community-list Operations + * + * (c) 2000 Martin Mares <mj@ucw.cz> + * (c) 2000 Pavel Machek <pavel@ucw.cz> + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#include "nest/bird.h" +#include "nest/route.h" +#include "lib/resource.h" diff --git a/nest/attrs.h b/nest/attrs.h new file mode 100644 index 00000000..c1a96f95 --- /dev/null +++ b/nest/attrs.h @@ -0,0 +1,16 @@ +/* + * BIRD Internet Routing Daemon -- Attribute Operations + * + * (c) 2000 Martin Mares <mj@ucw.cz> + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#ifndef _BIRD_ATTRS_H_ +#define _BIRD_ATTRS_H_ + +/* a-path.c */ + +struct adata *as_path_prepend(struct linpool *pool, struct adata *olda, int as); + +#endif |