1 --- a/src/drivers/driver_madwifi.c
2 +++ b/src/drivers/driver_madwifi.c
5 #define WPA_KEY_RSC_LEN 8
9 #include "priv_netlink.h"
12 struct madwifi_driver_data {
13 struct hostapd_data *hapd; /* back pointer */
15 - char iface[IFNAMSIZ + 1];
16 + void *wext; /* private data for driver_wext */
18 + char ifname[IFNAMSIZ + 1];
19 + int ioctl_sock; /* socket for ioctl() use */
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;
28 u8 acct_mac[ETH_ALEN];
29 struct hostap_sta_driver_data acct_data;
31 struct l2_packet_data *sock_raw; /* raw 802.11 management frames */
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;
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
48 memset(&iwr, 0, sizeof(iwr));
49 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
50 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
52 memcpy(iwr.u.name+sizeof(__u32), &arg, sizeof(arg));
54 @@ -233,6 +237,7 @@ ether_sprintf(const u8 *addr)
56 #endif /* CONFIG_NO_STDOUT_DEBUG */
60 * Configure WPA parameters.
62 @@ -395,7 +400,7 @@ madwifi_sta_set_flags(void *priv, const
63 return madwifi_set_sta_authorized(priv, addr, 0);
69 madwifi_del_key(void *priv, const u8 *addr, int key_idx)
71 @@ -407,28 +412,20 @@ madwifi_del_key(void *priv, const u8 *ad
72 __func__, ether_sprintf(addr), key_idx);
74 memset(&wk, 0, sizeof(wk));
75 + wk.idk_keyix = key_idx;
77 memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
78 - wk.idk_keyix = (u8) IEEE80211_KEYIX_NONE;
80 - wk.idk_keyix = key_idx;
83 - ret = set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk));
85 - wpa_printf(MSG_DEBUG, "%s: Failed to delete key (addr %s"
86 - " key_idx %d)", __func__, ether_sprintf(addr),
91 + set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk));
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)
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);
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
123 madwifi_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
125 @@ -591,7 +592,7 @@ madwifi_read_sta_driver_data(void *priv,
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));
134 @@ -757,7 +758,7 @@ static int madwifi_receive_probe_req(str
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)
143 @@ -1017,7 +1018,7 @@ madwifi_get_we_version(struct madwifi_dr
146 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.data.pointer = (caddr_t) range;
150 iwr.u.data.length = buflen;
152 @@ -1134,17 +1135,17 @@ madwifi_init(struct hostapd_data *hapd,
153 perror("socket[PF_INET,SOCK_DGRAM]");
156 - memcpy(drv->iface, params->ifname, sizeof(drv->iface));
157 + memcpy(drv->ifname, params->ifname, sizeof(drv->ifname));
159 memset(&ifr, 0, sizeof(ifr));
160 - os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
161 + os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
162 if (ioctl(drv->ioctl_sock, SIOCGIFINDEX, &ifr) != 0) {
163 perror("ioctl(SIOCGIFINDEX)");
166 drv->ifindex = ifr.ifr_ifindex;
168 - drv->sock_xmit = l2_packet_init(drv->iface, NULL, ETH_P_EAPOL,
169 + drv->sock_xmit = l2_packet_init(drv->ifname, NULL, ETH_P_EAPOL,
170 handle_read, drv, 1);
171 if (drv->sock_xmit == NULL)
173 @@ -1158,7 +1159,7 @@ madwifi_init(struct hostapd_data *hapd,
175 if (drv->sock_recv == NULL)
177 - } else if (linux_br_get(brname, drv->iface) == 0) {
178 + } else if (linux_br_get(brname, drv->ifname) == 0) {
179 wpa_printf(MSG_DEBUG, "Interface in bridge %s; configure for "
180 "EAPOL receive", brname);
181 drv->sock_recv = l2_packet_init(brname, NULL, ETH_P_EAPOL,
182 @@ -1169,7 +1170,7 @@ madwifi_init(struct hostapd_data *hapd,
183 drv->sock_recv = drv->sock_xmit;
185 memset(&iwr, 0, sizeof(iwr));
186 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
187 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
189 iwr.u.mode = IW_MODE_MASTER;
191 @@ -1180,7 +1181,7 @@ madwifi_init(struct hostapd_data *hapd,
194 /* mark down during setup */
195 - linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
196 + linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0);
197 madwifi_set_privacy(drv, 0); /* default to no privacy */
199 madwifi_receive_probe_req(drv);
200 @@ -1206,7 +1207,7 @@ madwifi_deinit(void *priv)
201 struct madwifi_driver_data *drv = priv;
203 netlink_deinit(drv->netlink);
204 - (void) linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
205 + (void) linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0);
206 if (drv->ioctl_sock >= 0)
207 close(drv->ioctl_sock);
208 if (drv->sock_recv != NULL && drv->sock_recv != drv->sock_xmit)
209 @@ -1225,7 +1226,7 @@ madwifi_set_ssid(void *priv, const u8 *b
212 memset(&iwr, 0, sizeof(iwr));
213 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
214 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
215 iwr.u.essid.flags = 1; /* SSID active */
216 iwr.u.essid.pointer = (caddr_t) buf;
217 iwr.u.essid.length = len + 1;
218 @@ -1246,7 +1247,7 @@ madwifi_get_ssid(void *priv, u8 *buf, in
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.pointer = (caddr_t) buf;
225 iwr.u.essid.length = len;
227 @@ -1271,140 +1272,19 @@ static int
228 madwifi_commit(void *priv)
230 struct madwifi_driver_data *drv = priv;
231 - return linux_set_iface_flags(drv->ioctl_sock, drv->iface, 1);
232 + return linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1);
236 +#endif /* HOSTAPD */
238 -struct wpa_driver_madwifi_data {
239 - void *wext; /* private data for driver_wext */
241 - char ifname[IFNAMSIZ + 1];
244 +#if !defined(NO_SUPPLICANT)
246 static int wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg);
247 static int wpa_driver_madwifi_set_probe_req_ie(void *priv, const u8 *ies,
252 -set80211priv(struct wpa_driver_madwifi_data *drv, int op, void *data, int len,
257 - os_memset(&iwr, 0, sizeof(iwr));
258 - os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
259 - if (len < IFNAMSIZ &&
260 - op != IEEE80211_IOCTL_SET_APPIEBUF) {
262 - * Argument data fits inline; put it there.
264 - os_memcpy(iwr.u.name, data, len);
267 - * Argument data too big for inline transfer; setup a
268 - * parameter block instead; the kernel will transfer
269 - * the data for the driver.
271 - iwr.u.data.pointer = data;
272 - iwr.u.data.length = len;
275 - if (ioctl(drv->sock, op, &iwr) < 0) {
278 - int first = IEEE80211_IOCTL_SETPARAM;
279 - int last = IEEE80211_IOCTL_KICKMAC;
280 - static const char *opnames[] = {
281 - "ioctl[IEEE80211_IOCTL_SETPARAM]",
282 - "ioctl[IEEE80211_IOCTL_GETPARAM]",
283 - "ioctl[IEEE80211_IOCTL_SETMODE]",
284 - "ioctl[IEEE80211_IOCTL_GETMODE]",
285 - "ioctl[IEEE80211_IOCTL_SETWMMPARAMS]",
286 - "ioctl[IEEE80211_IOCTL_GETWMMPARAMS]",
287 - "ioctl[IEEE80211_IOCTL_SETCHANLIST]",
288 - "ioctl[IEEE80211_IOCTL_GETCHANLIST]",
289 - "ioctl[IEEE80211_IOCTL_CHANSWITCH]",
291 - "ioctl[IEEE80211_IOCTL_SET_APPIEBUF]",
292 - "ioctl[IEEE80211_IOCTL_GETSCANRESULTS]",
294 - "ioctl[IEEE80211_IOCTL_GETCHANINFO]",
295 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
296 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
297 - "ioctl[IEEE80211_IOCTL_SETMLME]",
299 - "ioctl[IEEE80211_IOCTL_SETKEY]",
301 - "ioctl[IEEE80211_IOCTL_DELKEY]",
303 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
305 - "ioctl[IEEE80211_IOCTL_DELMAC]",
307 - "ioctl[IEEE80211_IOCTL_WDSMAC]",
309 - "ioctl[IEEE80211_IOCTL_WDSDELMAC]",
311 - "ioctl[IEEE80211_IOCTL_KICKMAC]",
313 -#else /* MADWIFI_NG */
314 - int first = IEEE80211_IOCTL_SETPARAM;
315 - int last = IEEE80211_IOCTL_CHANLIST;
316 - static const char *opnames[] = {
317 - "ioctl[IEEE80211_IOCTL_SETPARAM]",
318 - "ioctl[IEEE80211_IOCTL_GETPARAM]",
319 - "ioctl[IEEE80211_IOCTL_SETKEY]",
320 - "ioctl[IEEE80211_IOCTL_GETKEY]",
321 - "ioctl[IEEE80211_IOCTL_DELKEY]",
323 - "ioctl[IEEE80211_IOCTL_SETMLME]",
325 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
326 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
327 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
329 - "ioctl[IEEE80211_IOCTL_DELMAC]",
331 - "ioctl[IEEE80211_IOCTL_CHANLIST]",
333 -#endif /* MADWIFI_NG */
334 - int idx = op - first;
335 - if (first <= op && op <= last &&
336 - idx < (int) (sizeof(opnames) / sizeof(opnames[0]))
338 - perror(opnames[idx]);
340 - perror("ioctl[unknown???]");
348 -set80211param(struct wpa_driver_madwifi_data *drv, int op, int arg,
353 - os_memset(&iwr, 0, sizeof(iwr));
354 - os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
356 - os_memcpy(iwr.u.name+sizeof(u32), &arg, sizeof(arg));
358 - if (ioctl(drv->sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
360 - perror("ioctl[IEEE80211_IOCTL_SETPARAM]");
367 -wpa_driver_madwifi_set_wpa_ie(struct wpa_driver_madwifi_data *drv,
368 +wpa_driver_madwifi_set_wpa_ie(struct madwifi_driver_data *drv,
369 const u8 *wpa_ie, size_t wpa_ie_len)
372 @@ -1415,7 +1295,7 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
373 iwr.u.data.pointer = (void *) wpa_ie;
374 iwr.u.data.length = wpa_ie_len;
376 - if (ioctl(drv->sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
377 + if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
378 perror("ioctl[IEEE80211_IOCTL_SETOPTIE]");
381 @@ -1423,157 +1303,51 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
385 -wpa_driver_madwifi_del_key(struct wpa_driver_madwifi_data *drv, int key_idx,
388 - struct ieee80211req_del_key wk;
390 - wpa_printf(MSG_DEBUG, "%s: keyidx=%d", __FUNCTION__, key_idx);
391 - os_memset(&wk, 0, sizeof(wk));
392 - wk.idk_keyix = key_idx;
394 - os_memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
396 - return set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk), 1);
400 -wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
401 - const u8 *addr, int key_idx, int set_tx,
402 - const u8 *seq, size_t seq_len,
403 - const u8 *key, size_t key_len)
405 - struct wpa_driver_madwifi_data *drv = priv;
406 - struct ieee80211req_key wk;
410 - if (alg == WPA_ALG_NONE)
411 - return wpa_driver_madwifi_del_key(drv, key_idx, addr);
415 - if (addr == NULL || os_memcmp(addr, "\xff\xff\xff\xff\xff\xff",
418 - * madwifi did not seem to like static WEP key
419 - * configuration with IEEE80211_IOCTL_SETKEY, so use
420 - * Linux wireless extensions ioctl for this.
422 - return wpa_driver_wext_set_key(ifname, drv->wext, alg,
423 - addr, key_idx, set_tx,
428 - cipher = IEEE80211_CIPHER_WEP;
432 - cipher = IEEE80211_CIPHER_TKIP;
436 - cipher = IEEE80211_CIPHER_AES_CCM;
439 - wpa_printf(MSG_DEBUG, "%s: unknown/unsupported algorithm %d",
440 - __FUNCTION__, alg);
444 - wpa_printf(MSG_DEBUG, "%s: alg=%s key_idx=%d set_tx=%d seq_len=%lu "
445 - "key_len=%lu", __FUNCTION__, alg_name, key_idx, set_tx,
446 - (unsigned long) seq_len, (unsigned long) key_len);
448 - if (seq_len > sizeof(u_int64_t)) {
449 - wpa_printf(MSG_DEBUG, "%s: seq_len %lu too big",
450 - __FUNCTION__, (unsigned long) seq_len);
453 - if (key_len > sizeof(wk.ik_keydata)) {
454 - wpa_printf(MSG_DEBUG, "%s: key length %lu too big",
455 - __FUNCTION__, (unsigned long) key_len);
459 - os_memset(&wk, 0, sizeof(wk));
460 - wk.ik_type = cipher;
461 - wk.ik_flags = IEEE80211_KEY_RECV;
462 - if (addr == NULL ||
463 - os_memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0)
464 - wk.ik_flags |= IEEE80211_KEY_GROUP;
466 - wk.ik_flags |= IEEE80211_KEY_XMIT | IEEE80211_KEY_DEFAULT;
467 - os_memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
469 - os_memset(wk.ik_macaddr, 0, IEEE80211_ADDR_LEN);
470 - wk.ik_keyix = key_idx;
471 - wk.ik_keylen = key_len;
472 -#ifdef WORDS_BIGENDIAN
475 - u8 tmp[WPA_KEY_RSC_LEN];
476 - os_memset(tmp, 0, sizeof(tmp));
477 - for (i = 0; i < seq_len; i++)
478 - tmp[WPA_KEY_RSC_LEN - i - 1] = seq[i];
479 - os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
481 -#else /* WORDS_BIGENDIAN */
483 - os_memcpy(&wk.ik_keyrsc, seq, seq_len);
484 -#endif /* WORDS_BIGENDIAN */
485 - os_memcpy(wk.ik_keydata, key, key_len);
487 - return set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk), 1);
491 wpa_driver_madwifi_set_countermeasures(void *priv, int enabled)
493 - struct wpa_driver_madwifi_data *drv = priv;
494 + struct madwifi_driver_data *drv = priv;
495 wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
496 - return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled, 1);
497 + return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled);
501 wpa_driver_madwifi_deauthenticate(void *priv, const u8 *addr, int reason_code)
503 - struct wpa_driver_madwifi_data *drv = priv;
504 + struct madwifi_driver_data *drv = priv;
505 struct ieee80211req_mlme mlme;
507 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
508 mlme.im_op = IEEE80211_MLME_DEAUTH;
509 mlme.im_reason = reason_code;
510 os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
511 - return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme), 1);
512 + return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
516 wpa_driver_madwifi_disassociate(void *priv, const u8 *addr, int reason_code)
518 - struct wpa_driver_madwifi_data *drv = priv;
519 + struct madwifi_driver_data *drv = priv;
520 struct ieee80211req_mlme mlme;
522 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
523 mlme.im_op = IEEE80211_MLME_DISASSOC;
524 mlme.im_reason = reason_code;
525 os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
526 - return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme), 1);
527 + return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
531 wpa_driver_madwifi_associate(void *priv,
532 struct wpa_driver_associate_params *params)
534 - struct wpa_driver_madwifi_data *drv = priv;
535 + struct madwifi_driver_data *drv = priv;
536 struct ieee80211req_mlme mlme;
537 int ret = 0, privacy = 1;
539 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
541 if (set80211param(drv, IEEE80211_PARAM_DROPUNENCRYPTED,
542 - params->drop_unencrypted, 1) < 0)
543 + params->drop_unencrypted) < 0)
545 if (wpa_driver_madwifi_set_auth_alg(drv, params->auth_alg) < 0)
547 @@ -1596,12 +1370,12 @@ wpa_driver_madwifi_associate(void *priv,
548 params->wpa_ie_len == 0)
551 - if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy, 1) < 0)
552 + if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy) < 0)
555 if (params->wpa_ie_len &&
556 set80211param(drv, IEEE80211_PARAM_WPA,
557 - params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1, 1) < 0)
558 + params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1) < 0)
561 if (params->bssid == NULL) {
562 @@ -1609,14 +1383,14 @@ wpa_driver_madwifi_associate(void *priv,
564 /* FIX: this does not seem to work; would probably need to
565 * change something in the driver */
566 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0)
567 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0) < 0)
570 if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
571 params->ssid_len) < 0)
574 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0)
575 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0)
577 if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
578 params->ssid_len) < 0)
579 @@ -1625,7 +1399,7 @@ wpa_driver_madwifi_associate(void *priv,
580 mlme.im_op = IEEE80211_MLME_ASSOC;
581 os_memcpy(mlme.im_macaddr, params->bssid, IEEE80211_ADDR_LEN);
582 if (set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
583 - sizeof(mlme), 1) < 0) {
584 + sizeof(mlme)) < 0) {
585 wpa_printf(MSG_DEBUG, "%s: SETMLME[ASSOC] failed",
588 @@ -1638,7 +1412,7 @@ wpa_driver_madwifi_associate(void *priv,
590 wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg)
592 - struct wpa_driver_madwifi_data *drv = priv;
593 + struct madwifi_driver_data *drv = priv;
596 if ((auth_alg & WPA_AUTH_ALG_OPEN) &&
597 @@ -1649,13 +1423,13 @@ wpa_driver_madwifi_set_auth_alg(void *pr
599 authmode = IEEE80211_AUTH_OPEN;
601 - return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode, 1);
602 + return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode);
606 wpa_driver_madwifi_scan(void *priv, struct wpa_driver_scan_params *params)
608 - struct wpa_driver_madwifi_data *drv = priv;
609 + struct madwifi_driver_data *drv = priv;
612 const u8 *ssid = params->ssids[0].ssid;
613 @@ -1673,7 +1447,7 @@ wpa_driver_madwifi_scan(void *priv, stru
614 if (wpa_driver_wext_set_ssid(drv->wext, ssid, ssid_len) < 0)
617 - if (ioctl(drv->sock, SIOCSIWSCAN, &iwr) < 0) {
618 + if (ioctl(drv->ioctl_sock, SIOCSIWSCAN, &iwr) < 0) {
619 perror("ioctl[SIOCSIWSCAN]");
622 @@ -1695,14 +1469,14 @@ wpa_driver_madwifi_scan(void *priv, stru
624 static int wpa_driver_madwifi_get_bssid(void *priv, u8 *bssid)
626 - struct wpa_driver_madwifi_data *drv = priv;
627 + struct madwifi_driver_data *drv = priv;
628 return wpa_driver_wext_get_bssid(drv->wext, bssid);
632 static int wpa_driver_madwifi_get_ssid(void *priv, u8 *ssid)
634 - struct wpa_driver_madwifi_data *drv = priv;
635 + struct madwifi_driver_data *drv = priv;
636 return wpa_driver_wext_get_ssid(drv->wext, ssid);
639 @@ -1710,14 +1484,16 @@ static int wpa_driver_madwifi_get_ssid(v
640 static struct wpa_scan_results *
641 wpa_driver_madwifi_get_scan_results(void *priv)
643 - struct wpa_driver_madwifi_data *drv = priv;
644 + struct madwifi_driver_data *drv = priv;
645 return wpa_driver_wext_get_scan_results(drv->wext);
649 static int wpa_driver_madwifi_set_operstate(void *priv, int state)
651 - struct wpa_driver_madwifi_data *drv = priv;
652 + struct madwifi_driver_data *drv = priv;
655 return wpa_driver_wext_set_operstate(drv->wext, state);
658 @@ -1738,7 +1514,7 @@ static int wpa_driver_madwifi_set_probe_
660 ret = set80211priv(priv, IEEE80211_IOCTL_SET_APPIEBUF, probe_req_ie,
661 sizeof(struct ieee80211req_getset_appiebuf) +
665 os_free(probe_req_ie);
667 @@ -1748,7 +1524,7 @@ static int wpa_driver_madwifi_set_probe_
669 static void * wpa_driver_madwifi_init(void *ctx, const char *ifname)
671 - struct wpa_driver_madwifi_data *drv;
672 + struct madwifi_driver_data *drv;
674 drv = os_zalloc(sizeof(*drv));
676 @@ -1759,17 +1535,17 @@ static void * wpa_driver_madwifi_init(vo
679 os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
680 - drv->sock = socket(PF_INET, SOCK_DGRAM, 0);
682 + drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
683 + if (drv->ioctl_sock < 0)
686 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0) {
687 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0) {
688 wpa_printf(MSG_DEBUG, "%s: failed to set wpa_supplicant-based "
689 "roaming", __FUNCTION__);
693 - if (set80211param(drv, IEEE80211_PARAM_WPA, 3, 1) < 0) {
694 + if (set80211param(drv, IEEE80211_PARAM_WPA, 3) < 0) {
695 wpa_printf(MSG_DEBUG, "%s: failed to enable WPA support",
698 @@ -1778,7 +1554,7 @@ static void * wpa_driver_madwifi_init(vo
703 + close(drv->ioctl_sock);
705 wpa_driver_wext_deinit(drv->wext);
707 @@ -1789,38 +1565,37 @@ fail:
709 static void wpa_driver_madwifi_deinit(void *priv)
711 - struct wpa_driver_madwifi_data *drv = priv;
712 + struct madwifi_driver_data *drv = priv;
714 if (wpa_driver_madwifi_set_wpa_ie(drv, NULL, 0) < 0) {
715 wpa_printf(MSG_DEBUG, "%s: failed to clear WPA IE",
718 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0) {
719 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0) < 0) {
720 wpa_printf(MSG_DEBUG, "%s: failed to enable driver-based "
721 "roaming", __FUNCTION__);
723 - if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0, 1) < 0) {
724 + if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0) < 0) {
725 wpa_printf(MSG_DEBUG, "%s: failed to disable forced Privacy "
726 "flag", __FUNCTION__);
728 - if (set80211param(drv, IEEE80211_PARAM_WPA, 0, 1) < 0) {
729 + if (set80211param(drv, IEEE80211_PARAM_WPA, 0) < 0) {
730 wpa_printf(MSG_DEBUG, "%s: failed to disable WPA",
734 wpa_driver_wext_deinit(drv->wext);
737 + close(drv->ioctl_sock);
741 -#endif /* HOSTAPD */
745 const struct wpa_driver_ops wpa_driver_madwifi_ops = {
747 .desc = "MADWIFI 802.11 support (Atheros, etc.)",
748 - .set_key = wpa_driver_madwifi_set_key,
749 + .set_key = madwifi_set_key,
751 .hapd_init = madwifi_init,
752 .hapd_deinit = madwifi_deinit,
753 @@ -1840,7 +1615,8 @@ const struct wpa_driver_ops wpa_driver_m
754 .sta_clear_stats = madwifi_sta_clear_stats,
755 .commit = madwifi_commit,
756 .set_ap_wps_ie = madwifi_set_ap_wps_ie,
758 +#endif /* HOSTAPD */
759 +#if !defined(NO_SUPPLICANT)
760 .get_bssid = wpa_driver_madwifi_get_bssid,
761 .get_ssid = wpa_driver_madwifi_get_ssid,
762 .init = wpa_driver_madwifi_init,
763 @@ -1852,5 +1628,5 @@ const struct wpa_driver_ops wpa_driver_m
764 .disassociate = wpa_driver_madwifi_disassociate,
765 .associate = wpa_driver_madwifi_associate,
766 .set_operstate = wpa_driver_madwifi_set_operstate,
767 -#endif /* HOSTAPD */
770 --- a/src/drivers/drivers.mak
771 +++ b/src/drivers/drivers.mak
772 @@ -144,8 +144,8 @@ DRV_WPA_OBJS += ../src/drivers/driver_ro
775 ifdef CONFIG_WIRELESS_EXTENSION
776 -DRV_WPA_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
777 -DRV_WPA_OBJS += ../src/drivers/driver_wext.o
778 +DRV_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
779 +DRV_OBJS += ../src/drivers/driver_wext.o