diff options
author | ume <ume@FreeBSD.org> | 2011-01-20 15:22:01 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2011-01-20 15:22:01 +0000 |
commit | 95417d69062ea9181cd7b53a2910a7ec94edc83b (patch) | |
tree | bc8d29382d764c3225c80e14d16c86074e24929f /usr.bin/netstat/route.c | |
parent | 45845f433453e448646962c7f9e5def56cec6655 (diff) | |
download | FreeBSD-src-95417d69062ea9181cd7b53a2910a7ec94edc83b.zip FreeBSD-src-95417d69062ea9181cd7b53a2910a7ec94edc83b.tar.gz |
- Hide the internal scope address representation of the KAME IPv6
stack from the output of `netstat -ani'.
- The node-local multicast address in the output of `netstat -rn'
should be handled as well.
Spotted by: Bernd Walter <ticso__at__cicely7.cicely.de>
Diffstat (limited to 'usr.bin/netstat/route.c')
-rw-r--r-- | usr.bin/netstat/route.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 4e5b5c7..2b4ad2f 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -633,18 +633,8 @@ fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags) case AF_INET6: { struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa; - struct in6_addr *in6 = &sa6->sin6_addr; - - /* - * XXX: This is a special workaround for KAME kernels. - * sin6_scope_id field of SA should be set in the future. - */ - if (IN6_IS_ADDR_LINKLOCAL(in6) || - IN6_IS_ADDR_MC_LINKLOCAL(in6)) { - /* XXX: override is ok? */ - sa6->sin6_scope_id = (u_int32_t)ntohs(*(u_short *)&in6->s6_addr[2]); - *(u_short *)&in6->s6_addr[2] = 0; - } + + in6_fillscopeid(sa6); if (flags & RTF_HOST) cp = routename6(sa6); @@ -895,6 +885,25 @@ netname(in_addr_t in, u_long mask) #undef NSHIFT #ifdef INET6 +void +in6_fillscopeid(struct sockaddr_in6 *sa6) +{ +#if defined(__KAME__) + /* + * XXX: This is a special workaround for KAME kernels. + * sin6_scope_id field of SA should be set in the future. + */ + if (IN6_IS_ADDR_LINKLOCAL(&sa6->sin6_addr) || + IN6_IS_ADDR_MC_NODELOCAL(&sa6->sin6_addr) || + IN6_IS_ADDR_MC_LINKLOCAL(&sa6->sin6_addr)) { + /* XXX: override is ok? */ + sa6->sin6_scope_id = + ntohs(*(u_int16_t *)&sa6->sin6_addr.s6_addr[2]); + sa6->sin6_addr.s6_addr[2] = sa6->sin6_addr.s6_addr[3] = 0; + } +#endif +} + const char * netname6(struct sockaddr_in6 *sa6, struct in6_addr *mask) { |