fix(wpa_supplicant): Fix for WPS-PBC overlap detection in dual band

When WPS is running on dual band(e.g. a separate 2.4 GHz and 5 GHz band
    radios in an AP device), detect pbc overlap only if UUID differs.
This commit is contained in:
aditi 2024-08-08 12:11:02 +05:30 committed by Aditi
parent ac8f354458
commit e145e04fca
2 changed files with 39 additions and 3 deletions

View File

@ -353,11 +353,32 @@ static bool ap_supports_sae(struct wps_scan_ie *scan)
return false;
}
static bool
is_wps_pbc_overlap(struct wps_sm *sm, const u8 *sel_uuid)
{
if (!sel_uuid) {
wpa_printf(MSG_DEBUG, "WPS: null uuid field");
return false;
}
if (os_memcmp(sel_uuid, sm->uuid, WPS_UUID_LEN) != 0) {
wpa_printf(MSG_DEBUG, "uuid is not same");
wpa_hexdump(MSG_DEBUG, "WPS: UUID of scanned BSS is",
sel_uuid, WPS_UUID_LEN);
wpa_hexdump(MSG_DEBUG, "WPS: UUID of sm BSS is",
sm->uuid, WPS_UUID_LEN);
return true;
}
return false;
}
static bool
wps_parse_scan_result(struct wps_scan_ie *scan)
{
struct wps_sm *sm = gWpsSm;
wifi_mode_t op_mode = 0;
sm->wps_pbc_overlap = false;
if (!sm->is_wps_scan || !scan->bssid) {
return false;
@ -393,6 +414,7 @@ wps_parse_scan_result(struct wps_scan_ie *scan)
bool ap_found = false;
struct wpabuf *buf = wpabuf_alloc_copy(scan->wps + 6, scan->wps[1] - 4);
int count;
const u8 *scan_uuid;
if ((wps_get_type() == WPS_TYPE_PBC && wps_is_selected_pbc_registrar(buf)) ||
(wps_get_type() == WPS_TYPE_PIN && wps_is_addr_authorized(buf, sm->ownaddr, 1))) {
@ -413,8 +435,8 @@ wps_parse_scan_result(struct wps_scan_ie *scan)
}
if (ap_found || sm->ignore_sel_reg) {
wpabuf_free(buf);
if (scan->ssid[1] > SSID_MAX_LEN) {
wpabuf_free(buf);
return false;
}
esp_wifi_enable_sta_privacy_internal();
@ -425,7 +447,18 @@ wps_parse_scan_result(struct wps_scan_ie *scan)
wpa_printf(MSG_INFO, "sm BSSid: "MACSTR " scan BSSID " MACSTR,
MAC2STR(sm->bssid), MAC2STR(scan->bssid));
sm->discover_ssid_cnt++;
wpa_printf(MSG_INFO, "discoverd cnt is %d and chan is %d ", sm->discover_ssid_cnt, scan->chan);
os_memcpy(sm->bssid, scan->bssid, ETH_ALEN);
scan_uuid = wps_get_uuid_e(buf);
if (scan_uuid) {
if (wps_get_type() == WPS_TYPE_PBC && is_wps_pbc_overlap(sm, scan_uuid) == true) {
wpa_printf(MSG_INFO, "pbc_overlap flag is true");
sm->wps_pbc_overlap = true;
}
os_memcpy(sm->uuid, scan_uuid, WPS_UUID_LEN);
}
if (ap_supports_sae(scan)) {
wpa_printf(MSG_INFO, "AP supports SAE, get password in passphrase");
sm->dev->config_methods |= WPS_CONFIG_DISPLAY | WPS_CONFIG_VIRT_DISPLAY;
@ -434,7 +467,8 @@ wps_parse_scan_result(struct wps_scan_ie *scan)
wps_build_ic_appie_wps_ar();
}
}
wpa_printf(MSG_DEBUG, "wps discover [%s]", (char *)sm->ssid);
wpabuf_free(buf);
wpa_printf(MSG_DEBUG, "wps discover [%s] ", (char *)sm->ssid);
sm->channel = scan->chan;
return true;
@ -1594,7 +1628,8 @@ wifi_wps_scan_done(void *arg, ETS_STATUS status)
} else if (sm->discover_ssid_cnt == 0) {
wps_set_status(WPS_STATUS_SCANNING);
} else {
if (wps_get_type() == WPS_TYPE_PBC) {
if (sm->wps_pbc_overlap) {
sm->wps_pbc_overlap = false;
wpa_printf(MSG_INFO, "PBC session overlap!");
wps_set_status(WPS_STATUS_DISABLE);
esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_PBC_OVERLAP, 0, 0, OS_BLOCK);

View File

@ -91,6 +91,7 @@ struct wps_sm {
#endif
u8 discover_ssid_cnt;
bool ignore_sel_reg;
bool wps_pbc_overlap;
struct discard_ap_list_t dis_ap_list[WPS_MAX_DIS_AP_NUM];
u8 discard_ap_cnt;
};