summaryrefslogtreecommitdiffstats
path: root/proto/bgp/packets.c
diff options
context:
space:
mode:
Diffstat (limited to 'proto/bgp/packets.c')
-rw-r--r--proto/bgp/packets.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c
index bf98640..1a1e7b7 100644
--- a/proto/bgp/packets.c
+++ b/proto/bgp/packets.c
@@ -117,12 +117,12 @@ bgp_create_notification(struct bgp_conn *conn, byte *buf)
static byte *
bgp_put_cap_ipv6(struct bgp_conn *conn UNUSED, byte *buf)
{
- *buf++ = 1; /* Capability 1: Multiprotocol extensions */
+ *buf++ = BGP_CAP_MP; /* Capability 1: Multiprotocol extensions */
*buf++ = 4; /* Capability data length */
*buf++ = 0; /* We support AF IPv6 */
*buf++ = BGP_AF_IPV6;
*buf++ = 0; /* RFU */
- *buf++ = 1; /* and SAFI 1 */
+ *buf++ = BGP_SAF_UNICAST; /* and SAFI 1 */
return buf;
}
@@ -131,20 +131,32 @@ bgp_put_cap_ipv6(struct bgp_conn *conn UNUSED, byte *buf)
static byte *
bgp_put_cap_ipv4(struct bgp_conn *conn UNUSED, byte *buf)
{
- *buf++ = 1; /* Capability 1: Multiprotocol extensions */
+ *buf++ = BGP_CAP_MP; /* Capability 1: Multiprotocol extensions */
*buf++ = 4; /* Capability data length */
*buf++ = 0; /* We support AF IPv4 */
*buf++ = BGP_AF_IPV4;
*buf++ = 0; /* RFU */
- *buf++ = 1; /* and SAFI 1 */
+ *buf++ = BGP_SAF_UNICAST; /* and SAFI 1 */
return buf;
}
#endif
static byte *
+bgp_put_cap_multicast(struct bgp_conn *conn UNUSED, byte *buf)
+{
+ *buf++ = BGP_CAP_MP; /* Capability 1: Multiprotocol extensions */
+ *buf++ = 4; /* Capability data length */
+ *buf++ = 0;
+ *buf++ = BGP_AF;
+ *buf++ = 0; /* RFU */
+ *buf++ = BGP_SAF_MULTICAST; /* and SAFI 2 */
+ return buf;
+}
+
+static byte *
bgp_put_cap_rr(struct bgp_conn *conn UNUSED, byte *buf)
{
- *buf++ = 2; /* Capability 2: Support for route refresh */
+ *buf++ = BGP_CAP_REFRESH; /* Capability 2: Support for route refresh */
*buf++ = 0; /* Capability data length */
return buf;
}
@@ -152,7 +164,7 @@ bgp_put_cap_rr(struct bgp_conn *conn UNUSED, byte *buf)
static byte *
bgp_put_cap_as4(struct bgp_conn *conn, byte *buf)
{
- *buf++ = 65; /* Capability 65: Support for 4-octet AS number */
+ *buf++ = BGP_CAP_AS4; /* Capability 65: Support for 4-octet AS number */
*buf++ = 4; /* Capability data length */
put_u32(buf, conn->bgp->local_as);
return buf + 4;
@@ -197,6 +209,9 @@ bgp_create_open(struct bgp_conn *conn, byte *buf)
if (conn->want_as4_support)
cap = bgp_put_cap_as4(conn, cap);
+ if (conn->want_multicast_support)
+ cap = bgp_put_cap_multicast(conn, cap);
+
cap_len = cap - buf - 12;
if (cap_len > 0)
{
@@ -625,13 +640,24 @@ bgp_parse_capabilities(struct bgp_conn *conn, byte *opt, int len)
switch (opt[0])
{
- case 2: /* Route refresh capability, RFC 2918 */
+ case BGP_CAP_MP: /* Multiprotocol capability, RFC 4760 */
+ if (cl != 4)
+ goto err;
+
+ if (get_u16(opt + 2) != BGP_AF)
+ break;
+
+ if (opt[5] == BGP_SAF_MULTICAST)
+ conn->peer_multicast_support = 1;
+ break;
+
+ case BGP_CAP_REFRESH: /* Route refresh capability, RFC 2918 */
if (cl != 0)
goto err;
conn->peer_refresh_support = 1;
break;
- case 65: /* AS4 capability, RFC 4893 */
+ case BGP_CAP_AS4: /* AS4 capability, RFC 4893 */
if (cl != 4)
goto err;
conn->peer_as4_support = 1;