WPS: Remove unused Credential AP Channel processing
authorJouni Malinen <jouni@qca.qualcomm.com>
Mon, 3 Feb 2014 08:54:21 +0000 (10:54 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 4 Feb 2014 11:23:35 +0000 (13:23 +0200)
Commit bd3a3737672aaf6eb50dba2b8caa3941c8df42e9 added a mechanism to use
AP Channel attribute from within a Credential attribute to optimize
scans. However, this design is not actually used with the WPS NFC use
cases. With configuration token, the AP Channel attribute is in the same
container with the Credential attribute (and that was also handled in
the previous implementation). With connection handover, AP Channel
information is outside the Credential attribute as well.

Simplify implementation by removing the AP Channel within Credential
case. This allows wpas_wps_use_cred() to get the AP Channel from the
container instead of having to find this during credential iteration.

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

src/wps/wps.h
src/wps/wps_attr_process.c
wpa_supplicant/wpa_supplicant_i.h
wpa_supplicant/wps_supplicant.c

index 6ccce1a..574fb60 100644 (file)
@@ -42,7 +42,6 @@ struct wps_parse_attr;
  * @cred_attr: Unparsed Credential attribute data (used only in cred_cb());
  *     this may be %NULL, if not used
  * @cred_attr_len: Length of cred_attr in octets
- * @ap_channel: AP channel
  */
 struct wps_credential {
        u8 ssid[32];
@@ -55,7 +54,6 @@ struct wps_credential {
        u8 mac_addr[ETH_ALEN];
        const u8 *cred_attr;
        size_t cred_attr_len;
-       u16 ap_channel;
 };
 
 #define WPS_DEV_TYPE_LEN 8
index 81cbc32..5266620 100644 (file)
@@ -207,19 +207,6 @@ static int wps_process_cred_mac_addr(struct wps_credential *cred,
 }
 
 
-static int wps_process_cred_ap_channel(struct wps_credential *cred,
-                                      const u8 *ap_channel)
-{
-       if (ap_channel == NULL)
-               return 0; /* optional attribute */
-
-       cred->ap_channel = WPA_GET_BE16(ap_channel);
-       wpa_printf(MSG_DEBUG, "WPS: AP Channel: %u", cred->ap_channel);
-
-       return 0;
-}
-
-
 static int wps_workaround_cred_key(struct wps_credential *cred)
 {
        if (cred->auth_type & (WPS_AUTH_WPAPSK | WPS_AUTH_WPA2PSK) &&
@@ -259,8 +246,7 @@ int wps_process_cred(struct wps_parse_attr *attr,
            wps_process_cred_network_key_idx(cred, attr->network_key_idx) ||
            wps_process_cred_network_key(cred, attr->network_key,
                                         attr->network_key_len) ||
-           wps_process_cred_mac_addr(cred, attr->mac_addr) ||
-           wps_process_cred_ap_channel(cred, attr->ap_channel))
+           wps_process_cred_mac_addr(cred, attr->mac_addr))
                return -1;
 
        return wps_workaround_cred_key(cred);
index 267c226..4ca0306 100644 (file)
@@ -751,7 +751,6 @@ struct wpa_supplicant {
        int after_wps;
        int known_wps_freq;
        unsigned int wps_freq;
-       u16 wps_ap_channel;
        int wps_fragment_size;
        int auto_reconnect_disabled;
 
index 537aac3..3c14bb7 100644 (file)
@@ -489,9 +489,6 @@ static int wpa_supplicant_wps_cred(void *ctx,
 
        wpas_wps_security_workaround(wpa_s, ssid, cred);
 
-       if (cred->ap_channel)
-               wpa_s->wps_ap_channel = cred->ap_channel;
-
        wpas_wps_remove_dup_network(wpa_s, ssid);
 
 #ifndef CONFIG_NO_CONFIG_WRITE
@@ -2197,8 +2194,6 @@ int wpas_wps_start_nfc(struct wpa_supplicant *wpa_s, const u8 *go_dev_addr,
 static int wpas_wps_use_cred(struct wpa_supplicant *wpa_s,
                             struct wps_parse_attr *attr)
 {
-       wpa_s->wps_ap_channel = 0;
-
        /*
         * Disable existing networks temporarily to allow the newly learned
         * credential to be preferred. Enable the temporarily disabled networks
@@ -2214,18 +2209,8 @@ static int wpas_wps_use_cred(struct wpa_supplicant *wpa_s,
        if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
                return 0;
 
-       if (!wpa_s->wps_ap_channel && attr->ap_channel) {
-               wpa_s->wps_ap_channel = WPA_GET_BE16(attr->ap_channel);
-               wpa_printf(MSG_DEBUG, "WPS: Credential container indicated AP Channel %d",
-                          wpa_s->wps_ap_channel);
-       }
-
-       wpa_printf(MSG_DEBUG, "WPS: Request reconnection with new network "
-                  "based on the received credential added");
-       wpa_s->normal_scans = 0;
-       wpa_supplicant_reinit_autoscan(wpa_s);
-       if (wpa_s->wps_ap_channel) {
-               u16 chan = wpa_s->wps_ap_channel;
+       if (attr->ap_channel) {
+               u16 chan = WPA_GET_BE16(attr->ap_channel);
                int freq = 0;
 
                if (chan >= 1 && chan <= 13)
@@ -2236,12 +2221,17 @@ static int wpas_wps_use_cred(struct wpa_supplicant *wpa_s,
                        freq = 5000 + 5 * chan;
 
                if (freq) {
-                       wpa_printf(MSG_DEBUG, "WPS: Credential indicated "
-                                  "AP channel %u -> %u MHz", chan, freq);
+                       wpa_printf(MSG_DEBUG, "WPS: Credential container indicated AP channel %u -> %u MHz",
+                                  chan, freq);
                        wpa_s->after_wps = 5;
                        wpa_s->wps_freq = freq;
                }
        }
+
+       wpa_printf(MSG_DEBUG, "WPS: Request reconnection with new network "
+                  "based on the received credential added");
+       wpa_s->normal_scans = 0;
+       wpa_supplicant_reinit_autoscan(wpa_s);
        wpa_s->disconnected = 0;
        wpa_s->reassociate = 1;