summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2015-05-06 16:43:44 +0000
committerglebius <glebius@FreeBSD.org>2015-05-06 16:43:44 +0000
commitf9e194c4522d1ea9c0d6fc67545673fcc09afeb7 (patch)
treedf0beb345beaf5fb8b66d96d24ef7cbe305f502a /usr.bin/netstat
parent7776059e98331e0dd518aa210f210fce7b64c55b (diff)
downloadFreeBSD-src-f9e194c4522d1ea9c0d6fc67545673fcc09afeb7.zip
FreeBSD-src-f9e194c4522d1ea9c0d6fc67545673fcc09afeb7.tar.gz
Printing interface names:
o Restore historical behaviour of appending '*' if interface is down, and we have enough space to print it (usually we don't). [1] o Do not truncate interface names when printing in encoded format. o Report interface flags into encoded format. PR: 199873 [1] Sponsored by: Nginx, Inc.
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/if.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index f04c531..109ef2d 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -315,7 +315,7 @@ intpr(int interval, void (*pfunc)(char *), int af)
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
bool network = false, link = false;
- char *name;
+ char *name, *xname, buf[IFNAMSIZ+1];
if (interface != NULL && strcmp(ifa->ifa_name, interface) != 0)
continue;
@@ -341,10 +341,20 @@ intpr(int interval, void (*pfunc)(char *), int af)
xo_open_instance("interface");
+ if ((ifa->ifa_flags & IFF_UP) == 0) {
+ xname = stpcpy(buf, name);
+ *xname++ = '*';
+ *xname = '\0';
+ xname = buf;
+ } else
+ xname = name;
+
if (Wflag)
- xo_emit("{tk:name/%-7.7s}", name);
+ xo_emit("{etk:name/%s}{e:flags/0x%x}{d:/%7.7s}",
+ name, ifa->ifa_flags, xname);
else
- xo_emit("{tk:name/%-5.5s}", name);
+ xo_emit("{etk:name/%s}{e:flags/0x%x}{d:/%5.5s}",
+ name, ifa->ifa_flags, xname);
#define IFA_MTU(ifa) (((struct if_data *)(ifa)->ifa_data)->ifi_mtu)
show_stat("lu", 6, "mtu", IFA_MTU(ifa), IFA_MTU(ifa));
OpenPOWER on IntegriCloud