]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Indicate current AP settings in M7 in unconfigurated state
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 16 Jan 2014 15:35:45 +0000 (17:35 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 7 Feb 2014 17:33:19 +0000 (19:33 +0200)
Previously, unconfigured state was forcing the best supported
authentication and encryption state to be shown in WPS messages,
including AP Settings in M7 in case the AP acts as an Enrollee. This is
not really correct for the AP Settings case, so change that one to
indicate the currently configured state.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/ap/wps_hostapd.c
src/wps/wps.h
src/wps/wps_enrollee.c

index 1b1dce4c4a15c6d5242f0f9117ff117ba4fd9607..8aafa639ed339137d2838558f632a8e7dc90195f 100644 (file)
@@ -471,6 +471,8 @@ static int hapd_wps_cred_cb(struct hostapd_data *hapd, void *ctx)
        hapd->wps->ssid_len = cred->ssid_len;
        hapd->wps->encr_types = cred->encr_type;
        hapd->wps->auth_types = cred->auth_type;
+       hapd->wps->ap_encr_type = cred->encr_type;
+       hapd->wps->ap_auth_type = cred->auth_type;
        if (cred->key_len == 0) {
                os_free(hapd->wps->network_key);
                hapd->wps->network_key = NULL;
@@ -1146,6 +1148,8 @@ int hostapd_init_wps(struct hostapd_data *hapd,
                wps->psk_set = 1;
        }
 
+       wps->ap_auth_type = wps->auth_types;
+       wps->ap_encr_type = wps->encr_types;
        if (conf->wps_state == WPS_STATE_NOT_CONFIGURED) {
                /* Override parameters to enable security by default */
                wps->auth_types = WPS_AUTH_WPA2PSK | WPS_AUTH_WPAPSK;
index 574fb60622bf04c4e4a605205c72c95d8a69728f..192d283514a36084145a403f070f3cae3243f56a 100644 (file)
@@ -667,6 +667,16 @@ struct wps_context {
         */
        u16 auth_types;
 
+       /**
+        * encr_types - Current AP encryption type (WPS_ENCR_*)
+        */
+       u16 ap_encr_type;
+
+       /**
+        * ap_auth_type - Current AP authentication types (WPS_AUTH_*)
+        */
+       u16 ap_auth_type;
+
        /**
         * network_key - The current Network Key (PSK) or %NULL to generate new
         *
index 9d48ca51e8c947207414cfb32c1ca3426f802204..257d124cc1016aca2e217f828aa8a57d65bdeff7 100644 (file)
@@ -243,47 +243,22 @@ static int wps_build_cred_ssid(struct wps_data *wps, struct wpabuf *msg)
 
 static int wps_build_cred_auth_type(struct wps_data *wps, struct wpabuf *msg)
 {
-       u16 auth_type = wps->wps->auth_types;
-
-       /* Select the best authentication type */
-       if (auth_type & WPS_AUTH_WPA2PSK)
-               auth_type = WPS_AUTH_WPA2PSK;
-       else if (auth_type & WPS_AUTH_WPAPSK)
-               auth_type = WPS_AUTH_WPAPSK;
-       else if (auth_type & WPS_AUTH_OPEN)
-               auth_type = WPS_AUTH_OPEN;
-       else if (auth_type & WPS_AUTH_SHARED)
-               auth_type = WPS_AUTH_SHARED;
-
-       wpa_printf(MSG_DEBUG, "WPS:  * Authentication Type (0x%x)", auth_type);
+       wpa_printf(MSG_DEBUG, "WPS:  * Authentication Type (0x%x)",
+                  wps->wps->ap_auth_type);
        wpabuf_put_be16(msg, ATTR_AUTH_TYPE);
        wpabuf_put_be16(msg, 2);
-       wpabuf_put_be16(msg, auth_type);
+       wpabuf_put_be16(msg, wps->wps->ap_auth_type);
        return 0;
 }
 
 
 static int wps_build_cred_encr_type(struct wps_data *wps, struct wpabuf *msg)
 {
-       u16 encr_type = wps->wps->encr_types;
-
-       /* Select the best encryption type */
-       if (wps->wps->auth_types & (WPS_AUTH_WPA2PSK | WPS_AUTH_WPAPSK)) {
-               if (encr_type & WPS_ENCR_AES)
-                       encr_type = WPS_ENCR_AES;
-               else if (encr_type & WPS_ENCR_TKIP)
-                       encr_type = WPS_ENCR_TKIP;
-       } else {
-               if (encr_type & WPS_ENCR_WEP)
-                       encr_type = WPS_ENCR_WEP;
-               else if (encr_type & WPS_ENCR_NONE)
-                       encr_type = WPS_ENCR_NONE;
-       }
-
-       wpa_printf(MSG_DEBUG, "WPS:  * Encryption Type (0x%x)", encr_type);
+       wpa_printf(MSG_DEBUG, "WPS:  * Encryption Type (0x%x)",
+                  wps->wps->ap_encr_type);
        wpabuf_put_be16(msg, ATTR_ENCR_TYPE);
        wpabuf_put_be16(msg, 2);
-       wpabuf_put_be16(msg, encr_type);
+       wpabuf_put_be16(msg, wps->wps->ap_encr_type);
        return 0;
 }