summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/if.c
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>1999-04-26 16:11:50 +0000
committerluigi <luigi@FreeBSD.org>1999-04-26 16:11:50 +0000
commit564d182065fdf8f65991755b00f96cb3a2bcf24b (patch)
tree90b99fb7e9aa264ea4586a5385baf62f4646be49 /usr.bin/netstat/if.c
parente73255d2dc2d278abb31a282e8193f082523b660 (diff)
downloadFreeBSD-src-564d182065fdf8f65991755b00f96cb3a2bcf24b.zip
FreeBSD-src-564d182065fdf8f65991755b00f96cb3a2bcf24b.tar.gz
Add support for printing bridging statistics with ``-p bdg '' .
If someone has a better flag to use I'll be glad to change it.
Diffstat (limited to 'usr.bin/netstat/if.c')
-rw-r--r--usr.bin/netstat/if.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index 8b9b883..26191f8 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -36,18 +36,20 @@
static char sccsid[] = "@(#)if.c 8.3 (Berkeley) 4/28/95";
*/
static const char rcsid[] =
- "$Id: if.c,v 1.24 1998/07/06 21:01:23 bde Exp $";
+ "$Id: if.c,v 1.25 1999/04/20 22:04:31 billf Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/protosw.h>
#include <sys/socket.h>
+#include <sys/sysctl.h>
#include <sys/time.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/if_types.h>
+#include <net/bridge.h>
#include <net/ethernet.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
@@ -76,6 +78,39 @@ static const char rcsid[] =
static void sidewaysintpr __P((u_int, u_long));
static void catchalarm __P((int));
+void
+bdg_stats(u_long dummy, char *name) /* print bridge statistics */
+{
+ int i, slen ;
+ struct bdg_stats s ;
+ int mib[4] ;
+
+ slen = sizeof(s);
+
+ mib[0] = CTL_NET ;
+ mib[1] = PF_LINK ;
+ mib[2] = IFT_ETHER ;
+ mib[3] = PF_BDG ;
+ if (sysctl(mib,4, &s,&slen,NULL,0)==-1)
+ return ; /* no bridging */
+ printf("-- Bridging statistics (%s) --\n", name) ;
+ printf(
+"Name In Out Forward Drop Bcast Mcast Local Unknown\n");
+ for (i = 0 ; i < 16 ; i++) {
+ if (s.s[i].name[0])
+ printf("%-6s %9d%9d%9d%9d%9d%9d%9d%9d\n",
+ s.s[i].name,
+ s.s[i].p_in[(int)BDG_IN],
+ s.s[i].p_in[(int)BDG_OUT],
+ s.s[i].p_in[(int)BDG_FORWARD],
+ s.s[i].p_in[(int)BDG_DROP],
+ s.s[i].p_in[(int)BDG_BCAST],
+ s.s[i].p_in[(int)BDG_MCAST],
+ s.s[i].p_in[(int)BDG_LOCAL],
+ s.s[i].p_in[(int)BDG_UNKNOWN] );
+ }
+}
+
/*
* Print a description of the network interfaces.
*/
OpenPOWER on IntegriCloud