MBO: Add Supported Operating Classes element to Association Request
[mech_eap.git] / wpa_supplicant / sme.c
index d945db7..068ded7 100644 (file)
@@ -208,6 +208,9 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s,
        u8 ext_capab[18];
        int ext_capab_len;
        int skip_auth;
+#ifdef CONFIG_MBO
+       const u8 *mbo;
+#endif /* CONFIG_MBO */
 
        if (bss == NULL) {
                wpa_msg(wpa_s, MSG_ERROR, "SME: No scan result available for "
@@ -453,6 +456,21 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s,
        }
 #endif /* CONFIG_FST */
 
+#ifdef CONFIG_MBO
+       mbo = wpa_bss_get_vendor_ie(bss, MBO_IE_VENDOR_TYPE);
+       if (mbo) {
+               int len;
+
+               len = wpas_mbo_supp_op_class_ie(
+                       wpa_s, bss->freq,
+                       wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len,
+                       sizeof(wpa_s->sme.assoc_req_ie) -
+                       wpa_s->sme.assoc_req_ie_len);
+               if (len > 0)
+                       wpa_s->sme.assoc_req_ie_len += len;
+       }
+#endif /* CONFIG_MBO */
+
        ext_capab_len = wpas_build_ext_capab(wpa_s, ext_capab,
                                             sizeof(ext_capab));
        if (ext_capab_len > 0) {
@@ -482,6 +500,19 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s,
 
        sme_auth_handle_rrm(wpa_s, bss);
 
+#ifdef CONFIG_MBO
+       if (mbo) {
+               int len;
+
+               len = wpas_mbo_ie(wpa_s, wpa_s->sme.assoc_req_ie +
+                                 wpa_s->sme.assoc_req_ie_len,
+                                 sizeof(wpa_s->sme.assoc_req_ie) -
+                                 wpa_s->sme.assoc_req_ie_len);
+               if (len >= 0)
+                       wpa_s->sme.assoc_req_ie_len += len;
+       }
+#endif /* CONFIG_MBO */
+
 #ifdef CONFIG_SAE
        if (!skip_auth && params.auth_alg == WPA_AUTH_ALG_SAE &&
            pmksa_cache_set_current(wpa_s->wpa, NULL, bss->bssid, ssid, 0) == 0)
@@ -598,7 +629,8 @@ static void sme_auth_start_cb(struct wpa_radio_work *work, int deinit)
        wpa_s->connect_work = work;
 
        if (cwork->bss_removed ||
-           !wpas_valid_bss_ssid(wpa_s, cwork->bss, cwork->ssid)) {
+           !wpas_valid_bss_ssid(wpa_s, cwork->bss, cwork->ssid) ||
+           wpas_network_disabled(wpa_s, cwork->ssid)) {
                wpa_dbg(wpa_s, MSG_DEBUG, "SME: BSS/SSID entry for authentication not valid anymore - drop connection attempt");
                wpas_connect_work_done(wpa_s);
                return;
@@ -631,6 +663,8 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
                radio_remove_works(wpa_s, "sme-connect", 0);
        }
 
+       wpas_abort_ongoing_scan(wpa_s);
+
        cwork = os_zalloc(sizeof(*cwork));
        if (cwork == NULL)
                return;
@@ -811,13 +845,27 @@ void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data)
                wpa_printf(MSG_DEBUG, "SME: SAE completed - setting PMK for "
                           "4-way handshake");
                wpa_sm_set_pmk(wpa_s->wpa, wpa_s->sme.sae.pmk, PMK_LEN,
-                              wpa_s->pending_bssid);
+                              wpa_s->sme.sae.pmkid, wpa_s->pending_bssid);
        }
 #endif /* CONFIG_SAE */
 
        if (data->auth.status_code != WLAN_STATUS_SUCCESS) {
-               wpa_dbg(wpa_s, MSG_DEBUG, "SME: Authentication failed (status "
-                       "code %d)", data->auth.status_code);
+               char *ie_txt = NULL;
+
+               if (data->auth.ies && data->auth.ies_len) {
+                       size_t buflen = 2 * data->auth.ies_len + 1;
+                       ie_txt = os_malloc(buflen);
+                       if (ie_txt) {
+                               wpa_snprintf_hex(ie_txt, buflen, data->auth.ies,
+                                                data->auth.ies_len);
+                       }
+               }
+               wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_AUTH_REJECT MACSTR
+                       " auth_type=%u auth_transaction=%u status_code=%u ie=%s",
+                       MAC2STR(data->auth.peer), data->auth.auth_type,
+                       data->auth.auth_transaction, data->auth.status_code,
+                       ie_txt);
+               os_free(ie_txt);
 
                if (data->auth.status_code !=
                    WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG ||
@@ -1305,21 +1353,6 @@ int sme_proc_obss_scan(struct wpa_supplicant *wpa_s)
 }
 
 
-static struct hostapd_hw_modes * get_mode(struct hostapd_hw_modes *modes,
-                                         u16 num_modes,
-                                         enum hostapd_hw_mode mode)
-{
-       u16 i;
-
-       for (i = 0; i < num_modes; i++) {
-               if (modes[i].mode == mode)
-                       return &modes[i];
-       }
-
-       return NULL;
-}
-
-
 static void wpa_obss_scan_freqs_list(struct wpa_supplicant *wpa_s,
                                     struct wpa_driver_scan_params *params)
 {