Index: bgpd/bgp_attr.c =================================================================== RCS file: /var/cvsroot/quagga/bgpd/bgp_attr.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 bgp_attr.c --- bgpd/bgp_attr.c 13 Dec 2002 20:15:29 -0000 1.1.1.1 +++ bgpd/bgp_attr.c 9 Oct 2003 14:10:02 -0000 @@ -1738,7 +1738,7 @@ /* Make attribute packet. */ void -bgp_dump_routes_attr (struct stream *s, struct attr *attr) +bgp_dump_routes_attr (struct stream *s, struct attr *attr, struct prefix *prefix) { unsigned long cp; unsigned long len; @@ -1773,10 +1773,14 @@ stream_put (s, aspath->data, aspath->length); /* Nexthop attribute. */ - stream_putc (s, BGP_ATTR_FLAG_TRANS); - stream_putc (s, BGP_ATTR_NEXT_HOP); - stream_putc (s, 4); - stream_put_ipv4 (s, attr->nexthop.s_addr); + /* If it's an IPv6 prefix, don't dump the IPv4 nexthop to save space */ + if(prefix != NULL && prefix->family != AF_INET6) + { + stream_putc (s, BGP_ATTR_FLAG_TRANS); + stream_putc (s, BGP_ATTR_NEXT_HOP); + stream_putc (s, 4); + stream_put_ipv4 (s, attr->nexthop.s_addr); + } /* MED attribute. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) @@ -1830,6 +1834,37 @@ stream_putc (s, attr->community->size * 4); } stream_put (s, attr->community->val, attr->community->size * 4); + } + + /* Add a MP_NLRI attribute to dump the IPv6 next hop */ + if(prefix != NULL && prefix->family == AF_INET6 && + (attr->mp_nexthop_len == 16 || attr->mp_nexthop_len == 32) ) + { + int sizep; + + stream_putc(s, BGP_ATTR_FLAG_OPTIONAL); + stream_putc(s, BGP_ATTR_MP_REACH_NLRI); + sizep = stream_get_putp (s); + + /* MP header */ + stream_putc (s, 0); /* Length of this attribute. */ + stream_putw(s, AFI_IP6); /* AFI */ + stream_putc(s, SAFI_UNICAST); /* SAFI */ + + /* Next hop */ + stream_putc(s, attr->mp_nexthop_len); + stream_put(s, &attr->mp_nexthop_global, 16); + if(attr->mp_nexthop_len == 32) + stream_put(s, &attr->mp_nexthop_local, 16); + + /* SNPA */ + stream_putc(s, 0); + + /* Prefix */ + stream_put_prefix(s, prefix); + + /* Set MP attribute length. */ + stream_putc_at (s, sizep, (stream_get_putp (s) - sizep) - 1); } /* Return total size of attribute. */ Index: bgpd/bgp_attr.h =================================================================== RCS file: /var/cvsroot/quagga/bgpd/bgp_attr.h,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 bgp_attr.h --- bgpd/bgp_attr.h 13 Dec 2002 20:15:29 -0000 1.1.1.1 +++ bgpd/bgp_attr.h 9 Oct 2003 14:10:02 -0000 @@ -112,7 +112,7 @@ struct attr *bgp_attr_aggregate_intern (struct bgp *, u_char, struct aspath *, struct community *, int as_set); bgp_size_t bgp_packet_attribute (struct bgp *bgp, struct peer *, struct stream *, struct attr *, struct prefix *, afi_t, safi_t, struct peer *, struct prefix_rd *, u_char *); bgp_size_t bgp_packet_withdraw (struct peer *peer, struct stream *s, struct prefix *p, afi_t, safi_t, struct prefix_rd *, u_char *); -void bgp_dump_routes_attr (struct stream *, struct attr *); +void bgp_dump_routes_attr (struct stream *, struct attr *, struct prefix *); unsigned int attrhash_key_make (struct attr *); int attrhash_cmp (struct attr *, struct attr *); void attr_show_all (struct vty *); Index: bgpd/bgp_dump.c =================================================================== RCS file: /var/cvsroot/quagga/bgpd/bgp_dump.c,v retrieving revision 1.2 diff -u -r1.2 bgp_dump.c --- bgpd/bgp_dump.c 10 May 2003 18:33:28 -0000 1.2 +++ bgpd/bgp_dump.c 9 Oct 2003 14:10:02 -0000 @@ -217,7 +217,7 @@ stream_putw (obuf, peer->as); /* Dump attribute. */ - bgp_dump_routes_attr (obuf, attr); + bgp_dump_routes_attr (obuf, attr, NULL); } else { @@ -227,7 +227,7 @@ stream_putc (obuf, p->prefixlen); plen = PSIZE (p->prefixlen); stream_put (obuf, &p->u.prefix4, plen); - bgp_dump_routes_attr (obuf, attr); + bgp_dump_routes_attr (obuf, attr, NULL); } } #ifdef HAVE_IPV6 @@ -253,7 +253,7 @@ stream_putw (obuf, peer->as); /* Dump attribute. */ - bgp_dump_routes_attr (obuf, attr); + bgp_dump_routes_attr (obuf, attr, p); } else { @@ -332,7 +332,7 @@ stream_putw (obuf, peer->as); stream_putw (obuf, peer->local_as); - if (peer->afc[AFI_IP][SAFI_UNICAST]) + if (peer->su.sa.sa_family == AF_INET) { stream_putw (obuf, peer->ifindex); stream_putw (obuf, AFI_IP); @@ -345,7 +345,7 @@ stream_put (obuf, empty, IPV4_MAX_BYTELEN); } #ifdef HAVE_IPV6 - else if (peer->afc[AFI_IP6][SAFI_UNICAST]) + else if (peer->su.sa.sa_family == AF_INET6) { /* Interface Index and Address family. */ stream_putw (obuf, peer->ifindex);