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;
struct eap_sm;
struct wpa_config_blob;
struct wpabuf;
-struct wps_credential;
struct eap_method_type {
int vendor;
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
* @field: Field name (e.g., "IDENTITY")
* 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,
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);
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);
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;
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);
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);
}
}
-#ifdef CONFIG_WPS
-static int eapol_sm_wps_cred(void *ctx, const struct wps_credential *cred)
-{
- struct eapol_sm *sm = ctx;
- wpa_printf(MSG_DEBUG, "EAPOL: received new WPS credential");
- if (sm->ctx->wps_cred)
- return sm->ctx->wps_cred(sm->ctx->ctx, cred);
- return 0;
-}
-#else /* CONFIG_WPS */
-#define eapol_sm_wps_cred NULL
-#endif /* CONFIG_WPS */
-
-
#if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
static void eapol_sm_eap_param_needed(void *ctx, const char *field,
const char *txt)
eapol_sm_set_config_blob,
eapol_sm_get_config_blob,
eapol_sm_notify_pending,
- eapol_sm_wps_cred,
eapol_sm_eap_param_needed
};
#endif /* EAP_TLS_OPENSSL */
conf.mac_addr = ctx->mac_addr;
conf.uuid = ctx->uuid;
+ conf.wps = ctx->wps;
sm->eap = eap_peer_sm_init(sm, &eapol_cb, sm->ctx->msg_ctx, &conf);
if (sm->eap == NULL) {
struct eapol_sm;
struct wpa_config_blob;
-struct wps_credential;
/**
* struct eapol_ctx - Global (for all networks) EAPOL state machine context
const u8 *uuid;
/**
- * wps_cred - Notify that new credential was received from WPS
- * @ctx: Callback context (ctx)
- * Returns: 0 on success (credential stored), -1 on failure
+ * wps - WPS context data
*
- * This callback is only needed when using WPS Enrollee to configure
- * new credentials. This can be left %NULL if no WPS functionality is
- * enabled.
+ * This is only used by EAP-WSC and can be left %NULL if not available.
*/
- int (*wps_cred)(void *ctx, const struct wps_credential *cred);
+ struct wps_context *wps;
/**
* eap_param_needed - Notify that EAP parameter is needed
#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"
wpa_supplicant_cancel_auth_timeout(wpa_s);
ieee80211_sta_deinit(wpa_s);
+
+ wpas_wps_deinit(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);
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;
};
#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;
{
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;
+}
#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;