aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/wps_supplicant.c
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2010-10-20 10:37:01 (GMT)
committerJouni Malinen <j@w1.fi>2010-10-20 10:37:01 (GMT)
commitef10f4733f2f28cfe0094ae3429485a4a30c57be (patch)
treea66e8e08db38463276d1d1250fa291957caa8149 /wpa_supplicant/wps_supplicant.c
parentcbbf4a1cc3f3341b0ffe0d3caeae4fa2560feb64 (diff)
downloadhostap-ef10f4733f2f28cfe0094ae3429485a4a30c57be.zip
hostap-ef10f4733f2f28cfe0094ae3429485a4a30c57be.tar.gz
hostap-ef10f4733f2f28cfe0094ae3429485a4a30c57be.tar.bz2
WPS ER: Add wps_er_set_config to use local configuration
This command can be used to enroll a network based on a local network configuration block instead of having to (re-)learn the current AP settings with wps_er_learn.
Diffstat (limited to 'wpa_supplicant/wps_supplicant.c')
-rw-r--r--wpa_supplicant/wps_supplicant.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c
index af8c4c4..bc8dc42 100644
--- a/wpa_supplicant/wps_supplicant.c
+++ b/wpa_supplicant/wps_supplicant.c
@@ -1362,6 +1362,49 @@ int wpas_wps_er_learn(struct wpa_supplicant *wpa_s, const char *uuid,
}
+int wpas_wps_er_set_config(struct wpa_supplicant *wpa_s, const char *uuid,
+ int id)
+{
+ u8 u[UUID_LEN];
+ struct wpa_ssid *ssid;
+ struct wps_credential cred;
+
+ if (uuid_str2bin(uuid, u))
+ return -1;
+ ssid = wpa_config_get_network(wpa_s->conf, id);
+ if (ssid == NULL || ssid->ssid == NULL)
+ return -1;
+
+ os_memset(&cred, 0, sizeof(cred));
+ if (ssid->ssid_len > 32)
+ return -1;
+ os_memcpy(cred.ssid, ssid->ssid, ssid->ssid_len);
+ cred.ssid_len = ssid->ssid_len;
+ if (ssid->key_mgmt & WPA_KEY_MGMT_PSK) {
+ cred.auth_type = (ssid->proto & WPA_PROTO_RSN) ?
+ WPS_AUTH_WPA2PSK : WPS_AUTH_WPAPSK;
+ if (ssid->pairwise_cipher & WPA_CIPHER_CCMP)
+ cred.encr_type = WPS_ENCR_AES;
+ else
+ cred.encr_type = WPS_ENCR_TKIP;
+ if (ssid->passphrase) {
+ cred.key_len = os_strlen(ssid->passphrase);
+ if (cred.key_len >= 64)
+ return -1;
+ os_memcpy(cred.key, ssid->passphrase, cred.key_len);
+ } else if (ssid->psk_set) {
+ cred.key_len = 32;
+ os_memcpy(cred.key, ssid->psk, 32);
+ } else
+ return -1;
+ } else {
+ cred.auth_type = WPS_AUTH_OPEN;
+ cred.encr_type = WPS_ENCR_NONE;
+ }
+ return wps_er_set_config(wpa_s->wps_er, u, &cred);
+}
+
+
int wpas_wps_er_config(struct wpa_supplicant *wpa_s, const char *uuid,
const char *pin, struct wps_new_ap_settings *settings)
{