|
Lines 1-5
Link Here
|
| 1 |
--- src/wireless.c.orig 2004-03-09 20:39:17.000000000 +0100 |
1 |
--- src/wireless.c.orig 2004-03-09 19:39:17 UTC |
| 2 |
+++ src/wireless.c 2007-11-01 17:58:13.170763665 +0100 |
2 |
+++ src/wireless.c |
| 3 |
@@ -25,7 +25,13 @@ |
3 |
@@ -25,7 +25,13 @@ |
| 4 |
#include <net/if_mib.h> |
4 |
#include <net/if_mib.h> |
| 5 |
#include <net/if_var.h> |
5 |
#include <net/if_var.h> |
|
Lines 14-20
Link Here
|
| 14 |
#else |
14 |
#else |
| 15 |
#error "sorry, your OS is not supported yet" |
15 |
#error "sorry, your OS is not supported yet" |
| 16 |
#endif |
16 |
#endif |
| 17 |
@@ -143,6 +149,7 @@ |
17 |
@@ -138,11 +144,13 @@ int get_wlaniface(int old, int dir) |
|
|
18 |
int i, max, step, found, index; |
| 19 |
struct ifmibdata ifmd; |
| 20 |
struct ifmediareq ifmr; |
| 21 |
- int name[6], len, s; |
| 22 |
+ int name[6], s; |
| 23 |
+ size_t len; |
| 24 |
char *iface[IFNAMSIZ]; |
| 18 |
|
25 |
|
| 19 |
max = get_max_ifs(); |
26 |
max = get_max_ifs(); |
| 20 |
step = 0; |
27 |
step = 0; |
|
Lines 22-28
Link Here
|
| 22 |
|
29 |
|
| 23 |
if (old > max) |
30 |
if (old > max) |
| 24 |
old = max; /* just be sure to not be out of bounds */ |
31 |
old = max; /* just be sure to not be out of bounds */ |
| 25 |
@@ -178,8 +185,8 @@ |
32 |
@@ -178,8 +186,8 @@ int get_wlaniface(int old, int dir) |
| 26 |
len = sizeof(ifmd); |
33 |
len = sizeof(ifmd); |
| 27 |
sysctl(name, 6, &ifmd, &len, NULL, 0); |
34 |
sysctl(name, 6, &ifmd, &len, NULL, 0); |
| 28 |
|
35 |
|
|
Lines 33-39
Link Here
|
| 33 |
continue; |
40 |
continue; |
| 34 |
|
41 |
|
| 35 |
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); |
42 |
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); |
| 36 |
@@ -193,9 +200,11 @@ |
43 |
@@ -193,9 +201,11 @@ int get_wlaniface(int old, int dir) |
| 37 |
|
44 |
|
| 38 |
if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) |
45 |
if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) |
| 39 |
{ |
46 |
{ |
|
Lines 47-53
Link Here
|
| 47 |
} |
54 |
} |
| 48 |
close(s); |
55 |
close(s); |
| 49 |
/* we cannot monitor interfaces in hostap mode, so just |
56 |
/* we cannot monitor interfaces in hostap mode, so just |
| 50 |
@@ -207,6 +216,10 @@ |
57 |
@@ -207,12 +217,17 @@ int get_wlaniface(int old, int dir) |
| 51 |
found++; |
58 |
found++; |
| 52 |
} |
59 |
} |
| 53 |
} |
60 |
} |
|
Lines 58-64
Link Here
|
| 58 |
return index; |
65 |
return index; |
| 59 |
} |
66 |
} |
| 60 |
/* how many interfaces do we have? this includes non-wireless! */ |
67 |
/* how many interfaces do we have? this includes non-wireless! */ |
| 61 |
@@ -224,9 +237,18 @@ |
68 |
int get_max_ifs(void) |
|
|
69 |
{ |
| 70 |
- int count, len; |
| 71 |
+ int count; |
| 72 |
+ size_t len; |
| 73 |
|
| 74 |
len = sizeof(count); |
| 75 |
sysctlbyname("net.link.generic.system.ifcount", &count, &len, NULL, 0); |
| 76 |
@@ -220,13 +235,23 @@ int get_max_ifs(void) |
| 77 |
} |
| 78 |
int wifi_info(struct wifi *wfi) |
| 79 |
{ |
| 80 |
- int name[6], len; /* interface name */ |
| 81 |
+ int name[6]; /* interface name */ |
| 82 |
+ size_t len; |
| 62 |
struct ifmibdata ifmd; |
83 |
struct ifmibdata ifmd; |
| 63 |
|
84 |
|
| 64 |
struct ifreq ifr; /* interface stats */ |
85 |
struct ifreq ifr; /* interface stats */ |
|
Lines 77-83
Link Here
|
| 77 |
/* lets find the current interface name */ |
98 |
/* lets find the current interface name */ |
| 78 |
name[0] = CTL_NET; |
99 |
name[0] = CTL_NET; |
| 79 |
name[1] = PF_LINK; |
100 |
name[1] = PF_LINK; |
| 80 |
@@ -247,13 +269,38 @@ |
101 |
@@ -247,13 +272,38 @@ int wifi_info(struct wifi *wfi) |
| 81 |
perror("socket"); |
102 |
perror("socket"); |
| 82 |
exit(1); |
103 |
exit(1); |
| 83 |
} |
104 |
} |
|
Lines 117-123
Link Here
|
| 117 |
strncpy(ifr.ifr_name, wfi->ifname, strlen(wfi->ifname)); |
138 |
strncpy(ifr.ifr_name, wfi->ifname, strlen(wfi->ifname)); |
| 118 |
wireq.wi_type = WI_RID_COMMS_QUALITY; |
139 |
wireq.wi_type = WI_RID_COMMS_QUALITY; |
| 119 |
wireq.wi_len = WI_MAX_DATALEN; |
140 |
wireq.wi_len = WI_MAX_DATALEN; |
| 120 |
@@ -272,7 +319,7 @@ |
141 |
@@ -272,7 +322,7 @@ int wifi_info(struct wifi *wfi) |
| 121 |
* wi_val[2] = noise |
142 |
* wi_val[2] = noise |
| 122 |
*/ |
143 |
*/ |
| 123 |
wfi->link = (int) wireq.wi_val[1]; |
144 |
wfi->link = (int) wireq.wi_val[1]; |