diff options
author | Jouni Malinen <j@w1.fi> | 2009-01-03 20:18:35 +0200 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2009-01-03 20:18:35 +0200 |
commit | c5adf528a2d9a35ac3fb7376ada2187ff5582c7f (patch) | |
tree | c188a9379e698839abcdd825868129c58e943b49 | |
parent | 41c00105f254344cb352963bc5d11e2322b93886 (diff) | |
download | external_wpa_supplicant_8_ti-c5adf528a2d9a35ac3fb7376ada2187ff5582c7f.zip external_wpa_supplicant_8_ti-c5adf528a2d9a35ac3fb7376ada2187ff5582c7f.tar.gz external_wpa_supplicant_8_ti-c5adf528a2d9a35ac3fb7376ada2187ff5582c7f.tar.bz2 |
Moved WPS Registrar initialization from EAP peer to wps_supplicant.c
This matches the style used in hostapd, i.e., Registrar is initialized
only once and callbacks are now processed in wps_supplicant.c.
-rw-r--r-- | src/eap_peer/eap_wsc.c | 57 | ||||
-rw-r--r-- | wpa_supplicant/wps_supplicant.c | 49 |
2 files changed, 49 insertions, 57 deletions
diff --git a/src/eap_peer/eap_wsc.c b/src/eap_peer/eap_wsc.c index 7d52181..35c9cce 100644 --- a/src/eap_peer/eap_wsc.c +++ b/src/eap_peer/eap_wsc.c @@ -65,38 +65,6 @@ static void eap_wsc_state(struct eap_wsc_data *data, int state) } -static int eap_wsc_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *psk, - size_t psk_len) -{ - wpa_printf(MSG_DEBUG, "EAP-WSC: Received new WPA/WPA2-PSK from WPS for" - " STA " MACSTR, MAC2STR(mac_addr)); - wpa_hexdump_key(MSG_DEBUG, "Per-device PSK", psk, psk_len); - - /* TODO */ - - return 0; -} - - -static void eap_wsc_pin_needed_cb(void *ctx, const u8 *uuid_e, - const struct wps_device_data *dev) -{ - char uuid[40], txt[400]; - int len; - if (uuid_bin2str(uuid_e, uuid, sizeof(uuid))) - return; - wpa_printf(MSG_DEBUG, "EAP-WSC: PIN needed for E-UUID %s", uuid); - len = os_snprintf(txt, sizeof(txt), "WPS-EVENT-PIN-NEEDED " - "%s " MACSTR " [%s|%s|%s|%s|%s|%d-%08X-%d]", - uuid, MAC2STR(dev->mac_addr), dev->device_name, - dev->manufacturer, dev->model_name, - dev->model_number, dev->serial_number, - dev->categ, dev->oui, dev->sub_categ); - if (len > 0 && len < (int) sizeof(txt)) - wpa_printf(MSG_INFO, "%s", txt); -} - - static void * eap_wsc_init(struct eap_sm *sm) { struct eap_wsc_data *data; @@ -135,29 +103,6 @@ static void * eap_wsc_init(struct eap_sm *sm) data->registrar = registrar; data->wps_ctx = wps; - if (registrar) { - struct wps_registrar_config rcfg; - - wps->auth_types = WPS_AUTH_WPA2PSK | WPS_AUTH_WPAPSK; - wps->encr_types = WPS_ENCR_AES | WPS_ENCR_TKIP; - - os_memset(&rcfg, 0, sizeof(rcfg)); - rcfg.new_psk_cb = eap_wsc_new_psk_cb; - rcfg.pin_needed_cb = eap_wsc_pin_needed_cb; - rcfg.cb_ctx = data; - - wps->registrar = wps_registrar_init(wps, &rcfg); - if (wps->registrar == NULL) { - wpa_printf(MSG_DEBUG, "EAP-WSC: Failed to initialize " - "WPS Registrar"); - os_free(wps->network_key); - os_free(wps); - os_free(data); - return NULL; - } - - } - os_memset(&cfg, 0, sizeof(cfg)); cfg.wps = wps; cfg.registrar = registrar; @@ -212,8 +157,6 @@ static void eap_wsc_deinit(struct eap_sm *sm, void *priv) wpabuf_free(data->in_buf); wpabuf_free(data->out_buf); wps_deinit(data->wps); - wps_registrar_deinit(data->wps_ctx->registrar); - data->wps_ctx->registrar = NULL; os_free(data->wps_ctx->network_key); data->wps_ctx->network_key = NULL; os_free(data); diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c index 662d117..9bf764c 100644 --- a/wpa_supplicant/wps_supplicant.c +++ b/wpa_supplicant/wps_supplicant.c @@ -394,9 +394,42 @@ int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid, } +static int wpas_wps_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *psk, + size_t psk_len) +{ + wpa_printf(MSG_DEBUG, "WPS: Received new WPA/WPA2-PSK from WPS for " + "STA " MACSTR, MAC2STR(mac_addr)); + wpa_hexdump_key(MSG_DEBUG, "Per-device PSK", psk, psk_len); + + /* TODO */ + + return 0; +} + + +static void wpas_wps_pin_needed_cb(void *ctx, const u8 *uuid_e, + const struct wps_device_data *dev) +{ + char uuid[40], txt[400]; + int len; + if (uuid_bin2str(uuid_e, uuid, sizeof(uuid))) + return; + wpa_printf(MSG_DEBUG, "WPS: PIN needed for UUID-E %s", uuid); + len = os_snprintf(txt, sizeof(txt), "WPS-EVENT-PIN-NEEDED %s " MACSTR + " [%s|%s|%s|%s|%s|%d-%08X-%d]", + uuid, MAC2STR(dev->mac_addr), dev->device_name, + dev->manufacturer, dev->model_name, + dev->model_number, dev->serial_number, + dev->categ, dev->oui, dev->sub_categ); + if (len > 0 && len < (int) sizeof(txt)) + wpa_printf(MSG_INFO, "%s", txt); +} + + int wpas_wps_init(struct wpa_supplicant *wpa_s) { struct wps_context *wps; + struct wps_registrar_config rcfg; wps = os_zalloc(sizeof(*wps)); if (wps == NULL) @@ -448,6 +481,21 @@ int wpas_wps_init(struct wpa_supplicant *wpa_s) } else os_memcpy(wps->uuid, wpa_s->conf->uuid, WPS_UUID_LEN); + wps->auth_types = WPS_AUTH_WPA2PSK | WPS_AUTH_WPAPSK; + wps->encr_types = WPS_ENCR_AES | WPS_ENCR_TKIP; + + os_memset(&rcfg, 0, sizeof(rcfg)); + rcfg.new_psk_cb = wpas_wps_new_psk_cb; + rcfg.pin_needed_cb = wpas_wps_pin_needed_cb; + rcfg.cb_ctx = wpa_s; + + wps->registrar = wps_registrar_init(wps, &rcfg); + if (wps->registrar == NULL) { + wpa_printf(MSG_DEBUG, "Failed to initialize WPS Registrar"); + os_free(wps); + return -1; + } + wpa_s->wps = wps; return 0; @@ -461,6 +509,7 @@ void wpas_wps_deinit(struct wpa_supplicant *wpa_s) if (wpa_s->wps == NULL) return; + wps_registrar_deinit(wpa_s->wps->registrar); os_free(wpa_s->wps->network_key); os_free(wpa_s->wps); wpa_s->wps = NULL; |