WPS: Remove unused Credential AP Channel processing

Commit bd3a373767 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>
This commit is contained in:
Jouni Malinen 2014-02-03 10:54:21 +02:00 committed by Jouni Malinen
parent 1536cb5756
commit 0b5ff2ae12
4 changed files with 10 additions and 37 deletions

View 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

View 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);

View 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;

View 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;