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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
$NetBSD: patch-af,v 1.9 2004/06/26 23:56:21 xtraeme Exp $
Add some code for NetBSD to
a) check if an interface is up, and
b) get the in/out character count for that interface
--- src/apppstatus.cc.orig Sat Sep 27 08:54:45 2003
+++ src/apppstatus.cc Sun Jun 20 20:45:26 2004
@@ -358,6 +358,26 @@
return isUpIsdn();
#endif
+#ifdef __NetBSD__
+ struct ifreq ifr;
+
+ if (fNetDev == 0)
+ return false;
+
+ int s = socket(AF_INET, SOCK_DGRAM, 0);
+
+ if( s != -1 ) {
+ strncpy(ifr.ifr_name, fNetDev, sizeof(ifr.ifr_name));
+ if( ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) != -1 ) {
+ if( ifr.ifr_flags & IFF_UP ) {
+ close(s);
+ return true;
+ }
+ }
+ close(s);
+ }
+ return false;
+#else
char buffer[32 * sizeof(struct ifreq)];
struct ifconf ifc;
struct ifreq *ifr;
@@ -390,6 +410,7 @@
close(s);
return false;
+#endif
}
void NetStatus::updateStatus() {
@@ -510,6 +531,21 @@
}
}
#endif //FreeBSD
+#ifdef __NetBSD__
+ struct ifdatareq ifdr;
+ struct if_data * const ifi = &ifdr.ifdr_data;
+ int s;
+
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+ if( s != -1 ) {
+ strncpy(ifdr.ifdr_name, fNetDev, sizeof(ifdr.ifdr_name));
+ if (ioctl(s, SIOCGIFDATA, &ifdr) != -1) {
+ cur_ibytes = ifi->ifi_ibytes;
+ cur_obytes = ifi->ifi_obytes;
+ }
+ close(s);
+ }
+#endif //__NetBSD__
// correct the values and look for overflows
//msg("w/o corrections: ibytes: %lld, prev_ibytes; %lld, offset: %lld", cur_ibytes, prev_ibytes, offset_ibytes);
|