]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Send the credential when learning AP params in registrar role
authorOlivier Sobrie <olivier@sobrie.be>
Sun, 30 Oct 2011 20:10:40 +0000 (22:10 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 30 Oct 2011 20:10:40 +0000 (22:10 +0200)
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>
src/wps/wps_registrar.c

index 37b06db33cc3b520802ef34f275be04359a9f74d..4a49197904d5d12a542b43219fbfbd3a18b576f6 100644 (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)
 {
        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,
                                     struct wps_parse_attr *attr)
 {
+       struct wpabuf *msg;
+
        if (wps->wps->ap || wps->er)
                return 0;
 
@@ -2586,12 +2617,24 @@ static int wps_process_ap_settings_r(struct wps_data *wps,
                 */
                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) {
                        wps->ap_settings_cb(wps->ap_settings_cb_ctx,
                                            &wps->cred);
+                       wpabuf_free(msg);
                        return 1;
                }
                wps_sta_cred_cb(wps);
+
+               wps->cred.cred_attr = NULL;
+               wps->cred.cred_attr_len = 0;
+               wpabuf_free(msg);
+
                return 1;
        }
 }