[package] uhttpd: provide rpath-link flag, thanks mazilo
[openwrt.git] / package / hostapd / patches / 310-madwifi_merge.patch
1 --- a/src/drivers/driver_madwifi.c
2 +++ b/src/drivers/driver_madwifi.c
3 @@ -71,7 +71,6 @@
4
5 #define WPA_KEY_RSC_LEN 8
6
7 -#ifdef HOSTAPD
8
9 #include "priv_netlink.h"
10 #include "netlink.h"
11 @@ -82,17 +81,22 @@
12 struct madwifi_driver_data {
13 struct hostapd_data *hapd; /* back pointer */
14
15 - char iface[IFNAMSIZ + 1];
16 + void *wext; /* private data for driver_wext */
17 + void *ctx;
18 + char ifname[IFNAMSIZ + 1];
19 + int ioctl_sock; /* socket for ioctl() use */
20 +
21 +#ifdef HOSTAPD
22 int ifindex;
23 struct l2_packet_data *sock_xmit; /* raw packet xmit socket */
24 struct l2_packet_data *sock_recv; /* raw packet recv socket */
25 - int ioctl_sock; /* socket for ioctl() use */
26 struct netlink_data *netlink;
27 int we_version;
28 u8 acct_mac[ETH_ALEN];
29 struct hostap_sta_driver_data acct_data;
30
31 struct l2_packet_data *sock_raw; /* raw 802.11 management frames */
32 +#endif
33 };
34
35 static int madwifi_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
36 @@ -105,7 +109,7 @@ set80211priv(struct madwifi_driver_data
37 int do_inline = len < IFNAMSIZ;
38
39 memset(&iwr, 0, sizeof(iwr));
40 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
41 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
42 #ifdef IEEE80211_IOCTL_FILTERFRAME
43 /* FILTERFRAME must be NOT inline, regardless of size. */
44 if (op == IEEE80211_IOCTL_FILTERFRAME)
45 @@ -206,7 +210,7 @@ set80211param(struct madwifi_driver_data
46 struct iwreq iwr;
47
48 memset(&iwr, 0, sizeof(iwr));
49 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
50 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
51 iwr.u.mode = op;
52 memcpy(iwr.u.name+sizeof(__u32), &arg, sizeof(arg));
53
54 @@ -233,6 +237,7 @@ ether_sprintf(const u8 *addr)
55 }
56 #endif /* CONFIG_NO_STDOUT_DEBUG */
57
58 +#ifdef HOSTAPD
59 /*
60 * Configure WPA parameters.
61 */
62 @@ -395,7 +400,7 @@ madwifi_sta_set_flags(void *priv, const
63 return madwifi_set_sta_authorized(priv, addr, 0);
64 return 0;
65 }
66 -
67 +#endif /* HOSTAPD */
68 static int
69 madwifi_del_key(void *priv, const u8 *addr, int key_idx)
70 {
71 @@ -407,28 +412,20 @@ madwifi_del_key(void *priv, const u8 *ad
72 __func__, ether_sprintf(addr), key_idx);
73
74 memset(&wk, 0, sizeof(wk));
75 + wk.idk_keyix = key_idx;
76 if (addr != NULL) {
77 memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
78 - wk.idk_keyix = (u8) IEEE80211_KEYIX_NONE;
79 - } else {
80 - wk.idk_keyix = key_idx;
81 - }
82 -
83 - ret = set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk));
84 - if (ret < 0) {
85 - wpa_printf(MSG_DEBUG, "%s: Failed to delete key (addr %s"
86 - " key_idx %d)", __func__, ether_sprintf(addr),
87 - key_idx);
88 }
89
90 - return ret;
91 + set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk));
92 + return 0;
93 }
94
95 static int
96 -wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
97 - const u8 *addr, int key_idx, int set_tx,
98 - const u8 *seq, size_t seq_len,
99 - const u8 *key, size_t key_len)
100 +madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
101 + const u8 *addr, int key_idx, int set_tx,
102 + const u8 *seq, size_t seq_len,
103 + const u8 *key, size_t key_len)
104 {
105 struct madwifi_driver_data *drv = priv;
106 struct ieee80211req_key wk;
107 @@ -466,6 +463,9 @@ wpa_driver_madwifi_set_key(const char *i
108 memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
109 wk.ik_keyix = key_idx;
110 wk.ik_flags |= IEEE80211_KEY_DEFAULT;
111 + } else if (!memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN)) {
112 + wk.ik_flags |= IEEE80211_KEY_GROUP;
113 + memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
114 } else {
115 memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
116 wk.ik_keyix = IEEE80211_KEYIX_NONE;
117 @@ -485,6 +485,7 @@ wpa_driver_madwifi_set_key(const char *i
118 }
119
120
121 +#ifdef HOSTAPD
122 static int
123 madwifi_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
124 u8 *seq)
125 @@ -591,7 +592,7 @@ madwifi_read_sta_driver_data(void *priv,
126
127 memset(data, 0, sizeof(*data));
128 snprintf(buf, sizeof(buf), "/proc/net/madwifi/%s/" MACSTR,
129 - drv->iface, MAC2STR(addr));
130 + drv->ifname, MAC2STR(addr));
131
132 f = fopen(buf, "r");
133 if (!f) {
134 @@ -759,7 +760,7 @@ static int madwifi_receive_probe_req(str
135 if (ret)
136 return ret;
137
138 - drv->sock_raw = l2_packet_init(drv->iface, NULL, ETH_P_80211_RAW,
139 + drv->sock_raw = l2_packet_init(drv->ifname, NULL, ETH_P_80211_RAW,
140 madwifi_raw_receive, drv, 1);
141 if (drv->sock_raw == NULL)
142 return -1;
143 @@ -812,7 +813,7 @@ static int madwifi_set_freq(void *priv,
144 struct iwreq iwr;
145
146 os_memset(&iwr, 0, sizeof(iwr));
147 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
148 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
149 iwr.u.freq.m = freq->channel;
150 iwr.u.freq.e = 0;
151
152 @@ -1037,7 +1038,7 @@ madwifi_get_we_version(struct madwifi_dr
153 return -1;
154
155 memset(&iwr, 0, sizeof(iwr));
156 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
157 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
158 iwr.u.data.pointer = (caddr_t) range;
159 iwr.u.data.length = buflen;
160
161 @@ -1154,17 +1155,17 @@ madwifi_init(struct hostapd_data *hapd,
162 perror("socket[PF_INET,SOCK_DGRAM]");
163 goto bad;
164 }
165 - memcpy(drv->iface, params->ifname, sizeof(drv->iface));
166 + memcpy(drv->ifname, params->ifname, sizeof(drv->ifname));
167
168 memset(&ifr, 0, sizeof(ifr));
169 - os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
170 + os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
171 if (ioctl(drv->ioctl_sock, SIOCGIFINDEX, &ifr) != 0) {
172 perror("ioctl(SIOCGIFINDEX)");
173 goto bad;
174 }
175 drv->ifindex = ifr.ifr_ifindex;
176
177 - drv->sock_xmit = l2_packet_init(drv->iface, NULL, ETH_P_EAPOL,
178 + drv->sock_xmit = l2_packet_init(drv->ifname, NULL, ETH_P_EAPOL,
179 handle_read, drv, 1);
180 if (drv->sock_xmit == NULL)
181 goto bad;
182 @@ -1178,7 +1179,7 @@ madwifi_init(struct hostapd_data *hapd,
183 1);
184 if (drv->sock_recv == NULL)
185 goto bad;
186 - } else if (linux_br_get(brname, drv->iface) == 0) {
187 + } else if (linux_br_get(brname, drv->ifname) == 0) {
188 wpa_printf(MSG_DEBUG, "Interface in bridge %s; configure for "
189 "EAPOL receive", brname);
190 drv->sock_recv = l2_packet_init(brname, NULL, ETH_P_EAPOL,
191 @@ -1189,7 +1190,7 @@ madwifi_init(struct hostapd_data *hapd,
192 drv->sock_recv = drv->sock_xmit;
193
194 memset(&iwr, 0, sizeof(iwr));
195 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
196 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
197
198 iwr.u.mode = IW_MODE_MASTER;
199
200 @@ -1200,7 +1201,7 @@ madwifi_init(struct hostapd_data *hapd,
201 }
202
203 /* mark down during setup */
204 - linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
205 + linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0);
206 madwifi_set_privacy(drv, 0); /* default to no privacy */
207
208 madwifi_receive_probe_req(drv);
209 @@ -1226,7 +1227,7 @@ madwifi_deinit(void *priv)
210 struct madwifi_driver_data *drv = priv;
211
212 netlink_deinit(drv->netlink);
213 - (void) linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
214 + (void) linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0);
215 if (drv->ioctl_sock >= 0)
216 close(drv->ioctl_sock);
217 if (drv->sock_recv != NULL && drv->sock_recv != drv->sock_xmit)
218 @@ -1245,7 +1246,7 @@ madwifi_set_ssid(void *priv, const u8 *b
219 struct iwreq iwr;
220
221 memset(&iwr, 0, sizeof(iwr));
222 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
223 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
224 iwr.u.essid.flags = 1; /* SSID active */
225 iwr.u.essid.pointer = (caddr_t) buf;
226 iwr.u.essid.length = len + 1;
227 @@ -1266,7 +1267,7 @@ madwifi_get_ssid(void *priv, u8 *buf, in
228 int ret = 0;
229
230 memset(&iwr, 0, sizeof(iwr));
231 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
232 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
233 iwr.u.essid.pointer = (caddr_t) buf;
234 iwr.u.essid.length = len;
235
236 @@ -1291,140 +1292,19 @@ static int
237 madwifi_commit(void *priv)
238 {
239 struct madwifi_driver_data *drv = priv;
240 - return linux_set_iface_flags(drv->ioctl_sock, drv->iface, 1);
241 + return linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1);
242 }
243
244 -#else /* HOSTAPD */
245 +#endif /* HOSTAPD */
246
247 -struct wpa_driver_madwifi_data {
248 - void *wext; /* private data for driver_wext */
249 - void *ctx;
250 - char ifname[IFNAMSIZ + 1];
251 - int sock;
252 -};
253 +#if !defined(NO_SUPPLICANT)
254
255 static int wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg);
256 static int wpa_driver_madwifi_set_probe_req_ie(void *priv, const u8 *ies,
257 size_t ies_len);
258
259 -
260 -static int
261 -set80211priv(struct wpa_driver_madwifi_data *drv, int op, void *data, int len,
262 - int show_err)
263 -{
264 - struct iwreq iwr;
265 -
266 - os_memset(&iwr, 0, sizeof(iwr));
267 - os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
268 - if (len < IFNAMSIZ &&
269 - op != IEEE80211_IOCTL_SET_APPIEBUF) {
270 - /*
271 - * Argument data fits inline; put it there.
272 - */
273 - os_memcpy(iwr.u.name, data, len);
274 - } else {
275 - /*
276 - * Argument data too big for inline transfer; setup a
277 - * parameter block instead; the kernel will transfer
278 - * the data for the driver.
279 - */
280 - iwr.u.data.pointer = data;
281 - iwr.u.data.length = len;
282 - }
283 -
284 - if (ioctl(drv->sock, op, &iwr) < 0) {
285 - if (show_err) {
286 -#ifdef MADWIFI_NG
287 - int first = IEEE80211_IOCTL_SETPARAM;
288 - int last = IEEE80211_IOCTL_KICKMAC;
289 - static const char *opnames[] = {
290 - "ioctl[IEEE80211_IOCTL_SETPARAM]",
291 - "ioctl[IEEE80211_IOCTL_GETPARAM]",
292 - "ioctl[IEEE80211_IOCTL_SETMODE]",
293 - "ioctl[IEEE80211_IOCTL_GETMODE]",
294 - "ioctl[IEEE80211_IOCTL_SETWMMPARAMS]",
295 - "ioctl[IEEE80211_IOCTL_GETWMMPARAMS]",
296 - "ioctl[IEEE80211_IOCTL_SETCHANLIST]",
297 - "ioctl[IEEE80211_IOCTL_GETCHANLIST]",
298 - "ioctl[IEEE80211_IOCTL_CHANSWITCH]",
299 - NULL,
300 - "ioctl[IEEE80211_IOCTL_SET_APPIEBUF]",
301 - "ioctl[IEEE80211_IOCTL_GETSCANRESULTS]",
302 - NULL,
303 - "ioctl[IEEE80211_IOCTL_GETCHANINFO]",
304 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
305 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
306 - "ioctl[IEEE80211_IOCTL_SETMLME]",
307 - NULL,
308 - "ioctl[IEEE80211_IOCTL_SETKEY]",
309 - NULL,
310 - "ioctl[IEEE80211_IOCTL_DELKEY]",
311 - NULL,
312 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
313 - NULL,
314 - "ioctl[IEEE80211_IOCTL_DELMAC]",
315 - NULL,
316 - "ioctl[IEEE80211_IOCTL_WDSMAC]",
317 - NULL,
318 - "ioctl[IEEE80211_IOCTL_WDSDELMAC]",
319 - NULL,
320 - "ioctl[IEEE80211_IOCTL_KICKMAC]",
321 - };
322 -#else /* MADWIFI_NG */
323 - int first = IEEE80211_IOCTL_SETPARAM;
324 - int last = IEEE80211_IOCTL_CHANLIST;
325 - static const char *opnames[] = {
326 - "ioctl[IEEE80211_IOCTL_SETPARAM]",
327 - "ioctl[IEEE80211_IOCTL_GETPARAM]",
328 - "ioctl[IEEE80211_IOCTL_SETKEY]",
329 - "ioctl[IEEE80211_IOCTL_GETKEY]",
330 - "ioctl[IEEE80211_IOCTL_DELKEY]",
331 - NULL,
332 - "ioctl[IEEE80211_IOCTL_SETMLME]",
333 - NULL,
334 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
335 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
336 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
337 - NULL,
338 - "ioctl[IEEE80211_IOCTL_DELMAC]",
339 - NULL,
340 - "ioctl[IEEE80211_IOCTL_CHANLIST]",
341 - };
342 -#endif /* MADWIFI_NG */
343 - int idx = op - first;
344 - if (first <= op && op <= last &&
345 - idx < (int) (sizeof(opnames) / sizeof(opnames[0]))
346 - && opnames[idx])
347 - perror(opnames[idx]);
348 - else
349 - perror("ioctl[unknown???]");
350 - }
351 - return -1;
352 - }
353 - return 0;
354 -}
355 -
356 static int
357 -set80211param(struct wpa_driver_madwifi_data *drv, int op, int arg,
358 - int show_err)
359 -{
360 - struct iwreq iwr;
361 -
362 - os_memset(&iwr, 0, sizeof(iwr));
363 - os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
364 - iwr.u.mode = op;
365 - os_memcpy(iwr.u.name+sizeof(u32), &arg, sizeof(arg));
366 -
367 - if (ioctl(drv->sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
368 - if (show_err)
369 - perror("ioctl[IEEE80211_IOCTL_SETPARAM]");
370 - return -1;
371 - }
372 - return 0;
373 -}
374 -
375 -static int
376 -wpa_driver_madwifi_set_wpa_ie(struct wpa_driver_madwifi_data *drv,
377 +wpa_driver_madwifi_set_wpa_ie(struct madwifi_driver_data *drv,
378 const u8 *wpa_ie, size_t wpa_ie_len)
379 {
380 struct iwreq iwr;
381 @@ -1435,7 +1315,7 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
382 iwr.u.data.pointer = (void *) wpa_ie;
383 iwr.u.data.length = wpa_ie_len;
384
385 - if (ioctl(drv->sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
386 + if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
387 perror("ioctl[IEEE80211_IOCTL_SETOPTIE]");
388 return -1;
389 }
390 @@ -1443,157 +1323,51 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
391 }
392
393 static int
394 -wpa_driver_madwifi_del_key(struct wpa_driver_madwifi_data *drv, int key_idx,
395 - const u8 *addr)
396 -{
397 - struct ieee80211req_del_key wk;
398 -
399 - wpa_printf(MSG_DEBUG, "%s: keyidx=%d", __FUNCTION__, key_idx);
400 - os_memset(&wk, 0, sizeof(wk));
401 - wk.idk_keyix = key_idx;
402 - if (addr != NULL)
403 - os_memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
404 -
405 - return set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk), 1);
406 -}
407 -
408 -static int
409 -wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
410 - const u8 *addr, int key_idx, int set_tx,
411 - const u8 *seq, size_t seq_len,
412 - const u8 *key, size_t key_len)
413 -{
414 - struct wpa_driver_madwifi_data *drv = priv;
415 - struct ieee80211req_key wk;
416 - char *alg_name;
417 - u_int8_t cipher;
418 -
419 - if (alg == WPA_ALG_NONE)
420 - return wpa_driver_madwifi_del_key(drv, key_idx, addr);
421 -
422 - switch (alg) {
423 - case WPA_ALG_WEP:
424 - if (addr == NULL || os_memcmp(addr, "\xff\xff\xff\xff\xff\xff",
425 - ETH_ALEN) == 0) {
426 - /*
427 - * madwifi did not seem to like static WEP key
428 - * configuration with IEEE80211_IOCTL_SETKEY, so use
429 - * Linux wireless extensions ioctl for this.
430 - */
431 - return wpa_driver_wext_set_key(ifname, drv->wext, alg,
432 - addr, key_idx, set_tx,
433 - seq, seq_len,
434 - key, key_len);
435 - }
436 - alg_name = "WEP";
437 - cipher = IEEE80211_CIPHER_WEP;
438 - break;
439 - case WPA_ALG_TKIP:
440 - alg_name = "TKIP";
441 - cipher = IEEE80211_CIPHER_TKIP;
442 - break;
443 - case WPA_ALG_CCMP:
444 - alg_name = "CCMP";
445 - cipher = IEEE80211_CIPHER_AES_CCM;
446 - break;
447 - default:
448 - wpa_printf(MSG_DEBUG, "%s: unknown/unsupported algorithm %d",
449 - __FUNCTION__, alg);
450 - return -1;
451 - }
452 -
453 - wpa_printf(MSG_DEBUG, "%s: alg=%s key_idx=%d set_tx=%d seq_len=%lu "
454 - "key_len=%lu", __FUNCTION__, alg_name, key_idx, set_tx,
455 - (unsigned long) seq_len, (unsigned long) key_len);
456 -
457 - if (seq_len > sizeof(u_int64_t)) {
458 - wpa_printf(MSG_DEBUG, "%s: seq_len %lu too big",
459 - __FUNCTION__, (unsigned long) seq_len);
460 - return -2;
461 - }
462 - if (key_len > sizeof(wk.ik_keydata)) {
463 - wpa_printf(MSG_DEBUG, "%s: key length %lu too big",
464 - __FUNCTION__, (unsigned long) key_len);
465 - return -3;
466 - }
467 -
468 - os_memset(&wk, 0, sizeof(wk));
469 - wk.ik_type = cipher;
470 - wk.ik_flags = IEEE80211_KEY_RECV;
471 - if (addr == NULL ||
472 - os_memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0)
473 - wk.ik_flags |= IEEE80211_KEY_GROUP;
474 - if (set_tx) {
475 - wk.ik_flags |= IEEE80211_KEY_XMIT | IEEE80211_KEY_DEFAULT;
476 - os_memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
477 - } else
478 - os_memset(wk.ik_macaddr, 0, IEEE80211_ADDR_LEN);
479 - wk.ik_keyix = key_idx;
480 - wk.ik_keylen = key_len;
481 -#ifdef WORDS_BIGENDIAN
482 - if (seq) {
483 - size_t i;
484 - u8 tmp[WPA_KEY_RSC_LEN];
485 - os_memset(tmp, 0, sizeof(tmp));
486 - for (i = 0; i < seq_len; i++)
487 - tmp[WPA_KEY_RSC_LEN - i - 1] = seq[i];
488 - os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
489 - }
490 -#else /* WORDS_BIGENDIAN */
491 - if (seq)
492 - os_memcpy(&wk.ik_keyrsc, seq, seq_len);
493 -#endif /* WORDS_BIGENDIAN */
494 - os_memcpy(wk.ik_keydata, key, key_len);
495 -
496 - return set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk), 1);
497 -}
498 -
499 -static int
500 wpa_driver_madwifi_set_countermeasures(void *priv, int enabled)
501 {
502 - struct wpa_driver_madwifi_data *drv = priv;
503 + struct madwifi_driver_data *drv = priv;
504 wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
505 - return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled, 1);
506 + return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled);
507 }
508
509 static int
510 wpa_driver_madwifi_deauthenticate(void *priv, const u8 *addr, int reason_code)
511 {
512 - struct wpa_driver_madwifi_data *drv = priv;
513 + struct madwifi_driver_data *drv = priv;
514 struct ieee80211req_mlme mlme;
515
516 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
517 mlme.im_op = IEEE80211_MLME_DEAUTH;
518 mlme.im_reason = reason_code;
519 os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
520 - return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme), 1);
521 + return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
522 }
523
524 static int
525 wpa_driver_madwifi_disassociate(void *priv, const u8 *addr, int reason_code)
526 {
527 - struct wpa_driver_madwifi_data *drv = priv;
528 + struct madwifi_driver_data *drv = priv;
529 struct ieee80211req_mlme mlme;
530
531 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
532 mlme.im_op = IEEE80211_MLME_DISASSOC;
533 mlme.im_reason = reason_code;
534 os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
535 - return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme), 1);
536 + return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
537 }
538
539 static int
540 wpa_driver_madwifi_associate(void *priv,
541 struct wpa_driver_associate_params *params)
542 {
543 - struct wpa_driver_madwifi_data *drv = priv;
544 + struct madwifi_driver_data *drv = priv;
545 struct ieee80211req_mlme mlme;
546 int ret = 0, privacy = 1;
547
548 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
549
550 if (set80211param(drv, IEEE80211_PARAM_DROPUNENCRYPTED,
551 - params->drop_unencrypted, 1) < 0)
552 + params->drop_unencrypted) < 0)
553 ret = -1;
554 if (wpa_driver_madwifi_set_auth_alg(drv, params->auth_alg) < 0)
555 ret = -1;
556 @@ -1616,12 +1390,12 @@ wpa_driver_madwifi_associate(void *priv,
557 params->wpa_ie_len == 0)
558 privacy = 0;
559
560 - if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy, 1) < 0)
561 + if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy) < 0)
562 ret = -1;
563
564 if (params->wpa_ie_len &&
565 set80211param(drv, IEEE80211_PARAM_WPA,
566 - params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1, 1) < 0)
567 + params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1) < 0)
568 ret = -1;
569
570 if (params->bssid == NULL) {
571 @@ -1629,14 +1403,14 @@ wpa_driver_madwifi_associate(void *priv,
572 * roaming */
573 /* FIX: this does not seem to work; would probably need to
574 * change something in the driver */
575 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0)
576 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0) < 0)
577 ret = -1;
578
579 if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
580 params->ssid_len) < 0)
581 ret = -1;
582 } else {
583 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0)
584 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0)
585 ret = -1;
586 if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
587 params->ssid_len) < 0)
588 @@ -1645,7 +1419,7 @@ wpa_driver_madwifi_associate(void *priv,
589 mlme.im_op = IEEE80211_MLME_ASSOC;
590 os_memcpy(mlme.im_macaddr, params->bssid, IEEE80211_ADDR_LEN);
591 if (set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
592 - sizeof(mlme), 1) < 0) {
593 + sizeof(mlme)) < 0) {
594 wpa_printf(MSG_DEBUG, "%s: SETMLME[ASSOC] failed",
595 __func__);
596 ret = -1;
597 @@ -1658,7 +1432,7 @@ wpa_driver_madwifi_associate(void *priv,
598 static int
599 wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg)
600 {
601 - struct wpa_driver_madwifi_data *drv = priv;
602 + struct madwifi_driver_data *drv = priv;
603 int authmode;
604
605 if ((auth_alg & WPA_AUTH_ALG_OPEN) &&
606 @@ -1669,13 +1443,13 @@ wpa_driver_madwifi_set_auth_alg(void *pr
607 else
608 authmode = IEEE80211_AUTH_OPEN;
609
610 - return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode, 1);
611 + return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode);
612 }
613
614 static int
615 wpa_driver_madwifi_scan(void *priv, struct wpa_driver_scan_params *params)
616 {
617 - struct wpa_driver_madwifi_data *drv = priv;
618 + struct madwifi_driver_data *drv = priv;
619 struct iwreq iwr;
620 int ret = 0;
621 const u8 *ssid = params->ssids[0].ssid;
622 @@ -1693,7 +1467,7 @@ wpa_driver_madwifi_scan(void *priv, stru
623 if (wpa_driver_wext_set_ssid(drv->wext, ssid, ssid_len) < 0)
624 ret = -1;
625
626 - if (ioctl(drv->sock, SIOCSIWSCAN, &iwr) < 0) {
627 + if (ioctl(drv->ioctl_sock, SIOCSIWSCAN, &iwr) < 0) {
628 perror("ioctl[SIOCSIWSCAN]");
629 ret = -1;
630 }
631 @@ -1715,14 +1489,14 @@ wpa_driver_madwifi_scan(void *priv, stru
632
633 static int wpa_driver_madwifi_get_bssid(void *priv, u8 *bssid)
634 {
635 - struct wpa_driver_madwifi_data *drv = priv;
636 + struct madwifi_driver_data *drv = priv;
637 return wpa_driver_wext_get_bssid(drv->wext, bssid);
638 }
639
640
641 static int wpa_driver_madwifi_get_ssid(void *priv, u8 *ssid)
642 {
643 - struct wpa_driver_madwifi_data *drv = priv;
644 + struct madwifi_driver_data *drv = priv;
645 return wpa_driver_wext_get_ssid(drv->wext, ssid);
646 }
647
648 @@ -1730,14 +1504,16 @@ static int wpa_driver_madwifi_get_ssid(v
649 static struct wpa_scan_results *
650 wpa_driver_madwifi_get_scan_results(void *priv)
651 {
652 - struct wpa_driver_madwifi_data *drv = priv;
653 + struct madwifi_driver_data *drv = priv;
654 return wpa_driver_wext_get_scan_results(drv->wext);
655 }
656
657
658 static int wpa_driver_madwifi_set_operstate(void *priv, int state)
659 {
660 - struct wpa_driver_madwifi_data *drv = priv;
661 + struct madwifi_driver_data *drv = priv;
662 + if (!drv->wext)
663 + return 0;
664 return wpa_driver_wext_set_operstate(drv->wext, state);
665 }
666
667 @@ -1758,7 +1534,7 @@ static int wpa_driver_madwifi_set_probe_
668
669 ret = set80211priv(priv, IEEE80211_IOCTL_SET_APPIEBUF, probe_req_ie,
670 sizeof(struct ieee80211req_getset_appiebuf) +
671 - ies_len, 1);
672 + ies_len);
673
674 os_free(probe_req_ie);
675
676 @@ -1768,7 +1544,7 @@ static int wpa_driver_madwifi_set_probe_
677
678 static void * wpa_driver_madwifi_init(void *ctx, const char *ifname)
679 {
680 - struct wpa_driver_madwifi_data *drv;
681 + struct madwifi_driver_data *drv;
682
683 drv = os_zalloc(sizeof(*drv));
684 if (drv == NULL)
685 @@ -1779,17 +1555,17 @@ static void * wpa_driver_madwifi_init(vo
686
687 drv->ctx = ctx;
688 os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
689 - drv->sock = socket(PF_INET, SOCK_DGRAM, 0);
690 - if (drv->sock < 0)
691 + drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
692 + if (drv->ioctl_sock < 0)
693 goto fail2;
694
695 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0) {
696 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0) {
697 wpa_printf(MSG_DEBUG, "%s: failed to set wpa_supplicant-based "
698 "roaming", __FUNCTION__);
699 goto fail3;
700 }
701
702 - if (set80211param(drv, IEEE80211_PARAM_WPA, 3, 1) < 0) {
703 + if (set80211param(drv, IEEE80211_PARAM_WPA, 3) < 0) {
704 wpa_printf(MSG_DEBUG, "%s: failed to enable WPA support",
705 __FUNCTION__);
706 goto fail3;
707 @@ -1798,7 +1574,7 @@ static void * wpa_driver_madwifi_init(vo
708 return drv;
709
710 fail3:
711 - close(drv->sock);
712 + close(drv->ioctl_sock);
713 fail2:
714 wpa_driver_wext_deinit(drv->wext);
715 fail:
716 @@ -1809,38 +1585,37 @@ fail:
717
718 static void wpa_driver_madwifi_deinit(void *priv)
719 {
720 - struct wpa_driver_madwifi_data *drv = priv;
721 + struct madwifi_driver_data *drv = priv;
722
723 if (wpa_driver_madwifi_set_wpa_ie(drv, NULL, 0) < 0) {
724 wpa_printf(MSG_DEBUG, "%s: failed to clear WPA IE",
725 __FUNCTION__);
726 }
727 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0) {
728 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0) < 0) {
729 wpa_printf(MSG_DEBUG, "%s: failed to enable driver-based "
730 "roaming", __FUNCTION__);
731 }
732 - if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0, 1) < 0) {
733 + if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0) < 0) {
734 wpa_printf(MSG_DEBUG, "%s: failed to disable forced Privacy "
735 "flag", __FUNCTION__);
736 }
737 - if (set80211param(drv, IEEE80211_PARAM_WPA, 0, 1) < 0) {
738 + if (set80211param(drv, IEEE80211_PARAM_WPA, 0) < 0) {
739 wpa_printf(MSG_DEBUG, "%s: failed to disable WPA",
740 __FUNCTION__);
741 }
742
743 wpa_driver_wext_deinit(drv->wext);
744
745 - close(drv->sock);
746 + close(drv->ioctl_sock);
747 os_free(drv);
748 }
749
750 -#endif /* HOSTAPD */
751 -
752 +#endif
753
754 const struct wpa_driver_ops wpa_driver_madwifi_ops = {
755 .name = "madwifi",
756 .desc = "MADWIFI 802.11 support (Atheros, etc.)",
757 - .set_key = wpa_driver_madwifi_set_key,
758 + .set_key = madwifi_set_key,
759 #ifdef HOSTAPD
760 .hapd_init = madwifi_init,
761 .hapd_deinit = madwifi_deinit,
762 @@ -1861,7 +1636,8 @@ const struct wpa_driver_ops wpa_driver_m
763 .commit = madwifi_commit,
764 .set_ap_wps_ie = madwifi_set_ap_wps_ie,
765 .set_freq = madwifi_set_freq,
766 -#else /* HOSTAPD */
767 +#endif /* HOSTAPD */
768 +#if !defined(NO_SUPPLICANT)
769 .get_bssid = wpa_driver_madwifi_get_bssid,
770 .get_ssid = wpa_driver_madwifi_get_ssid,
771 .init = wpa_driver_madwifi_init,
772 @@ -1873,5 +1649,5 @@ const struct wpa_driver_ops wpa_driver_m
773 .disassociate = wpa_driver_madwifi_disassociate,
774 .associate = wpa_driver_madwifi_associate,
775 .set_operstate = wpa_driver_madwifi_set_operstate,
776 -#endif /* HOSTAPD */
777 +#endif
778 };
779 --- a/src/drivers/drivers.mak
780 +++ b/src/drivers/drivers.mak
781 @@ -144,8 +144,8 @@ DRV_WPA_OBJS += ../src/drivers/driver_ro
782 endif
783
784 ifdef CONFIG_WIRELESS_EXTENSION
785 -DRV_WPA_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
786 -DRV_WPA_OBJS += ../src/drivers/driver_wext.o
787 +DRV_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
788 +DRV_OBJS += ../src/drivers/driver_wext.o
789 NEED_RFKILL=y
790 endif
791
This page took 0.08375 seconds and 5 git commands to generate.