Send and receive communities.
This commit is contained in:
parent
c6add07fa6
commit
1ed2fe9609
3 changed files with 20 additions and 8 deletions
|
@ -54,7 +54,7 @@ bgp_check_path(struct bgp_proto *p, byte *a, int len)
|
||||||
{
|
{
|
||||||
DBG("Path segment %02x %02x\n", a[0], a[1]);
|
DBG("Path segment %02x %02x\n", a[0], a[1]);
|
||||||
if (len < 2 ||
|
if (len < 2 ||
|
||||||
a[0] != BGP_PATH_AS_SET && a[0] != BGP_PATH_AS_SEQUENCE ||
|
a[0] != AS_PATH_SET && a[0] != AS_PATH_SEQUENCE ||
|
||||||
2*a[1] + 2 > len)
|
2*a[1] + 2 > len)
|
||||||
return 11;
|
return 11;
|
||||||
len -= 2*a[1] + 2;
|
len -= 2*a[1] + 2;
|
||||||
|
@ -101,9 +101,9 @@ static struct attr_desc bgp_attr_table[] = {
|
||||||
NULL, NULL },
|
NULL, NULL },
|
||||||
{ "aggregator", 6, BAF_OPTIONAL, EAF_TYPE_OPAQUE, /* BA_AGGREGATOR */
|
{ "aggregator", 6, BAF_OPTIONAL, EAF_TYPE_OPAQUE, /* BA_AGGREGATOR */
|
||||||
NULL, NULL },
|
NULL, NULL },
|
||||||
|
{ "community", -1, BAF_OPTIONAL | BAF_TRANSITIVE, EAF_TYPE_INT_SET, /* BA_COMMUNITY */
|
||||||
|
NULL, NULL },
|
||||||
#if 0
|
#if 0
|
||||||
/* FIXME: Handle community lists and remember to convert their endianity and normalize them */
|
|
||||||
{ 0, 0 }, /* BA_COMMUNITY */
|
|
||||||
{ 0, 0 }, /* BA_ORIGINATOR_ID */
|
{ 0, 0 }, /* BA_ORIGINATOR_ID */
|
||||||
{ 0, 0 }, /* BA_CLUSTER_LIST */
|
{ 0, 0 }, /* BA_CLUSTER_LIST */
|
||||||
#endif
|
#endif
|
||||||
|
@ -177,9 +177,16 @@ bgp_encode_attrs(byte *w, struct bgp_bucket *buck)
|
||||||
memcpy(w, &ip, len);
|
memcpy(w, &ip, len);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case EAF_TYPE_INT_SET:
|
||||||
|
{
|
||||||
|
u32 *z = (u32 *)a->u.ptr->data;
|
||||||
|
int i;
|
||||||
|
for(i=0; i<len; i+=4)
|
||||||
|
put_u32(w+i, *z++);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case EAF_TYPE_OPAQUE:
|
case EAF_TYPE_OPAQUE:
|
||||||
case EAF_TYPE_AS_PATH:
|
case EAF_TYPE_AS_PATH:
|
||||||
case EAF_TYPE_INT_SET:
|
|
||||||
memcpy(w, a->u.ptr->data, len);
|
memcpy(w, a->u.ptr->data, len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -318,7 +325,7 @@ bgp_get_bucket(struct bgp_proto *p, ea_list *old, ea_list *tmp)
|
||||||
a = &new->attrs[i];
|
a = &new->attrs[i];
|
||||||
#ifdef LOCAL_DEBUG
|
#ifdef LOCAL_DEBUG
|
||||||
{
|
{
|
||||||
byte buf[256];
|
byte buf[EA_FORMAT_BUF_SIZE];
|
||||||
ea_format(a, buf);
|
ea_format(a, buf);
|
||||||
DBG("\t%s\n", buf);
|
DBG("\t%s\n", buf);
|
||||||
}
|
}
|
||||||
|
@ -710,6 +717,13 @@ bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct lin
|
||||||
case EAF_TYPE_IP_ADDRESS:
|
case EAF_TYPE_IP_ADDRESS:
|
||||||
ipa_ntoh(*(ip_addr *)ad->data);
|
ipa_ntoh(*(ip_addr *)ad->data);
|
||||||
break;
|
break;
|
||||||
|
case EAF_TYPE_INT_SET:
|
||||||
|
{
|
||||||
|
u32 *z = (u32 *) ad->data;
|
||||||
|
for(i=0; i<ad->length/4; i++)
|
||||||
|
z[i] = ntohl(z[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,9 +139,6 @@ int bgp_rx(struct birdsock *sk, int size);
|
||||||
#define BA_MP_UNREACH_NLRI 0x0f
|
#define BA_MP_UNREACH_NLRI 0x0f
|
||||||
#define BA_EXTENDED_COMM 0x10 /* draft-ramachandra-bgp-ext-communities */
|
#define BA_EXTENDED_COMM 0x10 /* draft-ramachandra-bgp-ext-communities */
|
||||||
|
|
||||||
#define BGP_PATH_AS_SET 1 /* Types of path segments */
|
|
||||||
#define BGP_PATH_AS_SEQUENCE 2
|
|
||||||
|
|
||||||
/* BGP states */
|
/* BGP states */
|
||||||
|
|
||||||
#define BS_IDLE 0
|
#define BS_IDLE 0
|
||||||
|
|
|
@ -81,6 +81,7 @@ bgp_create_update(struct bgp_conn *conn, byte *buf)
|
||||||
int r_size = 0;
|
int r_size = 0;
|
||||||
|
|
||||||
DBG("BGP: Sending update\n");
|
DBG("BGP: Sending update\n");
|
||||||
|
/* FIXME: Better timing of updates */
|
||||||
w = buf+2;
|
w = buf+2;
|
||||||
if ((buck = bgp->withdraw_bucket) && !EMPTY_LIST(buck->prefixes))
|
if ((buck = bgp->withdraw_bucket) && !EMPTY_LIST(buck->prefixes))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue