From owner-svn-src-head@freebsd.org Wed Nov 4 14:47:12 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1FF9FA262CC; Wed, 4 Nov 2015 14:47:12 +0000 (UTC) (envelope-from ume@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DBC9F15E0; Wed, 4 Nov 2015 14:47:11 +0000 (UTC) (envelope-from ume@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tA4ElAbg044811; Wed, 4 Nov 2015 14:47:10 GMT (envelope-from ume@FreeBSD.org) Received: (from ume@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tA4ElAwm044810; Wed, 4 Nov 2015 14:47:10 GMT (envelope-from ume@FreeBSD.org) Message-Id: <201511041447.tA4ElAwm044810@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ume set sender to ume@FreeBSD.org using -f From: Hajimu UMEMOTO Date: Wed, 4 Nov 2015 14:47:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r290366 - head/usr.bin/netstat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Nov 2015 14:47:12 -0000 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;