ar71xx: ag71xx: use dynamically allocated buffer for napi_stats
[openwrt.git] / package / hostapd / patches / 310-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 @@ -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);
114 } else {
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
118 }
119
120
121 +#ifdef HOSTAPD
122 static int
123 madwifi_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
124 u8 *seq)
125 @@ -591,7 +592,7 @@ madwifi_read_sta_driver_data(void *priv,
126
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));
131
132 f = fopen(buf, "r");
133 if (!f) {
134 @@ -757,7 +758,7 @@ static int madwifi_receive_probe_req(str
135 if (ret)
136 return ret;
137
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)
142 return -1;
143 @@ -1017,7 +1018,7 @@ madwifi_get_we_version(struct madwifi_dr
144 return -1;
145
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;
151
152 @@ -1134,17 +1135,17 @@ madwifi_init(struct hostapd_data *hapd,
153 perror("socket[PF_INET,SOCK_DGRAM]");
154 goto bad;
155 }
156 - memcpy(drv->iface, params->ifname, sizeof(drv->iface));
157 + memcpy(drv->ifname, params->ifname, sizeof(drv->ifname));
158
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)");
164 goto bad;
165 }
166 drv->ifindex = ifr.ifr_ifindex;
167
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)
172 goto bad;
173 @@ -1158,7 +1159,7 @@ madwifi_init(struct hostapd_data *hapd,
174 1);
175 if (drv->sock_recv == NULL)
176 goto bad;
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;
184
185 memset(&iwr, 0, sizeof(iwr));
186 - os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
187 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
188
189 iwr.u.mode = IW_MODE_MASTER;
190
191 @@ -1180,7 +1181,7 @@ madwifi_init(struct hostapd_data *hapd,
192 }
193
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 */
198
199 madwifi_receive_probe_req(drv);
200 @@ -1206,7 +1207,7 @@ madwifi_deinit(void *priv)
201 struct madwifi_driver_data *drv = priv;
202
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
210 struct iwreq iwr;
211
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
219 int ret = 0;
220
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;
226
227 @@ -1271,140 +1272,19 @@ static int
228 madwifi_commit(void *priv)
229 {
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);
233 }
234
235 -#else /* HOSTAPD */
236 +#endif /* HOSTAPD */
237
238 -struct wpa_driver_madwifi_data {
239 - void *wext; /* private data for driver_wext */
240 - void *ctx;
241 - char ifname[IFNAMSIZ + 1];
242 - int sock;
243 -};
244 +#if !defined(NO_SUPPLICANT)
245
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,
248 size_t ies_len);
249
250 -
251 -static int
252 -set80211priv(struct wpa_driver_madwifi_data *drv, int op, void *data, int len,
253 - int show_err)
254 -{
255 - struct iwreq iwr;
256 -
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) {
261 - /*
262 - * Argument data fits inline; put it there.
263 - */
264 - os_memcpy(iwr.u.name, data, len);
265 - } else {
266 - /*
267 - * Argument data too big for inline transfer; setup a
268 - * parameter block instead; the kernel will transfer
269 - * the data for the driver.
270 - */
271 - iwr.u.data.pointer = data;
272 - iwr.u.data.length = len;
273 - }
274 -
275 - if (ioctl(drv->sock, op, &iwr) < 0) {
276 - if (show_err) {
277 -#ifdef MADWIFI_NG
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]",
290 - NULL,
291 - "ioctl[IEEE80211_IOCTL_SET_APPIEBUF]",
292 - "ioctl[IEEE80211_IOCTL_GETSCANRESULTS]",
293 - NULL,
294 - "ioctl[IEEE80211_IOCTL_GETCHANINFO]",
295 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
296 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
297 - "ioctl[IEEE80211_IOCTL_SETMLME]",
298 - NULL,
299 - "ioctl[IEEE80211_IOCTL_SETKEY]",
300 - NULL,
301 - "ioctl[IEEE80211_IOCTL_DELKEY]",
302 - NULL,
303 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
304 - NULL,
305 - "ioctl[IEEE80211_IOCTL_DELMAC]",
306 - NULL,
307 - "ioctl[IEEE80211_IOCTL_WDSMAC]",
308 - NULL,
309 - "ioctl[IEEE80211_IOCTL_WDSDELMAC]",
310 - NULL,
311 - "ioctl[IEEE80211_IOCTL_KICKMAC]",
312 - };
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]",
322 - NULL,
323 - "ioctl[IEEE80211_IOCTL_SETMLME]",
324 - NULL,
325 - "ioctl[IEEE80211_IOCTL_SETOPTIE]",
326 - "ioctl[IEEE80211_IOCTL_GETOPTIE]",
327 - "ioctl[IEEE80211_IOCTL_ADDMAC]",
328 - NULL,
329 - "ioctl[IEEE80211_IOCTL_DELMAC]",
330 - NULL,
331 - "ioctl[IEEE80211_IOCTL_CHANLIST]",
332 - };
333 -#endif /* MADWIFI_NG */
334 - int idx = op - first;
335 - if (first <= op && op <= last &&
336 - idx < (int) (sizeof(opnames) / sizeof(opnames[0]))
337 - && opnames[idx])
338 - perror(opnames[idx]);
339 - else
340 - perror("ioctl[unknown???]");
341 - }
342 - return -1;
343 - }
344 - return 0;
345 -}
346 -
347 -static int
348 -set80211param(struct wpa_driver_madwifi_data *drv, int op, int arg,
349 - int show_err)
350 -{
351 - struct iwreq iwr;
352 -
353 - os_memset(&iwr, 0, sizeof(iwr));
354 - os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
355 - iwr.u.mode = op;
356 - os_memcpy(iwr.u.name+sizeof(u32), &arg, sizeof(arg));
357 -
358 - if (ioctl(drv->sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
359 - if (show_err)
360 - perror("ioctl[IEEE80211_IOCTL_SETPARAM]");
361 - return -1;
362 - }
363 - return 0;
364 -}
365 -
366 static int
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)
370 {
371 struct iwreq iwr;
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;
375
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]");
379 return -1;
380 }
381 @@ -1423,157 +1303,51 @@ wpa_driver_madwifi_set_wpa_ie(struct wpa
382 }
383
384 static int
385 -wpa_driver_madwifi_del_key(struct wpa_driver_madwifi_data *drv, int key_idx,
386 - const u8 *addr)
387 -{
388 - struct ieee80211req_del_key wk;
389 -
390 - wpa_printf(MSG_DEBUG, "%s: keyidx=%d", __FUNCTION__, key_idx);
391 - os_memset(&wk, 0, sizeof(wk));
392 - wk.idk_keyix = key_idx;
393 - if (addr != NULL)
394 - os_memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
395 -
396 - return set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk), 1);
397 -}
398 -
399 -static int
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)
404 -{
405 - struct wpa_driver_madwifi_data *drv = priv;
406 - struct ieee80211req_key wk;
407 - char *alg_name;
408 - u_int8_t cipher;
409 -
410 - if (alg == WPA_ALG_NONE)
411 - return wpa_driver_madwifi_del_key(drv, key_idx, addr);
412 -
413 - switch (alg) {
414 - case WPA_ALG_WEP:
415 - if (addr == NULL || os_memcmp(addr, "\xff\xff\xff\xff\xff\xff",
416 - ETH_ALEN) == 0) {
417 - /*
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.
421 - */
422 - return wpa_driver_wext_set_key(ifname, drv->wext, alg,
423 - addr, key_idx, set_tx,
424 - seq, seq_len,
425 - key, key_len);
426 - }
427 - alg_name = "WEP";
428 - cipher = IEEE80211_CIPHER_WEP;
429 - break;
430 - case WPA_ALG_TKIP:
431 - alg_name = "TKIP";
432 - cipher = IEEE80211_CIPHER_TKIP;
433 - break;
434 - case WPA_ALG_CCMP:
435 - alg_name = "CCMP";
436 - cipher = IEEE80211_CIPHER_AES_CCM;
437 - break;
438 - default:
439 - wpa_printf(MSG_DEBUG, "%s: unknown/unsupported algorithm %d",
440 - __FUNCTION__, alg);
441 - return -1;
442 - }
443 -
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);
447 -
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);
451 - return -2;
452 - }
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);
456 - return -3;
457 - }
458 -
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;
465 - if (set_tx) {
466 - wk.ik_flags |= IEEE80211_KEY_XMIT | IEEE80211_KEY_DEFAULT;
467 - os_memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
468 - } else
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
473 - if (seq) {
474 - size_t i;
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);
480 - }
481 -#else /* WORDS_BIGENDIAN */
482 - if (seq)
483 - os_memcpy(&wk.ik_keyrsc, seq, seq_len);
484 -#endif /* WORDS_BIGENDIAN */
485 - os_memcpy(wk.ik_keydata, key, key_len);
486 -
487 - return set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk), 1);
488 -}
489 -
490 -static int
491 wpa_driver_madwifi_set_countermeasures(void *priv, int enabled)
492 {
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);
498 }
499
500 static int
501 wpa_driver_madwifi_deauthenticate(void *priv, const u8 *addr, int reason_code)
502 {
503 - struct wpa_driver_madwifi_data *drv = priv;
504 + struct madwifi_driver_data *drv = priv;
505 struct ieee80211req_mlme mlme;
506
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));
513 }
514
515 static int
516 wpa_driver_madwifi_disassociate(void *priv, const u8 *addr, int reason_code)
517 {
518 - struct wpa_driver_madwifi_data *drv = priv;
519 + struct madwifi_driver_data *drv = priv;
520 struct ieee80211req_mlme mlme;
521
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));
528 }
529
530 static int
531 wpa_driver_madwifi_associate(void *priv,
532 struct wpa_driver_associate_params *params)
533 {
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;
538
539 wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
540
541 if (set80211param(drv, IEEE80211_PARAM_DROPUNENCRYPTED,
542 - params->drop_unencrypted, 1) < 0)
543 + params->drop_unencrypted) < 0)
544 ret = -1;
545 if (wpa_driver_madwifi_set_auth_alg(drv, params->auth_alg) < 0)
546 ret = -1;
547 @@ -1596,12 +1370,12 @@ wpa_driver_madwifi_associate(void *priv,
548 params->wpa_ie_len == 0)
549 privacy = 0;
550
551 - if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy, 1) < 0)
552 + if (set80211param(drv, IEEE80211_PARAM_PRIVACY, privacy) < 0)
553 ret = -1;
554
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)
559 ret = -1;
560
561 if (params->bssid == NULL) {
562 @@ -1609,14 +1383,14 @@ wpa_driver_madwifi_associate(void *priv,
563 * roaming */
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)
568 ret = -1;
569
570 if (wpa_driver_wext_set_ssid(drv->wext, params->ssid,
571 params->ssid_len) < 0)
572 ret = -1;
573 } else {
574 - if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2, 1) < 0)
575 + if (set80211param(drv, IEEE80211_PARAM_ROAMING, 2) < 0)
576 ret = -1;
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",
586 __func__);
587 ret = -1;
588 @@ -1638,7 +1412,7 @@ wpa_driver_madwifi_associate(void *priv,
589 static int
590 wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg)
591 {
592 - struct wpa_driver_madwifi_data *drv = priv;
593 + struct madwifi_driver_data *drv = priv;
594 int authmode;
595
596 if ((auth_alg & WPA_AUTH_ALG_OPEN) &&
597 @@ -1649,13 +1423,13 @@ wpa_driver_madwifi_set_auth_alg(void *pr
598 else
599 authmode = IEEE80211_AUTH_OPEN;
600
601 - return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode, 1);
602 + return set80211param(drv, IEEE80211_PARAM_AUTHMODE, authmode);
603 }
604
605 static int
606 wpa_driver_madwifi_scan(void *priv, struct wpa_driver_scan_params *params)
607 {
608 - struct wpa_driver_madwifi_data *drv = priv;
609 + struct madwifi_driver_data *drv = priv;
610 struct iwreq iwr;
611 int ret = 0;
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)
615 ret = -1;
616
617 - if (ioctl(drv->sock, SIOCSIWSCAN, &iwr) < 0) {
618 + if (ioctl(drv->ioctl_sock, SIOCSIWSCAN, &iwr) < 0) {
619 perror("ioctl[SIOCSIWSCAN]");
620 ret = -1;
621 }
622 @@ -1695,14 +1469,14 @@ wpa_driver_madwifi_scan(void *priv, stru
623
624 static int wpa_driver_madwifi_get_bssid(void *priv, u8 *bssid)
625 {
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);
629 }
630
631
632 static int wpa_driver_madwifi_get_ssid(void *priv, u8 *ssid)
633 {
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);
637 }
638
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)
642 {
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);
646 }
647
648
649 static int wpa_driver_madwifi_set_operstate(void *priv, int state)
650 {
651 - struct wpa_driver_madwifi_data *drv = priv;
652 + struct madwifi_driver_data *drv = priv;
653 + if (!drv->wext)
654 + return 0;
655 return wpa_driver_wext_set_operstate(drv->wext, state);
656 }
657
658 @@ -1738,7 +1514,7 @@ static int wpa_driver_madwifi_set_probe_
659
660 ret = set80211priv(priv, IEEE80211_IOCTL_SET_APPIEBUF, probe_req_ie,
661 sizeof(struct ieee80211req_getset_appiebuf) +
662 - ies_len, 1);
663 + ies_len);
664
665 os_free(probe_req_ie);
666
667 @@ -1748,7 +1524,7 @@ static int wpa_driver_madwifi_set_probe_
668
669 static void * wpa_driver_madwifi_init(void *ctx, const char *ifname)
670 {
671 - struct wpa_driver_madwifi_data *drv;
672 + struct madwifi_driver_data *drv;
673
674 drv = os_zalloc(sizeof(*drv));
675 if (drv == NULL)
676 @@ -1759,17 +1535,17 @@ static void * wpa_driver_madwifi_init(vo
677
678 drv->ctx = ctx;
679 os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
680 - drv->sock = socket(PF_INET, SOCK_DGRAM, 0);
681 - if (drv->sock < 0)
682 + drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
683 + if (drv->ioctl_sock < 0)
684 goto fail2;
685
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__);
690 goto fail3;
691 }
692
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",
696 __FUNCTION__);
697 goto fail3;
698 @@ -1778,7 +1554,7 @@ static void * wpa_driver_madwifi_init(vo
699 return drv;
700
701 fail3:
702 - close(drv->sock);
703 + close(drv->ioctl_sock);
704 fail2:
705 wpa_driver_wext_deinit(drv->wext);
706 fail:
707 @@ -1789,38 +1565,37 @@ fail:
708
709 static void wpa_driver_madwifi_deinit(void *priv)
710 {
711 - struct wpa_driver_madwifi_data *drv = priv;
712 + struct madwifi_driver_data *drv = priv;
713
714 if (wpa_driver_madwifi_set_wpa_ie(drv, NULL, 0) < 0) {
715 wpa_printf(MSG_DEBUG, "%s: failed to clear WPA IE",
716 __FUNCTION__);
717 }
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__);
722 }
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__);
727 }
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",
731 __FUNCTION__);
732 }
733
734 wpa_driver_wext_deinit(drv->wext);
735
736 - close(drv->sock);
737 + close(drv->ioctl_sock);
738 os_free(drv);
739 }
740
741 -#endif /* HOSTAPD */
742 -
743 +#endif
744
745 const struct wpa_driver_ops wpa_driver_madwifi_ops = {
746 .name = "madwifi",
747 .desc = "MADWIFI 802.11 support (Atheros, etc.)",
748 - .set_key = wpa_driver_madwifi_set_key,
749 + .set_key = madwifi_set_key,
750 #ifdef HOSTAPD
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,
757 -#else /* HOSTAPD */
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 */
768 +#endif
769 };
770 --- a/src/drivers/drivers.mak
771 +++ b/src/drivers/drivers.mak
772 @@ -144,8 +144,8 @@ DRV_WPA_OBJS += ../src/drivers/driver_ro
773 endif
774
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
780 NEED_RFKILL=y
781 endif
782
This page took 0.085124 seconds and 5 git commands to generate.