hostapd: update to 2010-07-05
[openwrt.git] / package / hostapd / patches / 330-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 @@ -462,10 +459,14 @@ wpa_driver_madwifi_set_key(const char *i
108 memset(&wk, 0, sizeof(wk));
109 wk.ik_type = cipher;
110 wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
111 +
112 if (addr == NULL) {
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);
119 } else {
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
123 }
124
125
126 +#ifdef HOSTAPD
127 static int
128 madwifi_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
129 u8 *seq)
130 @@ -591,7 +593,7 @@ madwifi_read_sta_driver_data(void *priv,
131
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));
136
137 f = fopen(buf, "r");
138 if (!f) {
139 @@ -757,7 +759,7 @@ static int madwifi_receive_probe_req(str
140 if (ret)
141 return ret;
142
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)
147 return -1;
148 @@ -1016,7 +1018,7 @@ madwifi_get_we_version(struct madwifi_dr
149 return -1;
150
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;
156
157 @@ -1133,17 +1135,17 @@ madwifi_init(struct hostapd_data *hapd,
158 perror("socket[PF_INET,SOCK_DGRAM]");
159 goto bad;
160 }
161 - memcpy(drv->iface, params->ifname, sizeof(drv->iface));
162 + memcpy(drv->ifname, params->ifname, sizeof(drv->ifname));
163
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)");
169 goto bad;
170 }
171 drv->ifindex = ifr.ifr_ifindex;
172
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)
177 goto bad;
178 @@ -1157,7 +1159,7 @@ madwifi_init(struct hostapd_data *hapd,
179 1);
180 if (drv->sock_recv == NULL)
181 goto bad;
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;
189
190 memset(&iwr, 0, sizeof(iwr));
191 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
192 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
193
194 iwr.u.mode = IW_MODE_MASTER;
195
196 @@ -1203,7 +1205,7 @@ madwifi_deinit(void *priv)
197 struct madwifi_driver_data *drv = priv;
198
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
206 struct iwreq iwr;
207
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
215 int ret = 0;
216
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;
222
223 @@ -1270,137 +1272,16 @@ madwifi_commit(void *priv)
224 return 0;
225 }
226
227 -#else /* HOSTAPD */
228 +#endif /* HOSTAPD */
229
230 -struct wpa_driver_madwifi_data {
231 - void *wext; /* private data for driver_wext */
232 - void *ctx;
233 - char ifname[IFNAMSIZ + 1];
234 - int sock;
235 -};
236 +#if !defined(NO_SUPPLICANT)
237
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,
240 size_t ies_len);
241
242 -
243 -static int
244 -set80211priv(struct wpa_driver_madwifi_data *drv, int op, void *data, int len,
245 - int show_err)
246 -{
247 - struct iwreq iwr;
248 -
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) {
253 - /*
254 - * Argument data fits inline; put it there.
255 - */
256 - os_memcpy(iwr.u.name, data, len);
257 - } else {
258 - /*
259 - * Argument data too big for inline transfer; setup a
260 - * parameter block instead; the kernel will transfer
261 - * the data for the driver.
262 - */
263 - iwr.u.data.pointer = data;
264 - iwr.u.data.length = len;
265 - }
266 -
267 - if (ioctl(drv->sock, op, &iwr) < 0) {
268 - if (show_err) {
269 -#ifdef MADWIFI_NG
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]",
282 - NULL,
283 - "ioctl[IEEE80211_IOCTL_SET_APPIEBUF]",
284 - "ioctl[IEEE80211_IOCTL_GETSCANRESULTS]",
285 - NULL,
286 - "ioctl[IEEE80211_IOCTL_GETCHANINFO]",
287 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
288 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
289 - "ioctl[IEEE80211_IOCTL_SETMLME]",
290 - NULL,
291 - "ioctl[IEEE80211_IOCTL_SETKEY]",
292 - NULL,
293 - "ioctl[IEEE80211_IOCTL_DELKEY]",
294 - NULL,
295 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
296 - NULL,
297 - "ioctl[IEEE80211_IOCTL_DELMAC]",
298 - NULL,
299 - "ioctl[IEEE80211_IOCTL_WDSMAC]",
300 - NULL,
301 - "ioctl[IEEE80211_IOCTL_WDSDELMAC]",
302 - NULL,
303 - "ioctl[IEEE80211_IOCTL_KICKMAC]",
304 - };
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]",
314 - NULL,
315 - "ioctl[IEEE80211_IOCTL_SETMLME]",
316 - NULL,
317 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
318 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
319 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
320 - NULL,
321 - "ioctl[IEEE80211_IOCTL_DELMAC]",
322 - NULL,
323 - "ioctl[IEEE80211_IOCTL_CHANLIST]",
324 - };
325 -#endif /* MADWIFI_NG */
326 - int idx = op - first;
327 - if (first <= op && op <= last &&
328 - idx < (int) (sizeof(opnames) / sizeof(opnames[0]))
329 - && opnames[idx])
330 - perror(opnames[idx]);
331 - else
332 - perror("ioctl[unknown???]");
333 - }
334 - return -1;
335 - }
336 - return 0;
337 -}
338 -
339 static int
340 -set80211param(struct wpa_driver_madwifi_data *drv, int op, int arg,
341 - int show_err)
342 -{
343 - struct iwreq iwr;
344 -
345 - os_memset(&iwr, 0, sizeof(iwr));
346 - os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
347 - iwr.u.mode = op;
348 - os_memcpy(iwr.u.name+sizeof(u32), &arg, sizeof(arg));
349 -
350 - if (ioctl(drv->sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
351 - if (show_err)
352 - perror("ioctl[IEEE80211_IOCTL_SETPARAM]");
353 - return -1;
354 - }
355 - return 0;
356 -}
357 -
358 -static int
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)
362 {
363 struct iwreq iwr;
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;
367
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]");
371 return -1;
372 }
373 @@ -1419,156 +1300,51 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
374 }
375
376 static int
377 -wpa_driver_madwifi_del_key(struct wpa_driver_madwifi_data *drv, int key_idx,
378 - const u8 *addr)
379 -{
380 - struct ieee80211req_del_key wk;
381 -
382 - wpa_printf(MSG_DEBUG, "%s: keyidx=%d", __FUNCTION__, key_idx);
383 - os_memset(&wk, 0, sizeof(wk));
384 - wk.idk_keyix = key_idx;
385 - if (addr != NULL)
386 - os_memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
387 -
388 - return set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk), 1);
389 -}
390 -
391 -static int
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)
396 -{
397 - struct wpa_driver_madwifi_data *drv = priv;
398 - struct ieee80211req_key wk;
399 - char *alg_name;
400 - u_int8_t cipher;
401 -
402 - if (alg == WPA_ALG_NONE)
403 - return wpa_driver_madwifi_del_key(drv, key_idx, addr);
404 -
405 - switch (alg) {
406 - case WPA_ALG_WEP:
407 - if (addr == NULL || os_memcmp(addr, "\xff\xff\xff\xff\xff\xff",
408 - ETH_ALEN) == 0) {
409 - /*
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.
413 - */
414 - return wpa_driver_wext_set_key(ifname, drv->wext, alg,
415 - addr, key_idx, set_tx,
416 - seq, seq_len,
417 - key, key_len);
418 - }
419 - alg_name = "WEP";
420 - cipher = IEEE80211_CIPHER_WEP;
421 - break;
422 - case WPA_ALG_TKIP:
423 - alg_name = "TKIP";
424 - cipher = IEEE80211_CIPHER_TKIP;
425 - break;
426 - case WPA_ALG_CCMP:
427 - alg_name = "CCMP";
428 - cipher = IEEE80211_CIPHER_AES_CCM;
429 - break;
430 - default:
431 - wpa_printf(MSG_DEBUG, "%s: unknown/unsupported algorithm %d",
432 - __FUNCTION__, alg);
433 - return -1;
434 - }
435 -
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);
439 -
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);
443 - return -2;
444 - }
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);
448 - return -3;
449 - }
450 -
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;
457 - if (set_tx) {
458 - wk.ik_flags |= IEEE80211_KEY_XMIT | IEEE80211_KEY_DEFAULT;
459 - os_memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
460 - } else
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
465 - {
466 - size_t i;
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);
472 - }
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);
477 -
478 - return set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk), 1);
479 -}
480 -
481 -static int
482 wpa_driver_madwifi_set_countermeasures(void *priv, int enabled)
483 {
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);
489 }
490
491 static int
492 wpa_driver_madwifi_deauthenticate(void *priv, const u8 *addr, int reason_code)
493 {
494 - struct wpa_driver_madwifi_data *drv = priv;
495 + struct madwifi_driver_data *drv = priv;
496 struct ieee80211req_mlme mlme;
497
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));
504 }
505
506 static int
507 wpa_driver_madwifi_disassociate(void *priv, const u8 *addr, int reason_code)
508 {
509 - struct wpa_driver_madwifi_data *drv = priv;
510 + struct madwifi_driver_data *drv = priv;
511 struct ieee80211req_mlme mlme;
512
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));
519 }
520
521 static int
522 wpa_driver_madwifi_associate(void *priv,
523 struct wpa_driver_associate_params *params)
524 {
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;
529
530 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
531
532 if (set80211param(drv, IEEE80211_PARAM_DROPUNENCRYPTED,
533 - params->drop_unencrypted, 1) < 0)
534 + params->drop_unencrypted) < 0)
535 ret = -1;
536 if (wpa_driver_madwifi_set_auth_alg(drv, params->auth_alg) < 0)
537 ret = -1;
538 @@ -1591,12 +1367,12 @@ wpa_driver_madwifi_associate(void *priv,
539 params->wpa_ie_len == 0)
540 privacy = 0;
541
542 - if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy, 1) < 0)
543 + if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy) < 0)
544 ret = -1;
545
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)
550 ret = -1;
551
552 if (params->bssid == NULL) {
553 @@ -1604,14 +1380,14 @@ wpa_driver_madwifi_associate(void *priv,
554 * roaming */
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)
559 ret = -1;
560
561 if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
562 params->ssid_len) < 0)
563 ret = -1;
564 } else {
565 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0)
566 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0)
567 ret = -1;
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",
577 __func__);
578 ret = -1;
579 @@ -1633,7 +1409,7 @@ wpa_driver_madwifi_associate(void *priv,
580 static int
581 wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg)
582 {
583 - struct wpa_driver_madwifi_data *drv = priv;
584 + struct madwifi_driver_data *drv = priv;
585 int authmode;
586
587 if ((auth_alg & WPA_AUTH_ALG_OPEN) &&
588 @@ -1644,13 +1420,13 @@ wpa_driver_madwifi_set_auth_alg(void *pr
589 else
590 authmode = IEEE80211_AUTH_OPEN;
591
592 - return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode, 1);
593 + return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode);
594 }
595
596 static int
597 wpa_driver_madwifi_scan(void *priv, struct wpa_driver_scan_params *params)
598 {
599 - struct wpa_driver_madwifi_data *drv = priv;
600 + struct madwifi_driver_data *drv = priv;
601 struct iwreq iwr;
602 int ret = 0;
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)
606 ret = -1;
607
608 - if (ioctl(drv->sock, SIOCSIWSCAN, &iwr) < 0) {
609 + if (ioctl(drv->ioctl_sock, SIOCSIWSCAN, &iwr) < 0) {
610 perror("ioctl[SIOCSIWSCAN]");
611 ret = -1;
612 }
613 @@ -1690,14 +1466,14 @@ wpa_driver_madwifi_scan(void *priv, stru
614
615 static int wpa_driver_madwifi_get_bssid(void *priv, u8 *bssid)
616 {
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);
620 }
621
622
623 static int wpa_driver_madwifi_get_ssid(void *priv, u8 *ssid)
624 {
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);
628 }
629
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)
633 {
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);
637 }
638
639
640 static int wpa_driver_madwifi_set_operstate(void *priv, int state)
641 {
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);
645 }
646
647 @@ -1733,7 +1509,7 @@ static int wpa_driver_madwifi_set_probe_
648
649 ret = set80211priv(priv, IEEE80211_IOCTL_SET_APPIEBUF, probe_req_ie,
650 sizeof(struct ieee80211req_getset_appiebuf) +
651 - ies_len, 1);
652 + ies_len);
653
654 os_free(probe_req_ie);
655
656 @@ -1743,7 +1519,7 @@ static int wpa_driver_madwifi_set_probe_
657
658 static void * wpa_driver_madwifi_init(void *ctx, const char *ifname)
659 {
660 - struct wpa_driver_madwifi_data *drv;
661 + struct madwifi_driver_data *drv;
662
663 drv = os_zalloc(sizeof(*drv));
664 if (drv == NULL)
665 @@ -1754,17 +1530,17 @@ static void * wpa_driver_madwifi_init(vo
666
667 drv->ctx = ctx;
668 os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
669 - drv->sock = socket(PF_INET, SOCK_DGRAM, 0);
670 - if (drv->sock < 0)
671 + drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
672 + if (drv->ioctl_sock < 0)
673 goto fail2;
674
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__);
679 goto fail3;
680 }
681
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",
685 __FUNCTION__);
686 goto fail3;
687 @@ -1773,7 +1549,7 @@ static void * wpa_driver_madwifi_init(vo
688 return drv;
689
690 fail3:
691 - close(drv->sock);
692 + close(drv->ioctl_sock);
693 fail2:
694 wpa_driver_wext_deinit(drv->wext);
695 fail:
696 @@ -1784,38 +1560,37 @@ fail:
697
698 static void wpa_driver_madwifi_deinit(void *priv)
699 {
700 - struct wpa_driver_madwifi_data *drv = priv;
701 + struct madwifi_driver_data *drv = priv;
702
703 if (wpa_driver_madwifi_set_wpa_ie(drv, NULL, 0) < 0) {
704 wpa_printf(MSG_DEBUG, "%s: failed to clear WPA IE",
705 __FUNCTION__);
706 }
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__);
711 }
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__);
716 }
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",
720 __FUNCTION__);
721 }
722
723 wpa_driver_wext_deinit(drv->wext);
724
725 - close(drv->sock);
726 + close(drv->ioctl_sock);
727 os_free(drv);
728 }
729
730 -#endif /* HOSTAPD */
731 -
732 +#endif
733
734 const struct wpa_driver_ops wpa_driver_madwifi_ops = {
735 .name = "madwifi",
736 .desc = "MADWIFI 802.11 support (Atheros, etc.)",
737 - .set_key = wpa_driver_madwifi_set_key,
738 + .set_key = madwifi_set_key,
739 #ifdef HOSTAPD
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,
746 -#else /* HOSTAPD */
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 */
757 +#endif
758 };
This page took 0.078024 seconds and 5 git commands to generate.