]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
cfg80211: introduce scan IE limit attribute
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 31 Mar 2009 10:12:05 +0000 (12:12 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 22 Apr 2009 20:54:39 +0000 (16:54 -0400)
This patch introduces a new attribute for a wiphy that tells
userspace how long the information elements added to a probe
request frame can be at most. It also updates the at76 to
advertise that it cannot support that, and, for now until I
can fix that, iwlwifi too.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/at76c50x-usb.c
drivers/net/wireless/iwlwifi/iwl-core.c
include/linux/nl80211.h
include/net/wireless.h
net/mac80211/main.c
net/mac80211/util.c
net/wireless/nl80211.c

index 69248ded51022adf05f0a2c8f4ae22bc4ae2f578..55f947ac56d1f78ac321ad9b0ba9de6526139f34 100644 (file)
@@ -2250,6 +2250,7 @@ static int at76_init_new_device(struct at76_priv *priv,
 
        /* mac80211 initialisation */
        priv->hw->wiphy->max_scan_ssids = 1;
+       priv->hw->wiphy->max_scan_ie_len = 0;
        priv->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
        priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &at76_supported_band;
        priv->hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
index 82abb1f9087fefce7fed4797dc65246b0278e585..ef55f91374a164f9d34cd6c40e38821b8cb321ef 100644 (file)
@@ -1306,6 +1306,7 @@ int iwl_setup_mac(struct iwl_priv *priv)
 
        hw->wiphy->custom_regulatory = true;
        hw->wiphy->max_scan_ssids = 1;
+       hw->wiphy->max_scan_ie_len = 0; /* XXX for now */
 
        /* Default value; 4 EDCA QOS priorities */
        hw->queues = 4;
index 27f230f063b30a9f8afc6a1917e7ab53a159518b..209cacee52858984a7829389fb40f1badec3e9b7 100644 (file)
@@ -390,6 +390,8 @@ enum nl80211_commands {
  *
  * @NL80211_ATTR_MAX_NUM_SCAN_SSIDS: number of SSIDs you can scan with
  *     a single scan request, a wiphy attribute.
+ * @NL80211_ATTR_MAX_SCAN_IE_LEN: maximum length of information elements
+ *     that can be added to a scan request
  *
  * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz)
  * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive
@@ -507,6 +509,8 @@ enum nl80211_attrs {
 
        NL80211_ATTR_KEY_TYPE,
 
+       NL80211_ATTR_MAX_SCAN_IE_LEN,
+
        /* add attributes here, update the policy in nl80211.c */
 
        __NL80211_ATTR_AFTER_LAST,
index 64a76208580c66ec4d8f2bc3562f5b86287fd723..2bcdeda46d81107c0f748ffa34024f9e2b18a939 100644 (file)
@@ -222,6 +222,7 @@ struct wiphy {
 
        int bss_priv_size;
        u8 max_scan_ssids;
+       u16 max_scan_ie_len;
 
        /* If multiple wiphys are registered and you're handed e.g.
         * a regular netdev with assigned ieee80211_ptr, you won't
index fbcbed6cad017ec6596bf4546d9142493b70a25d..ee58a7873699ccc71766065c5aadcc9ad22861be 100644 (file)
@@ -728,7 +728,18 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
                return NULL;
 
        wiphy->privid = mac80211_wiphy_privid;
-       wiphy->max_scan_ssids = 4;
+
+       if (!ops->hw_scan) {
+               /* For hw_scan, driver needs to set these up. */
+               wiphy->max_scan_ssids = 4;
+
+               /* we support a maximum of 32 rates in cfg80211 */
+               wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN
+                                        - 2 - 32 /* SSID */
+                                        - 4 - 32 /* (ext) supp rates */;
+
+       }
+
        /* Yes, putting cfg80211_bss into ieee80211_bss is a hack */
        wiphy->bss_priv_size = sizeof(struct ieee80211_bss) -
                               sizeof(struct cfg80211_bss);
index fdf432f14554d018b3cca371288d5d96d01aafbf..05caf34f31dafa20fc6c47ff69785daee95ea167 100644 (file)
@@ -890,6 +890,8 @@ void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
                *pos = rate->bitrate / 5;
        }
 
+       /* if adding more here, adjust max_scan_ie_len */
+
        if (ie)
                memcpy(skb_put(skb, ie_len), ie, ie_len);
 
index 1394115cde95e12d8d5fe20eb9dc6cd3e0255105..447fa1790b4e82e4a42c78e75423c4c366542517 100644 (file)
@@ -181,6 +181,8 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
        NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy));
        NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS,
                   dev->wiphy.max_scan_ssids);
+       NLA_PUT_U16(msg, NL80211_ATTR_MAX_SCAN_IE_LEN,
+                   dev->wiphy.max_scan_ie_len);
 
        nl_modes = nla_nest_start(msg, NL80211_ATTR_SUPPORTED_IFTYPES);
        if (!nl_modes)
@@ -2528,6 +2530,11 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
        else
                ie_len = 0;
 
+       if (ie_len > wiphy->max_scan_ie_len) {
+               err = -EINVAL;
+               goto out;
+       }
+
        request = kzalloc(sizeof(*request)
                        + sizeof(*ssid) * n_ssids
                        + sizeof(channel) * n_channels