diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2008-11-08 23:33:22 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2008-11-08 23:33:22 +0100 |
commit | aebe06b40ce730a88cc8a3121be1944b3ddf5765 (patch) | |
tree | ad154b3ccaef4c816a8a325db7c5561aaf2d7586 /nest | |
parent | b21f68b4cd4794c84e5f0eb2c34204c87ccf0e9a (diff) |
Proper format functions for ORIGINATOR_ID, CLUSTER_LIST
Diffstat (limited to 'nest')
-rw-r--r-- | nest/a-set.c | 11 | ||||
-rw-r--r-- | nest/attrs.h | 2 | ||||
-rw-r--r-- | nest/proto-hooks.c | 2 | ||||
-rw-r--r-- | nest/protocol.h | 2 | ||||
-rw-r--r-- | nest/rt-attr.c | 4 |
5 files changed, 14 insertions, 7 deletions
diff --git a/nest/a-set.c b/nest/a-set.c index 69c090b7..505c0e51 100644 --- a/nest/a-set.c +++ b/nest/a-set.c @@ -14,7 +14,7 @@ #include "lib/string.h" void -int_set_format(struct adata *set, byte *buf, unsigned int size) +int_set_format(struct adata *set, int way, byte *buf, unsigned int size) { u32 *z = (u32 *) set->data; int l = set->length / 4; @@ -30,7 +30,14 @@ int_set_format(struct adata *set, byte *buf, unsigned int size) strcpy(buf, "..."); return; } - buf += bsprintf(buf, "(%d,%d)", *z >> 16, *z & 0xffff); + + if (way) + buf += bsprintf(buf, "(%d,%d)", *z >> 16, *z & 0xffff); + else + buf += bsprintf(buf, "%d.%d.%d.%d", + (*z >> 24) & 0xff, (*z >> 16) & 0xff, + (*z >> 8) & 0xff, *z & 0xff); + z++; sp = 0; } diff --git a/nest/attrs.h b/nest/attrs.h index fee2c2c8..6f0bc1f5 100644 --- a/nest/attrs.h +++ b/nest/attrs.h @@ -43,7 +43,7 @@ int as_path_match(struct adata *path, struct f_path_mask *mask); /* a-set.c */ -void int_set_format(struct adata *set, byte *buf, unsigned int size); +void int_set_format(struct adata *set, int way, byte *buf, unsigned int size); struct adata *int_set_add(struct linpool *pool, struct adata *list, u32 val); int int_set_contains(struct adata *list, u32 val); struct adata *int_set_del(struct linpool *pool, struct adata *list, u32 val); diff --git a/nest/proto-hooks.c b/nest/proto-hooks.c index 4035fdd7..82df5cb7 100644 --- a/nest/proto-hooks.c +++ b/nest/proto-hooks.c @@ -146,7 +146,7 @@ void get_route_info(rte *e, byte *buf, ea_list *attrs) * or doing the whole conversion (used in case the value requires extra * care; return %GA_FULL). */ -int get_attr(eattr *a, byte *buf) +int get_attr(eattr *a, byte *buf, int buflen) { DUMMY; } /** diff --git a/nest/protocol.h b/nest/protocol.h index 64ea4661..d681ae68 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -48,7 +48,7 @@ struct protocol { int (*shutdown)(struct proto *); /* Stop the instance */ void (*get_status)(struct proto *, byte *buf); /* Get instance status (for `show protocols' command) */ void (*get_route_info)(struct rte *, byte *buf, struct ea_list *attrs); /* Get route information (for `show route' command) */ - int (*get_attr)(struct eattr *, byte *buf); /* ASCIIfy dynamic attribute (returns GA_*) */ + int (*get_attr)(struct eattr *, byte *buf, int buflen); /* ASCIIfy dynamic attribute (returns GA_*) */ }; void protos_build(void); diff --git a/nest/rt-attr.c b/nest/rt-attr.c index cbece881..e79cba1f 100644 --- a/nest/rt-attr.c +++ b/nest/rt-attr.c @@ -386,7 +386,7 @@ ea_format(eattr *e, byte *buf) { buf += bsprintf(buf, "%s.", p->name); if (p->get_attr) - status = p->get_attr(e, buf); + status = p->get_attr(e, buf, end - buf); buf += strlen(buf); } else if (EA_PROTO(e->id)) @@ -429,7 +429,7 @@ ea_format(eattr *e, byte *buf) as_path_format(ad, buf, end - buf); break; case EAF_TYPE_INT_SET: - int_set_format(ad, buf, end - buf); + int_set_format(ad, 1, buf, end - buf); break; case EAF_TYPE_UNDEF: default: |