cfg80211/mac80211: move wext SIWMLME into cfg80211
authorJohannes Berg <johannes@sipsolutions.net>
Sun, 19 Apr 2009 17:57:45 +0000 (19:57 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 22 Apr 2009 20:57:17 +0000 (16:57 -0400)
Since we have ->deauth and ->disassoc we can support the
wext SIWMLME call directly without driver wext handlers.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
include/net/cfg80211.h
net/mac80211/cfg.c
net/mac80211/mlme.c
net/mac80211/wext.c
net/wireless/wext-compat.c

index d303c269a69313cb623c821b46949b086ed9bee4..019a41efa0bbc5809e79a0629e2da0ef38070e60 100644 (file)
@@ -833,6 +833,9 @@ int cfg80211_wext_siwscan(struct net_device *dev,
 int cfg80211_wext_giwscan(struct net_device *dev,
                          struct iw_request_info *info,
                          struct iw_point *data, char *extra);
+int cfg80211_wext_siwmlme(struct net_device *dev,
+                         struct iw_request_info *info,
+                         struct iw_point *data, char *extra);
 int cfg80211_wext_giwrange(struct net_device *dev,
                           struct iw_request_info *info,
                           struct iw_point *data, char *extra);
index 520efa8a079136b16d00350e35ded81a5a5bd4c3..daf75287e92a2ecd9619e7ca2e79ea3ec63bbf4a 100644 (file)
@@ -1268,22 +1268,18 @@ 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;
-
-       sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+       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;
-
-       sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       /* TODO: req->ie */
+       /* TODO: req->ie, req->peer_addr */
        return ieee80211_sta_disassociate(sdata, req->reason_code);
 }
 
index a16c9d724be19c983c59941b7dabb781c671d71c..428742d7f440503cfb1cda9a0d4658a5796ae04a 100644 (file)
@@ -2338,9 +2338,6 @@ int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason
        printk(KERN_DEBUG "%s: deauthenticating by local choice (reason=%d)\n",
               sdata->dev->name, reason);
 
-       if (sdata->vif.type != NL80211_IFTYPE_STATION)
-               return -EINVAL;
-
        ieee80211_set_disassoc(sdata, true, true, reason);
        return 0;
 }
@@ -2352,9 +2349,6 @@ int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason)
        printk(KERN_DEBUG "%s: disassociating by local choice (reason=%d)\n",
               sdata->dev->name, reason);
 
-       if (sdata->vif.type != NL80211_IFTYPE_STATION)
-               return -EINVAL;
-
        if (!(ifmgd->flags & IEEE80211_STA_ASSOCIATED))
                return -ENOLINK;
 
index 1c4664b8b1a0029ac80def145a6b4e1ee72b5dff..896704cf94e13bef7bcd47dbc4fbd117e53f1b97 100644 (file)
@@ -612,29 +612,6 @@ static int ieee80211_ioctl_giwretry(struct net_device *dev,
        return 0;
 }
 
-static int ieee80211_ioctl_siwmlme(struct net_device *dev,
-                                  struct iw_request_info *info,
-                                  struct iw_point *data, char *extra)
-{
-       struct ieee80211_sub_if_data *sdata;
-       struct iw_mlme *mlme = (struct iw_mlme *) extra;
-
-       sdata = IEEE80211_DEV_TO_SUB_IF(dev);
-       if (!(sdata->vif.type == NL80211_IFTYPE_STATION))
-               return -EINVAL;
-
-       switch (mlme->cmd) {
-       case IW_MLME_DEAUTH:
-               /* TODO: mlme->addr.sa_data */
-               return ieee80211_sta_deauthenticate(sdata, mlme->reason_code);
-       case IW_MLME_DISASSOC:
-               /* TODO: mlme->addr.sa_data */
-               return ieee80211_sta_disassociate(sdata, mlme->reason_code);
-       default:
-               return -EOPNOTSUPP;
-       }
-}
-
 
 static int ieee80211_ioctl_siwencode(struct net_device *dev,
                                     struct iw_request_info *info,
@@ -1076,7 +1053,7 @@ static const iw_handler ieee80211_handler[] =
        (iw_handler) NULL,                              /* SIOCGIWTHRSPY */
        (iw_handler) ieee80211_ioctl_siwap,             /* SIOCSIWAP */
        (iw_handler) ieee80211_ioctl_giwap,             /* SIOCGIWAP */
-       (iw_handler) ieee80211_ioctl_siwmlme,           /* SIOCSIWMLME */
+       (iw_handler) cfg80211_wext_siwmlme,             /* SIOCSIWMLME */
        (iw_handler) NULL,                              /* SIOCGIWAPLIST */
        (iw_handler) cfg80211_wext_siwscan,             /* SIOCSIWSCAN */
        (iw_handler) cfg80211_wext_giwscan,             /* SIOCGIWSCAN */
index 0fd1db6e95bbe26ef13a9d3524a42ff5765d97c9..6fd7bf7b44816b172ce0c018081e17d921125cfa 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/wireless.h>
 #include <linux/nl80211.h>
+#include <linux/if_arp.h>
 #include <net/iw_handler.h>
 #include <net/wireless.h>
 #include <net/cfg80211.h>
@@ -206,7 +207,6 @@ int cfg80211_wext_giwrange(struct net_device *dev,
        range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
                          IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
 
-
        for (band = 0; band < IEEE80211_NUM_BANDS; band ++) {
                int i;
                struct ieee80211_supported_band *sband;
@@ -241,3 +241,47 @@ int cfg80211_wext_giwrange(struct net_device *dev,
        return 0;
 }
 EXPORT_SYMBOL(cfg80211_wext_giwrange);
+
+int cfg80211_wext_siwmlme(struct net_device *dev,
+                         struct iw_request_info *info,
+                         struct iw_point *data, char *extra)
+{
+       struct wireless_dev *wdev = dev->ieee80211_ptr;
+       struct iw_mlme *mlme = (struct iw_mlme *)extra;
+       struct cfg80211_registered_device *rdev;
+       union {
+               struct cfg80211_disassoc_request disassoc;
+               struct cfg80211_deauth_request deauth;
+       } cmd;
+
+       if (!wdev)
+               return -EOPNOTSUPP;
+
+       rdev = wiphy_to_dev(wdev->wiphy);
+
+       if (wdev->iftype != NL80211_IFTYPE_STATION)
+               return -EINVAL;
+
+       if (mlme->addr.sa_family != ARPHRD_ETHER)
+               return -EINVAL;
+
+       memset(&cmd, 0, sizeof(cmd));
+
+       switch (mlme->cmd) {
+       case IW_MLME_DEAUTH:
+               if (!rdev->ops->deauth)
+                       return -EOPNOTSUPP;
+               cmd.deauth.peer_addr = mlme->addr.sa_data;
+               cmd.deauth.reason_code = mlme->reason_code;
+               return rdev->ops->deauth(wdev->wiphy, dev, &cmd.deauth);
+       case IW_MLME_DISASSOC:
+               if (!rdev->ops->disassoc)
+                       return -EOPNOTSUPP;
+               cmd.disassoc.peer_addr = mlme->addr.sa_data;
+               cmd.disassoc.reason_code = mlme->reason_code;
+               return rdev->ops->disassoc(wdev->wiphy, dev, &cmd.disassoc);
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+EXPORT_SYMBOL(cfg80211_wext_siwmlme);