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
|
@ -39,6 +39,7 @@
|
|||
#include "blacklist.h"
|
||||
#include "wpas_glue.h"
|
||||
#include "wps/wps.h"
|
||||
#include "wps_supplicant.h"
|
||||
|
||||
const char *wpa_supplicant_version =
|
||||
"wpa_supplicant v" VERSION_STR "\n"
|
||||
|
@ -386,6 +387,8 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
|
|||
wpa_supplicant_cancel_auth_timeout(wpa_s);
|
||||
|
||||
ieee80211_sta_deinit(wpa_s);
|
||||
|
||||
wpas_wps_deinit(wpa_s);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1789,6 +1792,9 @@ static int wpa_supplicant_init_iface2(struct wpa_supplicant *wpa_s)
|
|||
|
||||
wpa_sm_set_own_addr(wpa_s->wpa, wpa_s->own_addr);
|
||||
|
||||
if (wpas_wps_init(wpa_s))
|
||||
return -1;
|
||||
|
||||
if (wpa_supplicant_init_eapol(wpa_s) < 0)
|
||||
return -1;
|
||||
wpa_sm_set_eapol(wpa_s->wpa, wpa_s->eapol);
|
||||
|
|
|
@ -338,6 +338,8 @@ struct wpa_supplicant {
|
|||
int pending_mic_error_report;
|
||||
int pending_mic_error_pairwise;
|
||||
int mic_errors_seen; /* Michael MIC errors with the current PTK */
|
||||
|
||||
struct wps_context *wps;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -560,7 +560,7 @@ int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
|
|||
#endif /* EAP_TLS_OPENSSL */
|
||||
ctx->mac_addr = wpa_s->own_addr;
|
||||
ctx->uuid = wpa_s->conf->uuid;
|
||||
ctx->wps_cred = wpas_wps_get_cred_cb();
|
||||
ctx->wps = wpa_s->wps;
|
||||
ctx->eap_param_needed = wpa_supplicant_eap_param_needed;
|
||||
ctx->cb = wpa_supplicant_eapol_cb;
|
||||
ctx->cb_ctx = wpa_s;
|
||||
|
|
|
@ -175,3 +175,41 @@ void * wpas_wps_get_cred_cb(void)
|
|||
{
|
||||
return wpa_supplicant_wps_cred;
|
||||
}
|
||||
|
||||
|
||||
int wpas_wps_init(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
struct wps_context *wps;
|
||||
|
||||
wps = os_zalloc(sizeof(*wps));
|
||||
if (wps == NULL)
|
||||
return -1;
|
||||
|
||||
wps->cred_cb = wpa_supplicant_wps_cred;
|
||||
wps->cb_ctx = wpa_s;
|
||||
|
||||
/* TODO: 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;
|
||||
|
||||
wpa_s->wps = wps;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void wpas_wps_deinit(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
if (wpa_s->wps == NULL)
|
||||
return;
|
||||
|
||||
os_free(wpa_s->wps->network_key);
|
||||
os_free(wpa_s->wps);
|
||||
wpa_s->wps = NULL;
|
||||
}
|
||||
|
|
|
@ -17,11 +17,22 @@
|
|||
|
||||
#ifdef CONFIG_WPS
|
||||
|
||||
int wpas_wps_init(struct wpa_supplicant *wpa_s);
|
||||
void wpas_wps_deinit(struct wpa_supplicant *wpa_s);
|
||||
int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s);
|
||||
void * wpas_wps_get_cred_cb(void);
|
||||
|
||||
#else /* CONFIG_WPS */
|
||||
|
||||
static inline int wpas_wps_init(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void wpas_wps_deinit(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue