aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/mlme.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/mlme.c')
-rw-r--r--net/mac80211/mlme.c942
1 files changed, 573 insertions, 369 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 2b890af01ba4..fbb766afe599 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * BSS client mode implementation 2 * BSS client mode implementation
3 * Copyright 2003, Jouni Malinen <jkmaline@cc.hut.fi> 3 * Copyright 2003-2008, Jouni Malinen <j@w1.fi>
4 * Copyright 2004, Instant802 Networks, Inc. 4 * Copyright 2004, Instant802 Networks, Inc.
5 * Copyright 2005, Devicescape Software, Inc. 5 * Copyright 2005, Devicescape Software, Inc.
6 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 6 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
@@ -55,10 +55,10 @@ static u8 *ieee80211_bss_get_ie(struct ieee80211_bss *bss, u8 ie)
55{ 55{
56 u8 *end, *pos; 56 u8 *end, *pos;
57 57
58 pos = bss->ies; 58 pos = bss->cbss.information_elements;
59 if (pos == NULL) 59 if (pos == NULL)
60 return NULL; 60 return NULL;
61 end = pos + bss->ies_len; 61 end = pos + bss->cbss.len_information_elements;
62 62
63 while (pos + 1 < end) { 63 while (pos + 1 < end) {
64 if (pos + 2 + pos[1] > end) 64 if (pos + 2 + pos[1] > end)
@@ -73,7 +73,7 @@ static u8 *ieee80211_bss_get_ie(struct ieee80211_bss *bss, u8 ie)
73 73
74static int ieee80211_compatible_rates(struct ieee80211_bss *bss, 74static int ieee80211_compatible_rates(struct ieee80211_bss *bss,
75 struct ieee80211_supported_band *sband, 75 struct ieee80211_supported_band *sband,
76 u64 *rates) 76 u32 *rates)
77{ 77{
78 int i, j, count; 78 int i, j, count;
79 *rates = 0; 79 *rates = 0;
@@ -93,14 +93,14 @@ static int ieee80211_compatible_rates(struct ieee80211_bss *bss,
93} 93}
94 94
95/* also used by mesh code */ 95/* also used by mesh code */
96u64 ieee80211_sta_get_rates(struct ieee80211_local *local, 96u32 ieee80211_sta_get_rates(struct ieee80211_local *local,
97 struct ieee802_11_elems *elems, 97 struct ieee802_11_elems *elems,
98 enum ieee80211_band band) 98 enum ieee80211_band band)
99{ 99{
100 struct ieee80211_supported_band *sband; 100 struct ieee80211_supported_band *sband;
101 struct ieee80211_rate *bitrates; 101 struct ieee80211_rate *bitrates;
102 size_t num_rates; 102 size_t num_rates;
103 u64 supp_rates; 103 u32 supp_rates;
104 int i, j; 104 int i, j;
105 sband = local->hw.wiphy->bands[band]; 105 sband = local->hw.wiphy->bands[band];
106 106
@@ -131,6 +131,12 @@ u64 ieee80211_sta_get_rates(struct ieee80211_local *local,
131 131
132/* frame sending functions */ 132/* frame sending functions */
133 133
134static void add_extra_ies(struct sk_buff *skb, u8 *ies, size_t ies_len)
135{
136 if (ies)
137 memcpy(skb_put(skb, ies_len), ies, ies_len);
138}
139
134/* also used by scanning code */ 140/* also used by scanning code */
135void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, 141void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
136 u8 *ssid, size_t ssid_len) 142 u8 *ssid, size_t ssid_len)
@@ -142,7 +148,8 @@ void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
142 u8 *pos, *supp_rates, *esupp_rates = NULL; 148 u8 *pos, *supp_rates, *esupp_rates = NULL;
143 int i; 149 int i;
144 150
145 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt) + 200); 151 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt) + 200 +
152 sdata->u.sta.ie_probereq_len);
146 if (!skb) { 153 if (!skb) {
147 printk(KERN_DEBUG "%s: failed to allocate buffer for probe " 154 printk(KERN_DEBUG "%s: failed to allocate buffer for probe "
148 "request\n", sdata->dev->name); 155 "request\n", sdata->dev->name);
@@ -189,6 +196,9 @@ void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
189 *pos = rate->bitrate / 5; 196 *pos = rate->bitrate / 5;
190 } 197 }
191 198
199 add_extra_ies(skb, sdata->u.sta.ie_probereq,
200 sdata->u.sta.ie_probereq_len);
201
192 ieee80211_tx_skb(sdata, skb, 0); 202 ieee80211_tx_skb(sdata, skb, 0);
193} 203}
194 204
@@ -202,7 +212,8 @@ static void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
202 struct ieee80211_mgmt *mgmt; 212 struct ieee80211_mgmt *mgmt;
203 213
204 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 214 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
205 sizeof(*mgmt) + 6 + extra_len); 215 sizeof(*mgmt) + 6 + extra_len +
216 sdata->u.sta.ie_auth_len);
206 if (!skb) { 217 if (!skb) {
207 printk(KERN_DEBUG "%s: failed to allocate buffer for auth " 218 printk(KERN_DEBUG "%s: failed to allocate buffer for auth "
208 "frame\n", sdata->dev->name); 219 "frame\n", sdata->dev->name);
@@ -225,6 +236,7 @@ static void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
225 mgmt->u.auth.status_code = cpu_to_le16(0); 236 mgmt->u.auth.status_code = cpu_to_le16(0);
226 if (extra) 237 if (extra)
227 memcpy(skb_put(skb, extra_len), extra, extra_len); 238 memcpy(skb_put(skb, extra_len), extra, extra_len);
239 add_extra_ies(skb, sdata->u.sta.ie_auth, sdata->u.sta.ie_auth_len);
228 240
229 ieee80211_tx_skb(sdata, skb, encrypt); 241 ieee80211_tx_skb(sdata, skb, encrypt);
230} 242}
@@ -235,17 +247,26 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
235 struct ieee80211_local *local = sdata->local; 247 struct ieee80211_local *local = sdata->local;
236 struct sk_buff *skb; 248 struct sk_buff *skb;
237 struct ieee80211_mgmt *mgmt; 249 struct ieee80211_mgmt *mgmt;
238 u8 *pos, *ies, *ht_ie; 250 u8 *pos, *ies, *ht_ie, *e_ies;
239 int i, len, count, rates_len, supp_rates_len; 251 int i, len, count, rates_len, supp_rates_len;
240 u16 capab; 252 u16 capab;
241 struct ieee80211_bss *bss; 253 struct ieee80211_bss *bss;
242 int wmm = 0; 254 int wmm = 0;
243 struct ieee80211_supported_band *sband; 255 struct ieee80211_supported_band *sband;
244 u64 rates = 0; 256 u32 rates = 0;
257 size_t e_ies_len;
258
259 if (ifsta->flags & IEEE80211_STA_PREV_BSSID_SET) {
260 e_ies = sdata->u.sta.ie_reassocreq;
261 e_ies_len = sdata->u.sta.ie_reassocreq_len;
262 } else {
263 e_ies = sdata->u.sta.ie_assocreq;
264 e_ies_len = sdata->u.sta.ie_assocreq_len;
265 }
245 266
246 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 267 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
247 sizeof(*mgmt) + 200 + ifsta->extra_ie_len + 268 sizeof(*mgmt) + 200 + ifsta->extra_ie_len +
248 ifsta->ssid_len); 269 ifsta->ssid_len + e_ies_len);
249 if (!skb) { 270 if (!skb) {
250 printk(KERN_DEBUG "%s: failed to allocate buffer for assoc " 271 printk(KERN_DEBUG "%s: failed to allocate buffer for assoc "
251 "frame\n", sdata->dev->name); 272 "frame\n", sdata->dev->name);
@@ -268,7 +289,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
268 local->hw.conf.channel->center_freq, 289 local->hw.conf.channel->center_freq,
269 ifsta->ssid, ifsta->ssid_len); 290 ifsta->ssid, ifsta->ssid_len);
270 if (bss) { 291 if (bss) {
271 if (bss->capability & WLAN_CAPABILITY_PRIVACY) 292 if (bss->cbss.capability & WLAN_CAPABILITY_PRIVACY)
272 capab |= WLAN_CAPABILITY_PRIVACY; 293 capab |= WLAN_CAPABILITY_PRIVACY;
273 if (bss->wmm_used) 294 if (bss->wmm_used)
274 wmm = 1; 295 wmm = 1;
@@ -279,7 +300,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
279 * b-only mode) */ 300 * b-only mode) */
280 rates_len = ieee80211_compatible_rates(bss, sband, &rates); 301 rates_len = ieee80211_compatible_rates(bss, sband, &rates);
281 302
282 if ((bss->capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && 303 if ((bss->cbss.capability & WLAN_CAPABILITY_SPECTRUM_MGMT) &&
283 (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)) 304 (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT))
284 capab |= WLAN_CAPABILITY_SPECTRUM_MGMT; 305 capab |= WLAN_CAPABILITY_SPECTRUM_MGMT;
285 306
@@ -391,10 +412,17 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
391 } 412 }
392 413
393 /* wmm support is a must to HT */ 414 /* wmm support is a must to HT */
415 /*
416 * IEEE802.11n does not allow TKIP/WEP as pairwise
417 * ciphers in HT mode. We still associate in non-ht
418 * mode (11a/b/g) if any one of these ciphers is
419 * configured as pairwise.
420 */
394 if (wmm && (ifsta->flags & IEEE80211_STA_WMM_ENABLED) && 421 if (wmm && (ifsta->flags & IEEE80211_STA_WMM_ENABLED) &&
395 sband->ht_cap.ht_supported && 422 sband->ht_cap.ht_supported &&
396 (ht_ie = ieee80211_bss_get_ie(bss, WLAN_EID_HT_INFORMATION)) && 423 (ht_ie = ieee80211_bss_get_ie(bss, WLAN_EID_HT_INFORMATION)) &&
397 ht_ie[1] >= sizeof(struct ieee80211_ht_info)) { 424 ht_ie[1] >= sizeof(struct ieee80211_ht_info) &&
425 (!(ifsta->flags & IEEE80211_STA_TKIP_WEP_USED))) {
398 struct ieee80211_ht_info *ht_info = 426 struct ieee80211_ht_info *ht_info =
399 (struct ieee80211_ht_info *)(ht_ie + 2); 427 (struct ieee80211_ht_info *)(ht_ie + 2);
400 u16 cap = sband->ht_cap.cap; 428 u16 cap = sband->ht_cap.cap;
@@ -429,6 +457,8 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
429 memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); 457 memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs));
430 } 458 }
431 459
460 add_extra_ies(skb, e_ies, e_ies_len);
461
432 kfree(ifsta->assocreq_ies); 462 kfree(ifsta->assocreq_ies);
433 ifsta->assocreq_ies_len = (skb->data + skb->len) - ies; 463 ifsta->assocreq_ies_len = (skb->data + skb->len) - ies;
434 ifsta->assocreq_ies = kmalloc(ifsta->assocreq_ies_len, GFP_KERNEL); 464 ifsta->assocreq_ies = kmalloc(ifsta->assocreq_ies_len, GFP_KERNEL);
@@ -446,8 +476,19 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
446 struct ieee80211_if_sta *ifsta = &sdata->u.sta; 476 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
447 struct sk_buff *skb; 477 struct sk_buff *skb;
448 struct ieee80211_mgmt *mgmt; 478 struct ieee80211_mgmt *mgmt;
479 u8 *ies;
480 size_t ies_len;
481
482 if (stype == IEEE80211_STYPE_DEAUTH) {
483 ies = sdata->u.sta.ie_deauth;
484 ies_len = sdata->u.sta.ie_deauth_len;
485 } else {
486 ies = sdata->u.sta.ie_disassoc;
487 ies_len = sdata->u.sta.ie_disassoc_len;
488 }
449 489
450 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt)); 490 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt) +
491 ies_len);
451 if (!skb) { 492 if (!skb) {
452 printk(KERN_DEBUG "%s: failed to allocate buffer for " 493 printk(KERN_DEBUG "%s: failed to allocate buffer for "
453 "deauth/disassoc frame\n", sdata->dev->name); 494 "deauth/disassoc frame\n", sdata->dev->name);
@@ -465,19 +506,55 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
465 /* u.deauth.reason_code == u.disassoc.reason_code */ 506 /* u.deauth.reason_code == u.disassoc.reason_code */
466 mgmt->u.deauth.reason_code = cpu_to_le16(reason); 507 mgmt->u.deauth.reason_code = cpu_to_le16(reason);
467 508
509 add_extra_ies(skb, ies, ies_len);
510
511 ieee80211_tx_skb(sdata, skb, ifsta->flags & IEEE80211_STA_MFP_ENABLED);
512}
513
514void ieee80211_send_pspoll(struct ieee80211_local *local,
515 struct ieee80211_sub_if_data *sdata)
516{
517 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
518 struct ieee80211_pspoll *pspoll;
519 struct sk_buff *skb;
520 u16 fc;
521
522 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll));
523 if (!skb) {
524 printk(KERN_DEBUG "%s: failed to allocate buffer for "
525 "pspoll frame\n", sdata->dev->name);
526 return;
527 }
528 skb_reserve(skb, local->hw.extra_tx_headroom);
529
530 pspoll = (struct ieee80211_pspoll *) skb_put(skb, sizeof(*pspoll));
531 memset(pspoll, 0, sizeof(*pspoll));
532 fc = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL | IEEE80211_FCTL_PM;
533 pspoll->frame_control = cpu_to_le16(fc);
534 pspoll->aid = cpu_to_le16(ifsta->aid);
535
536 /* aid in PS-Poll has its two MSBs each set to 1 */
537 pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14);
538
539 memcpy(pspoll->bssid, ifsta->bssid, ETH_ALEN);
540 memcpy(pspoll->ta, sdata->dev->dev_addr, ETH_ALEN);
541
468 ieee80211_tx_skb(sdata, skb, 0); 542 ieee80211_tx_skb(sdata, skb, 0);
543
544 return;
469} 545}
470 546
471/* MLME */ 547/* MLME */
472static void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, 548static void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
473 struct ieee80211_bss *bss) 549 const size_t supp_rates_len,
550 const u8 *supp_rates)
474{ 551{
475 struct ieee80211_local *local = sdata->local; 552 struct ieee80211_local *local = sdata->local;
476 int i, have_higher_than_11mbit = 0; 553 int i, have_higher_than_11mbit = 0;
477 554
478 /* cf. IEEE 802.11 9.2.12 */ 555 /* cf. IEEE 802.11 9.2.12 */
479 for (i = 0; i < bss->supp_rates_len; i++) 556 for (i = 0; i < supp_rates_len; i++)
480 if ((bss->supp_rates[i] & 0x7f) * 5 > 110) 557 if ((supp_rates[i] & 0x7f) * 5 > 110)
481 have_higher_than_11mbit = 1; 558 have_higher_than_11mbit = 1;
482 559
483 if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ && 560 if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ &&
@@ -568,6 +645,27 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local,
568 } 645 }
569} 646}
570 647
648static bool ieee80211_check_tim(struct ieee802_11_elems *elems, u16 aid)
649{
650 u8 mask;
651 u8 index, indexn1, indexn2;
652 struct ieee80211_tim_ie *tim = (struct ieee80211_tim_ie *) elems->tim;
653
654 aid &= 0x3fff;
655 index = aid / 8;
656 mask = 1 << (aid & 7);
657
658 indexn1 = tim->bitmap_ctrl & 0xfe;
659 indexn2 = elems->tim_len + indexn1 - 4;
660
661 if (index < indexn1 || index > indexn2)
662 return false;
663
664 index -= indexn1;
665
666 return !!(tim->virtual_map[index] & mask);
667}
668
571static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata, 669static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
572 u16 capab, bool erp_valid, u8 erp) 670 u16 capab, bool erp_valid, u8 erp)
573{ 671{
@@ -710,20 +808,17 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
710 bss_info_changed |= BSS_CHANGED_ASSOC; 808 bss_info_changed |= BSS_CHANGED_ASSOC;
711 ifsta->flags |= IEEE80211_STA_ASSOCIATED; 809 ifsta->flags |= IEEE80211_STA_ASSOCIATED;
712 810
713 if (sdata->vif.type != NL80211_IFTYPE_STATION)
714 return;
715
716 bss = ieee80211_rx_bss_get(local, ifsta->bssid, 811 bss = ieee80211_rx_bss_get(local, ifsta->bssid,
717 conf->channel->center_freq, 812 conf->channel->center_freq,
718 ifsta->ssid, ifsta->ssid_len); 813 ifsta->ssid, ifsta->ssid_len);
719 if (bss) { 814 if (bss) {
720 /* set timing information */ 815 /* set timing information */
721 sdata->vif.bss_conf.beacon_int = bss->beacon_int; 816 sdata->vif.bss_conf.beacon_int = bss->cbss.beacon_interval;
722 sdata->vif.bss_conf.timestamp = bss->timestamp; 817 sdata->vif.bss_conf.timestamp = bss->cbss.tsf;
723 sdata->vif.bss_conf.dtim_period = bss->dtim_period; 818 sdata->vif.bss_conf.dtim_period = bss->dtim_period;
724 819
725 bss_info_changed |= ieee80211_handle_bss_capability(sdata, 820 bss_info_changed |= ieee80211_handle_bss_capability(sdata,
726 bss->capability, bss->has_erp_value, bss->erp_value); 821 bss->cbss.capability, bss->has_erp_value, bss->erp_value);
727 822
728 ieee80211_rx_bss_put(local, bss); 823 ieee80211_rx_bss_put(local, bss);
729 } 824 }
@@ -745,13 +840,16 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
745 ieee80211_bss_info_change_notify(sdata, bss_info_changed); 840 ieee80211_bss_info_change_notify(sdata, bss_info_changed);
746 841
747 if (local->powersave) { 842 if (local->powersave) {
748 if (local->dynamic_ps_timeout > 0) 843 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) &&
844 local->hw.conf.dynamic_ps_timeout > 0) {
749 mod_timer(&local->dynamic_ps_timer, jiffies + 845 mod_timer(&local->dynamic_ps_timer, jiffies +
750 msecs_to_jiffies(local->dynamic_ps_timeout)); 846 msecs_to_jiffies(
751 else { 847 local->hw.conf.dynamic_ps_timeout));
848 } else {
849 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)
850 ieee80211_send_nullfunc(local, sdata, 1);
752 conf->flags |= IEEE80211_CONF_PS; 851 conf->flags |= IEEE80211_CONF_PS;
753 ieee80211_hw_config(local, 852 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
754 IEEE80211_CONF_CHANGE_PS);
755 } 853 }
756 } 854 }
757 855
@@ -770,6 +868,14 @@ static void ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata,
770 sdata->dev->name, ifsta->bssid); 868 sdata->dev->name, ifsta->bssid);
771 ifsta->state = IEEE80211_STA_MLME_DISABLED; 869 ifsta->state = IEEE80211_STA_MLME_DISABLED;
772 ieee80211_sta_send_apinfo(sdata, ifsta); 870 ieee80211_sta_send_apinfo(sdata, ifsta);
871
872 /*
873 * Most likely AP is not in the range so remove the
874 * bss information associated to the AP
875 */
876 ieee80211_rx_bss_remove(sdata, ifsta->bssid,
877 sdata->local->hw.conf.channel->center_freq,
878 ifsta->ssid, ifsta->ssid_len);
773 return; 879 return;
774 } 880 }
775 881
@@ -801,6 +907,9 @@ static void ieee80211_authenticate(struct ieee80211_sub_if_data *sdata,
801 sdata->dev->name, ifsta->bssid); 907 sdata->dev->name, ifsta->bssid);
802 ifsta->state = IEEE80211_STA_MLME_DISABLED; 908 ifsta->state = IEEE80211_STA_MLME_DISABLED;
803 ieee80211_sta_send_apinfo(sdata, ifsta); 909 ieee80211_sta_send_apinfo(sdata, ifsta);
910 ieee80211_rx_bss_remove(sdata, ifsta->bssid,
911 sdata->local->hw.conf.channel->center_freq,
912 ifsta->ssid, ifsta->ssid_len);
804 return; 913 return;
805 } 914 }
806 915
@@ -843,7 +952,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
843 netif_tx_stop_all_queues(sdata->dev); 952 netif_tx_stop_all_queues(sdata->dev);
844 netif_carrier_off(sdata->dev); 953 netif_carrier_off(sdata->dev);
845 954
846 ieee80211_sta_tear_down_BA_sessions(sdata, sta->sta.addr); 955 ieee80211_sta_tear_down_BA_sessions(sta);
847 956
848 if (self_disconnected) { 957 if (self_disconnected) {
849 if (deauth) 958 if (deauth)
@@ -863,14 +972,19 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
863 972
864 ieee80211_sta_send_apinfo(sdata, ifsta); 973 ieee80211_sta_send_apinfo(sdata, ifsta);
865 974
866 if (self_disconnected || reason == WLAN_REASON_DISASSOC_STA_HAS_LEFT) 975 if (self_disconnected || reason == WLAN_REASON_DISASSOC_STA_HAS_LEFT) {
867 ifsta->state = IEEE80211_STA_MLME_DISABLED; 976 ifsta->state = IEEE80211_STA_MLME_DISABLED;
977 ieee80211_rx_bss_remove(sdata, ifsta->bssid,
978 sdata->local->hw.conf.channel->center_freq,
979 ifsta->ssid, ifsta->ssid_len);
980 }
868 981
869 rcu_read_unlock(); 982 rcu_read_unlock();
870 983
871 local->hw.conf.ht.enabled = false; 984 /* channel(_type) changes are handled by ieee80211_hw_config */
872 local->oper_channel_type = NL80211_CHAN_NO_HT; 985 local->oper_channel_type = NL80211_CHAN_NO_HT;
873 config_changed |= IEEE80211_CONF_CHANGE_HT; 986
987 local->power_constr_level = 0;
874 988
875 del_timer_sync(&local->dynamic_ps_timer); 989 del_timer_sync(&local->dynamic_ps_timer);
876 cancel_work_sync(&local->dynamic_ps_enable_work); 990 cancel_work_sync(&local->dynamic_ps_enable_work);
@@ -924,7 +1038,7 @@ static int ieee80211_privacy_mismatch(struct ieee80211_sub_if_data *sdata,
924 if (!bss) 1038 if (!bss)
925 return 0; 1039 return 0;
926 1040
927 bss_privacy = !!(bss->capability & WLAN_CAPABILITY_PRIVACY); 1041 bss_privacy = !!(bss->cbss.capability & WLAN_CAPABILITY_PRIVACY);
928 wep_privacy = !!ieee80211_sta_wep_configured(sdata); 1042 wep_privacy = !!ieee80211_sta_wep_configured(sdata);
929 privacy_invoked = !!(ifsta->flags & IEEE80211_STA_PRIVACY_INVOKED); 1043 privacy_invoked = !!(ifsta->flags & IEEE80211_STA_PRIVACY_INVOKED);
930 1044
@@ -946,6 +1060,9 @@ static void ieee80211_associate(struct ieee80211_sub_if_data *sdata,
946 sdata->dev->name, ifsta->bssid); 1060 sdata->dev->name, ifsta->bssid);
947 ifsta->state = IEEE80211_STA_MLME_DISABLED; 1061 ifsta->state = IEEE80211_STA_MLME_DISABLED;
948 ieee80211_sta_send_apinfo(sdata, ifsta); 1062 ieee80211_sta_send_apinfo(sdata, ifsta);
1063 ieee80211_rx_bss_remove(sdata, ifsta->bssid,
1064 sdata->local->hw.conf.channel->center_freq,
1065 ifsta->ssid, ifsta->ssid_len);
949 return; 1066 return;
950 } 1067 }
951 1068
@@ -1049,6 +1166,30 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata,
1049 elems.challenge_len + 2, 1); 1166 elems.challenge_len + 2, 1);
1050} 1167}
1051 1168
1169static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata,
1170 struct ieee80211_if_sta *ifsta,
1171 struct ieee80211_mgmt *mgmt,
1172 size_t len)
1173{
1174 u16 auth_alg, auth_transaction, status_code;
1175
1176 if (len < 24 + 6)
1177 return;
1178
1179 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg);
1180 auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction);
1181 status_code = le16_to_cpu(mgmt->u.auth.status_code);
1182
1183 /*
1184 * IEEE 802.11 standard does not require authentication in IBSS
1185 * networks and most implementations do not seem to use it.
1186 * However, try to reply to authentication attempts if someone
1187 * has actually implemented this.
1188 */
1189 if (auth_alg == WLAN_AUTH_OPEN && auth_transaction == 1)
1190 ieee80211_send_auth(sdata, ifsta, 2, NULL, 0, 0);
1191}
1192
1052static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, 1193static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
1053 struct ieee80211_if_sta *ifsta, 1194 struct ieee80211_if_sta *ifsta,
1054 struct ieee80211_mgmt *mgmt, 1195 struct ieee80211_mgmt *mgmt,
@@ -1056,37 +1197,22 @@ static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
1056{ 1197{
1057 u16 auth_alg, auth_transaction, status_code; 1198 u16 auth_alg, auth_transaction, status_code;
1058 1199
1059 if (ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE && 1200 if (ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE)
1060 sdata->vif.type != NL80211_IFTYPE_ADHOC)
1061 return; 1201 return;
1062 1202
1063 if (len < 24 + 6) 1203 if (len < 24 + 6)
1064 return; 1204 return;
1065 1205
1066 if (sdata->vif.type != NL80211_IFTYPE_ADHOC && 1206 if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0)
1067 memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0)
1068 return; 1207 return;
1069 1208
1070 if (sdata->vif.type != NL80211_IFTYPE_ADHOC && 1209 if (memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0)
1071 memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0)
1072 return; 1210 return;
1073 1211
1074 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); 1212 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg);
1075 auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); 1213 auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction);
1076 status_code = le16_to_cpu(mgmt->u.auth.status_code); 1214 status_code = le16_to_cpu(mgmt->u.auth.status_code);
1077 1215
1078 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
1079 /*
1080 * IEEE 802.11 standard does not require authentication in IBSS
1081 * networks and most implementations do not seem to use it.
1082 * However, try to reply to authentication attempts if someone
1083 * has actually implemented this.
1084 */
1085 if (auth_alg != WLAN_AUTH_OPEN || auth_transaction != 1)
1086 return;
1087 ieee80211_send_auth(sdata, ifsta, 2, NULL, 0, 0);
1088 }
1089
1090 if (auth_alg != ifsta->auth_alg || 1216 if (auth_alg != ifsta->auth_alg ||
1091 auth_transaction != ifsta->auth_transaction) 1217 auth_transaction != ifsta->auth_transaction)
1092 return; 1218 return;
@@ -1211,7 +1337,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1211 struct ieee80211_local *local = sdata->local; 1337 struct ieee80211_local *local = sdata->local;
1212 struct ieee80211_supported_band *sband; 1338 struct ieee80211_supported_band *sband;
1213 struct sta_info *sta; 1339 struct sta_info *sta;
1214 u64 rates, basic_rates; 1340 u32 rates, basic_rates;
1215 u16 capab_info, status_code, aid; 1341 u16 capab_info, status_code, aid;
1216 struct ieee802_11_elems elems; 1342 struct ieee802_11_elems elems;
1217 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; 1343 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
@@ -1242,6 +1368,24 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1242 sdata->dev->name, reassoc ? "Rea" : "A", mgmt->sa, 1368 sdata->dev->name, reassoc ? "Rea" : "A", mgmt->sa,
1243 capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14)))); 1369 capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14))));
1244 1370
1371 pos = mgmt->u.assoc_resp.variable;
1372 ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
1373
1374 if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY &&
1375 elems.timeout_int && elems.timeout_int_len == 5 &&
1376 elems.timeout_int[0] == WLAN_TIMEOUT_ASSOC_COMEBACK) {
1377 u32 tu, ms;
1378 tu = get_unaligned_le32(elems.timeout_int + 1);
1379 ms = tu * 1024 / 1000;
1380 printk(KERN_DEBUG "%s: AP rejected association temporarily; "
1381 "comeback duration %u TU (%u ms)\n",
1382 sdata->dev->name, tu, ms);
1383 if (ms > IEEE80211_ASSOC_TIMEOUT)
1384 mod_timer(&ifsta->timer,
1385 jiffies + msecs_to_jiffies(ms));
1386 return;
1387 }
1388
1245 if (status_code != WLAN_STATUS_SUCCESS) { 1389 if (status_code != WLAN_STATUS_SUCCESS) {
1246 printk(KERN_DEBUG "%s: AP denied association (code=%d)\n", 1390 printk(KERN_DEBUG "%s: AP denied association (code=%d)\n",
1247 sdata->dev->name, status_code); 1391 sdata->dev->name, status_code);
@@ -1257,9 +1401,6 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1257 "set\n", sdata->dev->name, aid); 1401 "set\n", sdata->dev->name, aid);
1258 aid &= ~(BIT(15) | BIT(14)); 1402 aid &= ~(BIT(15) | BIT(14));
1259 1403
1260 pos = mgmt->u.assoc_resp.variable;
1261 ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
1262
1263 if (!elems.supp_rates) { 1404 if (!elems.supp_rates) {
1264 printk(KERN_DEBUG "%s: no SuppRates element in AssocResp\n", 1405 printk(KERN_DEBUG "%s: no SuppRates element in AssocResp\n",
1265 sdata->dev->name); 1406 sdata->dev->name);
@@ -1281,8 +1422,6 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1281 /* Add STA entry for the AP */ 1422 /* Add STA entry for the AP */
1282 sta = sta_info_get(local, ifsta->bssid); 1423 sta = sta_info_get(local, ifsta->bssid);
1283 if (!sta) { 1424 if (!sta) {
1284 struct ieee80211_bss *bss;
1285
1286 newsta = true; 1425 newsta = true;
1287 1426
1288 sta = sta_info_alloc(sdata, ifsta->bssid, GFP_ATOMIC); 1427 sta = sta_info_alloc(sdata, ifsta->bssid, GFP_ATOMIC);
@@ -1292,15 +1431,6 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1292 rcu_read_unlock(); 1431 rcu_read_unlock();
1293 return; 1432 return;
1294 } 1433 }
1295 bss = ieee80211_rx_bss_get(local, ifsta->bssid,
1296 local->hw.conf.channel->center_freq,
1297 ifsta->ssid, ifsta->ssid_len);
1298 if (bss) {
1299 sta->last_signal = bss->signal;
1300 sta->last_qual = bss->qual;
1301 sta->last_noise = bss->noise;
1302 ieee80211_rx_bss_put(local, bss);
1303 }
1304 1434
1305 /* update new sta with its last rx activity */ 1435 /* update new sta with its last rx activity */
1306 sta->last_rx = jiffies; 1436 sta->last_rx = jiffies;
@@ -1375,6 +1505,9 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1375 1505
1376 rate_control_rate_init(sta); 1506 rate_control_rate_init(sta);
1377 1507
1508 if (ifsta->flags & IEEE80211_STA_MFP_ENABLED)
1509 set_sta_flags(sta, WLAN_STA_MFP);
1510
1378 if (elems.wmm_param) 1511 if (elems.wmm_param)
1379 set_sta_flags(sta, WLAN_STA_WME); 1512 set_sta_flags(sta, WLAN_STA_WME);
1380 1513
@@ -1409,49 +1542,61 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1409} 1542}
1410 1543
1411 1544
1412static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, 1545static int __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
1413 struct ieee80211_if_sta *ifsta, 1546 struct ieee80211_if_sta *ifsta,
1414 struct ieee80211_bss *bss) 1547 const u8 *bssid, const int beacon_int,
1548 const int freq,
1549 const size_t supp_rates_len,
1550 const u8 *supp_rates,
1551 const u16 capability)
1415{ 1552{
1416 struct ieee80211_local *local = sdata->local; 1553 struct ieee80211_local *local = sdata->local;
1417 int res, rates, i, j; 1554 int res = 0, rates, i, j;
1418 struct sk_buff *skb; 1555 struct sk_buff *skb;
1419 struct ieee80211_mgmt *mgmt; 1556 struct ieee80211_mgmt *mgmt;
1420 u8 *pos; 1557 u8 *pos;
1421 struct ieee80211_supported_band *sband; 1558 struct ieee80211_supported_band *sband;
1422 union iwreq_data wrqu; 1559 union iwreq_data wrqu;
1423 1560
1424 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); 1561 if (local->ops->reset_tsf) {
1562 /* Reset own TSF to allow time synchronization work. */
1563 local->ops->reset_tsf(local_to_hw(local));
1564 }
1565
1566 if ((ifsta->flags & IEEE80211_STA_PREV_BSSID_SET) &&
1567 memcmp(ifsta->bssid, bssid, ETH_ALEN) == 0)
1568 return res;
1569
1570 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400 +
1571 sdata->u.sta.ie_proberesp_len);
1425 if (!skb) { 1572 if (!skb) {
1426 printk(KERN_DEBUG "%s: failed to allocate buffer for probe " 1573 printk(KERN_DEBUG "%s: failed to allocate buffer for probe "
1427 "response\n", sdata->dev->name); 1574 "response\n", sdata->dev->name);
1428 return -ENOMEM; 1575 return -ENOMEM;
1429 } 1576 }
1430 1577
1431 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 1578 if (!(ifsta->flags & IEEE80211_STA_PREV_BSSID_SET)) {
1432 1579 /* Remove possible STA entries from other IBSS networks. */
1433 /* Remove possible STA entries from other IBSS networks. */ 1580 sta_info_flush_delayed(sdata);
1434 sta_info_flush_delayed(sdata);
1435
1436 if (local->ops->reset_tsf) {
1437 /* Reset own TSF to allow time synchronization work. */
1438 local->ops->reset_tsf(local_to_hw(local));
1439 } 1581 }
1440 memcpy(ifsta->bssid, bss->bssid, ETH_ALEN); 1582
1583 memcpy(ifsta->bssid, bssid, ETH_ALEN);
1441 res = ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID); 1584 res = ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID);
1442 if (res) 1585 if (res)
1443 return res; 1586 return res;
1444 1587
1445 local->hw.conf.beacon_int = bss->beacon_int >= 10 ? bss->beacon_int : 10; 1588 local->hw.conf.beacon_int = beacon_int >= 10 ? beacon_int : 10;
1446 1589
1447 sdata->drop_unencrypted = bss->capability & 1590 sdata->drop_unencrypted = capability &
1448 WLAN_CAPABILITY_PRIVACY ? 1 : 0; 1591 WLAN_CAPABILITY_PRIVACY ? 1 : 0;
1449 1592
1450 res = ieee80211_set_freq(sdata, bss->freq); 1593 res = ieee80211_set_freq(sdata, freq);
1451 1594
1452 if (res) 1595 if (res)
1453 return res; 1596 return res;
1454 1597
1598 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
1599
1455 /* Build IBSS probe response */ 1600 /* Build IBSS probe response */
1456 1601
1457 skb_reserve(skb, local->hw.extra_tx_headroom); 1602 skb_reserve(skb, local->hw.extra_tx_headroom);
@@ -1460,33 +1605,32 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
1460 skb_put(skb, 24 + sizeof(mgmt->u.beacon)); 1605 skb_put(skb, 24 + sizeof(mgmt->u.beacon));
1461 memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); 1606 memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
1462 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 1607 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1463 IEEE80211_STYPE_PROBE_RESP); 1608 IEEE80211_STYPE_PROBE_RESP);
1464 memset(mgmt->da, 0xff, ETH_ALEN); 1609 memset(mgmt->da, 0xff, ETH_ALEN);
1465 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); 1610 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
1466 memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); 1611 memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
1467 mgmt->u.beacon.beacon_int = 1612 mgmt->u.beacon.beacon_int =
1468 cpu_to_le16(local->hw.conf.beacon_int); 1613 cpu_to_le16(local->hw.conf.beacon_int);
1469 mgmt->u.beacon.timestamp = cpu_to_le64(bss->timestamp); 1614 mgmt->u.beacon.capab_info = cpu_to_le16(capability);
1470 mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability);
1471 1615
1472 pos = skb_put(skb, 2 + ifsta->ssid_len); 1616 pos = skb_put(skb, 2 + ifsta->ssid_len);
1473 *pos++ = WLAN_EID_SSID; 1617 *pos++ = WLAN_EID_SSID;
1474 *pos++ = ifsta->ssid_len; 1618 *pos++ = ifsta->ssid_len;
1475 memcpy(pos, ifsta->ssid, ifsta->ssid_len); 1619 memcpy(pos, ifsta->ssid, ifsta->ssid_len);
1476 1620
1477 rates = bss->supp_rates_len; 1621 rates = supp_rates_len;
1478 if (rates > 8) 1622 if (rates > 8)
1479 rates = 8; 1623 rates = 8;
1480 pos = skb_put(skb, 2 + rates); 1624 pos = skb_put(skb, 2 + rates);
1481 *pos++ = WLAN_EID_SUPP_RATES; 1625 *pos++ = WLAN_EID_SUPP_RATES;
1482 *pos++ = rates; 1626 *pos++ = rates;
1483 memcpy(pos, bss->supp_rates, rates); 1627 memcpy(pos, supp_rates, rates);
1484 1628
1485 if (bss->band == IEEE80211_BAND_2GHZ) { 1629 if (sband->band == IEEE80211_BAND_2GHZ) {
1486 pos = skb_put(skb, 2 + 1); 1630 pos = skb_put(skb, 2 + 1);
1487 *pos++ = WLAN_EID_DS_PARAMS; 1631 *pos++ = WLAN_EID_DS_PARAMS;
1488 *pos++ = 1; 1632 *pos++ = 1;
1489 *pos++ = ieee80211_frequency_to_channel(bss->freq); 1633 *pos++ = ieee80211_frequency_to_channel(freq);
1490 } 1634 }
1491 1635
1492 pos = skb_put(skb, 2 + 2); 1636 pos = skb_put(skb, 2 + 2);
@@ -1496,43 +1640,59 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
1496 *pos++ = 0; 1640 *pos++ = 0;
1497 *pos++ = 0; 1641 *pos++ = 0;
1498 1642
1499 if (bss->supp_rates_len > 8) { 1643 if (supp_rates_len > 8) {
1500 rates = bss->supp_rates_len - 8; 1644 rates = supp_rates_len - 8;
1501 pos = skb_put(skb, 2 + rates); 1645 pos = skb_put(skb, 2 + rates);
1502 *pos++ = WLAN_EID_EXT_SUPP_RATES; 1646 *pos++ = WLAN_EID_EXT_SUPP_RATES;
1503 *pos++ = rates; 1647 *pos++ = rates;
1504 memcpy(pos, &bss->supp_rates[8], rates); 1648 memcpy(pos, &supp_rates[8], rates);
1505 } 1649 }
1506 1650
1651 add_extra_ies(skb, sdata->u.sta.ie_proberesp,
1652 sdata->u.sta.ie_proberesp_len);
1653
1507 ifsta->probe_resp = skb; 1654 ifsta->probe_resp = skb;
1508 1655
1509 ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON); 1656 ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON |
1657 IEEE80211_IFCC_BEACON_ENABLED);
1510 1658
1511 1659
1512 rates = 0; 1660 rates = 0;
1513 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 1661 for (i = 0; i < supp_rates_len; i++) {
1514 for (i = 0; i < bss->supp_rates_len; i++) { 1662 int bitrate = (supp_rates[i] & 0x7f) * 5;
1515 int bitrate = (bss->supp_rates[i] & 0x7f) * 5;
1516 for (j = 0; j < sband->n_bitrates; j++) 1663 for (j = 0; j < sband->n_bitrates; j++)
1517 if (sband->bitrates[j].bitrate == bitrate) 1664 if (sband->bitrates[j].bitrate == bitrate)
1518 rates |= BIT(j); 1665 rates |= BIT(j);
1519 } 1666 }
1520 ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates; 1667 ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates;
1521 1668
1522 ieee80211_sta_def_wmm_params(sdata, bss); 1669 ieee80211_sta_def_wmm_params(sdata, supp_rates_len, supp_rates);
1523 1670
1671 ifsta->flags |= IEEE80211_STA_PREV_BSSID_SET;
1524 ifsta->state = IEEE80211_STA_MLME_IBSS_JOINED; 1672 ifsta->state = IEEE80211_STA_MLME_IBSS_JOINED;
1525 mod_timer(&ifsta->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL); 1673 mod_timer(&ifsta->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL);
1526 1674
1527 ieee80211_led_assoc(local, true); 1675 ieee80211_led_assoc(local, true);
1528 1676
1529 memset(&wrqu, 0, sizeof(wrqu)); 1677 memset(&wrqu, 0, sizeof(wrqu));
1530 memcpy(wrqu.ap_addr.sa_data, bss->bssid, ETH_ALEN); 1678 memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN);
1531 wireless_send_event(sdata->dev, SIOCGIWAP, &wrqu, NULL); 1679 wireless_send_event(sdata->dev, SIOCGIWAP, &wrqu, NULL);
1532 1680
1533 return res; 1681 return res;
1534} 1682}
1535 1683
1684static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
1685 struct ieee80211_if_sta *ifsta,
1686 struct ieee80211_bss *bss)
1687{
1688 return __ieee80211_sta_join_ibss(sdata, ifsta,
1689 bss->cbss.bssid,
1690 bss->cbss.beacon_interval,
1691 bss->cbss.channel->center_freq,
1692 bss->supp_rates_len, bss->supp_rates,
1693 bss->cbss.capability);
1694}
1695
1536static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, 1696static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
1537 struct ieee80211_mgmt *mgmt, 1697 struct ieee80211_mgmt *mgmt,
1538 size_t len, 1698 size_t len,
@@ -1546,7 +1706,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
1546 struct sta_info *sta; 1706 struct sta_info *sta;
1547 struct ieee80211_channel *channel; 1707 struct ieee80211_channel *channel;
1548 u64 beacon_timestamp, rx_timestamp; 1708 u64 beacon_timestamp, rx_timestamp;
1549 u64 supp_rates = 0; 1709 u32 supp_rates = 0;
1550 enum ieee80211_band band = rx_status->band; 1710 enum ieee80211_band band = rx_status->band;
1551 1711
1552 if (elems->ds_params && elems->ds_params_len == 1) 1712 if (elems->ds_params && elems->ds_params_len == 1)
@@ -1567,7 +1727,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
1567 1727
1568 sta = sta_info_get(local, mgmt->sa); 1728 sta = sta_info_get(local, mgmt->sa);
1569 if (sta) { 1729 if (sta) {
1570 u64 prev_rates; 1730 u32 prev_rates;
1571 1731
1572 prev_rates = sta->sta.supp_rates[band]; 1732 prev_rates = sta->sta.supp_rates[band];
1573 /* make sure mandatory rates are always added */ 1733 /* make sure mandatory rates are always added */
@@ -1593,80 +1753,99 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
1593 } 1753 }
1594 1754
1595 bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems, 1755 bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems,
1596 freq, beacon); 1756 channel, beacon);
1597 if (!bss) 1757 if (!bss)
1598 return; 1758 return;
1599 1759
1760 if (elems->ch_switch_elem && (elems->ch_switch_elem_len == 3) &&
1761 (memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0)) {
1762 struct ieee80211_channel_sw_ie *sw_elem =
1763 (struct ieee80211_channel_sw_ie *)elems->ch_switch_elem;
1764 ieee80211_process_chanswitch(sdata, sw_elem, bss);
1765 }
1766
1600 /* was just updated in ieee80211_bss_info_update */ 1767 /* was just updated in ieee80211_bss_info_update */
1601 beacon_timestamp = bss->timestamp; 1768 beacon_timestamp = bss->cbss.tsf;
1602 1769
1603 /* 1770 if (sdata->vif.type != NL80211_IFTYPE_ADHOC)
1604 * In STA mode, the remaining parameters should not be overridden 1771 goto put_bss;
1605 * by beacons because they're not necessarily accurate there.
1606 */
1607 if (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
1608 bss->last_probe_resp && beacon) {
1609 ieee80211_rx_bss_put(local, bss);
1610 return;
1611 }
1612 1772
1613 /* check if we need to merge IBSS */ 1773 /* check if we need to merge IBSS */
1614 if (sdata->vif.type == NL80211_IFTYPE_ADHOC && beacon && 1774
1615 bss->capability & WLAN_CAPABILITY_IBSS && 1775 /* merge only on beacons (???) */
1616 bss->freq == local->oper_channel->center_freq && 1776 if (!beacon)
1617 elems->ssid_len == sdata->u.sta.ssid_len && 1777 goto put_bss;
1778
1779 /* we use a fixed BSSID */
1780 if (sdata->u.sta.flags & IEEE80211_STA_BSSID_SET)
1781 goto put_bss;
1782
1783 /* not an IBSS */
1784 if (!(bss->cbss.capability & WLAN_CAPABILITY_IBSS))
1785 goto put_bss;
1786
1787 /* different channel */
1788 if (bss->cbss.channel != local->oper_channel)
1789 goto put_bss;
1790
1791 /* different SSID */
1792 if (elems->ssid_len != sdata->u.sta.ssid_len ||
1618 memcmp(elems->ssid, sdata->u.sta.ssid, 1793 memcmp(elems->ssid, sdata->u.sta.ssid,
1619 sdata->u.sta.ssid_len) == 0) { 1794 sdata->u.sta.ssid_len))
1620 if (rx_status->flag & RX_FLAG_TSFT) { 1795 goto put_bss;
1621 /* in order for correct IBSS merging we need mactime 1796
1622 * 1797 if (rx_status->flag & RX_FLAG_TSFT) {
1623 * since mactime is defined as the time the first data 1798 /*
1624 * symbol of the frame hits the PHY, and the timestamp 1799 * For correct IBSS merging we need mactime; since mactime is
1625 * of the beacon is defined as "the time that the data 1800 * defined as the time the first data symbol of the frame hits
1626 * symbol containing the first bit of the timestamp is 1801 * the PHY, and the timestamp of the beacon is defined as "the
1627 * transmitted to the PHY plus the transmitting STA’s 1802 * time that the data symbol containing the first bit of the
1628 * delays through its local PHY from the MAC-PHY 1803 * timestamp is transmitted to the PHY plus the transmitting
1629 * interface to its interface with the WM" 1804 * STA's delays through its local PHY from the MAC-PHY
1630 * (802.11 11.1.2) - equals the time this bit arrives at 1805 * interface to its interface with the WM" (802.11 11.1.2)
1631 * the receiver - we have to take into account the 1806 * - equals the time this bit arrives at the receiver - we have
1632 * offset between the two. 1807 * to take into account the offset between the two.
1633 * e.g: at 1 MBit that means mactime is 192 usec earlier 1808 *
1634 * (=24 bytes * 8 usecs/byte) than the beacon timestamp. 1809 * E.g. at 1 MBit that means mactime is 192 usec earlier
1635 */ 1810 * (=24 bytes * 8 usecs/byte) than the beacon timestamp.
1636 int rate; 1811 */
1637 if (rx_status->flag & RX_FLAG_HT) { 1812 int rate;
1638 rate = 65; /* TODO: HT rates */ 1813
1639 } else { 1814 if (rx_status->flag & RX_FLAG_HT)
1640 rate = local->hw.wiphy->bands[band]-> 1815 rate = 65; /* TODO: HT rates */
1641 bitrates[rx_status->rate_idx].bitrate;
1642 }
1643 rx_timestamp = rx_status->mactime + (24 * 8 * 10 / rate);
1644 } else if (local && local->ops && local->ops->get_tsf)
1645 /* second best option: get current TSF */
1646 rx_timestamp = local->ops->get_tsf(local_to_hw(local));
1647 else 1816 else
1648 /* can't merge without knowing the TSF */ 1817 rate = local->hw.wiphy->bands[band]->
1649 rx_timestamp = -1LLU; 1818 bitrates[rx_status->rate_idx].bitrate;
1819
1820 rx_timestamp = rx_status->mactime + (24 * 8 * 10 / rate);
1821 } else if (local && local->ops && local->ops->get_tsf)
1822 /* second best option: get current TSF */
1823 rx_timestamp = local->ops->get_tsf(local_to_hw(local));
1824 else
1825 /* can't merge without knowing the TSF */
1826 rx_timestamp = -1LLU;
1827
1650#ifdef CONFIG_MAC80211_IBSS_DEBUG 1828#ifdef CONFIG_MAC80211_IBSS_DEBUG
1651 printk(KERN_DEBUG "RX beacon SA=%pM BSSID=" 1829 printk(KERN_DEBUG "RX beacon SA=%pM BSSID="
1652 "%pM TSF=0x%llx BCN=0x%llx diff=%lld @%lu\n", 1830 "%pM TSF=0x%llx BCN=0x%llx diff=%lld @%lu\n",
1653 mgmt->sa, mgmt->bssid, 1831 mgmt->sa, mgmt->bssid,
1654 (unsigned long long)rx_timestamp, 1832 (unsigned long long)rx_timestamp,
1655 (unsigned long long)beacon_timestamp, 1833 (unsigned long long)beacon_timestamp,
1656 (unsigned long long)(rx_timestamp - beacon_timestamp), 1834 (unsigned long long)(rx_timestamp - beacon_timestamp),
1657 jiffies); 1835 jiffies);
1658#endif /* CONFIG_MAC80211_IBSS_DEBUG */ 1836#endif
1659 if (beacon_timestamp > rx_timestamp) { 1837
1838 if (beacon_timestamp > rx_timestamp) {
1660#ifdef CONFIG_MAC80211_IBSS_DEBUG 1839#ifdef CONFIG_MAC80211_IBSS_DEBUG
1661 printk(KERN_DEBUG "%s: beacon TSF higher than " 1840 printk(KERN_DEBUG "%s: beacon TSF higher than "
1662 "local TSF - IBSS merge with BSSID %pM\n", 1841 "local TSF - IBSS merge with BSSID %pM\n",
1663 sdata->dev->name, mgmt->bssid); 1842 sdata->dev->name, mgmt->bssid);
1664#endif 1843#endif
1665 ieee80211_sta_join_ibss(sdata, &sdata->u.sta, bss); 1844 ieee80211_sta_join_ibss(sdata, &sdata->u.sta, bss);
1666 ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates); 1845 ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates);
1667 }
1668 } 1846 }
1669 1847
1848 put_bss:
1670 ieee80211_rx_bss_put(local, bss); 1849 ieee80211_rx_bss_put(local, bss);
1671} 1850}
1672 1851
@@ -1712,7 +1891,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
1712 struct ieee802_11_elems elems; 1891 struct ieee802_11_elems elems;
1713 struct ieee80211_local *local = sdata->local; 1892 struct ieee80211_local *local = sdata->local;
1714 u32 changed = 0; 1893 u32 changed = 0;
1715 bool erp_valid; 1894 bool erp_valid, directed_tim;
1716 u8 erp_value = 0; 1895 u8 erp_value = 0;
1717 1896
1718 /* Process beacon from the current BSS */ 1897 /* Process beacon from the current BSS */
@@ -1732,9 +1911,37 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
1732 memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) 1911 memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0)
1733 return; 1912 return;
1734 1913
1914 if (rx_status->freq != local->hw.conf.channel->center_freq)
1915 return;
1916
1735 ieee80211_sta_wmm_params(local, ifsta, elems.wmm_param, 1917 ieee80211_sta_wmm_params(local, ifsta, elems.wmm_param,
1736 elems.wmm_param_len); 1918 elems.wmm_param_len);
1737 1919
1920 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK &&
1921 local->hw.conf.flags & IEEE80211_CONF_PS) {
1922 directed_tim = ieee80211_check_tim(&elems, ifsta->aid);
1923
1924 if (directed_tim) {
1925 if (local->hw.conf.dynamic_ps_timeout > 0) {
1926 local->hw.conf.flags &= ~IEEE80211_CONF_PS;
1927 ieee80211_hw_config(local,
1928 IEEE80211_CONF_CHANGE_PS);
1929 ieee80211_send_nullfunc(local, sdata, 0);
1930 } else {
1931 local->pspolling = true;
1932
1933 /*
1934 * Here is assumed that the driver will be
1935 * able to send ps-poll frame and receive a
1936 * response even though power save mode is
1937 * enabled, but some drivers might require
1938 * to disable power save here. This needs
1939 * to be investigated.
1940 */
1941 ieee80211_send_pspoll(local, sdata);
1942 }
1943 }
1944 }
1738 1945
1739 if (elems.erp_info && elems.erp_info_len >= 1) { 1946 if (elems.erp_info && elems.erp_info_len >= 1) {
1740 erp_valid = true; 1947 erp_valid = true;
@@ -1778,6 +1985,13 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
1778 * for the BSSID we are associated to */ 1985 * for the BSSID we are associated to */
1779 regulatory_hint_11d(local->hw.wiphy, 1986 regulatory_hint_11d(local->hw.wiphy,
1780 elems.country_elem, elems.country_elem_len); 1987 elems.country_elem, elems.country_elem_len);
1988
1989 /* TODO: IBSS also needs this */
1990 if (elems.pwr_constr_elem)
1991 ieee80211_handle_pwr_constr(sdata,
1992 le16_to_cpu(mgmt->u.probe_resp.capab_info),
1993 elems.pwr_constr_elem,
1994 elems.pwr_constr_elem_len);
1781 } 1995 }
1782 1996
1783 ieee80211_bss_info_change_notify(sdata, changed); 1997 ieee80211_bss_info_change_notify(sdata, changed);
@@ -1787,8 +2001,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
1787static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, 2001static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
1788 struct ieee80211_if_sta *ifsta, 2002 struct ieee80211_if_sta *ifsta,
1789 struct ieee80211_mgmt *mgmt, 2003 struct ieee80211_mgmt *mgmt,
1790 size_t len, 2004 size_t len)
1791 struct ieee80211_rx_status *rx_status)
1792{ 2005{
1793 struct ieee80211_local *local = sdata->local; 2006 struct ieee80211_local *local = sdata->local;
1794 int tx_last_beacon; 2007 int tx_last_beacon;
@@ -1796,8 +2009,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
1796 struct ieee80211_mgmt *resp; 2009 struct ieee80211_mgmt *resp;
1797 u8 *pos, *end; 2010 u8 *pos, *end;
1798 2011
1799 if (sdata->vif.type != NL80211_IFTYPE_ADHOC || 2012 if (ifsta->state != IEEE80211_STA_MLME_IBSS_JOINED ||
1800 ifsta->state != IEEE80211_STA_MLME_IBSS_JOINED ||
1801 len < 24 + 2 || !ifsta->probe_resp) 2013 len < 24 + 2 || !ifsta->probe_resp)
1802 return; 2014 return;
1803 2015
@@ -1901,32 +2113,54 @@ static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1901 mgmt = (struct ieee80211_mgmt *) skb->data; 2113 mgmt = (struct ieee80211_mgmt *) skb->data;
1902 fc = le16_to_cpu(mgmt->frame_control); 2114 fc = le16_to_cpu(mgmt->frame_control);
1903 2115
1904 switch (fc & IEEE80211_FCTL_STYPE) { 2116 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
1905 case IEEE80211_STYPE_PROBE_REQ: 2117 switch (fc & IEEE80211_FCTL_STYPE) {
1906 ieee80211_rx_mgmt_probe_req(sdata, ifsta, mgmt, skb->len, 2118 case IEEE80211_STYPE_PROBE_REQ:
1907 rx_status); 2119 ieee80211_rx_mgmt_probe_req(sdata, ifsta, mgmt,
1908 break; 2120 skb->len);
1909 case IEEE80211_STYPE_PROBE_RESP: 2121 break;
1910 ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len, rx_status); 2122 case IEEE80211_STYPE_PROBE_RESP:
1911 break; 2123 ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len,
1912 case IEEE80211_STYPE_BEACON: 2124 rx_status);
1913 ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, rx_status); 2125 break;
1914 break; 2126 case IEEE80211_STYPE_BEACON:
1915 case IEEE80211_STYPE_AUTH: 2127 ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len,
1916 ieee80211_rx_mgmt_auth(sdata, ifsta, mgmt, skb->len); 2128 rx_status);
1917 break; 2129 break;
1918 case IEEE80211_STYPE_ASSOC_RESP: 2130 case IEEE80211_STYPE_AUTH:
1919 ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt, skb->len, 0); 2131 ieee80211_rx_mgmt_auth_ibss(sdata, ifsta, mgmt,
1920 break; 2132 skb->len);
1921 case IEEE80211_STYPE_REASSOC_RESP: 2133 break;
1922 ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt, skb->len, 1); 2134 }
1923 break; 2135 } else { /* NL80211_IFTYPE_STATION */
1924 case IEEE80211_STYPE_DEAUTH: 2136 switch (fc & IEEE80211_FCTL_STYPE) {
1925 ieee80211_rx_mgmt_deauth(sdata, ifsta, mgmt, skb->len); 2137 case IEEE80211_STYPE_PROBE_RESP:
1926 break; 2138 ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len,
1927 case IEEE80211_STYPE_DISASSOC: 2139 rx_status);
1928 ieee80211_rx_mgmt_disassoc(sdata, ifsta, mgmt, skb->len); 2140 break;
1929 break; 2141 case IEEE80211_STYPE_BEACON:
2142 ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len,
2143 rx_status);
2144 break;
2145 case IEEE80211_STYPE_AUTH:
2146 ieee80211_rx_mgmt_auth(sdata, ifsta, mgmt, skb->len);
2147 break;
2148 case IEEE80211_STYPE_ASSOC_RESP:
2149 ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt,
2150 skb->len, 0);
2151 break;
2152 case IEEE80211_STYPE_REASSOC_RESP:
2153 ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt,
2154 skb->len, 1);
2155 break;
2156 case IEEE80211_STYPE_DEAUTH:
2157 ieee80211_rx_mgmt_deauth(sdata, ifsta, mgmt, skb->len);
2158 break;
2159 case IEEE80211_STYPE_DISASSOC:
2160 ieee80211_rx_mgmt_disassoc(sdata, ifsta, mgmt,
2161 skb->len);
2162 break;
2163 }
1930 } 2164 }
1931 2165
1932 kfree_skb(skb); 2166 kfree_skb(skb);
@@ -1965,9 +2199,21 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata,
1965 if (ieee80211_sta_active_ibss(sdata)) 2199 if (ieee80211_sta_active_ibss(sdata))
1966 return; 2200 return;
1967 2201
2202 if ((sdata->u.sta.flags & IEEE80211_STA_BSSID_SET) &&
2203 (!(sdata->u.sta.flags & IEEE80211_STA_AUTO_CHANNEL_SEL)))
2204 return;
2205
1968 printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " 2206 printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other "
1969 "IBSS networks with same SSID (merge)\n", sdata->dev->name); 2207 "IBSS networks with same SSID (merge)\n", sdata->dev->name);
1970 ieee80211_request_scan(sdata, ifsta->ssid, ifsta->ssid_len); 2208
2209 /* XXX maybe racy? */
2210 if (sdata->local->scan_req)
2211 return;
2212
2213 memcpy(sdata->local->int_scan_req.ssids[0].ssid,
2214 ifsta->ssid, IEEE80211_MAX_SSID_LEN);
2215 sdata->local->int_scan_req.ssids[0].ssid_len = ifsta->ssid_len;
2216 ieee80211_request_scan(sdata, &sdata->local->int_scan_req);
1971} 2217}
1972 2218
1973 2219
@@ -2013,94 +2259,56 @@ static void ieee80211_sta_reset_auth(struct ieee80211_sub_if_data *sdata,
2013 netif_carrier_off(sdata->dev); 2259 netif_carrier_off(sdata->dev);
2014} 2260}
2015 2261
2016
2017static int ieee80211_sta_match_ssid(struct ieee80211_if_sta *ifsta,
2018 const char *ssid, int ssid_len)
2019{
2020 int tmp, hidden_ssid;
2021
2022 if (ssid_len == ifsta->ssid_len &&
2023 !memcmp(ifsta->ssid, ssid, ssid_len))
2024 return 1;
2025
2026 if (ifsta->flags & IEEE80211_STA_AUTO_BSSID_SEL)
2027 return 0;
2028
2029 hidden_ssid = 1;
2030 tmp = ssid_len;
2031 while (tmp--) {
2032 if (ssid[tmp] != '\0') {
2033 hidden_ssid = 0;
2034 break;
2035 }
2036 }
2037
2038 if (hidden_ssid && (ifsta->ssid_len == ssid_len || ssid_len == 0))
2039 return 1;
2040
2041 if (ssid_len == 1 && ssid[0] == ' ')
2042 return 1;
2043
2044 return 0;
2045}
2046
2047static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata, 2262static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata,
2048 struct ieee80211_if_sta *ifsta) 2263 struct ieee80211_if_sta *ifsta)
2049{ 2264{
2050 struct ieee80211_local *local = sdata->local; 2265 struct ieee80211_local *local = sdata->local;
2051 struct ieee80211_bss *bss;
2052 struct ieee80211_supported_band *sband; 2266 struct ieee80211_supported_band *sband;
2053 u8 bssid[ETH_ALEN], *pos; 2267 u8 *pos;
2268 u8 bssid[ETH_ALEN];
2269 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
2270 u16 capability;
2054 int i; 2271 int i;
2055 int ret; 2272
2056 2273 if (sdata->u.sta.flags & IEEE80211_STA_BSSID_SET) {
2057#if 0 2274 memcpy(bssid, ifsta->bssid, ETH_ALEN);
2058 /* Easier testing, use fixed BSSID. */ 2275 } else {
2059 memset(bssid, 0xfe, ETH_ALEN); 2276 /* Generate random, not broadcast, locally administered BSSID. Mix in
2060#else 2277 * own MAC address to make sure that devices that do not have proper
2061 /* Generate random, not broadcast, locally administered BSSID. Mix in 2278 * random number generator get different BSSID. */
2062 * own MAC address to make sure that devices that do not have proper 2279 get_random_bytes(bssid, ETH_ALEN);
2063 * random number generator get different BSSID. */ 2280 for (i = 0; i < ETH_ALEN; i++)
2064 get_random_bytes(bssid, ETH_ALEN); 2281 bssid[i] ^= sdata->dev->dev_addr[i];
2065 for (i = 0; i < ETH_ALEN; i++) 2282 bssid[0] &= ~0x01;
2066 bssid[i] ^= sdata->dev->dev_addr[i]; 2283 bssid[0] |= 0x02;
2067 bssid[0] &= ~0x01; 2284 }
2068 bssid[0] |= 0x02;
2069#endif
2070 2285
2071 printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %pM\n", 2286 printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %pM\n",
2072 sdata->dev->name, bssid); 2287 sdata->dev->name, bssid);
2073 2288
2074 bss = ieee80211_rx_bss_add(local, bssid, 2289 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
2075 local->hw.conf.channel->center_freq,
2076 sdata->u.sta.ssid, sdata->u.sta.ssid_len);
2077 if (!bss)
2078 return -ENOMEM;
2079
2080 bss->band = local->hw.conf.channel->band;
2081 sband = local->hw.wiphy->bands[bss->band];
2082 2290
2083 if (local->hw.conf.beacon_int == 0) 2291 if (local->hw.conf.beacon_int == 0)
2084 local->hw.conf.beacon_int = 100; 2292 local->hw.conf.beacon_int = 100;
2085 bss->beacon_int = local->hw.conf.beacon_int; 2293
2086 bss->last_update = jiffies; 2294 capability = WLAN_CAPABILITY_IBSS;
2087 bss->capability = WLAN_CAPABILITY_IBSS;
2088 2295
2089 if (sdata->default_key) 2296 if (sdata->default_key)
2090 bss->capability |= WLAN_CAPABILITY_PRIVACY; 2297 capability |= WLAN_CAPABILITY_PRIVACY;
2091 else 2298 else
2092 sdata->drop_unencrypted = 0; 2299 sdata->drop_unencrypted = 0;
2093 2300
2094 bss->supp_rates_len = sband->n_bitrates; 2301 pos = supp_rates;
2095 pos = bss->supp_rates;
2096 for (i = 0; i < sband->n_bitrates; i++) { 2302 for (i = 0; i < sband->n_bitrates; i++) {
2097 int rate = sband->bitrates[i].bitrate; 2303 int rate = sband->bitrates[i].bitrate;
2098 *pos++ = (u8) (rate / 5); 2304 *pos++ = (u8) (rate / 5);
2099 } 2305 }
2100 2306
2101 ret = ieee80211_sta_join_ibss(sdata, ifsta, bss); 2307 return __ieee80211_sta_join_ibss(sdata, ifsta,
2102 ieee80211_rx_bss_put(local, bss); 2308 bssid, local->hw.conf.beacon_int,
2103 return ret; 2309 local->hw.conf.channel->center_freq,
2310 sband->n_bitrates, supp_rates,
2311 capability);
2104} 2312}
2105 2313
2106 2314
@@ -2109,8 +2317,6 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata,
2109{ 2317{
2110 struct ieee80211_local *local = sdata->local; 2318 struct ieee80211_local *local = sdata->local;
2111 struct ieee80211_bss *bss; 2319 struct ieee80211_bss *bss;
2112 int found = 0;
2113 u8 bssid[ETH_ALEN];
2114 int active_ibss; 2320 int active_ibss;
2115 2321
2116 if (ifsta->ssid_len == 0) 2322 if (ifsta->ssid_len == 0)
@@ -2121,51 +2327,39 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata,
2121 printk(KERN_DEBUG "%s: sta_find_ibss (active_ibss=%d)\n", 2327 printk(KERN_DEBUG "%s: sta_find_ibss (active_ibss=%d)\n",
2122 sdata->dev->name, active_ibss); 2328 sdata->dev->name, active_ibss);
2123#endif /* CONFIG_MAC80211_IBSS_DEBUG */ 2329#endif /* CONFIG_MAC80211_IBSS_DEBUG */
2124 spin_lock_bh(&local->bss_lock); 2330
2125 list_for_each_entry(bss, &local->bss_list, list) { 2331 if (active_ibss)
2126 if (ifsta->ssid_len != bss->ssid_len || 2332 return 0;
2127 memcmp(ifsta->ssid, bss->ssid, bss->ssid_len) != 0 2333
2128 || !(bss->capability & WLAN_CAPABILITY_IBSS)) 2334 if (ifsta->flags & IEEE80211_STA_BSSID_SET)
2129 continue; 2335 bss = ieee80211_rx_bss_get(local, ifsta->bssid, 0,
2130#ifdef CONFIG_MAC80211_IBSS_DEBUG 2336 ifsta->ssid, ifsta->ssid_len);
2131 printk(KERN_DEBUG " bssid=%pM found\n", bss->bssid); 2337 else
2132#endif /* CONFIG_MAC80211_IBSS_DEBUG */ 2338 bss = (void *)cfg80211_get_ibss(local->hw.wiphy,
2133 memcpy(bssid, bss->bssid, ETH_ALEN); 2339 NULL,
2134 found = 1; 2340 ifsta->ssid, ifsta->ssid_len);
2135 if (active_ibss || memcmp(bssid, ifsta->bssid, ETH_ALEN) != 0)
2136 break;
2137 }
2138 spin_unlock_bh(&local->bss_lock);
2139 2341
2140#ifdef CONFIG_MAC80211_IBSS_DEBUG 2342#ifdef CONFIG_MAC80211_IBSS_DEBUG
2141 if (found) 2343 if (bss)
2142 printk(KERN_DEBUG " sta_find_ibss: selected %pM current " 2344 printk(KERN_DEBUG " sta_find_ibss: selected %pM current "
2143 "%pM\n", bssid, ifsta->bssid); 2345 "%pM\n", bss->cbss.bssid, ifsta->bssid);
2144#endif /* CONFIG_MAC80211_IBSS_DEBUG */ 2346#endif /* CONFIG_MAC80211_IBSS_DEBUG */
2145 2347
2146 if (found && memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0) { 2348 if (bss &&
2349 (!(ifsta->flags & IEEE80211_STA_PREV_BSSID_SET) ||
2350 memcmp(ifsta->bssid, bss->cbss.bssid, ETH_ALEN))) {
2147 int ret; 2351 int ret;
2148 int search_freq;
2149
2150 if (ifsta->flags & IEEE80211_STA_AUTO_CHANNEL_SEL)
2151 search_freq = bss->freq;
2152 else
2153 search_freq = local->hw.conf.channel->center_freq;
2154
2155 bss = ieee80211_rx_bss_get(local, bssid, search_freq,
2156 ifsta->ssid, ifsta->ssid_len);
2157 if (!bss)
2158 goto dont_join;
2159 2352
2160 printk(KERN_DEBUG "%s: Selected IBSS BSSID %pM" 2353 printk(KERN_DEBUG "%s: Selected IBSS BSSID %pM"
2161 " based on configured SSID\n", 2354 " based on configured SSID\n",
2162 sdata->dev->name, bssid); 2355 sdata->dev->name, bss->cbss.bssid);
2356
2163 ret = ieee80211_sta_join_ibss(sdata, ifsta, bss); 2357 ret = ieee80211_sta_join_ibss(sdata, ifsta, bss);
2164 ieee80211_rx_bss_put(local, bss); 2358 ieee80211_rx_bss_put(local, bss);
2165 return ret; 2359 return ret;
2166 } 2360 } else if (bss)
2361 ieee80211_rx_bss_put(local, bss);
2167 2362
2168dont_join:
2169#ifdef CONFIG_MAC80211_IBSS_DEBUG 2363#ifdef CONFIG_MAC80211_IBSS_DEBUG
2170 printk(KERN_DEBUG " did not try to join ibss\n"); 2364 printk(KERN_DEBUG " did not try to join ibss\n");
2171#endif /* CONFIG_MAC80211_IBSS_DEBUG */ 2365#endif /* CONFIG_MAC80211_IBSS_DEBUG */
@@ -2179,8 +2373,15 @@ dont_join:
2179 IEEE80211_SCAN_INTERVAL)) { 2373 IEEE80211_SCAN_INTERVAL)) {
2180 printk(KERN_DEBUG "%s: Trigger new scan to find an IBSS to " 2374 printk(KERN_DEBUG "%s: Trigger new scan to find an IBSS to "
2181 "join\n", sdata->dev->name); 2375 "join\n", sdata->dev->name);
2182 return ieee80211_request_scan(sdata, ifsta->ssid, 2376
2183 ifsta->ssid_len); 2377 /* XXX maybe racy? */
2378 if (local->scan_req)
2379 return -EBUSY;
2380
2381 memcpy(local->int_scan_req.ssids[0].ssid,
2382 ifsta->ssid, IEEE80211_MAX_SSID_LEN);
2383 local->int_scan_req.ssids[0].ssid_len = ifsta->ssid_len;
2384 return ieee80211_request_scan(sdata, &local->int_scan_req);
2184 } else if (ifsta->state != IEEE80211_STA_MLME_IBSS_JOINED) { 2385 } else if (ifsta->state != IEEE80211_STA_MLME_IBSS_JOINED) {
2185 int interval = IEEE80211_SCAN_INTERVAL; 2386 int interval = IEEE80211_SCAN_INTERVAL;
2186 2387
@@ -2214,76 +2415,81 @@ static int ieee80211_sta_config_auth(struct ieee80211_sub_if_data *sdata,
2214 struct ieee80211_if_sta *ifsta) 2415 struct ieee80211_if_sta *ifsta)
2215{ 2416{
2216 struct ieee80211_local *local = sdata->local; 2417 struct ieee80211_local *local = sdata->local;
2217 struct ieee80211_bss *bss, *selected = NULL; 2418 struct ieee80211_bss *bss;
2218 int top_rssi = 0, freq; 2419 u8 *bssid = ifsta->bssid, *ssid = ifsta->ssid;
2219 2420 u8 ssid_len = ifsta->ssid_len;
2220 spin_lock_bh(&local->bss_lock); 2421 u16 capa_mask = WLAN_CAPABILITY_ESS;
2221 freq = local->oper_channel->center_freq; 2422 u16 capa_val = WLAN_CAPABILITY_ESS;
2222 list_for_each_entry(bss, &local->bss_list, list) { 2423 struct ieee80211_channel *chan = local->oper_channel;
2223 if (!(bss->capability & WLAN_CAPABILITY_ESS)) 2424
2224 continue; 2425 if (ifsta->flags & (IEEE80211_STA_AUTO_SSID_SEL |
2225 2426 IEEE80211_STA_AUTO_BSSID_SEL |
2226 if ((ifsta->flags & (IEEE80211_STA_AUTO_SSID_SEL | 2427 IEEE80211_STA_AUTO_CHANNEL_SEL)) {
2227 IEEE80211_STA_AUTO_BSSID_SEL | 2428 capa_mask |= WLAN_CAPABILITY_PRIVACY;
2228 IEEE80211_STA_AUTO_CHANNEL_SEL)) && 2429 if (sdata->default_key)
2229 (!!(bss->capability & WLAN_CAPABILITY_PRIVACY) ^ 2430 capa_val |= WLAN_CAPABILITY_PRIVACY;
2230 !!sdata->default_key))
2231 continue;
2232
2233 if (!(ifsta->flags & IEEE80211_STA_AUTO_CHANNEL_SEL) &&
2234 bss->freq != freq)
2235 continue;
2236
2237 if (!(ifsta->flags & IEEE80211_STA_AUTO_BSSID_SEL) &&
2238 memcmp(bss->bssid, ifsta->bssid, ETH_ALEN))
2239 continue;
2240
2241 if (!(ifsta->flags & IEEE80211_STA_AUTO_SSID_SEL) &&
2242 !ieee80211_sta_match_ssid(ifsta, bss->ssid, bss->ssid_len))
2243 continue;
2244
2245 if (!selected || top_rssi < bss->signal) {
2246 selected = bss;
2247 top_rssi = bss->signal;
2248 }
2249 } 2431 }
2250 if (selected)
2251 atomic_inc(&selected->users);
2252 spin_unlock_bh(&local->bss_lock);
2253 2432
2254 if (selected) { 2433 if (ifsta->flags & IEEE80211_STA_AUTO_CHANNEL_SEL)
2255 ieee80211_set_freq(sdata, selected->freq); 2434 chan = NULL;
2435
2436 if (ifsta->flags & IEEE80211_STA_AUTO_BSSID_SEL)
2437 bssid = NULL;
2438
2439 if (ifsta->flags & IEEE80211_STA_AUTO_SSID_SEL) {
2440 ssid = NULL;
2441 ssid_len = 0;
2442 }
2443
2444 bss = (void *)cfg80211_get_bss(local->hw.wiphy, chan,
2445 bssid, ssid, ssid_len,
2446 capa_mask, capa_val);
2447
2448 if (bss) {
2449 ieee80211_set_freq(sdata, bss->cbss.channel->center_freq);
2256 if (!(ifsta->flags & IEEE80211_STA_SSID_SET)) 2450 if (!(ifsta->flags & IEEE80211_STA_SSID_SET))
2257 ieee80211_sta_set_ssid(sdata, selected->ssid, 2451 ieee80211_sta_set_ssid(sdata, bss->ssid,
2258 selected->ssid_len); 2452 bss->ssid_len);
2259 ieee80211_sta_set_bssid(sdata, selected->bssid); 2453 ieee80211_sta_set_bssid(sdata, bss->cbss.bssid);
2260 ieee80211_sta_def_wmm_params(sdata, selected); 2454 ieee80211_sta_def_wmm_params(sdata, bss->supp_rates_len,
2455 bss->supp_rates);
2456 if (sdata->u.sta.mfp == IEEE80211_MFP_REQUIRED)
2457 sdata->u.sta.flags |= IEEE80211_STA_MFP_ENABLED;
2458 else
2459 sdata->u.sta.flags &= ~IEEE80211_STA_MFP_ENABLED;
2261 2460
2262 /* Send out direct probe if no probe resp was received or 2461 /* Send out direct probe if no probe resp was received or
2263 * the one we have is outdated 2462 * the one we have is outdated
2264 */ 2463 */
2265 if (!selected->last_probe_resp || 2464 if (!bss->last_probe_resp ||
2266 time_after(jiffies, selected->last_probe_resp 2465 time_after(jiffies, bss->last_probe_resp
2267 + IEEE80211_SCAN_RESULT_EXPIRE)) 2466 + IEEE80211_SCAN_RESULT_EXPIRE))
2268 ifsta->state = IEEE80211_STA_MLME_DIRECT_PROBE; 2467 ifsta->state = IEEE80211_STA_MLME_DIRECT_PROBE;
2269 else 2468 else
2270 ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE; 2469 ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE;
2271 2470
2272 ieee80211_rx_bss_put(local, selected); 2471 ieee80211_rx_bss_put(local, bss);
2273 ieee80211_sta_reset_auth(sdata, ifsta); 2472 ieee80211_sta_reset_auth(sdata, ifsta);
2274 return 0; 2473 return 0;
2275 } else { 2474 } else {
2276 if (ifsta->assoc_scan_tries < IEEE80211_ASSOC_SCANS_MAX_TRIES) { 2475 if (ifsta->assoc_scan_tries < IEEE80211_ASSOC_SCANS_MAX_TRIES) {
2277 ifsta->assoc_scan_tries++; 2476 ifsta->assoc_scan_tries++;
2477 /* XXX maybe racy? */
2478 if (local->scan_req)
2479 return -1;
2480 memcpy(local->int_scan_req.ssids[0].ssid,
2481 ifsta->ssid, IEEE80211_MAX_SSID_LEN);
2278 if (ifsta->flags & IEEE80211_STA_AUTO_SSID_SEL) 2482 if (ifsta->flags & IEEE80211_STA_AUTO_SSID_SEL)
2279 ieee80211_start_scan(sdata, NULL, 0); 2483 local->int_scan_req.ssids[0].ssid_len = 0;
2280 else 2484 else
2281 ieee80211_start_scan(sdata, ifsta->ssid, 2485 local->int_scan_req.ssids[0].ssid_len = ifsta->ssid_len;
2282 ifsta->ssid_len); 2486 ieee80211_start_scan(sdata, &local->int_scan_req);
2283 ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE; 2487 ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE;
2284 set_bit(IEEE80211_STA_REQ_AUTH, &ifsta->request); 2488 set_bit(IEEE80211_STA_REQ_AUTH, &ifsta->request);
2285 } else 2489 } else {
2490 ifsta->assoc_scan_tries = 0;
2286 ifsta->state = IEEE80211_STA_MLME_DISABLED; 2491 ifsta->state = IEEE80211_STA_MLME_DISABLED;
2492 }
2287 } 2493 }
2288 return -1; 2494 return -1;
2289} 2495}
@@ -2315,8 +2521,7 @@ static void ieee80211_sta_work(struct work_struct *work)
2315 ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE && 2521 ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE &&
2316 ifsta->state != IEEE80211_STA_MLME_ASSOCIATE && 2522 ifsta->state != IEEE80211_STA_MLME_ASSOCIATE &&
2317 test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request)) { 2523 test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request)) {
2318 ieee80211_start_scan(sdata, ifsta->scan_ssid, 2524 ieee80211_start_scan(sdata, local->scan_req);
2319 ifsta->scan_ssid_len);
2320 return; 2525 return;
2321 } 2526 }
2322 2527
@@ -2376,8 +2581,11 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata)
2376 2581
2377 ifsta = &sdata->u.sta; 2582 ifsta = &sdata->u.sta;
2378 INIT_WORK(&ifsta->work, ieee80211_sta_work); 2583 INIT_WORK(&ifsta->work, ieee80211_sta_work);
2584 INIT_WORK(&ifsta->chswitch_work, ieee80211_chswitch_work);
2379 setup_timer(&ifsta->timer, ieee80211_sta_timer, 2585 setup_timer(&ifsta->timer, ieee80211_sta_timer,
2380 (unsigned long) sdata); 2586 (unsigned long) sdata);
2587 setup_timer(&ifsta->chswitch_timer, ieee80211_chswitch_timer,
2588 (unsigned long) sdata);
2381 skb_queue_head_init(&ifsta->skb_queue); 2589 skb_queue_head_init(&ifsta->skb_queue);
2382 2590
2383 ifsta->capab = WLAN_CAPABILITY_ESS; 2591 ifsta->capab = WLAN_CAPABILITY_ESS;
@@ -2396,7 +2604,7 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata)
2396 * must be callable in atomic context. 2604 * must be callable in atomic context.
2397 */ 2605 */
2398struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, 2606struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
2399 u8 *bssid,u8 *addr, u64 supp_rates) 2607 u8 *bssid,u8 *addr, u32 supp_rates)
2400{ 2608{
2401 struct ieee80211_local *local = sdata->local; 2609 struct ieee80211_local *local = sdata->local;
2402 struct sta_info *sta; 2610 struct sta_info *sta;
@@ -2474,16 +2682,16 @@ int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size
2474 memset(ifsta->ssid, 0, sizeof(ifsta->ssid)); 2682 memset(ifsta->ssid, 0, sizeof(ifsta->ssid));
2475 memcpy(ifsta->ssid, ssid, len); 2683 memcpy(ifsta->ssid, ssid, len);
2476 ifsta->ssid_len = len; 2684 ifsta->ssid_len = len;
2477 ifsta->flags &= ~IEEE80211_STA_PREV_BSSID_SET;
2478 } 2685 }
2479 2686
2687 ifsta->flags &= ~IEEE80211_STA_PREV_BSSID_SET;
2688
2480 if (len) 2689 if (len)
2481 ifsta->flags |= IEEE80211_STA_SSID_SET; 2690 ifsta->flags |= IEEE80211_STA_SSID_SET;
2482 else 2691 else
2483 ifsta->flags &= ~IEEE80211_STA_SSID_SET; 2692 ifsta->flags &= ~IEEE80211_STA_SSID_SET;
2484 2693
2485 if (sdata->vif.type == NL80211_IFTYPE_ADHOC && 2694 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
2486 !(ifsta->flags & IEEE80211_STA_BSSID_SET)) {
2487 ifsta->ibss_join_req = jiffies; 2695 ifsta->ibss_join_req = jiffies;
2488 ifsta->state = IEEE80211_STA_MLME_IBSS_SEARCH; 2696 ifsta->state = IEEE80211_STA_MLME_IBSS_SEARCH;
2489 return ieee80211_sta_find_ibss(sdata, ifsta); 2697 return ieee80211_sta_find_ibss(sdata, ifsta);
@@ -2503,31 +2711,25 @@ int ieee80211_sta_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size
2503int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid) 2711int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid)
2504{ 2712{
2505 struct ieee80211_if_sta *ifsta; 2713 struct ieee80211_if_sta *ifsta;
2506 int res;
2507 2714
2508 ifsta = &sdata->u.sta; 2715 ifsta = &sdata->u.sta;
2509 2716
2510 if (memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0) { 2717 if (is_valid_ether_addr(bssid)) {
2511 memcpy(ifsta->bssid, bssid, ETH_ALEN); 2718 memcpy(ifsta->bssid, bssid, ETH_ALEN);
2512 res = 0; 2719 ifsta->flags |= IEEE80211_STA_BSSID_SET;
2513 /* 2720 } else {
2514 * Hack! See also ieee80211_sta_set_ssid. 2721 memset(ifsta->bssid, 0, ETH_ALEN);
2515 */ 2722 ifsta->flags &= ~IEEE80211_STA_BSSID_SET;
2516 if (netif_running(sdata->dev)) 2723 }
2517 res = ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID); 2724
2518 if (res) { 2725 if (netif_running(sdata->dev)) {
2726 if (ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID)) {
2519 printk(KERN_DEBUG "%s: Failed to config new BSSID to " 2727 printk(KERN_DEBUG "%s: Failed to config new BSSID to "
2520 "the low-level driver\n", sdata->dev->name); 2728 "the low-level driver\n", sdata->dev->name);
2521 return res;
2522 } 2729 }
2523 } 2730 }
2524 2731
2525 if (is_valid_ether_addr(bssid)) 2732 return ieee80211_sta_set_ssid(sdata, ifsta->ssid, ifsta->ssid_len);
2526 ifsta->flags |= IEEE80211_STA_BSSID_SET;
2527 else
2528 ifsta->flags &= ~IEEE80211_STA_BSSID_SET;
2529
2530 return 0;
2531} 2733}
2532 2734
2533int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata, char *ie, size_t len) 2735int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata, char *ie, size_t len)
@@ -2590,9 +2792,8 @@ void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local)
2590 2792
2591 if (sdata && sdata->vif.type == NL80211_IFTYPE_ADHOC) { 2793 if (sdata && sdata->vif.type == NL80211_IFTYPE_ADHOC) {
2592 ifsta = &sdata->u.sta; 2794 ifsta = &sdata->u.sta;
2593 if (!(ifsta->flags & IEEE80211_STA_BSSID_SET) || 2795 if ((!(ifsta->flags & IEEE80211_STA_PREV_BSSID_SET)) ||
2594 (!(ifsta->state == IEEE80211_STA_MLME_IBSS_JOINED) && 2796 !ieee80211_sta_active_ibss(sdata))
2595 !ieee80211_sta_active_ibss(sdata)))
2596 ieee80211_sta_find_ibss(sdata, ifsta); 2797 ieee80211_sta_find_ibss(sdata, ifsta);
2597 } 2798 }
2598 2799
@@ -2623,12 +2824,15 @@ void ieee80211_dynamic_ps_enable_work(struct work_struct *work)
2623 struct ieee80211_local *local = 2824 struct ieee80211_local *local =
2624 container_of(work, struct ieee80211_local, 2825 container_of(work, struct ieee80211_local,
2625 dynamic_ps_enable_work); 2826 dynamic_ps_enable_work);
2827 struct ieee80211_sub_if_data *sdata = local->scan_sdata;
2626 2828
2627 if (local->hw.conf.flags & IEEE80211_CONF_PS) 2829 if (local->hw.conf.flags & IEEE80211_CONF_PS)
2628 return; 2830 return;
2629 2831
2630 local->hw.conf.flags |= IEEE80211_CONF_PS; 2832 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)
2833 ieee80211_send_nullfunc(local, sdata, 1);
2631 2834
2835 local->hw.conf.flags |= IEEE80211_CONF_PS;
2632 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); 2836 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
2633} 2837}
2634 2838