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 /proto | |
parent | b21f68b4cd4794c84e5f0eb2c34204c87ccf0e9a (diff) | |
download | bird-aebe06b40ce730a88cc8a3121be1944b3ddf5765.tar bird-aebe06b40ce730a88cc8a3121be1944b3ddf5765.zip |
Proper format functions for ORIGINATOR_ID, CLUSTER_LIST
Diffstat (limited to 'proto')
-rw-r--r-- | proto/bgp/attrs.c | 22 | ||||
-rw-r--r-- | proto/bgp/bgp.h | 2 | ||||
-rw-r--r-- | proto/ospf/ospf.c | 2 | ||||
-rw-r--r-- | proto/rip/rip.c | 2 |
4 files changed, 17 insertions, 11 deletions
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index 811d52e..c13f905 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -35,7 +35,7 @@ struct attr_desc { int type; int allow_in_ebgp; int (*validate)(struct bgp_proto *p, byte *attr, int len); - void (*format)(eattr *ea, byte *buf); + void (*format)(eattr *ea, byte *buf, int buflen); }; static int @@ -47,7 +47,7 @@ bgp_check_origin(struct bgp_proto *p UNUSED, byte *a UNUSED, int len) } static void -bgp_format_origin(eattr *a, byte *buf) +bgp_format_origin(eattr *a, byte *buf, int buflen) { static char *bgp_origin_names[] = { "IGP", "EGP", "Incomplete" }; @@ -104,7 +104,7 @@ bgp_check_next_hop(struct bgp_proto *p UNUSED, byte *a, int len) } static int -bgp_check_aggregator(struct bgp_proto *p, UNUSED byte *a, int len) +bgp_check_aggregator(struct bgp_proto *p, byte *a UNUSED, int len) { int exp_len = p->as4_session ? 8 : 6; @@ -112,11 +112,17 @@ bgp_check_aggregator(struct bgp_proto *p, UNUSED byte *a, int len) } static int -bgp_check_cluster_list(struct bgp_proto *p UNUSED, UNUSED byte *a, int len) +bgp_check_cluster_list(struct bgp_proto *p UNUSED, byte *a UNUSED, int len) { return ((len % 4) == 0) ? 0 : 5; } +static void +bgp_format_cluster_list(eattr *a, byte *buf, int buflen UNUSED) +{ + int_set_format(a->u.ptr, 0, buf, buflen); +} + static int bgp_check_reach_nlri(struct bgp_proto *p UNUSED, byte *a UNUSED, int len UNUSED) { @@ -156,10 +162,10 @@ static struct attr_desc bgp_attr_table[] = { bgp_check_aggregator, NULL }, { "community", -1, BAF_OPTIONAL | BAF_TRANSITIVE, EAF_TYPE_INT_SET, 1, /* BA_COMMUNITY */ NULL, NULL }, - { "originator_id", 4, BAF_OPTIONAL, EAF_TYPE_INT, 0, /* BA_ORIGINATOR_ID */ + { "originator_id", 4, BAF_OPTIONAL, EAF_TYPE_ROUTER_ID, 0, /* BA_ORIGINATOR_ID */ NULL, NULL }, { "cluster_list", -1, BAF_OPTIONAL, EAF_TYPE_INT_SET, 0, /* BA_CLUSTER_LIST */ - bgp_check_cluster_list, NULL }, + bgp_check_cluster_list, bgp_format_cluster_list }, { NULL, }, /* BA_DPA */ { NULL, }, /* BA_ADVERTISER */ { NULL, }, /* BA_RCID_PATH */ @@ -1306,7 +1312,7 @@ err: } int -bgp_get_attr(eattr *a, byte *buf) +bgp_get_attr(eattr *a, byte *buf, int buflen) { unsigned int i = EA_ID(a->id); struct attr_desc *d; @@ -1319,7 +1325,7 @@ bgp_get_attr(eattr *a, byte *buf) { *buf++ = ':'; *buf++ = ' '; - d->format(a, buf); + d->format(a, buf, buflen); return GA_FULL; } return GA_NAME; diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h index ea64584..aaa2c4a 100644 --- a/proto/bgp/bgp.h +++ b/proto/bgp/bgp.h @@ -132,7 +132,7 @@ void bgp_close_conn(struct bgp_conn *c); void bgp_attach_attr(struct ea_list **to, struct linpool *pool, unsigned attr, uintptr_t val); byte *bgp_attach_attr_wa(struct ea_list **to, struct linpool *pool, unsigned attr, unsigned len); struct rta *bgp_decode_attrs(struct bgp_conn *conn, byte *a, unsigned int len, struct linpool *pool, int mandatory); -int bgp_get_attr(struct eattr *e, byte *buf); +int bgp_get_attr(struct eattr *e, byte *buf, int buflen); int bgp_rte_better(struct rte *, struct rte *); void bgp_rt_notify(struct proto *, struct network *, struct rte *, struct rte *, struct ea_list *); int bgp_import_control(struct proto *, struct rte **, struct ea_list **, struct linpool *); diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index cd510bc..1eae376 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -529,7 +529,7 @@ ospf_get_route_info(rte * rte, byte * buf, ea_list * attrs UNUSED) } static int -ospf_get_attr(eattr * a, byte * buf) +ospf_get_attr(eattr * a, byte * buf, int buflen UNUSED) { switch (a->id) { diff --git a/proto/rip/rip.c b/proto/rip/rip.c index 6c7bd36..b5a4cc3 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -972,7 +972,7 @@ rip_init_config(struct rip_proto_config *c) } static int -rip_get_attr(eattr *a, byte *buf) +rip_get_attr(eattr *a, byte *buf, int buflen UNUSED) { switch (a->id) { case EA_RIP_METRIC: buf += bsprintf( buf, "metric: %d", a->u.data ); return GA_FULL; |