summaryrefslogtreecommitdiffstats
path: root/nest/a-path.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-04-17 12:18:55 +0200
committerMartin Mares <mj@ucw.cz>2000-04-17 12:18:55 +0200
commitc6add07fa6ca8366fbdcfcd9bc2872c129378366 (patch)
tree326030c1a1798b35c68ef11428461dd7a60e02cd /nest/a-path.c
parentafc54517db6946e9cfb62bbdc855954316152c62 (diff)
downloadbird-c6add07fa6ca8366fbdcfcd9bc2872c129378366.tar
bird-c6add07fa6ca8366fbdcfcd9bc2872c129378366.zip
Printing of AS paths and community sets.
Diffstat (limited to 'nest/a-path.c')
-rw-r--r--nest/a-path.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/nest/a-path.c b/nest/a-path.c
index 557f29c..ca39e29 100644
--- a/nest/a-path.c
+++ b/nest/a-path.c
@@ -9,8 +9,10 @@
#include "nest/bird.h"
#include "nest/route.h"
+#include "nest/attrs.h"
#include "lib/resource.h"
#include "lib/unaligned.h"
+#include "lib/string.h"
struct adata *
as_path_prepend(struct linpool *pool, struct adata *olda, int as)
@@ -36,3 +38,46 @@ as_path_prepend(struct linpool *pool, struct adata *olda, int as)
put_u16(newa->data+2, as);
return newa;
}
+
+void
+as_path_format(struct adata *path, byte *buf, unsigned int size)
+{
+ byte *p = path->data;
+ byte *e = p + path->length - 8;
+ byte *end = buf + size;
+ int sp = 1;
+ int l, type, isset, as;
+
+ while (p < e)
+ {
+ if (buf > end)
+ {
+ strcpy(buf, " ...");
+ return;
+ }
+ isset = (*p++ == AS_PATH_SET);
+ l = *p++;
+ if (isset)
+ {
+ if (!sp)
+ *buf++ = ' ';
+ *buf++ = '{';
+ sp = 0;
+ }
+ while (l-- && buf <= end)
+ {
+ if (!sp)
+ *buf++ = ' ';
+ buf += bsprintf(buf, "%d", get_u16(p));
+ p += 2;
+ sp = 0;
+ }
+ if (isset)
+ {
+ *buf++ = ' ';
+ *buf++ = '}';
+ sp = 0;
+ }
+ }
+ *buf = 0;
+}