diff options
author | luigi <luigi@FreeBSD.org> | 1999-04-26 16:11:50 +0000 |
---|---|---|
committer | luigi <luigi@FreeBSD.org> | 1999-04-26 16:11:50 +0000 |
commit | 564d182065fdf8f65991755b00f96cb3a2bcf24b (patch) | |
tree | 90b99fb7e9aa264ea4586a5385baf62f4646be49 /usr.bin | |
parent | e73255d2dc2d278abb31a282e8193f082523b660 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | usr.bin/netstat/if.c | 37 | ||||
-rw-r--r-- | usr.bin/netstat/main.c | 4 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.1 | 2 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.h | 1 |
4 files changed, 42 insertions, 2 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. */ diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index 8f9998f..b1ada41 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -42,7 +42,7 @@ char const copyright[] = static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 3/1/94"; #endif static const char rcsid[] = - "$Id: main.c,v 1.23 1999/01/18 02:09:15 fenner Exp $"; + "$Id: main.c,v 1.24 1999/02/06 19:12:48 jhay Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -145,6 +145,8 @@ struct protox { icmp_stats, "icmp", IPPROTO_ICMP }, { -1, -1, 1, protopr, igmp_stats, "igmp", IPPROTO_IGMP }, + { -1, -1, 1, protopr, + bdg_stats, "bdg", 1 /* bridging... */ }, { -1, -1, 0, 0, 0, 0 } }; diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1 index 65fd14a..7d7511f 100644 --- a/usr.bin/netstat/netstat.1 +++ b/usr.bin/netstat/netstat.1 @@ -169,6 +169,8 @@ Show statistics about which is either a well-known name for a protocol or an alias for it. Some protocol names and aliases are listed in the file .Pa /etc/protocols . +The special protocol name ``bdg'' +is used to show bridging statistics. A null response typically means that there are no interesting numbers to report. The program will complain if diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h index 92f0ac7..6ae25d8 100644 --- a/usr.bin/netstat/netstat.h +++ b/usr.bin/netstat/netstat.h @@ -66,6 +66,7 @@ void udp_stats __P((u_long, char *)); void ip_stats __P((u_long, char *)); void icmp_stats __P((u_long, char *)); void igmp_stats __P((u_long, char *)); +void bdg_stats __P((u_long, char *)); void protopr __P((u_long, char *)); void mbpr __P((void)); |