diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-12-13 20:00:54 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-12-13 20:00:54 +0000 |
commit | 90654a32a12cd0e30f6adb846ff6e9e5e6682a28 (patch) | |
tree | e8f59de8c6fe04c760d9e46528cb22f1da0c1cfc /sbin/sysctl/sysctl.c | |
parent | b03a990aaf0a66e97ca7dd68b5f8b065d05e4b95 (diff) |
implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.
discussed with deraadt@ claudio@ gilles@
ok deraadt@
Diffstat (limited to 'sbin/sysctl/sysctl.c')
-rw-r--r-- | sbin/sysctl/sysctl.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 62892805803..a3864058fc5 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.151 2007/11/26 13:36:33 deraadt Exp $ */ +/* $OpenBSD: sysctl.c,v 1.152 2007/12/13 20:00:53 reyk Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -40,7 +40,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)sysctl.c 8.5 (Berkeley) 5/9/95"; #else -static const char rcsid[] = "$OpenBSD: sysctl.c,v 1.151 2007/11/26 13:36:33 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: sysctl.c,v 1.152 2007/12/13 20:00:53 reyk Exp $"; #endif #endif /* not lint */ @@ -514,6 +514,18 @@ parse(char *string, int flags) break; case CTL_NET: + if (mib[1] == PF_INET && + ((mib[2] == IPPROTO_IP && mib[3] == IPCTL_STATS) || + (mib[2] == IPPROTO_TCP && mib[3] == TCPCTL_STATS) || + (mib[2] == IPPROTO_UDP && mib[3] == UDPCTL_STATS) || + (mib[2] == IPPROTO_ICMP && mib[3] == ICMPCTL_STATS))) { + if (flags == 0) + return; + warnx("use netstat to view %s information", + string); + return; + } + if (mib[1] == PF_INET) { len = sysctl_inet(string, &bufp, mib, flags, &type); if (len < 0) |