summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/netstat/main.c')
-rw-r--r--usr.bin/netstat/main.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index e8cf914..4e4428d 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -551,15 +551,15 @@ main(int argc, char *argv[])
exit(0);
}
-int
-fetch_stats(const char *sysctlname, u_long off, void *stats, size_t len,
- int (*kreadfn)(u_long, void *, size_t))
+static int
+fetch_stats_internal(const char *sysctlname, u_long off, void *stats,
+ size_t len, kreadfn_t kreadfn, int zero)
{
int error;
if (live) {
memset(stats, 0, len);
- if (zflag)
+ if (zero)
error = sysctlbyname(sysctlname, NULL, NULL, stats,
len);
else
@@ -574,6 +574,23 @@ fetch_stats(const char *sysctlname, u_long off, void *stats, size_t len,
return (error);
}
+int
+fetch_stats(const char *sysctlname, u_long off, void *stats,
+ size_t len, kreadfn_t kreadfn)
+{
+
+ return (fetch_stats_internal(sysctlname, off, stats, len, kreadfn,
+ zflag));
+}
+
+int
+fetch_stats_ro(const char *sysctlname, u_long off, void *stats,
+ size_t len, kreadfn_t kreadfn)
+{
+
+ return (fetch_stats_internal(sysctlname, off, stats, len, kreadfn, 0));
+}
+
/*
* Print out protocol statistics or control blocks (per sflag).
* If the interface was not specifically requested, and the symbol
OpenPOWER on IntegriCloud