WNM: Add testing option to reject BSS Transition Management Request
[mech_eap.git] / wpa_supplicant / mesh.c
index c5f089e..d67d3b2 100644 (file)
@@ -70,6 +70,7 @@ static struct mesh_conf * mesh_config_create(struct wpa_supplicant *wpa_s,
                                             struct wpa_ssid *ssid)
 {
        struct mesh_conf *conf;
+       int cipher;
 
        conf = os_zalloc(sizeof(struct mesh_conf));
        if (!conf)
@@ -90,8 +91,24 @@ static struct mesh_conf * mesh_config_create(struct wpa_supplicant *wpa_s,
                else
                        conf->ieee80211w = NO_MGMT_FRAME_PROTECTION;
        }
-       conf->pairwise_cipher = WPA_CIPHER_CCMP;
-       conf->group_cipher = WPA_CIPHER_CCMP;
+
+       cipher = wpa_pick_pairwise_cipher(ssid->pairwise_cipher, 0);
+       if (cipher < 0 || cipher == WPA_CIPHER_TKIP) {
+               wpa_msg(wpa_s, MSG_INFO, "mesh: Invalid pairwise cipher");
+               os_free(conf);
+               return NULL;
+       }
+       conf->pairwise_cipher = cipher;
+
+       cipher = wpa_pick_group_cipher(ssid->group_cipher);
+       if (cipher < 0 || cipher == WPA_CIPHER_TKIP ||
+           cipher == WPA_CIPHER_GTK_NOT_USED) {
+               wpa_msg(wpa_s, MSG_INFO, "mesh: Invalid group cipher");
+               os_free(conf);
+               return NULL;
+       }
+
+       conf->group_cipher = cipher;
        if (conf->ieee80211w != NO_MGMT_FRAME_PROTECTION)
                conf->mgmt_group_cipher = WPA_CIPHER_AES_128_CMAC;
 
@@ -161,6 +178,7 @@ static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
        ifmsh->bss[0] = bss = os_zalloc(sizeof(struct hostapd_data));
        if (!bss)
                goto out_free;
+       dl_list_init(&bss->nr_db);
 
        os_memcpy(bss->own_addr, wpa_s->own_addr, ETH_ALEN);
        bss->driver = wpa_s->driver;
@@ -383,7 +401,11 @@ int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
                params.beacon_int = ssid->beacon_int;
        else if (wpa_s->conf->beacon_int > 0)
                params.beacon_int = wpa_s->conf->beacon_int;
-       params.max_peer_links = wpa_s->conf->max_peer_links;
+       if (ssid->dtim_period > 0)
+               params.dtim_period = ssid->dtim_period;
+       else if (wpa_s->conf->dtim_period > 0)
+               params.dtim_period = wpa_s->conf->dtim_period;
+       params.conf.max_peer_links = wpa_s->conf->max_peer_links;
 
        if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
                params.flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
@@ -393,10 +415,10 @@ int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
 
        if (wpa_s->conf->user_mpm) {
                params.flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
-               params.conf.flags &= ~WPA_DRIVER_MESH_CONF_FLAG_AUTO_PLINKS;
+               params.conf.auto_plinks = 0;
        } else {
                params.flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
-               params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_AUTO_PLINKS;
+               params.conf.auto_plinks = 1;
        }
        params.conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
 
@@ -417,6 +439,8 @@ int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
                params.ies = wpa_s->ifmsh->mconf->rsn_ie;
                params.ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
                params.basic_rates = wpa_s->ifmsh->basic_rates;
+               params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE;
+               params.conf.ht_opmode = wpa_s->ifmsh->bss[0]->iface->ht_op_mode;
        }
 
        wpa_msg(wpa_s, MSG_INFO, "joining mesh %s",
@@ -428,6 +452,9 @@ int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
        /* hostapd sets the interface down until we associate */
        wpa_drv_set_operstate(wpa_s, 1);
 
+       if (!ret)
+               wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
+
 out:
        return ret;
 }