[MAC80211]: only honor IW_SCAN_THIS_ESSID in STA, IBSS, and AP modes
authorJohn W. Linville <linville@tuxdriver.com>
Thu, 18 Oct 2007 04:16:16 +0000 (21:16 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 18 Oct 2007 04:16:16 +0000 (21:16 -0700)
The previous IW_SCAN_THIS_ESSID patch left a hole allowing scan
requests on interfaces in inappropriate modes.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/mac80211/ieee80211_ioctl.c

index a57fed77db272a42083f384e7cdf6bb8c99a097f..6caa3ec2cff7798ef13e1f604fc8bdfff50a0c4c 100644 (file)
@@ -522,29 +522,30 @@ static int ieee80211_ioctl_siwscan(struct net_device *dev,
        if (!netif_running(dev))
                return -ENETDOWN;
 
+       switch (sdata->type) {
+       case IEEE80211_IF_TYPE_STA:
+       case IEEE80211_IF_TYPE_IBSS:
+               if (local->scan_flags & IEEE80211_SCAN_MATCH_SSID) {
+                       ssid = sdata->u.sta.ssid;
+                       ssid_len = sdata->u.sta.ssid_len;
+               }
+               break;
+       case IEEE80211_IF_TYPE_AP:
+               if (local->scan_flags & IEEE80211_SCAN_MATCH_SSID) {
+                       ssid = sdata->u.ap.ssid;
+                       ssid_len = sdata->u.ap.ssid_len;
+               }
+               break;
+       default:
+               return -EOPNOTSUPP;
+       }
+
+       /* if SSID was specified explicitly then use that */
        if (wrqu->data.length == sizeof(struct iw_scan_req) &&
            wrqu->data.flags & IW_SCAN_THIS_ESSID) {
                req = (struct iw_scan_req *)extra;
                ssid = req->essid;
                ssid_len = req->essid_len;
-       } else {
-               switch (sdata->type) {
-               case IEEE80211_IF_TYPE_STA:
-               case IEEE80211_IF_TYPE_IBSS:
-                       if (local->scan_flags & IEEE80211_SCAN_MATCH_SSID) {
-                               ssid = sdata->u.sta.ssid;
-                               ssid_len = sdata->u.sta.ssid_len;
-                       }
-                       break;
-               case IEEE80211_IF_TYPE_AP:
-                       if (local->scan_flags & IEEE80211_SCAN_MATCH_SSID) {
-                               ssid = sdata->u.ap.ssid;
-                               ssid_len = sdata->u.ap.ssid_len;
-                       }
-                       break;
-               default:
-                       return -EOPNOTSUPP;
-               }
        }
 
        return ieee80211_sta_req_scan(dev, ssid, ssid_len);