]> Pileus Git - ~andy/linux/blobdiff - net/mac80211/cfg.c
mac80211: unify config_interface and bss_info_changed
[~andy/linux] / net / mac80211 / cfg.c
index f5c15c9a00ce80d0dd571eb01f7052e7ab46c80e..648bac1c850e32ab15600fdc7442ef161b064046 100644 (file)
@@ -451,18 +451,11 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata,
         * This is a kludge. beacon interval should really be part
         * of the beacon information.
         */
-       if (params->interval && (sdata->local->hw.conf.beacon_int !=
-                                params->interval)) {
-               sdata->local->hw.conf.beacon_int = params->interval;
-               err = ieee80211_hw_config(sdata->local,
-                                       IEEE80211_CONF_CHANGE_BEACON_INTERVAL);
-               if (err < 0)
-                       return err;
-               /*
-                * We updated some parameter so if below bails out
-                * it's not an error.
-                */
-               err = 0;
+       if (params->interval &&
+           (sdata->vif.bss_conf.beacon_int != params->interval)) {
+               sdata->vif.bss_conf.beacon_int = params->interval;
+               ieee80211_bss_info_change_notify(sdata,
+                                                BSS_CHANGED_BEACON_INT);
        }
 
        /* Need to have a beacon head if we don't have one yet */
@@ -528,8 +521,9 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata,
 
        kfree(old);
 
-       return ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON |
-                                         IEEE80211_IFCC_BEACON_ENABLED);
+       ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
+                                               BSS_CHANGED_BEACON);
+       return 0;
 }
 
 static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev,
@@ -540,9 +534,6 @@ static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev,
 
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (sdata->vif.type != NL80211_IFTYPE_AP)
-               return -EINVAL;
-
        old = sdata->u.ap.beacon;
 
        if (old)
@@ -559,9 +550,6 @@ static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev,
 
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (sdata->vif.type != NL80211_IFTYPE_AP)
-               return -EINVAL;
-
        old = sdata->u.ap.beacon;
 
        if (!old)
@@ -577,9 +565,6 @@ static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev)
 
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (sdata->vif.type != NL80211_IFTYPE_AP)
-               return -EINVAL;
-
        old = sdata->u.ap.beacon;
 
        if (!old)
@@ -589,7 +574,8 @@ static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev)
        synchronize_rcu();
        kfree(old);
 
-       return ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON_ENABLED);
+       ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
+       return 0;
 }
 
 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
@@ -728,10 +714,6 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
        int err;
        int layer2_update;
 
-       /* Prevent a race with changing the rate control algorithm */
-       if (!netif_running(dev))
-               return -ENETDOWN;
-
        if (params->vlan) {
                sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
 
@@ -860,14 +842,8 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
        struct sta_info *sta;
        int err;
 
-       if (!netif_running(dev))
-               return -ENETDOWN;
-
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
-               return -ENOTSUPP;
-
        rcu_read_lock();
        sta = sta_info_get(local, next_hop);
        if (!sta) {
@@ -913,14 +889,8 @@ static int ieee80211_change_mpath(struct wiphy *wiphy,
        struct mesh_path *mpath;
        struct sta_info *sta;
 
-       if (!netif_running(dev))
-               return -ENETDOWN;
-
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
-               return -ENOTSUPP;
-
        rcu_read_lock();
 
        sta = sta_info_get(local, next_hop);
@@ -989,9 +959,6 @@ static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
 
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
-               return -ENOTSUPP;
-
        rcu_read_lock();
        mpath = mesh_path_lookup(dst, sdata);
        if (!mpath) {
@@ -1013,9 +980,6 @@ static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
 
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
-               return -ENOTSUPP;
-
        rcu_read_lock();
        mpath = mesh_path_lookup_by_idx(idx, sdata);
        if (!mpath) {
@@ -1035,8 +999,6 @@ static int ieee80211_get_mesh_params(struct wiphy *wiphy,
        struct ieee80211_sub_if_data *sdata;
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
-               return -ENOTSUPP;
        memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
        return 0;
 }
@@ -1054,9 +1016,6 @@ static int ieee80211_set_mesh_params(struct wiphy *wiphy,
        struct ieee80211_sub_if_data *sdata;
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
-               return -ENOTSUPP;
-
        /* Set the config options which we are interested in setting */
        conf = &(sdata->u.mesh.mshcfg);
        if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
@@ -1104,9 +1063,6 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
 
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (sdata->vif.type != NL80211_IFTYPE_AP)
-               return -EINVAL;
-
        if (params->use_cts_prot >= 0) {
                sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
                changed |= BSS_CHANGED_ERP_CTS_PROT;
@@ -1202,14 +1158,12 @@ static int ieee80211_scan(struct wiphy *wiphy,
 {
        struct ieee80211_sub_if_data *sdata;
 
-       if (!netif_running(dev))
-               return -ENETDOWN;
-
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
        if (sdata->vif.type != NL80211_IFTYPE_STATION &&
            sdata->vif.type != NL80211_IFTYPE_ADHOC &&
-           sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
+           sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
+           (sdata->vif.type != NL80211_IFTYPE_AP || sdata->u.ap.beacon))
                return -EOPNOTSUPP;
 
        return ieee80211_request_scan(sdata, req);
@@ -1220,14 +1174,8 @@ static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
 {
        struct ieee80211_sub_if_data *sdata;
 
-       if (!netif_running(dev))
-               return -ENETDOWN;
-
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (sdata->vif.type != NL80211_IFTYPE_STATION)
-               return -EOPNOTSUPP;
-
        switch (req->auth_type) {
        case NL80211_AUTHTYPE_OPEN_SYSTEM:
                sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_OPEN;
@@ -1282,14 +1230,8 @@ static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
        struct ieee80211_sub_if_data *sdata;
        int ret;
 
-       if (!netif_running(dev))
-               return -ENETDOWN;
-
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (sdata->vif.type != NL80211_IFTYPE_STATION)
-               return -EOPNOTSUPP;
-
        if (memcmp(sdata->u.mgd.bssid, req->peer_addr, ETH_ALEN) != 0 ||
            !(sdata->u.mgd.flags & IEEE80211_STA_AUTHENTICATED))
                return -ENOLINK; /* not authenticated */
@@ -1321,34 +1263,60 @@ static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
                            struct cfg80211_deauth_request *req)
 {
-       struct ieee80211_sub_if_data *sdata;
-
-       if (!netif_running(dev))
-               return -ENETDOWN;
-
-       sdata = IEEE80211_DEV_TO_SUB_IF(dev);
-       if (sdata->vif.type != NL80211_IFTYPE_STATION)
-               return -EOPNOTSUPP;
+       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       /* TODO: req->ie */
+       /* TODO: req->ie, req->peer_addr */
        return ieee80211_sta_deauthenticate(sdata, req->reason_code);
 }
 
 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
                              struct cfg80211_disassoc_request *req)
 {
-       struct ieee80211_sub_if_data *sdata;
+       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (!netif_running(dev))
-               return -ENETDOWN;
+       /* TODO: req->ie, req->peer_addr */
+       return ieee80211_sta_disassociate(sdata, req->reason_code);
+}
 
-       sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
+                              struct cfg80211_ibss_params *params)
+{
+       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       if (sdata->vif.type != NL80211_IFTYPE_STATION)
-               return -EOPNOTSUPP;
+       return ieee80211_ibss_join(sdata, params);
+}
 
-       /* TODO: req->ie */
-       return ieee80211_sta_disassociate(sdata, req->reason_code);
+static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
+{
+       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+       return ieee80211_ibss_leave(sdata);
+}
+
+static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
+{
+       struct ieee80211_local *local = wiphy_priv(wiphy);
+
+       if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
+               int err;
+
+               if (local->ops->set_rts_threshold) {
+                       err = local->ops->set_rts_threshold(
+                               local_to_hw(local), wiphy->rts_threshold);
+                       if (err)
+                               return err;
+               }
+       }
+
+       if (changed & WIPHY_PARAM_RETRY_SHORT)
+               local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
+       if (changed & WIPHY_PARAM_RETRY_LONG)
+               local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
+       if (changed &
+           (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
+               ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
+
+       return 0;
 }
 
 struct cfg80211_ops mac80211_config_ops = {
@@ -1387,4 +1355,7 @@ struct cfg80211_ops mac80211_config_ops = {
        .assoc = ieee80211_assoc,
        .deauth = ieee80211_deauth,
        .disassoc = ieee80211_disassoc,
+       .join_ibss = ieee80211_join_ibss,
+       .leave_ibss = ieee80211_leave_ibss,
+       .set_wiphy_params = ieee80211_set_wiphy_params,
 };