diff options
author | martin <martin> | 2002-05-24 18:12:36 +0000 |
---|---|---|
committer | martin <martin> | 2002-05-24 18:12:36 +0000 |
commit | 68364f7d69f54b7db469a703d8644181fd170df0 (patch) | |
tree | e55e2d52a2f329e67bf968c64585d5541809f46e /net/pload/patches/patch-aa | |
parent | 380ed5a9632e6d8f54f2f2ee2ba6f7d5d1070587 (diff) | |
download | pkgsrc-68364f7d69f54b7db469a703d8644181fd170df0.tar.gz |
If the SIOCGIFDATA ioctl is available, use that instead of the PPP
specific one. This makes the tool useable on any network interface.
Diffstat (limited to 'net/pload/patches/patch-aa')
-rw-r--r-- | net/pload/patches/patch-aa | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/net/pload/patches/patch-aa b/net/pload/patches/patch-aa index be744407c0e..dccb394dde9 100644 --- a/net/pload/patches/patch-aa +++ b/net/pload/patches/patch-aa @@ -1,18 +1,22 @@ -$NetBSD: patch-aa,v 1.2 2002/01/29 13:46:17 wiz Exp $ +$NetBSD: patch-aa,v 1.3 2002/05/24 18:12:36 martin Exp $ --- ioctl_stat.c.orig Thu Mar 4 08:33:03 1999 -+++ ioctl_stat.c -@@ -68,6 +68,9 @@ ++++ ioctl_stat.c Fri May 24 20:03:05 2002 +@@ -68,6 +68,13 @@ void ioctl_stat(if_data *ifd) { +#ifdef __NetBSD__ + struct ifreq ifr; ++#ifdef SIOCGIFDATA ++ struct ifdatareq ifdr; ++ struct if_data * const ifi = &ifdr.ifdr_data; ++#endif +#endif struct ifpppstatsreq req; if (s < 0) getsocket(); -@@ -78,8 +81,20 @@ +@@ -78,8 +85,33 @@ #define ifr_name ifr__name req.stats_ptr = (caddr_t) &req.stats; #endif @@ -30,7 +34,28 @@ $NetBSD: patch-aa,v 1.2 2002/01/29 13:46:17 wiz Exp $ + } +#endif + ++#if defined(__NetBSD__) && defined(SIOCGIFDATA) ++ /* prefere the generic interface statistics over the PPP specific ones */ ++ strncpy(ifdr.ifdr_name, ifd->device, sizeof(ifdr.ifdr_name)); ++ if (ioctl(s, SIOCGIFDATA, &ifdr) == -1) ++ { ++ /* non-existant device? */ ++ ifd->in_bytes = 0UL; ++ ifd->out_bytes = 0UL; ++ return; ++ } ++ ifd->in_bytes = (unsigned long)ifi->ifi_ibytes; ++ ifd->out_bytes = (unsigned long)ifi->ifi_obytes; ++#else + sprintf(req.ifr_name, ifd->device); if (ioctl(s, SIOCGPPPSTATS, &req) != 0) { /* non-existant device? */ +@@ -90,6 +122,7 @@ + + ifd->in_bytes = (unsigned long)req.stats.p.ppp_ibytes; + ifd->out_bytes = (unsigned long)req.stats.p.ppp_obytes; ++#endif + + return; + } |