diff options
| author | Hajimu UMEMOTO <ume@FreeBSD.org> | 2015-11-24 14:25:40 +0000 |
|---|---|---|
| committer | Hajimu UMEMOTO <ume@FreeBSD.org> | 2015-11-24 14:25:40 +0000 |
| commit | 046aad399a48d3166ad00f02b5e589ccda1ffd27 (patch) | |
| tree | 1c46ea07ae509e51be30877481ae044c4e9b8099 /usr.bin/netstat | |
| parent | b09e6b5c6e8ba20797adafd42a099bbb42958bec (diff) | |
Notes
Diffstat (limited to 'usr.bin/netstat')
| -rw-r--r-- | usr.bin/netstat/inet.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 5644af33b366..c85e62ec299f 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -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, int af1, int proto) 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, int af1, int proto) 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, int af1, int proto) } 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, int af1, int proto) } 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 char *name, int af1 __unused, */ 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 in_addr *in, int port, 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 |
