summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/sctp.c
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2016-01-07 07:21:37 +0000
committermarkj <markj@FreeBSD.org>2016-01-07 07:21:37 +0000
commit513e9b690f5bb0abdec4b77b4ab0de8385608740 (patch)
tree9d5b6667dd8dc576e2873ba33b97fbaf2f5a4ea1 /usr.bin/netstat/sctp.c
parent7e512433ae5da8eb21b09cbeee9d63820e41199d (diff)
downloadFreeBSD-src-513e9b690f5bb0abdec4b77b4ab0de8385608740.zip
FreeBSD-src-513e9b690f5bb0abdec4b77b4ab0de8385608740.tar.gz
MFC r287649:
Use a common subroutine to fetch and zero protocol stats instead of duplicating roughly similar code for each protocol.
Diffstat (limited to 'usr.bin/netstat/sctp.c')
-rw-r--r--usr.bin/netstat/sctp.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/usr.bin/netstat/sctp.c b/usr.bin/netstat/sctp.c
index a2ef7d568..687d039 100644
--- a/usr.bin/netstat/sctp.c
+++ b/usr.bin/netstat/sctp.c
@@ -607,20 +607,11 @@ sctp_statesprint(uint32_t state)
void
sctp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
{
- struct sctpstat sctpstat, zerostat;
- size_t len = sizeof(sctpstat);
-
- if (live) {
- if (zflag)
- memset(&zerostat, 0, len);
- if (sysctlbyname("net.inet.sctp.stats", &sctpstat, &len,
- zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
- if (errno != ENOENT)
- warn("sysctl: net.inet.sctp.stats");
- return;
- }
- } else
- kread(off, &sctpstat, len);
+ struct sctpstat sctpstat;
+
+ if (fetch_stats("net.inet.sctp.stats", off, &sctpstat,
+ sizeof(sctpstat), kread) != 0)
+ return;
printf ("%s:\n", name);
OpenPOWER on IntegriCloud