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 @@ -462,10 +459,14 @@ wpa_driver_madwifi_set_key(const char *i
108 memset(&wk, 0, sizeof(wk));
110 wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
113 memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
114 wk.ik_keyix = key_idx;
115 wk.ik_flags |= IEEE80211_KEY_DEFAULT;
116 + } else if (!memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN)) {
117 + wk.ik_flags |= IEEE80211_KEY_GROUP;
118 + memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
120 memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
121 wk.ik_keyix = IEEE80211_KEYIX_NONE;
122 @@ -485,6 +486,7 @@ wpa_driver_madwifi_set_key(const char *i
128 madwifi_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
130 @@ -591,7 +593,7 @@ madwifi_read_sta_driver_data(void *priv,
132 memset(data, 0, sizeof(*data));
133 snprintf(buf, sizeof(buf), "/proc/net/madwifi/%s/" MACSTR,
134 - drv->iface, MAC2STR(addr));
135 + drv->ifname, MAC2STR(addr));
139 @@ -757,7 +759,7 @@ static int madwifi_receive_probe_req(str
143 - drv->sock_raw = l2_packet_init(drv->iface, NULL, ETH_P_80211_RAW,
144 + drv->sock_raw = l2_packet_init(drv->ifname, NULL, ETH_P_80211_RAW,
145 madwifi_raw_receive, drv, 1);
146 if (drv->sock_raw == NULL)
148 @@ -1017,7 +1019,7 @@ madwifi_get_we_version(struct madwifi_dr
151 memset(&iwr, 0, sizeof(iwr));
152 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
153 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
154 iwr.u.data.pointer = (caddr_t) range;
155 iwr.u.data.length = buflen;
157 @@ -1134,17 +1136,17 @@ madwifi_init(struct hostapd_data *hapd,
158 perror("socket[PF_INET,SOCK_DGRAM]");
161 - memcpy(drv->iface, params->ifname, sizeof(drv->iface));
162 + memcpy(drv->ifname, params->ifname, sizeof(drv->ifname));
164 memset(&ifr, 0, sizeof(ifr));
165 - os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
166 + os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
167 if (ioctl(drv->ioctl_sock, SIOCGIFINDEX, &ifr) != 0) {
168 perror("ioctl(SIOCGIFINDEX)");
171 drv->ifindex = ifr.ifr_ifindex;
173 - drv->sock_xmit = l2_packet_init(drv->iface, NULL, ETH_P_EAPOL,
174 + drv->sock_xmit = l2_packet_init(drv->ifname, NULL, ETH_P_EAPOL,
175 handle_read, drv, 1);
176 if (drv->sock_xmit == NULL)
178 @@ -1158,7 +1160,7 @@ madwifi_init(struct hostapd_data *hapd,
180 if (drv->sock_recv == NULL)
182 - } else if (linux_br_get(brname, drv->iface) == 0) {
183 + } else if (linux_br_get(brname, drv->ifname) == 0) {
184 wpa_printf(MSG_DEBUG, "Interface in bridge %s; configure for "
185 "EAPOL receive", brname);
186 drv->sock_recv = l2_packet_init(brname, NULL, ETH_P_EAPOL,
187 @@ -1169,7 +1171,7 @@ madwifi_init(struct hostapd_data *hapd,
188 drv->sock_recv = drv->sock_xmit;
190 memset(&iwr, 0, sizeof(iwr));
191 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
192 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
194 iwr.u.mode = IW_MODE_MASTER;
196 @@ -1180,7 +1182,7 @@ madwifi_init(struct hostapd_data *hapd,
199 /* mark down during setup */
200 - linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
201 + linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0);
202 madwifi_set_privacy(drv, 0); /* default to no privacy */
204 madwifi_receive_probe_req(drv);
205 @@ -1206,7 +1208,7 @@ madwifi_deinit(void *priv)
206 struct madwifi_driver_data *drv = priv;
208 netlink_deinit(drv->netlink);
209 - (void) linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
210 + (void) linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0);
211 if (drv->ioctl_sock >= 0)
212 close(drv->ioctl_sock);
213 if (drv->sock_recv != NULL && drv->sock_recv != drv->sock_xmit)
214 @@ -1225,7 +1227,7 @@ madwifi_set_ssid(void *priv, const u8 *b
217 memset(&iwr, 0, sizeof(iwr));
218 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
219 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
220 iwr.u.essid.flags = 1; /* SSID active */
221 iwr.u.essid.pointer = (caddr_t) buf;
222 iwr.u.essid.length = len + 1;
223 @@ -1246,7 +1248,7 @@ madwifi_get_ssid(void *priv, u8 *buf, in
226 memset(&iwr, 0, sizeof(iwr));
227 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
228 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
229 iwr.u.essid.pointer = (caddr_t) buf;
230 iwr.u.essid.length = len;
232 @@ -1271,140 +1273,19 @@ static int
233 madwifi_commit(void *priv)
235 struct madwifi_driver_data *drv = priv;
236 - return linux_set_iface_flags(drv->ioctl_sock, drv->iface, 1);
237 + return linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1);
241 +#endif /* HOSTAPD */
243 -struct wpa_driver_madwifi_data {
244 - void *wext; /* private data for driver_wext */
246 - char ifname[IFNAMSIZ + 1];
249 +#if !defined(NO_SUPPLICANT)
251 static int wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg);
252 static int wpa_driver_madwifi_set_probe_req_ie(void *priv, const u8 *ies,
257 -set80211priv(struct wpa_driver_madwifi_data *drv, int op, void *data, int len,
262 - os_memset(&iwr, 0, sizeof(iwr));
263 - os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
264 - if (len < IFNAMSIZ &&
265 - op != IEEE80211_IOCTL_SET_APPIEBUF) {
267 - * Argument data fits inline; put it there.
269 - os_memcpy(iwr.u.name, data, len);
272 - * Argument data too big for inline transfer; setup a
273 - * parameter block instead; the kernel will transfer
274 - * the data for the driver.
276 - iwr.u.data.pointer = data;
277 - iwr.u.data.length = len;
280 - if (ioctl(drv->sock, op, &iwr) < 0) {
283 - int first = IEEE80211_IOCTL_SETPARAM;
284 - int last = IEEE80211_IOCTL_KICKMAC;
285 - static const char *opnames[] = {
286 - "ioctl[IEEE80211_IOCTL_SETPARAM]",
287 - "ioctl[IEEE80211_IOCTL_GETPARAM]",
288 - "ioctl[IEEE80211_IOCTL_SETMODE]",
289 - "ioctl[IEEE80211_IOCTL_GETMODE]",
290 - "ioctl[IEEE80211_IOCTL_SETWMMPARAMS]",
291 - "ioctl[IEEE80211_IOCTL_GETWMMPARAMS]",
292 - "ioctl[IEEE80211_IOCTL_SETCHANLIST]",
293 - "ioctl[IEEE80211_IOCTL_GETCHANLIST]",
294 - "ioctl[IEEE80211_IOCTL_CHANSWITCH]",
296 - "ioctl[IEEE80211_IOCTL_SET_APPIEBUF]",
297 - "ioctl[IEEE80211_IOCTL_GETSCANRESULTS]",
299 - "ioctl[IEEE80211_IOCTL_GETCHANINFO]",
300 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
301 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
302 - "ioctl[IEEE80211_IOCTL_SETMLME]",
304 - "ioctl[IEEE80211_IOCTL_SETKEY]",
306 - "ioctl[IEEE80211_IOCTL_DELKEY]",
308 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
310 - "ioctl[IEEE80211_IOCTL_DELMAC]",
312 - "ioctl[IEEE80211_IOCTL_WDSMAC]",
314 - "ioctl[IEEE80211_IOCTL_WDSDELMAC]",
316 - "ioctl[IEEE80211_IOCTL_KICKMAC]",
318 -#else /* MADWIFI_NG */
319 - int first = IEEE80211_IOCTL_SETPARAM;
320 - int last = IEEE80211_IOCTL_CHANLIST;
321 - static const char *opnames[] = {
322 - "ioctl[IEEE80211_IOCTL_SETPARAM]",
323 - "ioctl[IEEE80211_IOCTL_GETPARAM]",
324 - "ioctl[IEEE80211_IOCTL_SETKEY]",
325 - "ioctl[IEEE80211_IOCTL_GETKEY]",
326 - "ioctl[IEEE80211_IOCTL_DELKEY]",
328 - "ioctl[IEEE80211_IOCTL_SETMLME]",
330 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
331 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
332 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
334 - "ioctl[IEEE80211_IOCTL_DELMAC]",
336 - "ioctl[IEEE80211_IOCTL_CHANLIST]",
338 -#endif /* MADWIFI_NG */
339 - int idx = op - first;
340 - if (first <= op && op <= last &&
341 - idx < (int) (sizeof(opnames) / sizeof(opnames[0]))
343 - perror(opnames[idx]);
345 - perror("ioctl[unknown???]");
353 -set80211param(struct wpa_driver_madwifi_data *drv, int op, int arg,
358 - os_memset(&iwr, 0, sizeof(iwr));
359 - os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
361 - os_memcpy(iwr.u.name+sizeof(u32), &arg, sizeof(arg));
363 - if (ioctl(drv->sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
365 - perror("ioctl[IEEE80211_IOCTL_SETPARAM]");
372 -wpa_driver_madwifi_set_wpa_ie(struct wpa_driver_madwifi_data *drv,
373 +wpa_driver_madwifi_set_wpa_ie(struct madwifi_driver_data *drv,
374 const u8 *wpa_ie, size_t wpa_ie_len)
377 @@ -1415,7 +1296,7 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
378 iwr.u.data.pointer = (void *) wpa_ie;
379 iwr.u.data.length = wpa_ie_len;
381 - if (ioctl(drv->sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
382 + if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
383 perror("ioctl[IEEE80211_IOCTL_SETOPTIE]");
386 @@ -1423,156 +1304,51 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
390 -wpa_driver_madwifi_del_key(struct wpa_driver_madwifi_data *drv, int key_idx,
393 - struct ieee80211req_del_key wk;
395 - wpa_printf(MSG_DEBUG, "%s: keyidx=%d", __FUNCTION__, key_idx);
396 - os_memset(&wk, 0, sizeof(wk));
397 - wk.idk_keyix = key_idx;
399 - os_memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
401 - return set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk), 1);
405 -wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
406 - const u8 *addr, int key_idx, int set_tx,
407 - const u8 *seq, size_t seq_len,
408 - const u8 *key, size_t key_len)
410 - struct wpa_driver_madwifi_data *drv = priv;
411 - struct ieee80211req_key wk;
415 - if (alg == WPA_ALG_NONE)
416 - return wpa_driver_madwifi_del_key(drv, key_idx, addr);
420 - if (addr == NULL || os_memcmp(addr, "\xff\xff\xff\xff\xff\xff",
423 - * madwifi did not seem to like static WEP key
424 - * configuration with IEEE80211_IOCTL_SETKEY, so use
425 - * Linux wireless extensions ioctl for this.
427 - return wpa_driver_wext_set_key(ifname, drv->wext, alg,
428 - addr, key_idx, set_tx,
433 - cipher = IEEE80211_CIPHER_WEP;
437 - cipher = IEEE80211_CIPHER_TKIP;
441 - cipher = IEEE80211_CIPHER_AES_CCM;
444 - wpa_printf(MSG_DEBUG, "%s: unknown/unsupported algorithm %d",
445 - __FUNCTION__, alg);
449 - wpa_printf(MSG_DEBUG, "%s: alg=%s key_idx=%d set_tx=%d seq_len=%lu "
450 - "key_len=%lu", __FUNCTION__, alg_name, key_idx, set_tx,
451 - (unsigned long) seq_len, (unsigned long) key_len);
453 - if (seq_len > sizeof(u_int64_t)) {
454 - wpa_printf(MSG_DEBUG, "%s: seq_len %lu too big",
455 - __FUNCTION__, (unsigned long) seq_len);
458 - if (key_len > sizeof(wk.ik_keydata)) {
459 - wpa_printf(MSG_DEBUG, "%s: key length %lu too big",
460 - __FUNCTION__, (unsigned long) key_len);
464 - os_memset(&wk, 0, sizeof(wk));
465 - wk.ik_type = cipher;
466 - wk.ik_flags = IEEE80211_KEY_RECV;
467 - if (addr == NULL ||
468 - os_memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0)
469 - wk.ik_flags |= IEEE80211_KEY_GROUP;
471 - wk.ik_flags |= IEEE80211_KEY_XMIT | IEEE80211_KEY_DEFAULT;
472 - os_memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
474 - os_memset(wk.ik_macaddr, 0, IEEE80211_ADDR_LEN);
475 - wk.ik_keyix = key_idx;
476 - wk.ik_keylen = key_len;
477 -#ifdef WORDS_BIGENDIAN
480 - u8 tmp[WPA_KEY_RSC_LEN];
481 - os_memset(tmp, 0, sizeof(tmp));
482 - for (i = 0; i < seq_len; i++)
483 - tmp[WPA_KEY_RSC_LEN - i - 1] = seq[i];
484 - os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
486 -#else /* WORDS_BIGENDIAN */
487 - os_memcpy(&wk.ik_keyrsc, seq, seq_len);
488 -#endif /* WORDS_BIGENDIAN */
489 - os_memcpy(wk.ik_keydata, key, key_len);
491 - return set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk), 1);
495 wpa_driver_madwifi_set_countermeasures(void *priv, int enabled)
497 - struct wpa_driver_madwifi_data *drv = priv;
498 + struct madwifi_driver_data *drv = priv;
499 wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
500 - return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled, 1);
501 + return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled);
505 wpa_driver_madwifi_deauthenticate(void *priv, const u8 *addr, int reason_code)
507 - struct wpa_driver_madwifi_data *drv = priv;
508 + struct madwifi_driver_data *drv = priv;
509 struct ieee80211req_mlme mlme;
511 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
512 mlme.im_op = IEEE80211_MLME_DEAUTH;
513 mlme.im_reason = reason_code;
514 os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
515 - return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme), 1);
516 + return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
520 wpa_driver_madwifi_disassociate(void *priv, const u8 *addr, int reason_code)
522 - struct wpa_driver_madwifi_data *drv = priv;
523 + struct madwifi_driver_data *drv = priv;
524 struct ieee80211req_mlme mlme;
526 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
527 mlme.im_op = IEEE80211_MLME_DISASSOC;
528 mlme.im_reason = reason_code;
529 os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
530 - return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme), 1);
531 + return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
535 wpa_driver_madwifi_associate(void *priv,
536 struct wpa_driver_associate_params *params)
538 - struct wpa_driver_madwifi_data *drv = priv;
539 + struct madwifi_driver_data *drv = priv;
540 struct ieee80211req_mlme mlme;
541 int ret = 0, privacy = 1;
543 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
545 if (set80211param(drv, IEEE80211_PARAM_DROPUNENCRYPTED,
546 - params->drop_unencrypted, 1) < 0)
547 + params->drop_unencrypted) < 0)
549 if (wpa_driver_madwifi_set_auth_alg(drv, params->auth_alg) < 0)
551 @@ -1595,12 +1371,12 @@ wpa_driver_madwifi_associate(void *priv,
552 params->wpa_ie_len == 0)
555 - if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy, 1) < 0)
556 + if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy) < 0)
559 if (params->wpa_ie_len &&
560 set80211param(drv, IEEE80211_PARAM_WPA,
561 - params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1, 1) < 0)
562 + params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1) < 0)
565 if (params->bssid == NULL) {
566 @@ -1608,14 +1384,14 @@ wpa_driver_madwifi_associate(void *priv,
568 /* FIX: this does not seem to work; would probably need to
569 * change something in the driver */
570 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0)
571 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0) < 0)
574 if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
575 params->ssid_len) < 0)
578 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0)
579 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0)
581 if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
582 params->ssid_len) < 0)
583 @@ -1624,7 +1400,7 @@ wpa_driver_madwifi_associate(void *priv,
584 mlme.im_op = IEEE80211_MLME_ASSOC;
585 os_memcpy(mlme.im_macaddr, params->bssid, IEEE80211_ADDR_LEN);
586 if (set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
587 - sizeof(mlme), 1) < 0) {
588 + sizeof(mlme)) < 0) {
589 wpa_printf(MSG_DEBUG, "%s: SETMLME[ASSOC] failed",
592 @@ -1637,7 +1413,7 @@ wpa_driver_madwifi_associate(void *priv,
594 wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg)
596 - struct wpa_driver_madwifi_data *drv = priv;
597 + struct madwifi_driver_data *drv = priv;
600 if ((auth_alg & WPA_AUTH_ALG_OPEN) &&
601 @@ -1648,13 +1424,13 @@ wpa_driver_madwifi_set_auth_alg(void *pr
603 authmode = IEEE80211_AUTH_OPEN;
605 - return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode, 1);
606 + return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode);
610 wpa_driver_madwifi_scan(void *priv, struct wpa_driver_scan_params *params)
612 - struct wpa_driver_madwifi_data *drv = priv;
613 + struct madwifi_driver_data *drv = priv;
616 const u8 *ssid = params->ssids[0].ssid;
617 @@ -1672,7 +1448,7 @@ wpa_driver_madwifi_scan(void *priv, stru
618 if (wpa_driver_wext_set_ssid(drv->wext, ssid, ssid_len) < 0)
621 - if (ioctl(drv->sock, SIOCSIWSCAN, &iwr) < 0) {
622 + if (ioctl(drv->ioctl_sock, SIOCSIWSCAN, &iwr) < 0) {
623 perror("ioctl[SIOCSIWSCAN]");
626 @@ -1694,14 +1470,14 @@ wpa_driver_madwifi_scan(void *priv, stru
628 static int wpa_driver_madwifi_get_bssid(void *priv, u8 *bssid)
630 - struct wpa_driver_madwifi_data *drv = priv;
631 + struct madwifi_driver_data *drv = priv;
632 return wpa_driver_wext_get_bssid(drv->wext, bssid);
636 static int wpa_driver_madwifi_get_ssid(void *priv, u8 *ssid)
638 - struct wpa_driver_madwifi_data *drv = priv;
639 + struct madwifi_driver_data *drv = priv;
640 return wpa_driver_wext_get_ssid(drv->wext, ssid);
643 @@ -1709,14 +1485,16 @@ static int wpa_driver_madwifi_get_ssid(v
644 static struct wpa_scan_results *
645 wpa_driver_madwifi_get_scan_results(void *priv)
647 - struct wpa_driver_madwifi_data *drv = priv;
648 + struct madwifi_driver_data *drv = priv;
649 return wpa_driver_wext_get_scan_results(drv->wext);
653 static int wpa_driver_madwifi_set_operstate(void *priv, int state)
655 - struct wpa_driver_madwifi_data *drv = priv;
656 + struct madwifi_driver_data *drv = priv;
659 return wpa_driver_wext_set_operstate(drv->wext, state);
662 @@ -1737,7 +1515,7 @@ static int wpa_driver_madwifi_set_probe_
664 ret = set80211priv(priv, IEEE80211_IOCTL_SET_APPIEBUF, probe_req_ie,
665 sizeof(struct ieee80211req_getset_appiebuf) +
669 os_free(probe_req_ie);
671 @@ -1747,7 +1525,7 @@ static int wpa_driver_madwifi_set_probe_
673 static void * wpa_driver_madwifi_init(void *ctx, const char *ifname)
675 - struct wpa_driver_madwifi_data *drv;
676 + struct madwifi_driver_data *drv;
678 drv = os_zalloc(sizeof(*drv));
680 @@ -1758,17 +1536,17 @@ static void * wpa_driver_madwifi_init(vo
683 os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
684 - drv->sock = socket(PF_INET, SOCK_DGRAM, 0);
686 + drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
687 + if (drv->ioctl_sock < 0)
690 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0) {
691 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0) {
692 wpa_printf(MSG_DEBUG, "%s: failed to set wpa_supplicant-based "
693 "roaming", __FUNCTION__);
697 - if (set80211param(drv, IEEE80211_PARAM_WPA, 3, 1) < 0) {
698 + if (set80211param(drv, IEEE80211_PARAM_WPA, 3) < 0) {
699 wpa_printf(MSG_DEBUG, "%s: failed to enable WPA support",
702 @@ -1777,7 +1555,7 @@ static void * wpa_driver_madwifi_init(vo
707 + close(drv->ioctl_sock);
709 wpa_driver_wext_deinit(drv->wext);
711 @@ -1788,38 +1566,37 @@ fail:
713 static void wpa_driver_madwifi_deinit(void *priv)
715 - struct wpa_driver_madwifi_data *drv = priv;
716 + struct madwifi_driver_data *drv = priv;
718 if (wpa_driver_madwifi_set_wpa_ie(drv, NULL, 0) < 0) {
719 wpa_printf(MSG_DEBUG, "%s: failed to clear WPA IE",
722 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0) {
723 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0) < 0) {
724 wpa_printf(MSG_DEBUG, "%s: failed to enable driver-based "
725 "roaming", __FUNCTION__);
727 - if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0, 1) < 0) {
728 + if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0) < 0) {
729 wpa_printf(MSG_DEBUG, "%s: failed to disable forced Privacy "
730 "flag", __FUNCTION__);
732 - if (set80211param(drv, IEEE80211_PARAM_WPA, 0, 1) < 0) {
733 + if (set80211param(drv, IEEE80211_PARAM_WPA, 0) < 0) {
734 wpa_printf(MSG_DEBUG, "%s: failed to disable WPA",
738 wpa_driver_wext_deinit(drv->wext);
741 + close(drv->ioctl_sock);
745 -#endif /* HOSTAPD */
749 const struct wpa_driver_ops wpa_driver_madwifi_ops = {
751 .desc = "MADWIFI 802.11 support (Atheros, etc.)",
752 - .set_key = wpa_driver_madwifi_set_key,
753 + .set_key = madwifi_set_key,
755 .hapd_init = madwifi_init,
756 .hapd_deinit = madwifi_deinit,
757 @@ -1839,7 +1616,8 @@ const struct wpa_driver_ops wpa_driver_m
758 .sta_clear_stats = madwifi_sta_clear_stats,
759 .commit = madwifi_commit,
760 .set_ap_wps_ie = madwifi_set_ap_wps_ie,
762 +#endif /* HOSTAPD */
763 +#if !defined(NO_SUPPLICANT)
764 .get_bssid = wpa_driver_madwifi_get_bssid,
765 .get_ssid = wpa_driver_madwifi_get_ssid,
766 .init = wpa_driver_madwifi_init,
767 @@ -1851,5 +1629,5 @@ const struct wpa_driver_ops wpa_driver_m
768 .disassociate = wpa_driver_madwifi_disassociate,
769 .associate = wpa_driver_madwifi_associate,
770 .set_operstate = wpa_driver_madwifi_set_operstate,
771 -#endif /* HOSTAPD */
774 --- a/src/drivers/drivers.mak
775 +++ b/src/drivers/drivers.mak
776 @@ -168,8 +168,8 @@ DRV_WPA_OBJS += ../src/drivers/driver_ro
779 ifdef CONFIG_WIRELESS_EXTENSION
780 -DRV_WPA_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
781 -DRV_WPA_OBJS += ../src/drivers/driver_wext.o
782 +DRV_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
783 +DRV_OBJS += ../src/drivers/driver_wext.o