P2P: Fix persistent group for 60 GHz networks
[mech_eap.git] / wpa_supplicant / wnm_sta.c
index 3bb3556..f77d51a 100644 (file)
@@ -546,6 +546,17 @@ compare_scan_neighbor_results(struct wpa_supplicant *wpa_s)
                        continue;
                }
 
+               if (wpa_s->current_ssid &&
+                   !wpa_scan_res_match(wpa_s, 0, target, wpa_s->current_ssid,
+                                       1)) {
+                       wpa_printf(MSG_DEBUG, "Candidate BSS " MACSTR
+                                  " (pref %d) does not match the current network profile",
+                                  MAC2STR(nei->bssid),
+                                  nei->preference_present ? nei->preference :
+                                  -1);
+                       continue;
+               }
+
                if (wpa_is_bss_tmp_disallowed(wpa_s, target->bssid)) {
                        wpa_printf(MSG_DEBUG,
                                   "MBO: Candidate BSS " MACSTR
@@ -1115,11 +1126,22 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
                                rep = &wpa_s->wnm_neighbor_report_elements[
                                        wpa_s->wnm_num_neighbor_report];
                                wnm_parse_neighbor_report(wpa_s, pos, len, rep);
+                               wpa_s->wnm_num_neighbor_report++;
                        }
 
                        pos += len;
-                       wpa_s->wnm_num_neighbor_report++;
                }
+
+               if (!wpa_s->wnm_num_neighbor_report) {
+                       wpa_printf(MSG_DEBUG,
+                                  "WNM: Candidate list included bit is set, but no candidates found");
+                       wnm_send_bss_transition_mgmt_resp(
+                               wpa_s, wpa_s->wnm_dialog_token,
+                               WNM_BSS_TM_REJECT_NO_SUITABLE_CANDIDATES,
+                               0, NULL);
+                       return;
+               }
+
                wnm_sort_cand_list(wpa_s);
                wnm_dump_cand_list(wpa_s);
                valid_ms = valid_int * beacon_int * 128 / 125;
@@ -1148,6 +1170,14 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
                }
 
                wnm_set_scan_freqs(wpa_s);
+               if (wpa_s->wnm_num_neighbor_report == 1) {
+                       os_memcpy(wpa_s->next_scan_bssid,
+                                 wpa_s->wnm_neighbor_report_elements[0].bssid,
+                                 ETH_ALEN);
+                       wpa_printf(MSG_DEBUG,
+                                  "WNM: Scan only for a specific BSSID since there is only a single candidate "
+                                  MACSTR, MAC2STR(wpa_s->next_scan_bssid));
+               }
                wpa_supplicant_req_scan(wpa_s, 0, 0);
        } else if (reply) {
                enum bss_trans_mgmt_status_code status;
@@ -1165,16 +1195,17 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
 
 
 int wnm_send_bss_transition_mgmt_query(struct wpa_supplicant *wpa_s,
-                                      u8 query_reason)
+                                      u8 query_reason, int cand_list)
 {
-       u8 buf[1000], *pos;
+       u8 buf[2000], *pos;
        struct ieee80211_mgmt *mgmt;
        size_t len;
        int ret;
 
        wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Query to "
-                  MACSTR " query_reason=%u",
-                  MAC2STR(wpa_s->bssid), query_reason);
+                  MACSTR " query_reason=%u%s",
+                  MAC2STR(wpa_s->bssid), query_reason,
+                  cand_list ? " candidate list" : "");
 
        mgmt = (struct ieee80211_mgmt *) buf;
        os_memset(&buf, 0, sizeof(buf));
@@ -1189,6 +1220,9 @@ int wnm_send_bss_transition_mgmt_query(struct wpa_supplicant *wpa_s,
        mgmt->u.action.u.bss_tm_query.query_reason = query_reason;
        pos = mgmt->u.action.u.bss_tm_query.variable;
 
+       if (cand_list)
+               pos += wnm_add_cand_list(wpa_s, pos, buf + sizeof(buf) - pos);
+
        len = pos - (u8 *) &mgmt->u.action.category;
 
        ret = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid,