aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Karels <karels@FreeBSD.org>2022-07-02 16:03:36 +0000
committerMike Karels <karels@FreeBSD.org>2022-07-06 12:12:16 +0000
commit231092bb6fda75b922fc324edef6523e78e9e8ed (patch)
tree0c9007f7a3b69fac518711afcc1151b97bab028a
parentfbb5cb66f74cd9e7c2b1491dee6f5a3df72aea7a (diff)
downloadsrc-231092bb6fda75b922fc324edef6523e78e9e8ed.tar.gz
src-231092bb6fda75b922fc324edef6523e78e9e8ed.zip
-rw-r--r--usr.bin/netstat/if.c26
-rw-r--r--usr.bin/netstat/netstat.18
2 files changed, 20 insertions, 14 deletions
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index d9a7574c9e22..5ba4f3afc67b 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -284,20 +284,20 @@ intpr(void (*pfunc)(char *), int af)
if (aflag && getifmaddrs(&ifmap) != 0)
err(EX_OSERR, "getifmaddrs");
+ for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
+ if (interface != NULL &&
+ strcmp(ifa->ifa_name, interface) != 0)
+ continue;
+ if (af != AF_UNSPEC && ifa->ifa_addr->sa_family != af)
+ continue;
+ ifn_len = strlen(ifa->ifa_name);
+ if ((ifa->ifa_flags & IFF_UP) == 0)
+ ++ifn_len;
+ ifn_len_max = MAX(ifn_len_max, ifn_len);
+ if (ifa->ifa_addr->sa_family == AF_INET6)
+ has_ipv6 = 1;
+ }
if (Wflag) {
- for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
- if (interface != NULL &&
- strcmp(ifa->ifa_name, interface) != 0)
- continue;
- if (af != AF_UNSPEC && ifa->ifa_addr->sa_family != af)
- continue;
- ifn_len = strlen(ifa->ifa_name);
- if ((ifa->ifa_flags & IFF_UP) == 0)
- ++ifn_len;
- ifn_len_max = MAX(ifn_len_max, ifn_len);
- if (ifa->ifa_addr->sa_family == AF_INET6)
- has_ipv6 = 1;
- }
if (has_ipv6) {
net_len = 24;
addr_len = 39;
diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1
index 0907b5bc7a9f..d02e3c1299dd 100644
--- a/usr.bin/netstat/netstat.1
+++ b/usr.bin/netstat/netstat.1
@@ -309,7 +309,8 @@ Do not resolve numeric addresses and port numbers to names.
See
.Sx GENERAL OPTIONS .
.It Fl W
-Avoid truncating interface names even if this causes some fields to overflow.
+Avoid truncating addresses even if this causes some fields to overflow.
+See
.Sx GENERAL OPTIONS .
.It Fl f Ar protocol_family
Filter by
@@ -795,6 +796,11 @@ Normally
.Nm
attempts to resolve addresses and ports,
and display them symbolically.
+.It Fl W
+Wider output; expand address fields, etc, to avoid truncation.
+Non-numeric values such as domain names may still be truncated; use the
+.Fl n
+option if necessary to avoid ambiguity.
.El
.Sh EXAMPLES
Show packet traffic information (packets, bytes, errors, packet drops, etc) for