Gentoo Archives: gentoo-commits

From: "Luca Barbato (lu_zero)" <lu_zero@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in net-wireless/wpa_supplicant/files: wpa_supplicant-0.6.3-ps3_support.patch
Date: Mon, 10 Mar 2008 20:57:11
Message-Id: E1JYp3S-0005xt-Ll@stork.gentoo.org
1 lu_zero 08/03/10 20:57:06
2
3 Added: wpa_supplicant-0.6.3-ps3_support.patch
4 Log:
5 New version
6 (Portage version: 2.1.4.4)
7
8 Revision Changes Path
9 1.1 net-wireless/wpa_supplicant/files/wpa_supplicant-0.6.3-ps3_support.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-wireless/wpa_supplicant/files/wpa_supplicant-0.6.3-ps3_support.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-wireless/wpa_supplicant/files/wpa_supplicant-0.6.3-ps3_support.patch?rev=1.1&content-type=text/plain
13
14 Index: wpa_supplicant-0.6.3-ps3_support.patch
15 ===================================================================
16 This adds support for PS3 wireless to wpa_supplicant.
17
18 Although PS3 wireless driver is designed to conform the WEXT standard
19 as much as possible, unfortunately the wext driver wrapper of
20 wpa_supplicant can not support PS3 wireless fully because:
21
22 - PS3 wireless driver uses private WEXT ioctls for accepting PSK of
23 WPA-Personal from the userland.
24 WEXT does not specify the way to do it.
25
26 - The association and 4-way handshake are done by PS3 virtual
27 wireless device. The guest OSes can not interfere it.
28
29 - No EAPOL frames are allowed to go outside of the
30 hypervisor/firmware nor come from. They are eaten by the firmware.
31
32 Thus I needed to make a new driver wrapper for PS3 wireless.
33
34 This patch can be applied against the latest 0.6.x tree.
35 Please review!
36
37 Thanks in advance.
38
39 Signed-off-by: Masakazu Mokuno <mokuno@××××××××××.jp>
40 ---
41 src/drivers/driver_ps3.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++
42 src/drivers/driver_wext.c | 39 +--------
43 src/drivers/driver_wext.h | 34 ++++++++
44 src/drivers/drivers.c | 6 +
45 wpa_supplicant/Makefile | 6 +
46 5 files changed, 232 insertions(+), 34 deletions(-)
47
48 --- /dev/null
49 +++ b/src/drivers/driver_ps3.c
50 @@ -0,0 +1,181 @@
51 +/*
52 + * WPA Supplicant - PS3 Linux wireless extension driver interface
53 + * Copyright 2007, 2008 Sony Corporation
54 + *
55 + * This program is free software; you can redistribute it and/or modify
56 + * it under the terms of the GNU General Public License version 2 as
57 + * published by the Free Software Foundation.
58 + *
59 + */
60 +
61 +#include "includes.h"
62 +#include <sys/ioctl.h>
63 +#include "wireless_copy.h"
64 +#include "common.h"
65 +#include "wpa_common.h"
66 +#include "driver.h"
67 +#include "eloop.h"
68 +#include "driver_wext.h"
69 +#include "ieee802_11_defs.h"
70 +
71 +static int wpa_driver_ps3_set_wpa_key(struct wpa_driver_wext_data *drv,
72 + struct wpa_driver_associate_params *params)
73 +{
74 + int ret, i;
75 + struct iwreq iwr;
76 + char *buf, *str;
77 +
78 + if (!params->psk && !params->passphrase) {
79 + wpa_printf(MSG_INFO, "%s:no PSK error\n", __FUNCTION__);
80 + return -EINVAL;
81 + }
82 +
83 + os_memset(&iwr, 0, sizeof(iwr));
84 + if (params->psk) {
85 + /* includes null */
86 + iwr.u.data.length = PMK_LEN * 2 + 1;
87 + buf = os_malloc(iwr.u.data.length);
88 + if (!buf)
89 + return -ENOMEM;
90 + str = buf;
91 + for (i = 0; i < PMK_LEN; i++) {
92 + str += snprintf(str, iwr.u.data.length - (str - buf),
93 + "%02x", params->psk[i]);
94 + }
95 + } else if (params->passphrase) {
96 + /* including quotations and null */
97 + iwr.u.data.length = strlen(params->passphrase) + 3;
98 + if (!buf)
99 + return -ENOMEM;
100 + buf[0] = '"';
101 + os_memcpy(buf + 1, params->passphrase, iwr.u.data.length - 3);
102 + buf[iwr.u.data.length - 2] = '"';
103 + buf[iwr.u.data.length - 1] = '\0';
104 + }
105 + iwr.u.data.pointer = (caddr_t)buf;
106 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
107 + ret = ioctl(drv->ioctl_sock, SIOCIWFIRSTPRIV, &iwr);
108 + os_free(buf);
109 +
110 + return ret;
111 +}
112 +
113 +static int wpa_driver_ps3_set_wep_keys(struct wpa_driver_wext_data *drv,
114 + struct wpa_driver_associate_params *params)
115 +{
116 + int ret, i;
117 + struct iwreq iwr;
118 +
119 + for (i = 0; i < 4; i++) {
120 + os_memset(&iwr, 0, sizeof(iwr));
121 + os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
122 + iwr.u.encoding.flags = i + 1;
123 + if (params->wep_key_len[i]) {
124 + iwr.u.encoding.pointer = (caddr_t) params->wep_key[i];
125 + iwr.u.encoding.length = params->wep_key_len[i];
126 + } else
127 + iwr.u.encoding.flags = IW_ENCODE_NOKEY |
128 + IW_ENCODE_DISABLED;
129 +
130 + if (ioctl(drv->ioctl_sock, SIOCSIWENCODE, &iwr) < 0) {
131 + perror("ioctl[SIOCSIWENCODE]");
132 + ret = -1;
133 + }
134 + }
135 + return ret;
136 +}
137 +
138 +static int wpa_driver_ps3_associate(void *priv,
139 + struct wpa_driver_associate_params *params)
140 +{
141 + struct wpa_driver_wext_data *drv = priv;
142 + int ret, i, value;
143 +
144 + wpa_printf(MSG_DEBUG, "%s: <-\n", __func__);
145 +
146 + /* clear BSSID */
147 + if (!params->bssid &&
148 + wpa_driver_wext_set_bssid(drv, NULL) < 0)
149 + ret = -1;
150 +
151 + if (wpa_driver_wext_set_mode(drv, params->mode) < 0)
152 + ret = -1;
153 +
154 + if (params->wpa_ie == NULL || params->wpa_ie_len == 0)
155 + value = IW_AUTH_WPA_VERSION_DISABLED;
156 + else if (params->wpa_ie[0] == WLAN_EID_RSN)
157 + value = IW_AUTH_WPA_VERSION_WPA2;
158 + else
159 + value = IW_AUTH_WPA_VERSION_WPA;
160 + if (wpa_driver_wext_set_auth_param(drv,
161 + IW_AUTH_WPA_VERSION, value) < 0)
162 + ret = -1;
163 + value = wpa_driver_wext_cipher2wext(params->pairwise_suite);
164 + if (wpa_driver_wext_set_auth_param(drv,
165 + IW_AUTH_CIPHER_PAIRWISE, value) < 0)
166 + ret = -1;
167 + value = wpa_driver_wext_cipher2wext(params->group_suite);
168 + if (wpa_driver_wext_set_auth_param(drv,
169 + IW_AUTH_CIPHER_GROUP, value) < 0)
170 + ret = -1;
171 + value = wpa_driver_wext_keymgmt2wext(params->key_mgmt_suite);
172 + if (wpa_driver_wext_set_auth_param(drv,
173 + IW_AUTH_KEY_MGMT, value) < 0)
174 + ret = -1;
175 +
176 + /* set selected BSSID */
177 + if (params->bssid &&
178 + wpa_driver_wext_set_bssid(drv, params->bssid) < 0)
179 + ret = -1;
180 +
181 + switch (params->group_suite) {
182 + case CIPHER_NONE:
183 + ret = 0;
184 + break;
185 + case CIPHER_WEP40:
186 + case CIPHER_WEP104:
187 + ret = wpa_driver_ps3_set_wep_keys(drv, params);
188 + break;
189 + case CIPHER_TKIP:
190 + case CIPHER_CCMP:
191 + ret = wpa_driver_ps3_set_wpa_key(drv, params);
192 + break;
193 + }
194 +
195 + /* start to associate */
196 + ret = wpa_driver_wext_set_ssid(drv, params->ssid, params->ssid_len);
197 +
198 + wpa_printf(MSG_DEBUG, "%s: ->\n", __func__);
199 +
200 + return ret;
201 +}
202 +
203 +static int wpa_driver_ps3_get_capa(void *priv, struct wpa_driver_capa *capa)
204 +{
205 + int ret;
206 + wpa_printf(MSG_DEBUG, "%s:<-\n", __func__);
207 +
208 + ret = wpa_driver_wext_get_capa(priv, capa);
209 + if (ret) {
210 + wpa_printf(MSG_INFO, "%s: base wext returns error %d\n", __func__,
211 + ret);
212 + return ret;
213 + }
214 + /* PS3 hypervisor does association and 4way handshake by itself */
215 + capa->flags |= WPA_DRIVER_FLAGS_4WAY_HANDSHAKE;
216 + wpa_printf(MSG_DEBUG, "%s:->\n", __func__);
217 + return 0;
218 +}
219 +
220 +const struct wpa_driver_ops wpa_driver_ps3_ops = {
221 + .name = "ps3",
222 + .desc = "PLAYSTATION3 Linux wireless extension driver",
223 + .get_bssid = wpa_driver_wext_get_bssid,
224 + .get_ssid = wpa_driver_wext_get_ssid,
225 + .scan = wpa_driver_wext_scan,
226 + .get_scan_results2 = wpa_driver_wext_get_scan_results,
227 + .associate = wpa_driver_ps3_associate, /* PS3 */
228 + .init = wpa_driver_wext_init,
229 + .deinit = wpa_driver_wext_deinit,
230 + .get_capa = wpa_driver_ps3_get_capa, /* PS3 */
231 +};
232 --- a/src/drivers/driver_wext.c
233 +++ b/src/drivers/driver_wext.c
234 @@ -149,32 +149,6 @@ enum {
235 #endif /* CONFIG_CLIENT_MLME */
236
237
238 -struct wpa_driver_wext_data {
239 - void *ctx;
240 - int event_sock;
241 - int ioctl_sock;
242 - int mlme_sock;
243 - char ifname[IFNAMSIZ + 1];
244 - int ifindex;
245 - int ifindex2;
246 - u8 *assoc_req_ies;
247 - size_t assoc_req_ies_len;
248 - u8 *assoc_resp_ies;
249 - size_t assoc_resp_ies_len;
250 - struct wpa_driver_capa capa;
251 - int has_capability;
252 - int we_version_compiled;
253 -
254 - /* for set_auth_alg fallback */
255 - int use_crypt;
256 - int auth_alg_fallback;
257 -
258 - int operstate;
259 -
260 - char mlmedev[IFNAMSIZ + 1];
261 -
262 - int scan_complete_events;
263 -};
264
265
266 static int wpa_driver_wext_flush_pmkid(void *priv);
267 @@ -239,8 +213,8 @@ static int wpa_driver_wext_send_oper_ifl
268 }
269
270
271 -static int wpa_driver_wext_set_auth_param(struct wpa_driver_wext_data *drv,
272 - int idx, u32 value)
273 +int wpa_driver_wext_set_auth_param(struct wpa_driver_wext_data *drv,
274 + int idx, u32 value)
275 {
276 struct iwreq iwr;
277 int ret = 0;
278 @@ -1977,7 +1951,7 @@ static int wpa_driver_wext_set_gen_ie(vo
279 }
280
281
282 -static int wpa_driver_wext_cipher2wext(int cipher)
283 +int wpa_driver_wext_cipher2wext(int cipher)
284 {
285 switch (cipher) {
286 case CIPHER_NONE:
287 @@ -1996,7 +1970,7 @@ static int wpa_driver_wext_cipher2wext(i
288 }
289
290
291 -static int wpa_driver_wext_keymgmt2wext(int keymgmt)
292 +int wpa_driver_wext_keymgmt2wext(int keymgmt)
293 {
294 switch (keymgmt) {
295 case KEY_MGMT_802_1X:
296 @@ -2054,8 +2028,7 @@ wpa_driver_wext_auth_alg_fallback(struct
297 }
298
299
300 -static int
301 -wpa_driver_wext_associate(void *priv,
302 +int wpa_driver_wext_associate(void *priv,
303 struct wpa_driver_associate_params *params)
304 {
305 struct wpa_driver_wext_data *drv = priv;
306 @@ -2239,7 +2212,7 @@ static int wpa_driver_wext_flush_pmkid(v
307 }
308
309
310 -static int wpa_driver_wext_get_capa(void *priv, struct wpa_driver_capa *capa)
311 +int wpa_driver_wext_get_capa(void *priv, struct wpa_driver_capa *capa)
312 {
313 struct wpa_driver_wext_data *drv = priv;
314 if (!drv->has_capability)
315 --- a/src/drivers/driver_wext.h
316 +++ b/src/drivers/driver_wext.h
317 @@ -14,8 +14,32 @@
318
319 #ifndef DRIVER_WEXT_H
320 #define DRIVER_WEXT_H
321 +struct wpa_driver_wext_data {
322 + void *ctx;
323 + int event_sock;
324 + int ioctl_sock;
325 + int mlme_sock;
326 + char ifname[IFNAMSIZ + 1];
327 + int ifindex;
328 + int ifindex2;
329 + u8 *assoc_req_ies;
330 + size_t assoc_req_ies_len;
331 + u8 *assoc_resp_ies;
332 + size_t assoc_resp_ies_len;
333 + struct wpa_driver_capa capa;
334 + int has_capability;
335 + int we_version_compiled;
336 +
337 + /* for set_auth_alg fallback */
338 + int use_crypt;
339 + int auth_alg_fallback;
340
341 -struct wpa_driver_wext_data;
342 + int operstate;
343 +
344 + char mlmedev[IFNAMSIZ + 1];
345 +
346 + int scan_complete_events;
347 +};
348
349 int wpa_driver_wext_get_ifflags(struct wpa_driver_wext_data *drv, int *flags);
350 int wpa_driver_wext_set_ifflags(struct wpa_driver_wext_data *drv, int flags);
351 @@ -43,4 +67,12 @@ void wpa_driver_wext_deinit(void *priv);
352 int wpa_driver_wext_set_operstate(void *priv, int state);
353 int wpa_driver_wext_get_version(struct wpa_driver_wext_data *drv);
354
355 +int wpa_driver_wext_associate(void *priv,
356 + struct wpa_driver_associate_params *params);
357 +int wpa_driver_wext_get_capa(void *priv, struct wpa_driver_capa *capa);
358 +int wpa_driver_wext_set_auth_param(struct wpa_driver_wext_data *drv,
359 + int idx, u32 value);
360 +int wpa_driver_wext_cipher2wext(int cipher);
361 +int wpa_driver_wext_keymgmt2wext(int keymgmt);
362 +
363 #endif /* DRIVER_WEXT_H */
364 --- a/src/drivers/drivers.c
365 +++ b/src/drivers/drivers.c
366 @@ -61,6 +61,9 @@ extern struct wpa_driver_ops wpa_driver_
367 #ifdef CONFIG_DRIVER_OSX
368 extern struct wpa_driver_ops wpa_driver_osx_ops; /* driver_osx.m */
369 #endif /* CONFIG_DRIVER_OSX */
370 +#ifdef CONFIG_DRIVER_PS3
371 +extern struct wpa_driver_ops wpa_driver_ps3_ops; /* driver_ps3.c */
372 +#endif /* CONFIG_DRIVER_PS3 */
373 #ifdef CONFIG_DRIVER_IPHONE
374 extern struct wpa_driver_ops wpa_driver_iphone_ops; /* driver_iphone.m */
375 #endif /* CONFIG_DRIVER_IPHONE */
376 @@ -113,6 +116,9 @@ struct wpa_driver_ops *wpa_supplicant_dr
377 #ifdef CONFIG_DRIVER_OSX
378 &wpa_driver_osx_ops,
379 #endif /* CONFIG_DRIVER_OSX */
380 +#ifdef CONFIG_DRIVER_PS3
381 + &wpa_driver_ps3_ops,
382 +#endif /* CONFIG_DRIVER_PS3 */
383 #ifdef CONFIG_DRIVER_IPHONE
384 &wpa_driver_iphone_ops,
385 #endif /* CONFIG_DRIVER_IPHONE */
386 --- a/wpa_supplicant/Makefile
387 +++ b/wpa_supplicant/Makefile
388 @@ -210,6 +210,12 @@ LDFLAGS += -framework CoreFoundation
389 LDFLAGS += -F/System/Library/PrivateFrameworks -framework Apple80211
390 endif
391
392 +ifdef CONFIG_DRIVER_PS3
393 +CFLAGS += -DCONFIG_DRIVER_PS3 -m64
394 +OBJS_d += ../src/drivers/driver_ps3.o
395 +LDFLAGS += -m64
396 +endif
397 +
398 ifdef CONFIG_DRIVER_IPHONE
399 CFLAGS += -DCONFIG_DRIVER_IPHONE
400 OBJS_d += ../src/drivers/driver_iphone.o
401
402
403
404 --
405 gentoo-commits@l.g.o mailing list