how to get the next hop from ris raw data

Hi Lorenzo, Erik, I have to parse RIS raw data (in C) for a SG project. Bgpdump.c sort of shows how to do this, but I don't quite understand what's happening with next hop in the show_attr function: if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]) { printf("(IPv6 Unicast)\n"); printf("NEXT_HOP: %s\n",inet_ntop(AF_INET6,&attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop.v6_addr,buf,128)); if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop_len==32) printf("NEXT_HOP: %s\n",inet_ntop(AF_INET6,&attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop_local.v6_addr,buf,128)); } (and the same for IPv4 unicast) What is this special case where ... nexthop_len==32 ? If I read this piece of C correctly, it would result in two next hop addresses being printed ????? Can one of you explain? Thanks, -- Rene

Rene Wilhelm wrote:
What is this special case where ... nexthop_len==32 ? If I read this piece of C correctly, it would result in two next hop addresses being printed ?????
Yes. The two next-hops are the BGP next-hop and the link-local next-hop, as specified by RFC 2545 section 3: The value of the Length of Next Hop Network Address field on a MP_REACH_NLRI attribute shall be set to 16, when only a global address is present, or 32 if a link-local address is also included in the Next Hop field. The link-local address shall be included in the Next Hop field if and only if the BGP speaker shares a common subnet with the entity identified by the global IPv6 address carried in the Network Address of Next Hop field and the peer the route is being advertised to. Cheers, Lorenzo -- Lorenzo Colitti http://www.colitti.com/lorenzo/
participants (2)
-
Lorenzo Colitti
-
Rene Wilhelm