summaryrefslogtreecommitdiffstats
path: root/nest/rt-attr.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/rt-attr.c
parentafc54517db6946e9cfb62bbdc855954316152c62 (diff)
downloadbird-c6add07fa6ca8366fbdcfcd9bc2872c129378366.tar
bird-c6add07fa6ca8366fbdcfcd9bc2872c129378366.zip
Printing of AS paths and community sets.
Diffstat (limited to 'nest/rt-attr.c')
-rw-r--r--nest/rt-attr.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/nest/rt-attr.c b/nest/rt-attr.c
index 97cd70b..c16d08b 100644
--- a/nest/rt-attr.c
+++ b/nest/rt-attr.c
@@ -13,6 +13,7 @@
#include "nest/protocol.h"
#include "nest/iface.h"
#include "nest/cli.h"
+#include "nest/attrs.h"
#include "lib/resource.h"
#include "lib/string.h"
@@ -240,8 +241,9 @@ ea_format(eattr *e, byte *buf)
{
struct protocol *p;
int status = GA_UNKNOWN;
- unsigned int i, l;
+ unsigned int i;
struct adata *ad = (e->type & EAF_EMBEDDED) ? NULL : e->u.ptr;
+ byte *end = buf + EA_FORMAT_BUF_SIZE - 1;
if (p = attr_class_to_protocol[EA_PROTO(e->id)])
{
@@ -264,15 +266,17 @@ ea_format(eattr *e, byte *buf)
bsprintf(buf, "%d", e->u.data);
break;
case EAF_TYPE_OPAQUE:
- l = (ad->length < 16) ? ad->length : 16;
- for(i=0; i<l; i++)
+ for(i=0; i<ad->length; i++)
{
- buf += bsprintf(buf, "%02x", ad->data[i]);
- if (i < l)
+ if (buf > end - 8)
+ {
+ strcpy(buf, " ...");
+ break;
+ }
+ if (i)
*buf++ = ' ';
+ buf += bsprintf(buf, "%02x", ad->data[i]);
}
- if (l < ad->length)
- strcpy(buf, "...");
break;
case EAF_TYPE_IP_ADDRESS:
bsprintf(buf, "%I", *(ip_addr *) ad->data);
@@ -280,8 +284,12 @@ ea_format(eattr *e, byte *buf)
case EAF_TYPE_ROUTER_ID:
bsprintf(buf, "%08x", e->u.data); /* FIXME: Better printing of router ID's */
break;
- case EAF_TYPE_AS_PATH: /* FIXME */
- case EAF_TYPE_INT_SET: /* FIXME */
+ case EAF_TYPE_AS_PATH:
+ as_path_format(ad, buf, end - buf);
+ break;
+ case EAF_TYPE_INT_SET:
+ int_set_format(ad, buf, end - buf);
+ break;
case EAF_TYPE_UNDEF:
default:
bsprintf(buf, "<type %02x>", e->type);
@@ -542,7 +550,7 @@ rta_show(struct cli *c, rta *a)
static char *cast_names[] = { "unicast", "broadcast", "multicast", "anycast" };
ea_list *eal;
int i;
- byte buf[256];
+ byte buf[EA_FORMAT_BUF_SIZE];
cli_printf(c, -1008, "\tType: %s %s %s", src_names[a->source], cast_names[a->cast], ip_scope_text(a->scope));
for(eal=a->eattrs; eal; eal=eal->next)