cfg80211/mac80211: add mesh join/leave commands
[firefly-linux-kernel-4.4.55.git] / net / mac80211 / cfg.c
index d34c7c3dd762c2b485b424ba29d92601fba34801..68329d713c02402e53e61f49ed3c24aa6a5d23a7 100644 (file)
@@ -60,11 +60,6 @@ static int ieee80211_change_iface(struct wiphy *wiphy,
        if (ret)
                return ret;
 
-       if (ieee80211_vif_is_mesh(&sdata->vif) && params->mesh_id_len)
-               ieee80211_sdata_set_mesh_id(sdata,
-                                           params->mesh_id_len,
-                                           params->mesh_id);
-
        if (type == NL80211_IFTYPE_AP_VLAN &&
            params && params->use_4addr == 0)
                rcu_assign_pointer(sdata->u.vlan.sta, NULL);
@@ -1003,9 +998,9 @@ static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
        return (mask >> (parm-1)) & 0x1;
 }
 
-static int ieee80211_set_mesh_params(struct wiphy *wiphy,
-                               struct net_device *dev,
-                               const struct mesh_config *nconf, u32 mask)
+static int ieee80211_update_mesh_params(struct wiphy *wiphy,
+                                       struct net_device *dev, u32 mask,
+                                       const struct mesh_config *nconf)
 {
        struct mesh_config *conf;
        struct ieee80211_sub_if_data *sdata;
@@ -1056,6 +1051,30 @@ static int ieee80211_set_mesh_params(struct wiphy *wiphy,
        return 0;
 }
 
+static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
+                              const struct mesh_config *conf,
+                              const struct mesh_setup *setup)
+{
+       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+       struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
+
+       memcpy(&sdata->u.mesh.mshcfg, conf, sizeof(struct mesh_config));
+       ifmsh->mesh_id_len = setup->mesh_id_len;
+       memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
+
+       ieee80211_start_mesh(sdata);
+
+       return 0;
+}
+
+static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
+{
+       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+       ieee80211_stop_mesh(sdata);
+
+       return 0;
+}
 #endif
 
 static int ieee80211_change_bss(struct wiphy *wiphy,
@@ -1760,8 +1779,10 @@ struct cfg80211_ops mac80211_config_ops = {
        .change_mpath = ieee80211_change_mpath,
        .get_mpath = ieee80211_get_mpath,
        .dump_mpath = ieee80211_dump_mpath,
-       .set_mesh_params = ieee80211_set_mesh_params,
+       .update_mesh_params = ieee80211_update_mesh_params,
        .get_mesh_params = ieee80211_get_mesh_params,
+       .join_mesh = ieee80211_join_mesh,
+       .leave_mesh = ieee80211_leave_mesh,
 #endif
        .change_bss = ieee80211_change_bss,
        .set_txq_params = ieee80211_set_txq_params,