mac80211: Fix HT channel selection
[safe/jmp/linux-2.6] / net / mac80211 / mlme.c
index b209930..e4d1fca 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/delay.h>
 #include <linux/if_ether.h>
 #include <linux/skbuff.h>
-#include <linux/netdevice.h>
 #include <linux/if_arp.h>
 #include <linux/wireless.h>
 #include <linux/random.h>
@@ -803,6 +802,10 @@ static void ieee80211_authenticate(struct ieee80211_sub_if_data *sdata,
        mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT);
 }
 
+/*
+ * The disassoc 'reason' argument can be either our own reason
+ * if self disconnected or a reason code from the AP.
+ */
 static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
                                   struct ieee80211_if_sta *ifsta, bool deauth,
                                   bool self_disconnected, u16 reason)
@@ -849,19 +852,30 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
 
        ieee80211_sta_send_apinfo(sdata, ifsta);
 
-       if (self_disconnected)
+       if (self_disconnected || reason == WLAN_REASON_DISASSOC_STA_HAS_LEFT)
                ifsta->state = IEEE80211_STA_MLME_DISABLED;
 
-       sta_info_unlink(&sta);
-
        rcu_read_unlock();
 
-       sta_info_destroy(sta);
-
        local->hw.conf.ht.enabled = false;
+       local->oper_channel_type = NL80211_CHAN_NO_HT;
        ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_HT);
 
        ieee80211_bss_info_change_notify(sdata, changed);
+
+       rcu_read_lock();
+
+       sta = sta_info_get(local, ifsta->bssid);
+       if (!sta) {
+               rcu_read_unlock();
+               return;
+       }
+
+       sta_info_unlink(&sta);
+
+       rcu_read_unlock();
+
+       sta_info_destroy(sta);
 }
 
 static int ieee80211_sta_wep_configured(struct ieee80211_sub_if_data *sdata)
@@ -1164,7 +1178,7 @@ static void ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
                                      IEEE80211_RETRY_AUTH_INTERVAL);
        }
 
-       ieee80211_set_disassoc(sdata, ifsta, false, false, 0);
+       ieee80211_set_disassoc(sdata, ifsta, false, false, reason_code);
 }
 
 
@@ -1552,8 +1566,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
                                    (unsigned long long) sta->sta.supp_rates[band]);
 #endif
                } else {
-                       ieee80211_ibss_add_sta(sdata, NULL, mgmt->bssid,
-                                              mgmt->sa, supp_rates);
+                       ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates);
                }
 
                rcu_read_unlock();
@@ -1625,9 +1638,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
                               sdata->dev->name, mgmt->bssid);
 #endif
                        ieee80211_sta_join_ibss(sdata, &sdata->u.sta, bss);
-                       ieee80211_ibss_add_sta(sdata, NULL,
-                                              mgmt->bssid, mgmt->sa,
-                                              supp_rates);
+                       ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates);
                }
        }
 
@@ -1737,6 +1748,13 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
                                               ap_ht_cap_flags);
        }
 
+       if (elems.country_elem) {
+               /* Note we are only reviewing this on beacons
+                * for the BSSID we are associated to */
+               regulatory_hint_11d(local->hw.wiphy,
+                       elems.country_elem, elems.country_elem_len);
+       }
+
        ieee80211_bss_info_change_notify(sdata, changed);
 }
 
@@ -1992,7 +2010,7 @@ static int ieee80211_sta_match_ssid(struct ieee80211_if_sta *ifsta,
                }
        }
 
-       if (hidden_ssid && ifsta->ssid_len == ssid_len)
+       if (hidden_ssid && (ifsta->ssid_len == ssid_len || ssid_len == 0))
                return 1;
 
        if (ssid_len == 1 && ssid[0] == ' ')
@@ -2353,8 +2371,7 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata)
  * must be callable in atomic context.
  */
 struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
-                                       struct sk_buff *skb, u8 *bssid,
-                                       u8 *addr, u64 supp_rates)
+                                       u8 *bssid,u8 *addr, u64 supp_rates)
 {
        struct ieee80211_local *local = sdata->local;
        struct sta_info *sta;
@@ -2560,25 +2577,3 @@ void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local)
                ieee80211_restart_sta_timer(sdata);
        rcu_read_unlock();
 }
-
-/* driver notification call */
-void ieee80211_notify_mac(struct ieee80211_hw *hw,
-                         enum ieee80211_notification_types  notif_type)
-{
-       struct ieee80211_local *local = hw_to_local(hw);
-       struct ieee80211_sub_if_data *sdata;
-
-       switch (notif_type) {
-       case IEEE80211_NOTIFY_RE_ASSOC:
-               rtnl_lock();
-               list_for_each_entry(sdata, &local->interfaces, list) {
-                       if (sdata->vif.type != NL80211_IFTYPE_STATION)
-                               continue;
-
-                       ieee80211_sta_req_auth(sdata, &sdata->u.sta);
-               }
-               rtnl_unlock();
-               break;
-       }
-}
-EXPORT_SYMBOL(ieee80211_notify_mac);