struct eap_wsc_data {
- enum { WAIT_START, MSG, FRAG_ACK, WAIT_FRAG_ACK, DONE, FAIL } state;
+ enum { WAIT_START, MESG, FRAG_ACK, WAIT_FRAG_ACK, DONE, FAIL } state;
int registrar;
struct wpabuf *in_buf;
struct wpabuf *out_buf;
- u8 in_op_code, out_op_code;
+ enum wsc_op_code in_op_code, out_op_code;
size_t out_used;
size_t fragment_size;
struct wps_data *wps;
switch (state) {
case WAIT_START:
return "WAIT_START";
- case MSG:
- return "MSG";
+ case MESG:
+ return "MESG";
case FRAG_ACK:
return "FRAG_ACK";
case WAIT_FRAG_ACK:
static int eap_wsc_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *psk,
size_t psk_len)
{
- /* struct eap_wsc_data *data = ctx; */
-
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);
static void eap_wsc_pin_needed_cb(void *ctx, const u8 *uuid_e,
const struct wps_device_data *dev)
{
- /* struct eap_wsc_data *data = ctx; */
char uuid[40], txt[400];
int len;
if (uuid_bin2str(uuid_e, uuid, sizeof(uuid)))
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);
data = os_zalloc(sizeof(*data));
if (data == NULL)
return NULL;
- data->state = registrar ? MSG : WAIT_START;
+ data->state = registrar ? MESG : WAIT_START;
data->registrar = registrar;
+ data->wps_ctx = wps;
if (registrar) {
struct wps_registrar_config rcfg;
- wps = os_zalloc(sizeof(*wps));
- if (wps == NULL) {
- os_free(data);
- return NULL;
- }
-
- wps->cb_ctx = data;
-
- /* TODO: configure.. */
- wps->auth_types = WPS_AUTH_WPA2PSK;
- wps->encr_types = WPS_ENCR_AES;
- os_memcpy(wps->ssid, "test", 4);
- wps->ssid_len = 4;
+ 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;
return NULL;
}
- data->wps_ctx = wps;
}
os_memset(&cfg, 0, sizeof(cfg));
cfg.authenticator = 0;
cfg.wps = wps;
- cfg.registrar = data->wps_ctx ? data->wps_ctx->registrar : NULL;
- cfg.enrollee_mac_addr = sm->mac_addr;
+ cfg.registrar = registrar ? data->wps_ctx->registrar : NULL;
phase1 = eap_get_config_phase1(sm);
if (phase1 == NULL) {
return NULL;
}
- if (registrar && wps)
- os_memcpy(wps->uuid, sm->uuid, UUID_LEN);
- else
- cfg.uuid = sm->uuid;
- cfg.wps_cred_cb = sm->eapol_cb->wps_cred;
- cfg.cb_ctx = sm->eapol_ctx;
data->wps = wps_init(&cfg);
if (data->wps == NULL) {
os_free(data);
}
data->fragment_size = WSC_FRAGMENT_SIZE;
-
- if (registrar) {
- /* Testing */
- wpa_printf(MSG_INFO, "EAP-WSC: Registrar functionality not "
- "yet fully supported - using test values");
- u8 uuid_e[UUID_LEN];
- os_memset(uuid_e, 0, UUID_LEN);
- wps_registrar_add_pin(data->wps_ctx->registrar, uuid_e,
- (const u8 *) "12345670", 8);
+ if (registrar && cfg.pin) {
+ wps_registrar_add_pin(data->wps_ctx->registrar, NULL,
+ cfg.pin, cfg.pin_len);
}
return data;
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);
+ data->wps_ctx->registrar = NULL;
+ os_free(data->wps_ctx->network_key);
+ data->wps_ctx->network_key = NULL;
os_free(data);
}
eap_wsc_state(data, FAIL);
ret->methodState = METHOD_DONE;
} else
- eap_wsc_state(data, MSG);
+ eap_wsc_state(data, MESG);
} else {
wpa_printf(MSG_DEBUG, "EAP-WSC: Sending out %lu bytes "
"(%lu more to send)", (unsigned long) send_len,
return NULL;
}
wpa_printf(MSG_DEBUG, "EAP-WSC: Fragment acknowledged");
- eap_wsc_state(data, MSG);
+ eap_wsc_state(data, MESG);
return eap_wsc_build_msg(data, ret, id);
}
return NULL;
}
wpa_printf(MSG_DEBUG, "EAP-WSC: Received start");
- eap_wsc_state(data, MSG);
+ eap_wsc_state(data, MESG);
/* Start message has empty payload, skip processing */
goto send_msg;
} else if (op_code == WSC_Start) {
eap_wsc_state(data, FAIL);
break;
case WPS_CONTINUE:
- eap_wsc_state(data, MSG);
+ eap_wsc_state(data, MESG);
break;
case WPS_FAILURE:
wpa_printf(MSG_DEBUG, "EAP-WSC: WPS processing failed");
data->out_used = 0;
}
- eap_wsc_state(data, MSG);
+ eap_wsc_state(data, MESG);
return eap_wsc_build_msg(data, ret, id);
}