From 9eddb899d909fd8e9392e9de6b152b0999f57153 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Fri, 11 Sep 2015 04:37:01 +0000 Subject: Use a common subroutine to fetch and zero protocol stats instead of duplicating roughly similar code for each protocol. MFC after: 2 weeks --- usr.bin/netstat/flowtable.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'usr.bin/netstat/flowtable.c') diff --git a/usr.bin/netstat/flowtable.c b/usr.bin/netstat/flowtable.c index a232d801c1e6..c00dfd649f17 100644 --- a/usr.bin/netstat/flowtable.c +++ b/usr.bin/netstat/flowtable.c @@ -28,13 +28,15 @@ #include __FBSDID("$FreeBSD$"); + #include -#include + #include -#include + #include #include #include + #include "netstat.h" /* @@ -68,17 +70,18 @@ void flowtable_stats(void) { struct flowtable_stat stat; - size_t len = sizeof(stat); if (!live) return; - if (sysctlbyname("net.flowtable.ip4.stat", &stat, &len, NULL, 0) == 0) { + if (fetch_stats("net.flowtable.ip4.stat", 0, &stat, + sizeof(stat), NULL) == 0) { printf("flowtable for IPv4:\n"); print_stats(&stat); } - if (sysctlbyname("net.flowtable.ip6.stat", &stat, &len, NULL, 0) == 0) { + if (fetch_stats("net.flowtable.ip6.stat", 0, &stat, + sizeof(stat), NULL) == 0) { printf("flowtable for IPv6:\n"); print_stats(&stat); } -- cgit v1.2.3