From: Benjamin Cama Date: Thu, 21 Jul 2011 00:49:38 +0000 (+0200) Subject: Fix the AFI for IPv6. X-Git-Tag: debian/2.2.1-1fdn1~1^2^2~8 X-Git-Url: http://git.sameswireless.fr/l2tpns.git/commitdiff_plain/3ea85f7c57f8d555396feb5121e7253f04ee6774 Fix the AFI for IPv6. The Address Family Identifier was not the one I thought it was. Define it and fix its use for IPv6. Signed-off-by: Benjamin Cama --- diff --git a/bgp.c b/bgp.c index 7de3d3f..f0ff879 100644 --- a/bgp.c +++ b/bgp.c @@ -260,7 +260,7 @@ int bgp_start(struct bgp_peer *peer, char *name, int as, int keepalive, a.code = BGP_PATH_ATTR_CODE_MP_REACH_NLRI; a.data.s.len = 0; /* will be set on UPDATE */ - mp_reach_nlri_partial.afi = htons(AF_INET6); + mp_reach_nlri_partial.afi = htons(BGP_MP_AFI_IPv6); mp_reach_nlri_partial.safi = BGP_MP_SAFI_UNICAST; mp_reach_nlri_partial.reserved = 0; mp_reach_nlri_partial.next_hop_len = 16; @@ -286,7 +286,7 @@ int bgp_start(struct bgp_peer *peer, char *name, int as, int keepalive, a.code = BGP_PATH_ATTR_CODE_MP_UNREACH_NLRI; a.data.e.len = 0; /* will be set on UPDATE */ - mp_unreach_nlri_partial.afi = htons(AF_INET6); + mp_unreach_nlri_partial.afi = htons(BGP_MP_AFI_IPv6); mp_unreach_nlri_partial.safi = BGP_MP_SAFI_UNICAST; memcpy(&a.data.e.value, &mp_unreach_nlri_partial, @@ -1247,7 +1247,7 @@ static int bgp_handle_input(struct bgp_peer *peer) mp_cap = (struct bgp_mp_cap_param *)&capability->value; /* the only tuple we support */ - if (ntohs(mp_cap->afi) != AF_INET6 && mp_cap->safi != BGP_MP_SAFI_UNICAST) + if (ntohs(mp_cap->afi) != BGP_MP_AFI_IPv6 && mp_cap->safi != BGP_MP_SAFI_UNICAST) { LOG(4, 0, 0, "Unsupported multiprotocol AFI %d and SAFI %d from BGP peer %s\n", mp_cap->afi, mp_cap->safi, peer->name); @@ -1346,7 +1346,7 @@ static int bgp_handle_input(struct bgp_peer *peer) static int bgp_send_open(struct bgp_peer *peer) { struct bgp_data_open data; - struct bgp_mp_cap_param mp_ipv6 = { htons(AF_INET6), 0, BGP_MP_SAFI_UNICAST }; + struct bgp_mp_cap_param mp_ipv6 = { htons(BGP_MP_AFI_IPv6), 0, BGP_MP_SAFI_UNICAST }; struct bgp_capability cap_mp_ipv6; struct bgp_opt_param param_cap_mp_ipv6; uint16_t len = sizeof(peer->outbuf->packet.header); diff --git a/bgp.h b/bgp.h index 8702838..fc2e517 100644 --- a/bgp.h +++ b/bgp.h @@ -67,6 +67,10 @@ struct bgp_mp_cap_param { uint8_t safi; } __attribute__ ((packed)); +/* bgp_mp_cap_param.afi */ +#define BGP_MP_AFI_RESERVED 0 +#define BGP_MP_AFI_IPv4 1 +#define BGP_MP_AFI_IPv6 2 /* bgp_mp_cap_param.safi */ #define BGP_MP_SAFI_UNICAST 1 #define BGP_MP_SAFI_MULTICAST 2