From owner-svn-src-all@freebsd.org Tue Nov 24 14:25:41 2015 Return-Path: Delivered-To: svn-src-all@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 9FFDAA362DE; Tue, 24 Nov 2015 14:25:41 +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 7746C187F; Tue, 24 Nov 2015 14:25:41 +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 tAOEPeIW029638; Tue, 24 Nov 2015 14:25:40 GMT (envelope-from ume@FreeBSD.org) Received: (from ume@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tAOEPe5d029637; Tue, 24 Nov 2015 14:25:40 GMT (envelope-from ume@FreeBSD.org) Message-Id: <201511241425.tAOEPe5d029637@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ume set sender to ume@FreeBSD.org using -f From: Hajimu UMEMOTO Date: Tue, 24 Nov 2015 14:25:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291259 - 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-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Nov 2015 14:25:41 -0000 Author: ume Date: Tue Nov 24 14:25:40 2015 New Revision: 291259 URL: https://svnweb.freebsd.org/changeset/base/291259 Log: Correct alignment of the addresses in the `netstat -aW' output. Modified: head/usr.bin/netstat/inet.c Modified: head/usr.bin/netstat/inet.c ============================================================================== --- head/usr.bin/netstat/inet.c Tue Nov 24 13:57:41 2015 (r291258) +++ head/usr.bin/netstat/inet.c Tue Nov 24 14:25:40 2015 (r291259) @@ -84,7 +84,8 @@ __FBSDID("$FreeBSD$"); #include "netstat.h" char *inetname(struct in_addr *); -void inetprint(const char *, struct in_addr *, int, const char *, int); +void inetprint(const char *, struct in_addr *, int, const char *, int, + const int); #ifdef INET6 static int udp_done, tcp_done, sdp_done; #endif /* INET6 */ @@ -417,18 +418,24 @@ protopr(u_long off, const char *name, in if (Lflag) xo_emit((Aflag && !Wflag) ? "{T:/%-5.5s} {T:/%-14.14s} {T:/%-18.18s}" : - "{T:/%-5.5s} {T:/%-14.14s} {T:/%-22.22s}", + ((!Wflag || af1 == AF_INET) ? + "{T:/%-5.5s} {T:/%-14.14s} {T:/%-22.22s}" : + "{T:/%-5.5s} {T:/%-14.14s} {T:/%-45.45s}"), "Proto", "Listen", "Local Address"); else if (Tflag) xo_emit((Aflag && !Wflag) ? "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%s}" : - "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%s}", + ((!Wflag || af1 == AF_INET) ? + "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%s}" : + "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%s}"), "Proto", "Rexmit", "OOORcv", "0-win", "Local Address", "Foreign Address"); else { xo_emit((Aflag && !Wflag) ? "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%-18.18s}" : - "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%-22.22s}", + ((!Wflag || af1 == AF_INET) ? + "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%-22.22s}" : + "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%-45.45s}"), "Proto", "Recv-Q", "Send-Q", "Local Address", "Foreign Address"); if (!xflag && !Rflag) @@ -499,10 +506,10 @@ protopr(u_long off, const char *name, in if (numeric_port) { if (inp->inp_vflag & INP_IPV4) { inetprint("local", &inp->inp_laddr, - (int)inp->inp_lport, name, 1); + (int)inp->inp_lport, name, 1, af1); if (!Lflag) inetprint("remote", &inp->inp_faddr, - (int)inp->inp_fport, name, 1); + (int)inp->inp_fport, name, 1, af1); } #ifdef INET6 else if (inp->inp_vflag & INP_IPV6) { @@ -516,10 +523,10 @@ protopr(u_long off, const char *name, in } else if (inp->inp_flags & INP_ANONPORT) { if (inp->inp_vflag & INP_IPV4) { inetprint("local", &inp->inp_laddr, - (int)inp->inp_lport, name, 1); + (int)inp->inp_lport, name, 1, af1); if (!Lflag) inetprint("remote", &inp->inp_faddr, - (int)inp->inp_fport, name, 0); + (int)inp->inp_fport, name, 0, af1); } #ifdef INET6 else if (inp->inp_vflag & INP_IPV6) { @@ -533,11 +540,12 @@ protopr(u_long off, const char *name, in } else { if (inp->inp_vflag & INP_IPV4) { inetprint("local", &inp->inp_laddr, - (int)inp->inp_lport, name, 0); + (int)inp->inp_lport, name, 0, af1); if (!Lflag) inetprint("remote", &inp->inp_faddr, (int)inp->inp_fport, name, - inp->inp_lport != inp->inp_fport); + inp->inp_lport != inp->inp_fport, + af1); } #ifdef INET6 else if (inp->inp_vflag & INP_IPV6) { @@ -1364,7 +1372,7 @@ pim_stats(u_long off __unused, const cha */ void inetprint(const char *container, struct in_addr *in, int port, - const char *proto, int num_port) + const char *proto, int num_port, const int af1) { struct servent *sp = 0; char line[80], *cp; @@ -1384,7 +1392,8 @@ inetprint(const char *container, struct sprintf(cp, "%.15s ", sp ? sp->s_name : "*"); else sprintf(cp, "%d ", ntohs((u_short)port)); - width = (Aflag && !Wflag) ? 18 : 22; + width = (Aflag && !Wflag) ? 18 : + ((!Wflag || af1 == AF_INET) ? 22 : 45); if (Wflag) xo_emit("{d:target/%-*s} ", width, line); else