diff options
author | ume <ume@FreeBSD.org> | 2002-05-21 18:11:31 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2002-05-21 18:11:31 +0000 |
commit | a491c6f95a0bde0a1667d8dc7d0e50801a057133 (patch) | |
tree | bb82a668aac0f252ee70736d6a8055cf229eb64f /sbin | |
parent | df03dac70046c9c51920ea9d57e925f8fa86d527 (diff) | |
download | FreeBSD-src-a491c6f95a0bde0a1667d8dc7d0e50801a057133.zip FreeBSD-src-a491c6f95a0bde0a1667d8dc7d0e50801a057133.tar.gz |
Allow prefix/prefixlen syntax for IPv6 to have consistency
with IPv4.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/route/route.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c index d5eea5b..ba00033 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -114,7 +114,7 @@ const char *routename(), *netname(); void flushroutes(), newroute(), monitor(), sockaddr(), sodump(), bprintf(); void print_getmsg(), print_rtmsg(), pmsg_common(), pmsg_addrs(), mask_addr(); #ifdef INET6 -static int inet6_makenetandmask(struct sockaddr_in6 *); +static int inet6_makenetandmask(struct sockaddr_in6 *, char *); #endif int getaddr(), rtmsg(), x25_makemask(); int prefixlen(); @@ -867,23 +867,25 @@ inet_makenetandmask(net, sin, bits) * XXX the function may need more improvement... */ static int -inet6_makenetandmask(sin6) +inet6_makenetandmask(sin6, plen) struct sockaddr_in6 *sin6; -{ char *plen; +{ struct in6_addr in6; - plen = NULL; - if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) && - sin6->sin6_scope_id == 0) { - plen = "0"; - } else if ((sin6->sin6_addr.s6_addr[0] & 0xe0) == 0x20) { - /* aggregatable global unicast - RFC2374 */ - memset(&in6, 0, sizeof(in6)); - if (!memcmp(&sin6->sin6_addr.s6_addr[8], &in6.s6_addr[8], 8)) - plen = "64"; - else - plen = "128"; + if (!plen) { + if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) && + sin6->sin6_scope_id == 0) { + plen = "0"; + } else if ((sin6->sin6_addr.s6_addr[0] & 0xe0) == 0x20) { + /* aggregatable global unicast - RFC2374 */ + memset(&in6, 0, sizeof(in6)); + if (!memcmp(&sin6->sin6_addr.s6_addr[8], + &in6.s6_addr[8], 8)) + plen = "64"; + else + plen = "128"; + } } if (plen) { @@ -995,6 +997,9 @@ getaddr(which, s, hpp) { struct addrinfo hints, *res; + q = NULL; + if (which == RTA_DST && (q = strchr(s, '/')) != NULL) + *q = '\0'; memset(&hints, 0, sizeof(hints)); hints.ai_family = afamily; /*AF_INET6*/ hints.ai_flags = AI_NUMERICHOST; @@ -1016,8 +1021,10 @@ getaddr(which, s, hpp) } #endif freeaddrinfo(res); + if (q != NULL) + *q++ = '/'; if (which == RTA_DST) - if (inet6_makenetandmask(&su->sin6) == -1) + if (inet6_makenetandmask(&su->sin6, q) == -1) return (1); return (0); } |