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 @@ -1179,7 +1181,7 @@ madwifi_init(struct hostapd_data *hapd,
200 - madwifi_set_privacy(drv->iface, drv, 0); /* default to no privacy */
201 + madwifi_set_privacy(drv->ifname, drv, 0); /* default to no privacy */
203 madwifi_receive_probe_req(drv);
205 @@ -1204,7 +1206,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 @@ -1223,7 +1225,7 @@ madwifi_set_ssid(const char *ifname, voi
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 @@ -1244,7 +1246,7 @@ madwifi_get_ssid(const char *ifname, voi
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,137 +1273,16 @@ madwifi_commit(void *priv)
237 +#endif /* HOSTAPD */
239 -struct wpa_driver_madwifi_data {
240 - void *wext; /* private data for driver_wext */
242 - char ifname[IFNAMSIZ + 1];
245 +#if !defined(NO_SUPPLICANT)
247 static int wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg);
248 static int wpa_driver_madwifi_set_probe_req_ie(void *priv, const u8 *ies,
253 -set80211priv(struct wpa_driver_madwifi_data *drv, int op, void *data, int len,
258 - os_memset(&iwr, 0, sizeof(iwr));
259 - os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
260 - if (len < IFNAMSIZ &&
261 - op != IEEE80211_IOCTL_SET_APPIEBUF) {
263 - * Argument data fits inline; put it there.
265 - os_memcpy(iwr.u.name, data, len);
268 - * Argument data too big for inline transfer; setup a
269 - * parameter block instead; the kernel will transfer
270 - * the data for the driver.
272 - iwr.u.data.pointer = data;
273 - iwr.u.data.length = len;
276 - if (ioctl(drv->sock, op, &iwr) < 0) {
279 - int first = IEEE80211_IOCTL_SETPARAM;
280 - int last = IEEE80211_IOCTL_KICKMAC;
281 - static const char *opnames[] = {
282 - "ioctl[IEEE80211_IOCTL_SETPARAM]",
283 - "ioctl[IEEE80211_IOCTL_GETPARAM]",
284 - "ioctl[IEEE80211_IOCTL_SETMODE]",
285 - "ioctl[IEEE80211_IOCTL_GETMODE]",
286 - "ioctl[IEEE80211_IOCTL_SETWMMPARAMS]",
287 - "ioctl[IEEE80211_IOCTL_GETWMMPARAMS]",
288 - "ioctl[IEEE80211_IOCTL_SETCHANLIST]",
289 - "ioctl[IEEE80211_IOCTL_GETCHANLIST]",
290 - "ioctl[IEEE80211_IOCTL_CHANSWITCH]",
292 - "ioctl[IEEE80211_IOCTL_SET_APPIEBUF]",
293 - "ioctl[IEEE80211_IOCTL_GETSCANRESULTS]",
295 - "ioctl[IEEE80211_IOCTL_GETCHANINFO]",
296 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
297 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
298 - "ioctl[IEEE80211_IOCTL_SETMLME]",
300 - "ioctl[IEEE80211_IOCTL_SETKEY]",
302 - "ioctl[IEEE80211_IOCTL_DELKEY]",
304 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
306 - "ioctl[IEEE80211_IOCTL_DELMAC]",
308 - "ioctl[IEEE80211_IOCTL_WDSMAC]",
310 - "ioctl[IEEE80211_IOCTL_WDSDELMAC]",
312 - "ioctl[IEEE80211_IOCTL_KICKMAC]",
314 -#else /* MADWIFI_NG */
315 - int first = IEEE80211_IOCTL_SETPARAM;
316 - int last = IEEE80211_IOCTL_CHANLIST;
317 - static const char *opnames[] = {
318 - "ioctl[IEEE80211_IOCTL_SETPARAM]",
319 - "ioctl[IEEE80211_IOCTL_GETPARAM]",
320 - "ioctl[IEEE80211_IOCTL_SETKEY]",
321 - "ioctl[IEEE80211_IOCTL_GETKEY]",
322 - "ioctl[IEEE80211_IOCTL_DELKEY]",
324 - "ioctl[IEEE80211_IOCTL_SETMLME]",
326 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
327 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
328 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
330 - "ioctl[IEEE80211_IOCTL_DELMAC]",
332 - "ioctl[IEEE80211_IOCTL_CHANLIST]",
334 -#endif /* MADWIFI_NG */
335 - int idx = op - first;
336 - if (first <= op && op <= last &&
337 - idx < (int) (sizeof(opnames) / sizeof(opnames[0]))
339 - perror(opnames[idx]);
341 - perror("ioctl[unknown???]");
349 -set80211param(struct wpa_driver_madwifi_data *drv, int op, int arg,
354 - os_memset(&iwr, 0, sizeof(iwr));
355 - os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
357 - os_memcpy(iwr.u.name+sizeof(u32), &arg, sizeof(arg));
359 - if (ioctl(drv->sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
361 - perror("ioctl[IEEE80211_IOCTL_SETPARAM]");
368 -wpa_driver_madwifi_set_wpa_ie(struct wpa_driver_madwifi_data *drv,
369 +wpa_driver_madwifi_set_wpa_ie(struct madwifi_driver_data *drv,
370 const u8 *wpa_ie, size_t wpa_ie_len)
373 @@ -1412,7 +1293,7 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
374 iwr.u.data.pointer = (void *) wpa_ie;
375 iwr.u.data.length = wpa_ie_len;
377 - if (ioctl(drv->sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
378 + if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_SETOPTIE, &iwr) < 0) {
379 perror("ioctl[IEEE80211_IOCTL_SETOPTIE]");
382 @@ -1420,156 +1301,51 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
386 -wpa_driver_madwifi_del_key(struct wpa_driver_madwifi_data *drv, int key_idx,
389 - struct ieee80211req_del_key wk;
391 - wpa_printf(MSG_DEBUG, "%s: keyidx=%d", __FUNCTION__, key_idx);
392 - os_memset(&wk, 0, sizeof(wk));
393 - wk.idk_keyix = key_idx;
395 - os_memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
397 - return set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk), 1);
401 -wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
402 - const u8 *addr, int key_idx, int set_tx,
403 - const u8 *seq, size_t seq_len,
404 - const u8 *key, size_t key_len)
406 - struct wpa_driver_madwifi_data *drv = priv;
407 - struct ieee80211req_key wk;
411 - if (alg == WPA_ALG_NONE)
412 - return wpa_driver_madwifi_del_key(drv, key_idx, addr);
416 - if (addr == NULL || os_memcmp(addr, "\xff\xff\xff\xff\xff\xff",
419 - * madwifi did not seem to like static WEP key
420 - * configuration with IEEE80211_IOCTL_SETKEY, so use
421 - * Linux wireless extensions ioctl for this.
423 - return wpa_driver_wext_set_key(ifname, drv->wext, alg,
424 - addr, key_idx, set_tx,
429 - cipher = IEEE80211_CIPHER_WEP;
433 - cipher = IEEE80211_CIPHER_TKIP;
437 - cipher = IEEE80211_CIPHER_AES_CCM;
440 - wpa_printf(MSG_DEBUG, "%s: unknown/unsupported algorithm %d",
441 - __FUNCTION__, alg);
445 - wpa_printf(MSG_DEBUG, "%s: alg=%s key_idx=%d set_tx=%d seq_len=%lu "
446 - "key_len=%lu", __FUNCTION__, alg_name, key_idx, set_tx,
447 - (unsigned long) seq_len, (unsigned long) key_len);
449 - if (seq_len > sizeof(u_int64_t)) {
450 - wpa_printf(MSG_DEBUG, "%s: seq_len %lu too big",
451 - __FUNCTION__, (unsigned long) seq_len);
454 - if (key_len > sizeof(wk.ik_keydata)) {
455 - wpa_printf(MSG_DEBUG, "%s: key length %lu too big",
456 - __FUNCTION__, (unsigned long) key_len);
460 - os_memset(&wk, 0, sizeof(wk));
461 - wk.ik_type = cipher;
462 - wk.ik_flags = IEEE80211_KEY_RECV;
463 - if (addr == NULL ||
464 - os_memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0)
465 - wk.ik_flags |= IEEE80211_KEY_GROUP;
467 - wk.ik_flags |= IEEE80211_KEY_XMIT | IEEE80211_KEY_DEFAULT;
468 - os_memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
470 - os_memset(wk.ik_macaddr, 0, IEEE80211_ADDR_LEN);
471 - wk.ik_keyix = key_idx;
472 - wk.ik_keylen = key_len;
473 -#ifdef WORDS_BIGENDIAN
476 - u8 tmp[WPA_KEY_RSC_LEN];
477 - os_memset(tmp, 0, sizeof(tmp));
478 - for (i = 0; i < seq_len; i++)
479 - tmp[WPA_KEY_RSC_LEN - i - 1] = seq[i];
480 - os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
482 -#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 @@ -1592,12 +1368,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 @@ -1605,14 +1381,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 @@ -1621,7 +1397,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 @@ -1634,7 +1410,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 @@ -1645,13 +1421,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 @@ -1669,7 +1445,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 @@ -1691,14 +1467,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 @@ -1706,14 +1482,14 @@ 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;
653 return wpa_driver_wext_set_operstate(drv->wext, state);
656 @@ -1734,7 +1510,7 @@ static int wpa_driver_madwifi_set_probe_
658 ret = set80211priv(priv, IEEE80211_IOCTL_SET_APPIEBUF, probe_req_ie,
659 sizeof(struct ieee80211req_getset_appiebuf) +
663 os_free(probe_req_ie);
665 @@ -1744,7 +1520,7 @@ static int wpa_driver_madwifi_set_probe_
667 static void * wpa_driver_madwifi_init(void *ctx, const char *ifname)
669 - struct wpa_driver_madwifi_data *drv;
670 + struct madwifi_driver_data *drv;
672 drv = os_zalloc(sizeof(*drv));
674 @@ -1755,17 +1531,17 @@ static void * wpa_driver_madwifi_init(vo
677 os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
678 - drv->sock = socket(PF_INET, SOCK_DGRAM, 0);
680 + drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
681 + if (drv->ioctl_sock < 0)
684 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0) {
685 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0) {
686 wpa_printf(MSG_DEBUG, "%s: failed to set wpa_supplicant-based "
687 "roaming", __FUNCTION__);
691 - if (set80211param(drv, IEEE80211_PARAM_WPA, 3, 1) < 0) {
692 + if (set80211param(drv, IEEE80211_PARAM_WPA, 3) < 0) {
693 wpa_printf(MSG_DEBUG, "%s: failed to enable WPA support",
696 @@ -1774,7 +1550,7 @@ static void * wpa_driver_madwifi_init(vo
701 + close(drv->ioctl_sock);
703 wpa_driver_wext_deinit(drv->wext);
705 @@ -1785,38 +1561,37 @@ fail:
707 static void wpa_driver_madwifi_deinit(void *priv)
709 - struct wpa_driver_madwifi_data *drv = priv;
710 + struct madwifi_driver_data *drv = priv;
712 if (wpa_driver_madwifi_set_wpa_ie(drv, NULL, 0) < 0) {
713 wpa_printf(MSG_DEBUG, "%s: failed to clear WPA IE",
716 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0, 1) < 0) {
717 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 0) < 0) {
718 wpa_printf(MSG_DEBUG, "%s: failed to enable driver-based "
719 "roaming", __FUNCTION__);
721 - if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0, 1) < 0) {
722 + if (set80211param(drv, IEEE80211_PARAM_PRIVACY, 0) < 0) {
723 wpa_printf(MSG_DEBUG, "%s: failed to disable forced Privacy "
724 "flag", __FUNCTION__);
726 - if (set80211param(drv, IEEE80211_PARAM_WPA, 0, 1) < 0) {
727 + if (set80211param(drv, IEEE80211_PARAM_WPA, 0) < 0) {
728 wpa_printf(MSG_DEBUG, "%s: failed to disable WPA",
732 wpa_driver_wext_deinit(drv->wext);
735 + close(drv->ioctl_sock);
739 -#endif /* HOSTAPD */
743 const struct wpa_driver_ops wpa_driver_madwifi_ops = {
745 .desc = "MADWIFI 802.11 support (Atheros, etc.)",
746 - .set_key = wpa_driver_madwifi_set_key,
747 + .set_key = madwifi_set_key,
749 .hapd_init = madwifi_init,
750 .hapd_deinit = madwifi_deinit,
751 @@ -1836,7 +1611,8 @@ const struct wpa_driver_ops wpa_driver_m
752 .sta_clear_stats = madwifi_sta_clear_stats,
753 .commit = madwifi_commit,
754 .set_ap_wps_ie = madwifi_set_ap_wps_ie,
756 +#endif /* HOSTAPD */
757 +#if !defined(NO_SUPPLICANT)
758 .get_bssid = wpa_driver_madwifi_get_bssid,
759 .get_ssid = wpa_driver_madwifi_get_ssid,
760 .init = wpa_driver_madwifi_init,
761 @@ -1848,5 +1624,5 @@ const struct wpa_driver_ops wpa_driver_m
762 .disassociate = wpa_driver_madwifi_disassociate,
763 .associate = wpa_driver_madwifi_associate,
764 .set_operstate = wpa_driver_madwifi_set_operstate,
765 -#endif /* HOSTAPD */