blob: be744407c0ef510d734a86c3fdd07bb65f67b1fb (
plain)
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.2 2002/01/29 13:46:17 wiz Exp $
--- ioctl_stat.c.orig Thu Mar 4 08:33:03 1999
+++ ioctl_stat.c
@@ -68,6 +68,9 @@
void ioctl_stat(if_data *ifd)
{
+#ifdef __NetBSD__
+ struct ifreq ifr;
+#endif
struct ifpppstatsreq req;
if (s < 0) getsocket();
@@ -78,8 +81,20 @@
#define ifr_name ifr__name
req.stats_ptr = (caddr_t) &req.stats;
#endif
- sprintf(req.ifr_name, ifd->device);
+#ifdef __NetBSD__
+ sprintf(ifr.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
+
+ sprintf(req.ifr_name, ifd->device);
if (ioctl(s, SIOCGPPPSTATS, &req) != 0)
{
/* non-existant device? */
|