mesh: Generate a separate TX IGTK if PMF is enabled
[mech_eap.git] / wpa_supplicant / mesh.c
index 7925aa9..aed55da 100644 (file)
@@ -66,7 +66,8 @@ void wpa_supplicant_mesh_iface_deinit(struct wpa_supplicant *wpa_s,
 }
 
 
-static struct mesh_conf * mesh_config_create(struct wpa_ssid *ssid)
+static struct mesh_conf * mesh_config_create(struct wpa_supplicant *wpa_s,
+                                            struct wpa_ssid *ssid)
 {
        struct mesh_conf *conf;
 
@@ -82,6 +83,13 @@ static struct mesh_conf * mesh_config_create(struct wpa_ssid *ssid)
                        MESH_CONF_SEC_AMPE;
        else
                conf->security |= MESH_CONF_SEC_NONE;
+       conf->ieee80211w = ssid->ieee80211w;
+       if (conf->ieee80211w == MGMT_FRAME_PROTECTION_DEFAULT) {
+               if (wpa_s->drv_enc & WPA_DRIVER_CAPA_ENC_BIP)
+                       conf->ieee80211w = wpa_s->conf->pmf;
+               else
+                       conf->ieee80211w = NO_MGMT_FRAME_PROTECTION;
+       }
 
        /* defaults */
        conf->mesh_pp_id = MESH_PATH_PROTOCOL_HWMP;
@@ -175,19 +183,13 @@ static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
                wpa_s->conf->dot11RSNASAERetransPeriod;
        os_strlcpy(bss->conf->iface, wpa_s->ifname, sizeof(bss->conf->iface));
 
-       mconf = mesh_config_create(ssid);
+       mconf = mesh_config_create(wpa_s, ssid);
        if (!mconf)
                goto out_free;
        ifmsh->mconf = mconf;
 
        /* need conf->hw_mode for supported rates. */
-       if (ssid->frequency == 0) {
-               conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
-               conf->channel = 1;
-       } else {
-               conf->hw_mode = ieee80211_freq_to_chan(ssid->frequency,
-                                                      &conf->channel);
-       }
+       conf->hw_mode = ieee80211_freq_to_chan(ssid->frequency, &conf->channel);
        if (conf->hw_mode == NUM_HOSTAPD_MODES) {
                wpa_printf(MSG_ERROR, "Unsupported mesh mode frequency: %d MHz",
                           ssid->frequency);
@@ -417,7 +419,7 @@ int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
                wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
        ret = wpa_drv_join_mesh(wpa_s, &params);
        if (ret)
-               wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d\n", ret);
+               wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d", ret);
 
        /* hostapd sets the interface down until we associate */
        wpa_drv_set_operstate(wpa_s, 1);
@@ -591,9 +593,22 @@ int wpas_mesh_add_interface(struct wpa_supplicant *wpa_s, char *ifname,
        if (!mesh_wpa_s) {
                wpa_printf(MSG_ERROR,
                           "mesh: Failed to create new wpa_supplicant interface");
-               wpa_supplicant_remove_iface(wpa_s->global, wpa_s, 0);
+               wpa_drv_if_remove(wpa_s, WPA_IF_MESH, ifname);
                return -1;
        }
        mesh_wpa_s->mesh_if_created = 1;
        return 0;
 }
+
+
+int wpas_mesh_peer_remove(struct wpa_supplicant *wpa_s, const u8 *addr)
+{
+       return mesh_mpm_close_peer(wpa_s, addr);
+}
+
+
+int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr,
+                      int duration)
+{
+       return mesh_mpm_connect_peer(wpa_s, addr, duration);
+}