Date: Wed, 4 Nov 2015 14:47:10 +0000 (UTC) From: Hajimu UMEMOTO <ume@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r290366 - head/usr.bin/netstat Message-ID: <201511041447.tA4ElAwm044810@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ume Date: Wed Nov 4 14:47:10 2015 New Revision: 290366 URL: https://svnweb.freebsd.org/changeset/base/290366 Log: Mask an IPv6 network address. Modified: head/usr.bin/netstat/route.c Modified: head/usr.bin/netstat/route.c ============================================================================== --- head/usr.bin/netstat/route.c Wed Nov 4 13:59:13 2015 (r290365) +++ head/usr.bin/netstat/route.c Wed Nov 4 14:47:10 2015 (r290366) @@ -688,9 +688,10 @@ static const char * netname6(struct sockaddr_in6 *sa6, struct sockaddr_in6 *mask) { static char line[NI_MAXHOST + sizeof("/xxx") - 1]; + struct sockaddr_in6 addr; char nline[NI_MAXHOST]; u_char *p, *lim; - int masklen, illegal = 0; + int masklen, illegal = 0, i; if (mask) { p = (u_char *)&mask->sin6_addr; @@ -703,6 +704,12 @@ netname6(struct sockaddr_in6 *sa6, struc } if (illegal) xo_error("illegal prefixlen\n"); + + memcpy(&addr, sa6, sizeof(addr)); + for (i = 0; i < 16; ++i) + addr.sin6_addr.s6_addr[i] &= + mask->sin6_addr.s6_addr[i]; + sa6 = &addr; } else masklen = 128;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511041447.tA4ElAwm044810>