]> err.no Git - linux-2.6/blobdiff - net/mac80211/wext.c
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6] / net / mac80211 / wext.c
index 4806d96b9877f353f004a7a39d837ad6feacd176..736c32e340f20c4debeee33e77d84994275ba42b 100644 (file)
@@ -95,6 +95,13 @@ static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr,
                        }
                }
 
+               if (alg == ALG_WEP &&
+                       key_len != LEN_WEP40 && key_len != LEN_WEP104) {
+                       ieee80211_key_free(key);
+                       err = -EINVAL;
+                       goto out_unlock;
+               }
+
                ieee80211_key_link(key, sdata, sta);
 
                if (set_tx_key || (!sta && !sdata->default_key && key))
@@ -135,7 +142,39 @@ static int ieee80211_ioctl_giwname(struct net_device *dev,
                                   struct iw_request_info *info,
                                   char *name, char *extra)
 {
+       struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
+       struct ieee80211_supported_band *sband;
+       u8 is_ht = 0, is_a = 0, is_b = 0, is_g = 0;
+
+
+       sband = local->hw.wiphy->bands[IEEE80211_BAND_5GHZ];
+       if (sband) {
+               is_a = 1;
+               is_ht |= sband->ht_info.ht_supported;
+       }
+
+       sband = local->hw.wiphy->bands[IEEE80211_BAND_2GHZ];
+       if (sband) {
+               int i;
+               /* Check for mandatory rates */
+               for (i = 0; i < sband->n_bitrates; i++) {
+                       if (sband->bitrates[i].bitrate == 10)
+                               is_b = 1;
+                       if (sband->bitrates[i].bitrate == 60)
+                               is_g = 1;
+               }
+               is_ht |= sband->ht_info.ht_supported;
+       }
+
        strcpy(name, "IEEE 802.11");
+       if (is_a)
+               strcat(name, "a");
+       if (is_b)
+               strcat(name, "b");
+       if (is_g)
+               strcat(name, "g");
+       if (is_ht)
+               strcat(name, "n");
 
        return 0;
 }
@@ -508,7 +547,8 @@ static int ieee80211_ioctl_giwap(struct net_device *dev,
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
        if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
            sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
-               if (sdata->u.sta.state == IEEE80211_ASSOCIATED) {
+               if (sdata->u.sta.state == IEEE80211_ASSOCIATED ||
+                   sdata->u.sta.state == IEEE80211_IBSS_JOINED) {
                        ap_addr->sa_family = ARPHRD_ETHER;
                        memcpy(&ap_addr->sa_data, sdata->u.sta.bssid, ETH_ALEN);
                        return 0;
@@ -566,7 +606,7 @@ static int ieee80211_ioctl_giwscan(struct net_device *dev,
        if (local->sta_sw_scanning || local->sta_hw_scanning)
                return -EAGAIN;
 
-       res = ieee80211_sta_scan_results(dev, extra, data->length);
+       res = ieee80211_sta_scan_results(dev, info, extra, data->length);
        if (res >= 0) {
                data->length = res;
                return 0;
@@ -720,6 +760,9 @@ static int ieee80211_ioctl_siwrts(struct net_device *dev,
 
        if (rts->disabled)
                local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
+       else if (!rts->fixed)
+               /* if the rts value is not fixed, then take default */
+               local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
        else if (rts->value < 0 || rts->value > IEEE80211_MAX_RTS_THRESHOLD)
                return -EINVAL;
        else
@@ -757,6 +800,8 @@ static int ieee80211_ioctl_siwfrag(struct net_device *dev,
 
        if (frag->disabled)
                local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
+       else if (!frag->fixed)
+               local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
        else if (frag->value < 256 ||
                 frag->value > IEEE80211_MAX_FRAG_THRESHOLD)
                return -EINVAL;
@@ -948,6 +993,19 @@ static int ieee80211_ioctl_giwencode(struct net_device *dev,
        erq->length = sdata->keys[idx]->conf.keylen;
        erq->flags |= IW_ENCODE_ENABLED;
 
+       if (sdata->vif.type == IEEE80211_IF_TYPE_STA) {
+               struct ieee80211_if_sta *ifsta = &sdata->u.sta;
+               switch (ifsta->auth_alg) {
+               case WLAN_AUTH_OPEN:
+               case WLAN_AUTH_LEAP:
+                       erq->flags |= IW_ENCODE_OPEN;
+                       break;
+               case WLAN_AUTH_SHARED_KEY:
+                       erq->flags |= IW_ENCODE_RESTRICTED;
+                       break;
+               }
+       }
+
        return 0;
 }