mesh: Rename MPM FSM states to match the standard
[mech_eap.git] / src / drivers / driver_nl80211.c
index b4135cc..d3e4cfb 100644 (file)
@@ -445,6 +445,8 @@ static int nl_get_multicast_id(struct nl80211_global *global,
 void * nl80211_cmd(struct wpa_driver_nl80211_data *drv,
                   struct nl_msg *msg, int flags, uint8_t cmd)
 {
+       if (TEST_FAIL())
+               return NULL;
        return genlmsg_put(msg, 0, 0, drv->global->nl80211_id,
                           0, flags, cmd, 0);
 }
@@ -2412,6 +2414,7 @@ static int wpa_driver_nl80211_del_beacon(struct wpa_driver_nl80211_data *drv)
 static void wpa_driver_nl80211_deinit(struct i802_bss *bss)
 {
        struct wpa_driver_nl80211_data *drv = bss->drv;
+       unsigned int i;
 
        wpa_printf(MSG_INFO, "nl80211: deinit ifname=%s disabled_11b_rates=%d",
                   bss->ifname, drv->disabled_11b_rates);
@@ -2508,6 +2511,10 @@ static void wpa_driver_nl80211_deinit(struct i802_bss *bss)
 
        os_free(drv->extended_capa);
        os_free(drv->extended_capa_mask);
+       for (i = 0; i < drv->num_iface_ext_capa; i++) {
+               os_free(drv->iface_ext_capa[i].ext_capa);
+               os_free(drv->iface_ext_capa[i].ext_capa_mask);
+       }
        os_free(drv->first_bss);
        os_free(drv);
 }
@@ -3832,11 +3839,11 @@ static u32 sta_flags_nl80211(int flags)
 static u32 sta_plink_state_nl80211(enum mesh_plink_state state)
 {
        switch (state) {
-       case PLINK_LISTEN:
+       case PLINK_IDLE:
                return NL80211_PLINK_LISTEN;
-       case PLINK_OPEN_SENT:
+       case PLINK_OPN_SNT:
                return NL80211_PLINK_OPN_SNT;
-       case PLINK_OPEN_RCVD:
+       case PLINK_OPN_RCVD:
                return NL80211_PLINK_OPN_RCVD;
        case PLINK_CNF_RCVD:
                return NL80211_PLINK_CNF_RCVD;
@@ -4162,7 +4169,7 @@ void nl80211_remove_iface(struct wpa_driver_nl80211_data *drv, int ifidx)
 }
 
 
-static const char * nl80211_iftype_str(enum nl80211_iftype mode)
+const char * nl80211_iftype_str(enum nl80211_iftype mode)
 {
        switch (mode) {
        case NL80211_IFTYPE_ADHOC:
@@ -5113,6 +5120,9 @@ static int wpa_driver_nl80211_set_mode_impl(
        int res;
        int mode_switch_res;
 
+       if (TEST_FAIL())
+               return -1;
+
        mode_switch_res = nl80211_set_mode(drv, drv->ifindex, nlmode);
        if (mode_switch_res && nlmode == nl80211_get_ifmode(bss))
                mode_switch_res = 0;
@@ -7696,7 +7706,7 @@ static int wpa_driver_nl80211_update_ft_ies(void *priv, const u8 *md,
 }
 
 
-const u8 * wpa_driver_nl80211_get_macaddr(void *priv)
+static const u8 * wpa_driver_nl80211_get_macaddr(void *priv)
 {
        struct i802_bss *bss = priv;
        struct wpa_driver_nl80211_data *drv = bss->drv;
@@ -8304,6 +8314,9 @@ static int nl80211_set_mac_addr(void *priv, const u8 *addr)
        struct wpa_driver_nl80211_data *drv = bss->drv;
        int new_addr = addr != NULL;
 
+       if (TEST_FAIL())
+               return -1;
+
        if (!addr)
                addr = drv->perm_addr;
 
@@ -8414,8 +8427,7 @@ static int nl80211_join_mesh(struct i802_bss *bss,
        if (!(params->conf.flags & WPA_DRIVER_MESH_CONF_FLAG_AUTO_PLINKS) &&
            nla_put_u32(msg, NL80211_MESHCONF_AUTO_OPEN_PLINKS, 0))
                goto fail;
-       if ((params->conf.flags & WPA_DRIVER_MESH_FLAG_DRIVER_MPM) &&
-           nla_put_u16(msg, NL80211_MESHCONF_MAX_PEER_LINKS,
+       if (nla_put_u16(msg, NL80211_MESHCONF_MAX_PEER_LINKS,
                        params->max_peer_links))
                goto fail;
 
@@ -8439,7 +8451,7 @@ static int nl80211_join_mesh(struct i802_bss *bss,
                goto fail;
        }
        ret = 0;
-       bss->freq = params->freq.freq;
+       drv->assoc_freq = bss->freq = params->freq.freq;
        wpa_printf(MSG_DEBUG, "nl80211: mesh join request send successfully");
 
 fail:
@@ -9199,6 +9211,39 @@ static int nl80211_configure_data_frame_filters(void *priv, u32 filter_flags)
 }
 
 
+static int nl80211_get_ext_capab(void *priv, enum wpa_driver_if_type type,
+                                const u8 **ext_capa, const u8 **ext_capa_mask,
+                                unsigned int *ext_capa_len)
+{
+       struct i802_bss *bss = priv;
+       struct wpa_driver_nl80211_data *drv = bss->drv;
+       enum nl80211_iftype nlmode;
+       unsigned int i;
+
+       if (!ext_capa || !ext_capa_mask || !ext_capa_len)
+               return -1;
+
+       nlmode = wpa_driver_nl80211_if_type(type);
+
+       /* By default, use the per-radio values */
+       *ext_capa = drv->extended_capa;
+       *ext_capa_mask = drv->extended_capa_mask;
+       *ext_capa_len = drv->extended_capa_len;
+
+       /* Replace the default value if a per-interface type value exists */
+       for (i = 0; i < drv->num_iface_ext_capa; i++) {
+               if (nlmode == drv->iface_ext_capa[i].iftype) {
+                       *ext_capa = drv->iface_ext_capa[i].ext_capa;
+                       *ext_capa_mask = drv->iface_ext_capa[i].ext_capa_mask;
+                       *ext_capa_len = drv->iface_ext_capa[i].ext_capa_len;
+                       break;
+               }
+       }
+
+       return 0;
+}
+
+
 const struct wpa_driver_ops wpa_driver_nl80211_ops = {
        .name = "nl80211",
        .desc = "Linux nl80211/cfg80211",
@@ -9316,4 +9361,5 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
        .set_prob_oper_freq = nl80211_set_prob_oper_freq,
 #endif /* CONFIG_DRIVER_NL80211_QCA */
        .configure_data_frame_filters = nl80211_configure_data_frame_filters,
+       .get_ext_capab = nl80211_get_ext_capab,
 };