WPS: Moved wps_context initialization into wps_supplicant.c
The wps_context data is now managed at wpa_supplicant, not EAP-WSC. This makes wpa_supplicant design for WPS match with hostapd one and also makes it easier configure whatever parameters and callbacks are needed for WPS.
This commit is contained in:
parent
bcbbc7af45
commit
116654ce24
11 changed files with 81 additions and 63 deletions
|
@ -1182,6 +1182,7 @@ struct eap_sm * eap_peer_sm_init(void *eapol_ctx,
|
|||
os_memcpy(sm->mac_addr, conf->mac_addr, ETH_ALEN);
|
||||
if (conf->uuid)
|
||||
os_memcpy(sm->uuid, conf->uuid, 16);
|
||||
sm->wps = conf->wps;
|
||||
|
||||
os_memset(&tlsconf, 0, sizeof(tlsconf));
|
||||
tlsconf.opensc_engine_path = conf->opensc_engine_path;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
struct eap_sm;
|
||||
struct wpa_config_blob;
|
||||
struct wpabuf;
|
||||
struct wps_credential;
|
||||
|
||||
struct eap_method_type {
|
||||
int vendor;
|
||||
|
@ -214,17 +213,6 @@ struct eapol_callbacks {
|
|||
*/
|
||||
void (*notify_pending)(void *ctx);
|
||||
|
||||
/**
|
||||
* wps_cred - Notify that new credential was received from WPS
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
* Returns: 0 on success (credential stored), -1 on failure
|
||||
*
|
||||
* This callback is only needed when using WPS Enrollee to configure
|
||||
* new credentials. This can be left %NULL if no WPS functionality is
|
||||
* enabled.
|
||||
*/
|
||||
int (*wps_cred)(void *ctx, const struct wps_credential *cred);
|
||||
|
||||
/**
|
||||
* eap_param_needed - Notify that EAP parameter is needed
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
|
@ -269,6 +257,12 @@ struct eap_config {
|
|||
* This is only used by EAP-WSC and can be left %NULL if not available.
|
||||
*/
|
||||
const u8 *uuid;
|
||||
/**
|
||||
* wps - WPS context data
|
||||
*
|
||||
* This is only used by EAP-WSC and can be left %NULL if not available.
|
||||
*/
|
||||
struct wps_context *wps;
|
||||
};
|
||||
|
||||
struct eap_sm * eap_peer_sm_init(void *eapol_ctx,
|
||||
|
|
|
@ -335,6 +335,7 @@ struct eap_sm {
|
|||
|
||||
u8 mac_addr[ETH_ALEN];
|
||||
u8 uuid[16];
|
||||
struct wps_context *wps;
|
||||
};
|
||||
|
||||
const u8 * eap_get_config_identity(struct eap_sm *sm, size_t *len);
|
||||
|
|
|
@ -106,7 +106,13 @@ static void * eap_wsc_init(struct eap_sm *sm)
|
|||
struct wps_config cfg;
|
||||
const char *pos;
|
||||
const char *phase1;
|
||||
struct wps_context *wps = NULL;
|
||||
struct wps_context *wps;
|
||||
|
||||
wps = sm->wps;
|
||||
if (wps == NULL) {
|
||||
wpa_printf(MSG_ERROR, "EAP-WSC: WPS context not available");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
identity = eap_get_config_identity(sm, &identity_len);
|
||||
|
||||
|
@ -127,27 +133,7 @@ static void * eap_wsc_init(struct eap_sm *sm)
|
|||
return NULL;
|
||||
data->state = registrar ? MSG : WAIT_START;
|
||||
data->registrar = registrar;
|
||||
|
||||
wps = os_zalloc(sizeof(*wps));
|
||||
if (wps == NULL) {
|
||||
os_free(data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data->wps_ctx = wps;
|
||||
wps->cb_ctx = sm->eapol_ctx;
|
||||
wps->cred_cb = sm->eapol_cb->wps_cred;
|
||||
|
||||
/* TODO: store wps_context at higher layer and make the device data
|
||||
* configurable */
|
||||
wps->dev.device_name = "dev name";
|
||||
wps->dev.manufacturer = "manuf";
|
||||
wps->dev.model_name = "model name";
|
||||
wps->dev.model_number = "model number";
|
||||
wps->dev.serial_number = "12345";
|
||||
wps->dev.categ = WPS_DEV_COMPUTER;
|
||||
wps->dev.oui = WPS_DEV_OUI_WFA;
|
||||
wps->dev.sub_categ = WPS_DEV_COMPUTER_PC;
|
||||
|
||||
if (registrar) {
|
||||
struct wps_registrar_config rcfg;
|
||||
|
@ -175,7 +161,7 @@ static void * eap_wsc_init(struct eap_sm *sm)
|
|||
os_memset(&cfg, 0, sizeof(cfg));
|
||||
cfg.authenticator = 0;
|
||||
cfg.wps = wps;
|
||||
cfg.registrar = data->wps_ctx ? data->wps_ctx->registrar : NULL;
|
||||
cfg.registrar = registrar ? data->wps_ctx->registrar : NULL;
|
||||
cfg.enrollee_mac_addr = sm->mac_addr;
|
||||
|
||||
phase1 = eap_get_config_phase1(sm);
|
||||
|
@ -238,11 +224,9 @@ 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);
|
||||
if (data->wps_ctx) {
|
||||
wps_registrar_deinit(data->wps_ctx->registrar);
|
||||
os_free(data->wps_ctx->network_key);
|
||||
os_free(data->wps_ctx);
|
||||
}
|
||||
wps_registrar_deinit(data->wps_ctx->registrar);
|
||||
os_free(data->wps_ctx->network_key);
|
||||
data->wps_ctx->network_key = NULL;
|
||||
os_free(data);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue