diff options
author | martin <martin@pkgsrc.org> | 2002-05-24 18:27:16 +0000 |
---|---|---|
committer | martin <martin@pkgsrc.org> | 2002-05-24 18:27:16 +0000 |
commit | 36852534431704c967c249e92d6123f79c63874c (patch) | |
tree | d749ac0b9d1512e5624f2ba8ec83621e2d3be722 /net/wmpload | |
parent | d0b72a9b6ad3dc2c9f6226d42d6dde6d055e9dd6 (diff) | |
download | pkgsrc-36852534431704c967c249e92d6123f79c63874c.tar.gz |
Use the SIOCGIFDATA ioctl if available to make the tool usefull for
any kind of interface, not just PPP interfaces.
Diffstat (limited to 'net/wmpload')
-rw-r--r-- | net/wmpload/distinfo | 4 | ||||
-rw-r--r-- | net/wmpload/patches/patch-aa | 42 |
2 files changed, 34 insertions, 12 deletions
diff --git a/net/wmpload/distinfo b/net/wmpload/distinfo index 2d4e4d49782..53a615df2f2 100644 --- a/net/wmpload/distinfo +++ b/net/wmpload/distinfo @@ -1,6 +1,6 @@ -$NetBSD: distinfo,v 1.3 2001/07/22 16:52:30 wiz Exp $ +$NetBSD: distinfo,v 1.4 2002/05/24 18:27:16 martin Exp $ SHA1 (wmpload-0.9.4.tar.gz) = 3a589b1b64ba57ea1a073e85b150784db2cb7f9b Size (wmpload-0.9.4.tar.gz) = 21461 bytes -SHA1 (patch-aa) = 5182af48bfdeddf81bd087612272b3f43683e75c +SHA1 (patch-aa) = 0a2588b498503683835356a4cf931a9debed68f5 SHA1 (patch-ab) = 2bd0a6e27da3e79afa76c9164f3419756080d286 diff --git a/net/wmpload/patches/patch-aa b/net/wmpload/patches/patch-aa index f6d3404c8d8..3fd81869b4c 100644 --- a/net/wmpload/patches/patch-aa +++ b/net/wmpload/patches/patch-aa @@ -1,25 +1,27 @@ -$NetBSD: patch-aa,v 1.2 2001/07/22 16:52:30 wiz Exp $ +$NetBSD: patch-aa,v 1.3 2002/05/24 18:27:17 martin Exp $ --- ioctl_stat.c.orig Sat Dec 18 02:35:12 1999 -+++ ioctl_stat.c -@@ -68,6 +68,9 @@ ++++ ioctl_stat.c Fri May 24 20:22:27 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(); -@@ -79,8 +82,20 @@ +@@ -79,6 +86,31 @@ req.stats_ptr = (caddr_t) &req.stats; #endif /* sprintf(req.ifr_name, ifd->device); */ -- strncpy(req.ifr_name, ifd->device, sizeof(req.ifr_name)); - +#ifdef __NetBSD__ -+ snprintf(ifr.ifr_name, sizeof(req.ifr_name), ifd->device); ++ strncpy(ifr.ifr_name, ifd->device, sizeof(ifr.ifr_name)); + if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0 || + !(ifr.ifr_flags&IFF_UP)) + { @@ -30,7 +32,27 @@ $NetBSD: patch-aa,v 1.2 2001/07/22 16:52:30 wiz Exp $ + } +#endif + -+ strncpy(req.ifr_name, ifd->device, sizeof(req.ifr_name)); ++#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 + strncpy(req.ifr_name, ifd->device, sizeof(req.ifr_name)); + if (ioctl(s, SIOCGPPPSTATS, &req) != 0) - { - /* non-existant device? */ +@@ -91,6 +123,7 @@ + + ifd->in_bytes = (unsigned long)req.stats.p.ppp_ibytes; + ifd->out_bytes = (unsigned long)req.stats.p.ppp_obytes; ++#endif + + return; + } |