diff options
author | brian <brian@cvs.openbsd.org> | 2001-08-26 09:42:05 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 2001-08-26 09:42:05 +0000 |
commit | 6368b55e2df55e3ddc1cf9b6b703cd4ba8e11030 (patch) | |
tree | f7beae31c9277c5e28c066f85eda2f2f57ecf5fe /usr.bin/netstat/if.c | |
parent | c1ba8d213e9c957c72d57c56a9784ac87e49a7f1 (diff) |
Add a -q to silence zero-output lines and fix some whitespace and text nits.
Submitted by: Sam Smith <S@mSmith.net>
Ok: theo
Diffstat (limited to 'usr.bin/netstat/if.c')
-rw-r--r-- | usr.bin/netstat/if.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index 6173da114e9..158849b2934 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.24 2001/07/18 17:17:39 pvalchev Exp $ */ +/* $OpenBSD: if.c,v 1.25 2001/08/26 09:42:04 brian Exp $ */ /* $NetBSD: if.c,v 1.16.4.2 1996/06/07 21:46:46 thorpej Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94"; #else -static char *rcsid = "$OpenBSD: if.c,v 1.24 2001/07/18 17:17:39 pvalchev Exp $"; +static char *rcsid = "$OpenBSD: if.c,v 1.25 2001/08/26 09:42:04 brian Exp $"; #endif #endif /* not lint */ @@ -95,6 +95,7 @@ intpr(interval, ifnetaddr) struct ipx_ifaddr ipx; struct iso_ifaddr iso; } ifaddr; + u_long total; u_long ifaddraddr; struct sockaddr *sa; struct ifnet_head ifhead; /* TAILQ_HEAD */ @@ -153,6 +154,22 @@ intpr(interval, ifnetaddr) *cp = '\0'; ifaddraddr = (u_long)ifnet.if_addrlist.tqh_first; } + + if (qflag) { + total = ifnet.if_ibytes + ifnet.if_obytes + + ifnet.if_ipackets + ifnet.if_ierrors + + ifnet.if_opackets + ifnet.if_oerrors + + ifnet.if_collisions; + if (tflag) + total += ifnet.if_timer; + if (dflag) + total += ifnet.if_snd.ifq_drops; + if (total == 0) { + ifaddraddr = 0; + continue; + } + } + printf("%-7.7s %-5ld ", name, ifnet.if_mtu); if (ifaddraddr == 0) { printf("%-11.11s ", "none"); |