1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
$NetBSD: patch-aa,v 1.1.1.1 2000/01/25 10:54:55 abs Exp $
--- ioctl_stat.c Sat Dec 18 01:35:12 1999
+++ /tmp/ioctl_stat.c Tue Jan 25 10:32:46 2000
@@ -68,6 +68,9 @@
void ioctl_stat(if_data *ifd)
{
+#ifdef __NetBSD__
+ struct ifreq ifr;
+#endif
struct ifpppstatsreq req;
if (s < 0) getsocket();
@@ -79,8 +82,20 @@
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);
+ if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0 ||
+ !(ifr.ifr_flags&IFF_UP))
+ {
+ /* invalid interface, or interface down */
+ ifd->in_bytes = 0UL;
+ ifd->out_bytes = 0UL;
+ return;
+ }
+#endif
+
+ strncpy(req.ifr_name, ifd->device, sizeof(req.ifr_name));
if (ioctl(s, SIOCGPPPSTATS, &req) != 0)
{
/* non-existant device? */
|