WPS: Send the credential when learning AP params in registrar role

When the supplicant acts as a registrar to learn the access point
parameters send the credentials to the wpa_cli interface after
receiving the 7th message. This is needed for proper behavior with
wps_cred_processing set to 1 or 2.

Without this patch, after the 7th message you got the WPS-CRED-RECEIVED
notification without the credentials. This was because the cred_attr and
cred_attr_len were not filled in in the wps structure.

Signed-off-by: Olivier Sobrie <olivier@sobrie.be>
This commit is contained in:
Olivier Sobrie 2011-10-30 22:10:40 +02:00 committed by Jouni Malinen
parent 9339bd5cd2
commit 6f75536fc9

View File

@ -1602,6 +1602,35 @@ static int wps_build_ap_settings(struct wps_data *wps, struct wpabuf *msg)
} }
static struct wpabuf * wps_build_ap_cred(struct wps_data *wps)
{
struct wpabuf *msg, *plain;
msg = wpabuf_alloc(1000);
if (msg == NULL)
return NULL;
plain = wpabuf_alloc(200);
if (plain == NULL) {
wpabuf_free(msg);
return NULL;
}
if (wps_build_ap_settings(wps, plain)) {
wpabuf_free(plain);
wpabuf_free(msg);
return NULL;
}
wpabuf_put_be16(msg, ATTR_CRED);
wpabuf_put_be16(msg, wpabuf_len(plain));
wpabuf_put_buf(msg, plain);
wpabuf_free(plain);
return msg;
}
static struct wpabuf * wps_build_m2(struct wps_data *wps) static struct wpabuf * wps_build_m2(struct wps_data *wps)
{ {
struct wpabuf *msg; struct wpabuf *msg;
@ -2560,6 +2589,8 @@ static void wps_cred_update(struct wps_credential *dst,
static int wps_process_ap_settings_r(struct wps_data *wps, static int wps_process_ap_settings_r(struct wps_data *wps,
struct wps_parse_attr *attr) struct wps_parse_attr *attr)
{ {
struct wpabuf *msg;
if (wps->wps->ap || wps->er) if (wps->wps->ap || wps->er)
return 0; return 0;
@ -2586,12 +2617,24 @@ static int wps_process_ap_settings_r(struct wps_data *wps,
*/ */
wps_registrar_pin_completed(wps->wps->registrar); wps_registrar_pin_completed(wps->wps->registrar);
msg = wps_build_ap_cred(wps);
if (msg == NULL)
return -1;
wps->cred.cred_attr = wpabuf_head(msg);
wps->cred.cred_attr_len = wpabuf_len(msg);
if (wps->ap_settings_cb) { if (wps->ap_settings_cb) {
wps->ap_settings_cb(wps->ap_settings_cb_ctx, wps->ap_settings_cb(wps->ap_settings_cb_ctx,
&wps->cred); &wps->cred);
wpabuf_free(msg);
return 1; return 1;
} }
wps_sta_cred_cb(wps); wps_sta_cred_cb(wps);
wps->cred.cred_attr = NULL;
wps->cred.cred_attr_len = 0;
wpabuf_free(msg);
return 1; return 1;
} }
} }