2 * WPA Supplicant - PS3 Linux wireless extension driver interface
3 * Copyright 2007, 2008 Sony Corporation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
16 #include <sys/ioctl.h>
17 #include "wireless_copy.h"
19 #include "wpa_common.h"
22 #include "driver_wext.h"
23 #include "ieee802_11_defs.h"
25 static int wpa_driver_ps3_set_wpa_key(struct wpa_driver_wext_data
*drv
,
26 struct wpa_driver_associate_params
*params
)
32 if (!params
->psk
&& !params
->passphrase
) {
33 wpa_printf(MSG_INFO
, "%s:no PSK error", __func__
);
37 os_memset(&iwr
, 0, sizeof(iwr
));
40 iwr
.u
.data
.length
= PMK_LEN
* 2 + 1;
41 buf
= os_malloc(iwr
.u
.data
.length
);
45 for (i
= 0; i
< PMK_LEN
; i
++) {
46 str
+= snprintf(str
, iwr
.u
.data
.length
- (str
- buf
),
47 "%02x", params
->psk
[i
]);
49 } else if (params
->passphrase
) {
50 /* including quotations and null */
51 iwr
.u
.data
.length
= strlen(params
->passphrase
) + 3;
52 buf
= os_malloc(iwr
.u
.data
.length
);
56 os_memcpy(buf
+ 1, params
->passphrase
, iwr
.u
.data
.length
- 3);
57 buf
[iwr
.u
.data
.length
- 2] = '"';
58 buf
[iwr
.u
.data
.length
- 1] = '\0';
61 iwr
.u
.data
.pointer
= (caddr_t
) buf
;
62 os_strlcpy(iwr
.ifr_name
, drv
->ifname
, IFNAMSIZ
);
63 ret
= ioctl(drv
->ioctl_sock
, SIOCIWFIRSTPRIV
, &iwr
);
69 static int wpa_driver_ps3_set_wep_keys(struct wpa_driver_wext_data
*drv
,
70 struct wpa_driver_associate_params
*params
)
75 for (i
= 0; i
< 4; i
++) {
76 os_memset(&iwr
, 0, sizeof(iwr
));
77 os_strlcpy(iwr
.ifr_name
, drv
->ifname
, IFNAMSIZ
);
78 iwr
.u
.encoding
.flags
= i
+ 1;
79 if (params
->wep_key_len
[i
]) {
80 iwr
.u
.encoding
.pointer
= (caddr_t
) params
->wep_key
[i
];
81 iwr
.u
.encoding
.length
= params
->wep_key_len
[i
];
83 iwr
.u
.encoding
.flags
= IW_ENCODE_NOKEY
|
86 if (ioctl(drv
->ioctl_sock
, SIOCSIWENCODE
, &iwr
) < 0) {
87 perror("ioctl[SIOCSIWENCODE]");
94 static int wpa_driver_ps3_associate(void *priv
,
95 struct wpa_driver_associate_params
*params
)
97 struct wpa_driver_wext_data
*drv
= priv
;
100 wpa_printf(MSG_DEBUG
, "%s: <-", __func__
);
103 if (!params
->bssid
&&
104 wpa_driver_wext_set_bssid(drv
, NULL
) < 0)
107 if (wpa_driver_wext_set_mode(drv
, params
->mode
) < 0)
110 if (params
->wpa_ie
== NULL
|| params
->wpa_ie_len
== 0)
111 value
= IW_AUTH_WPA_VERSION_DISABLED
;
112 else if (params
->wpa_ie
[0] == WLAN_EID_RSN
)
113 value
= IW_AUTH_WPA_VERSION_WPA2
;
115 value
= IW_AUTH_WPA_VERSION_WPA
;
116 if (wpa_driver_wext_set_auth_param(drv
,
117 IW_AUTH_WPA_VERSION
, value
) < 0)
119 value
= wpa_driver_wext_cipher2wext(params
->pairwise_suite
);
120 if (wpa_driver_wext_set_auth_param(drv
,
121 IW_AUTH_CIPHER_PAIRWISE
, value
) < 0)
123 value
= wpa_driver_wext_cipher2wext(params
->group_suite
);
124 if (wpa_driver_wext_set_auth_param(drv
,
125 IW_AUTH_CIPHER_GROUP
, value
) < 0)
127 value
= wpa_driver_wext_keymgmt2wext(params
->key_mgmt_suite
);
128 if (wpa_driver_wext_set_auth_param(drv
, IW_AUTH_KEY_MGMT
, value
) < 0)
131 /* set selected BSSID */
133 wpa_driver_wext_set_bssid(drv
, params
->bssid
) < 0)
136 switch (params
->group_suite
) {
142 ret
= wpa_driver_ps3_set_wep_keys(drv
, params
);
146 ret
= wpa_driver_ps3_set_wpa_key(drv
, params
);
150 /* start to associate */
151 ret
= wpa_driver_wext_set_ssid(drv
, params
->ssid
, params
->ssid_len
);
153 wpa_printf(MSG_DEBUG
, "%s: ->", __func__
);
158 static int wpa_driver_ps3_get_capa(void *priv
, struct wpa_driver_capa
*capa
)
161 wpa_printf(MSG_DEBUG
, "%s:<-", __func__
);
163 ret
= wpa_driver_wext_get_capa(priv
, capa
);
165 wpa_printf(MSG_INFO
, "%s: base wext returns error %d",
169 /* PS3 hypervisor does association and 4way handshake by itself */
170 capa
->flags
|= WPA_DRIVER_FLAGS_4WAY_HANDSHAKE
;
171 wpa_printf(MSG_DEBUG
, "%s:->", __func__
);
175 const struct wpa_driver_ops wpa_driver_ps3_ops
= {
177 .desc
= "PLAYSTATION3 Linux wireless extension driver",
178 .get_bssid
= wpa_driver_wext_get_bssid
,
179 .get_ssid
= wpa_driver_wext_get_ssid
,
180 .scan
= wpa_driver_wext_scan
,
181 .get_scan_results2
= wpa_driver_wext_get_scan_results
,
182 .associate
= wpa_driver_ps3_associate
, /* PS3 */
183 .init
= wpa_driver_wext_init
,
184 .deinit
= wpa_driver_wext_deinit
,
185 .get_capa
= wpa_driver_ps3_get_capa
, /* PS3 */