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 @@ -1016,7 +1018,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 @@ -1133,17 +1135,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 @@ -1157,7 +1159,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 @@ -1168,7 +1170,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 @@ -1203,7 +1205,7 @@ madwifi_deinit(void *priv)
197 struct madwifi_driver_data *drv = priv;
199 netlink_deinit(drv->netlink);
200 - (void) linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
201 + (void) linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0);
202 if (drv->ioctl_sock >= 0)
203 close(drv->ioctl_sock);
204 if (drv->sock_recv != NULL && drv->sock_recv != drv->sock_xmit)
205 @@ -1222,7 +1224,7 @@ madwifi_set_ssid(void *priv, const u8 *b
208 memset(&iwr, 0, sizeof(iwr));
209 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
210 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
211 iwr.u.essid.flags = 1; /* SSID active */
212 iwr.u.essid.pointer = (caddr_t) buf;
213 iwr.u.essid.length = len + 1;
214 @@ -1243,7 +1245,7 @@ madwifi_get_ssid(void *priv, u8 *buf, in
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.pointer = (caddr_t) buf;
221 iwr.u.essid.length = len;
223 @@ -1270,137 +1272,16 @@ madwifi_commit(void *priv)
228 +#endif /* HOSTAPD */
230 -struct wpa_driver_madwifi_data {
231 - void *wext; /* private data for driver_wext */
233 - char ifname[IFNAMSIZ + 1];
236 +#if !defined(NO_SUPPLICANT)
238 static int wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg);
239 static int wpa_driver_madwifi_set_probe_req_ie(void *priv, const u8 *ies,
244 -set80211priv(struct wpa_driver_madwifi_data *drv, int op, void *data, int len,
249 - os_memset(&iwr, 0, sizeof(iwr));
250 - os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
251 - if (len < IFNAMSIZ &&
252 - op != IEEE80211_IOCTL_SET_APPIEBUF) {
254 - * Argument data fits inline; put it there.
256 - os_memcpy(iwr.u.name, data, len);
259 - * Argument data too big for inline transfer; setup a
260 - * parameter block instead; the kernel will transfer
261 - * the data for the driver.
263 - iwr.u.data.pointer = data;
264 - iwr.u.data.length = len;
267 - if (ioctl(drv->sock, op, &iwr) < 0) {
270 - int first = IEEE80211_IOCTL_SETPARAM;
271 - int last = IEEE80211_IOCTL_KICKMAC;
272 - static const char *opnames[] = {
273 - "ioctl[IEEE80211_IOCTL_SETPARAM]",
274 - "ioctl[IEEE80211_IOCTL_GETPARAM]",
275 - "ioctl[IEEE80211_IOCTL_SETMODE]",
276 - "ioctl[IEEE80211_IOCTL_GETMODE]",
277 - "ioctl[IEEE80211_IOCTL_SETWMMPARAMS]",
278 - "ioctl[IEEE80211_IOCTL_GETWMMPARAMS]",
279 - "ioctl[IEEE80211_IOCTL_SETCHANLIST]",
280 - "ioctl[IEEE80211_IOCTL_GETCHANLIST]",
281 - "ioctl[IEEE80211_IOCTL_CHANSWITCH]",
283 - "ioctl[IEEE80211_IOCTL_SET_APPIEBUF]",
284 - "ioctl[IEEE80211_IOCTL_GETSCANRESULTS]",
286 - "ioctl[IEEE80211_IOCTL_GETCHANINFO]",
287 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
288 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
289 - "ioctl[IEEE80211_IOCTL_SETMLME]",
291 - "ioctl[IEEE80211_IOCTL_SETKEY]",
293 - "ioctl[IEEE80211_IOCTL_DELKEY]",
295 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
297 - "ioctl[IEEE80211_IOCTL_DELMAC]",
299 - "ioctl[IEEE80211_IOCTL_WDSMAC]",
301 - "ioctl[IEEE80211_IOCTL_WDSDELMAC]",
303 - "ioctl[IEEE80211_IOCTL_KICKMAC]",
305 -#else /* MADWIFI_NG */
306 - int first = IEEE80211_IOCTL_SETPARAM;
307 - int last = IEEE80211_IOCTL_CHANLIST;
308 - static const char *opnames[] = {
309 - "ioctl[IEEE80211_IOCTL_SETPARAM]",
310 - "ioctl[IEEE80211_IOCTL_GETPARAM]",
311 - "ioctl[IEEE80211_IOCTL_SETKEY]",
312 - "ioctl[IEEE80211_IOCTL_GETKEY]",
313 - "ioctl[IEEE80211_IOCTL_DELKEY]",
315 - "ioctl[IEEE80211_IOCTL_SETMLME]",
317 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
318 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
319 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
321 - "ioctl[IEEE80211_IOCTL_DELMAC]",
323 - "ioctl[IEEE80211_IOCTL_CHANLIST]",
325 -#endif /* MADWIFI_NG */
326 - int idx = op - first;
327 - if (first <= op && op <= last &&
328 - idx < (int) (sizeof(opnames) / sizeof(opnames[0]))
330 - perror(opnames[idx]);
332 - perror("ioctl[unknown???]");
340 -set80211param(struct wpa_driver_madwifi_data *drv, int op, int arg,
345 - os_memset(&iwr, 0, sizeof(iwr));
346 - os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
348 - os_memcpy(iwr.u.name+sizeof(u32), &arg, sizeof(arg));
350 - if (ioctl(drv->sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
352 - perror("ioctl[IEEE80211_IOCTL_SETPARAM]");
359 -wpa_driver_madwifi_set_wpa_ie(struct wpa_driver_madwifi_data *drv,
360 +wpa_driver_madwifi_set_wpa_ie(struct madwifi_driver_data *drv,
361 const u8 *wpa_ie, size_t wpa_ie_len)
364 @@ -1411,7 +1292,7 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
365 iwr.u.data.pointer = (void *) wpa_ie;
366 iwr.u.data.length = wpa_ie_len;
368 - if (ioctl(drv->sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
369 + if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
370 perror("ioctl[IEEE80211_IOCTL_SETOPTIE]");
373 @@ -1419,156 +1300,51 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
377 -wpa_driver_madwifi_del_key(struct wpa_driver_madwifi_data *drv, int key_idx,
380 - struct ieee80211req_del_key wk;
382 - wpa_printf(MSG_DEBUG, "%s: keyidx=%d", __FUNCTION__, key_idx);
383 - os_memset(&wk, 0, sizeof(wk));
384 - wk.idk_keyix = key_idx;
386 - os_memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
388 - return set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk), 1);
392 -wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
393 - const u8 *addr, int key_idx, int set_tx,
394 - const u8 *seq, size_t seq_len,
395 - const u8 *key, size_t key_len)
397 - struct wpa_driver_madwifi_data *drv = priv;
398 - struct ieee80211req_key wk;
402 - if (alg == WPA_ALG_NONE)
403 - return wpa_driver_madwifi_del_key(drv, key_idx, addr);
407 - if (addr == NULL || os_memcmp(addr, "\xff\xff\xff\xff\xff\xff",
410 - * madwifi did not seem to like static WEP key
411 - * configuration with IEEE80211_IOCTL_SETKEY, so use
412 - * Linux wireless extensions ioctl for this.
414 - return wpa_driver_wext_set_key(ifname, drv->wext, alg,
415 - addr, key_idx, set_tx,
420 - cipher = IEEE80211_CIPHER_WEP;
424 - cipher = IEEE80211_CIPHER_TKIP;
428 - cipher = IEEE80211_CIPHER_AES_CCM;
431 - wpa_printf(MSG_DEBUG, "%s: unknown/unsupported algorithm %d",
432 - __FUNCTION__, alg);
436 - wpa_printf(MSG_DEBUG, "%s: alg=%s key_idx=%d set_tx=%d seq_len=%lu "
437 - "key_len=%lu", __FUNCTION__, alg_name, key_idx, set_tx,
438 - (unsigned long) seq_len, (unsigned long) key_len);
440 - if (seq_len > sizeof(u_int64_t)) {
441 - wpa_printf(MSG_DEBUG, "%s: seq_len %lu too big",
442 - __FUNCTION__, (unsigned long) seq_len);
445 - if (key_len > sizeof(wk.ik_keydata)) {
446 - wpa_printf(MSG_DEBUG, "%s: key length %lu too big",
447 - __FUNCTION__, (unsigned long) key_len);
451 - os_memset(&wk, 0, sizeof(wk));
452 - wk.ik_type = cipher;
453 - wk.ik_flags = IEEE80211_KEY_RECV;
454 - if (addr == NULL ||
455 - os_memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0)
456 - wk.ik_flags |= IEEE80211_KEY_GROUP;
458 - wk.ik_flags |= IEEE80211_KEY_XMIT | IEEE80211_KEY_DEFAULT;
459 - os_memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
461 - os_memset(wk.ik_macaddr, 0, IEEE80211_ADDR_LEN);
462 - wk.ik_keyix = key_idx;
463 - wk.ik_keylen = key_len;
464 -#ifdef WORDS_BIGENDIAN
467 - u8 tmp[WPA_KEY_RSC_LEN];
468 - os_memset(tmp, 0, sizeof(tmp));
469 - for (i = 0; i < seq_len; i++)
470 - tmp[WPA_KEY_RSC_LEN - i - 1] = seq[i];
471 - os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
473 -#else /* WORDS_BIGENDIAN */
474 - os_memcpy(&wk.ik_keyrsc, seq, seq_len);
475 -#endif /* WORDS_BIGENDIAN */
476 - os_memcpy(wk.ik_keydata, key, key_len);
478 - return set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk), 1);
482 wpa_driver_madwifi_set_countermeasures(void *priv, int enabled)
484 - struct wpa_driver_madwifi_data *drv = priv;
485 + struct madwifi_driver_data *drv = priv;
486 wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
487 - return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled, 1);
488 + return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled);
492 wpa_driver_madwifi_deauthenticate(void *priv, const u8 *addr, int reason_code)
494 - struct wpa_driver_madwifi_data *drv = priv;
495 + struct madwifi_driver_data *drv = priv;
496 struct ieee80211req_mlme mlme;
498 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
499 mlme.im_op = IEEE80211_MLME_DEAUTH;
500 mlme.im_reason = reason_code;
501 os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
502 - return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme), 1);
503 + return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
507 wpa_driver_madwifi_disassociate(void *priv, const u8 *addr, int reason_code)
509 - struct wpa_driver_madwifi_data *drv = priv;
510 + struct madwifi_driver_data *drv = priv;
511 struct ieee80211req_mlme mlme;
513 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
514 mlme.im_op = IEEE80211_MLME_DISASSOC;
515 mlme.im_reason = reason_code;
516 os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
517 - return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme), 1);
518 + return set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
522 wpa_driver_madwifi_associate(void *priv,
523 struct wpa_driver_associate_params *params)
525 - struct wpa_driver_madwifi_data *drv = priv;
526 + struct madwifi_driver_data *drv = priv;
527 struct ieee80211req_mlme mlme;
528 int ret = 0, privacy = 1;
530 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
532 if (set80211param(drv, IEEE80211_PARAM_DROPUNENCRYPTED,
533 - params->drop_unencrypted, 1) < 0)
534 + params->drop_unencrypted) < 0)
536 if (wpa_driver_madwifi_set_auth_alg(drv, params->auth_alg) < 0)
538 @@ -1591,12 +1367,12 @@ wpa_driver_madwifi_associate(void *priv,
539 params->wpa_ie_len == 0)
542 - if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy, 1) < 0)
543 + if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy) < 0)
546 if (params->wpa_ie_len &&
547 set80211param(drv, IEEE80211_PARAM_WPA,
548 - params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1, 1) < 0)
549 + params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1) < 0)
552 if (params->bssid == NULL) {
553 @@ -1604,14 +1380,14 @@ wpa_driver_madwifi_associate(void *priv,
555 /* FIX: this does not seem to work; would probably need to
556 * change something in the driver */
557 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0)
558 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0) < 0)
561 if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
562 params->ssid_len) < 0)
565 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0)
566 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0)
568 if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
569 params->ssid_len) < 0)
570 @@ -1620,7 +1396,7 @@ wpa_driver_madwifi_associate(void *priv,
571 mlme.im_op = IEEE80211_MLME_ASSOC;
572 os_memcpy(mlme.im_macaddr, params->bssid, IEEE80211_ADDR_LEN);
573 if (set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
574 - sizeof(mlme), 1) < 0) {
575 + sizeof(mlme)) < 0) {
576 wpa_printf(MSG_DEBUG, "%s: SETMLME[ASSOC] failed",
579 @@ -1633,7 +1409,7 @@ wpa_driver_madwifi_associate(void *priv,
581 wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg)
583 - struct wpa_driver_madwifi_data *drv = priv;
584 + struct madwifi_driver_data *drv = priv;
587 if ((auth_alg & WPA_AUTH_ALG_OPEN) &&
588 @@ -1644,13 +1420,13 @@ wpa_driver_madwifi_set_auth_alg(void *pr
590 authmode = IEEE80211_AUTH_OPEN;
592 - return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode, 1);
593 + return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode);
597 wpa_driver_madwifi_scan(void *priv, struct wpa_driver_scan_params *params)
599 - struct wpa_driver_madwifi_data *drv = priv;
600 + struct madwifi_driver_data *drv = priv;
603 const u8 *ssid = params->ssids[0].ssid;
604 @@ -1668,7 +1444,7 @@ wpa_driver_madwifi_scan(void *priv, stru
605 if (wpa_driver_wext_set_ssid(drv->wext, ssid, ssid_len) < 0)
608 - if (ioctl(drv->sock, SIOCSIWSCAN, &iwr) < 0) {
609 + if (ioctl(drv->ioctl_sock, SIOCSIWSCAN, &iwr) < 0) {
610 perror("ioctl[SIOCSIWSCAN]");
613 @@ -1690,14 +1466,14 @@ wpa_driver_madwifi_scan(void *priv, stru
615 static int wpa_driver_madwifi_get_bssid(void *priv, u8 *bssid)
617 - struct wpa_driver_madwifi_data *drv = priv;
618 + struct madwifi_driver_data *drv = priv;
619 return wpa_driver_wext_get_bssid(drv->wext, bssid);
623 static int wpa_driver_madwifi_get_ssid(void *priv, u8 *ssid)
625 - struct wpa_driver_madwifi_data *drv = priv;
626 + struct madwifi_driver_data *drv = priv;
627 return wpa_driver_wext_get_ssid(drv->wext, ssid);
630 @@ -1705,14 +1481,14 @@ static int wpa_driver_madwifi_get_ssid(v
631 static struct wpa_scan_results *
632 wpa_driver_madwifi_get_scan_results(void *priv)
634 - struct wpa_driver_madwifi_data *drv = priv;
635 + struct madwifi_driver_data *drv = priv;
636 return wpa_driver_wext_get_scan_results(drv->wext);
640 static int wpa_driver_madwifi_set_operstate(void *priv, int state)
642 - struct wpa_driver_madwifi_data *drv = priv;
643 + struct madwifi_driver_data *drv = priv;
644 return wpa_driver_wext_set_operstate(drv->wext, state);
647 @@ -1733,7 +1509,7 @@ static int wpa_driver_madwifi_set_probe_
649 ret = set80211priv(priv, IEEE80211_IOCTL_SET_APPIEBUF, probe_req_ie,
650 sizeof(struct ieee80211req_getset_appiebuf) +
654 os_free(probe_req_ie);
656 @@ -1743,7 +1519,7 @@ static int wpa_driver_madwifi_set_probe_
658 static void * wpa_driver_madwifi_init(void *ctx, const char *ifname)
660 - struct wpa_driver_madwifi_data *drv;
661 + struct madwifi_driver_data *drv;
663 drv = os_zalloc(sizeof(*drv));
665 @@ -1754,17 +1530,17 @@ static void * wpa_driver_madwifi_init(vo
668 os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
669 - drv->sock = socket(PF_INET, SOCK_DGRAM, 0);
671 + drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
672 + if (drv->ioctl_sock < 0)
675 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0) {
676 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0) {
677 wpa_printf(MSG_DEBUG, "%s: failed to set wpa_supplicant-based "
678 "roaming", __FUNCTION__);
682 - if (set80211param(drv, IEEE80211_PARAM_WPA, 3, 1) < 0) {
683 + if (set80211param(drv, IEEE80211_PARAM_WPA, 3) < 0) {
684 wpa_printf(MSG_DEBUG, "%s: failed to enable WPA support",
687 @@ -1773,7 +1549,7 @@ static void * wpa_driver_madwifi_init(vo
692 + close(drv->ioctl_sock);
694 wpa_driver_wext_deinit(drv->wext);
696 @@ -1784,38 +1560,37 @@ fail:
698 static void wpa_driver_madwifi_deinit(void *priv)
700 - struct wpa_driver_madwifi_data *drv = priv;
701 + struct madwifi_driver_data *drv = priv;
703 if (wpa_driver_madwifi_set_wpa_ie(drv, NULL, 0) < 0) {
704 wpa_printf(MSG_DEBUG, "%s: failed to clear WPA IE",
707 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0) {
708 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0) < 0) {
709 wpa_printf(MSG_DEBUG, "%s: failed to enable driver-based "
710 "roaming", __FUNCTION__);
712 - if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0, 1) < 0) {
713 + if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0) < 0) {
714 wpa_printf(MSG_DEBUG, "%s: failed to disable forced Privacy "
715 "flag", __FUNCTION__);
717 - if (set80211param(drv, IEEE80211_PARAM_WPA, 0, 1) < 0) {
718 + if (set80211param(drv, IEEE80211_PARAM_WPA, 0) < 0) {
719 wpa_printf(MSG_DEBUG, "%s: failed to disable WPA",
723 wpa_driver_wext_deinit(drv->wext);
726 + close(drv->ioctl_sock);
730 -#endif /* HOSTAPD */
734 const struct wpa_driver_ops wpa_driver_madwifi_ops = {
736 .desc = "MADWIFI 802.11 support (Atheros, etc.)",
737 - .set_key = wpa_driver_madwifi_set_key,
738 + .set_key = madwifi_set_key,
740 .hapd_init = madwifi_init,
741 .hapd_deinit = madwifi_deinit,
742 @@ -1835,7 +1610,8 @@ const struct wpa_driver_ops wpa_driver_m
743 .sta_clear_stats = madwifi_sta_clear_stats,
744 .commit = madwifi_commit,
745 .set_ap_wps_ie = madwifi_set_ap_wps_ie,
747 +#endif /* HOSTAPD */
748 +#if !defined(NO_SUPPLICANT)
749 .get_bssid = wpa_driver_madwifi_get_bssid,
750 .get_ssid = wpa_driver_madwifi_get_ssid,
751 .init = wpa_driver_madwifi_init,
752 @@ -1847,5 +1623,5 @@ const struct wpa_driver_ops wpa_driver_m
753 .disassociate = wpa_driver_madwifi_disassociate,
754 .associate = wpa_driver_madwifi_associate,
755 .set_operstate = wpa_driver_madwifi_set_operstate,
756 -#endif /* HOSTAPD */