ipv4: udp: fix short packet and bad checksum logging
[safe/jmp/linux-2.6] / net / wireless / wext-compat.c
index 4198243..a60a277 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/nl80211.h>
 #include <linux/if_arp.h>
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include <net/iw_handler.h>
 #include <net/cfg80211.h>
 #include "wext-compat.h"
@@ -1099,8 +1100,8 @@ int cfg80211_wext_siwpower(struct net_device *dev,
 {
        struct wireless_dev *wdev = dev->ieee80211_ptr;
        struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
-       bool ps = wdev->wext.ps;
-       int timeout = wdev->wext.ps_timeout;
+       bool ps = wdev->ps;
+       int timeout = wdev->ps_timeout;
        int err;
 
        if (wdev->iftype != NL80211_IFTYPE_STATION)
@@ -1133,8 +1134,8 @@ int cfg80211_wext_siwpower(struct net_device *dev,
        if (err)
                return err;
 
-       wdev->wext.ps = ps;
-       wdev->wext.ps_timeout = timeout;
+       wdev->ps = ps;
+       wdev->ps_timeout = timeout;
 
        return 0;
 
@@ -1147,7 +1148,7 @@ int cfg80211_wext_giwpower(struct net_device *dev,
 {
        struct wireless_dev *wdev = dev->ieee80211_ptr;
 
-       wrq->disabled = !wdev->wext.ps;
+       wrq->disabled = !wdev->ps;
 
        return 0;
 }
@@ -1204,21 +1205,47 @@ int cfg80211_wext_siwrate(struct net_device *dev,
        struct wireless_dev *wdev = dev->ieee80211_ptr;
        struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
        struct cfg80211_bitrate_mask mask;
+       u32 fixed, maxrate;
+       struct ieee80211_supported_band *sband;
+       int band, ridx;
+       bool match = false;
 
        if (!rdev->ops->set_bitrate_mask)
                return -EOPNOTSUPP;
 
-       mask.fixed = 0;
-       mask.maxrate = 0;
+       memset(&mask, 0, sizeof(mask));
+       fixed = 0;
+       maxrate = (u32)-1;
 
        if (rate->value < 0) {
                /* nothing */
        } else if (rate->fixed) {
-               mask.fixed = rate->value / 1000; /* kbps */
+               fixed = rate->value / 100000;
        } else {
-               mask.maxrate = rate->value / 1000; /* kbps */
+               maxrate = rate->value / 100000;
+       }
+
+       for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
+               sband = wdev->wiphy->bands[band];
+               if (sband == NULL)
+                       continue;
+               for (ridx = 0; ridx < sband->n_bitrates; ridx++) {
+                       struct ieee80211_rate *srate = &sband->bitrates[ridx];
+                       if (fixed == srate->bitrate) {
+                               mask.control[band].legacy = 1 << ridx;
+                               match = true;
+                               break;
+                       }
+                       if (srate->bitrate <= maxrate) {
+                               mask.control[band].legacy |= 1 << ridx;
+                               match = true;
+                       }
+               }
        }
 
+       if (!match)
+               return -EINVAL;
+
        return rdev->ops->set_bitrate_mask(wdev->wiphy, dev, NULL, &mask);
 }
 EXPORT_SYMBOL_GPL(cfg80211_wext_siwrate);