/kernel/2.6.32_froyo_photon_nightly/net/mac80211/mlme.c

http://photon-android.googlecode.com/ · C · 2581 lines · 1843 code · 454 blank · 284 comment · 320 complexity · 43a55046b6c3894fa42b534362c6c148 MD5 · raw file

Large files are truncated click here to view the full file

  1. /*
  2. * BSS client mode implementation
  3. * Copyright 2003-2008, Jouni Malinen <j@w1.fi>
  4. * Copyright 2004, Instant802 Networks, Inc.
  5. * Copyright 2005, Devicescape Software, Inc.
  6. * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
  7. * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/delay.h>
  14. #include <linux/if_ether.h>
  15. #include <linux/skbuff.h>
  16. #include <linux/if_arp.h>
  17. #include <linux/etherdevice.h>
  18. #include <linux/rtnetlink.h>
  19. #include <linux/pm_qos_params.h>
  20. #include <linux/crc32.h>
  21. #include <net/mac80211.h>
  22. #include <asm/unaligned.h>
  23. #include "ieee80211_i.h"
  24. #include "driver-ops.h"
  25. #include "rate.h"
  26. #include "led.h"
  27. #define IEEE80211_AUTH_TIMEOUT (HZ / 5)
  28. #define IEEE80211_AUTH_MAX_TRIES 3
  29. #define IEEE80211_ASSOC_TIMEOUT (HZ / 5)
  30. #define IEEE80211_ASSOC_MAX_TRIES 3
  31. #define IEEE80211_MAX_PROBE_TRIES 5
  32. /*
  33. * beacon loss detection timeout
  34. * XXX: should depend on beacon interval
  35. */
  36. #define IEEE80211_BEACON_LOSS_TIME (2 * HZ)
  37. /*
  38. * Time the connection can be idle before we probe
  39. * it to see if we can still talk to the AP.
  40. */
  41. #define IEEE80211_CONNECTION_IDLE_TIME (30 * HZ)
  42. /*
  43. * Time we wait for a probe response after sending
  44. * a probe request because of beacon loss or for
  45. * checking the connection still works.
  46. */
  47. #define IEEE80211_PROBE_WAIT (HZ / 2)
  48. #define TMR_RUNNING_TIMER 0
  49. #define TMR_RUNNING_CHANSW 1
  50. /*
  51. * All cfg80211 functions have to be called outside a locked
  52. * section so that they can acquire a lock themselves... This
  53. * is much simpler than queuing up things in cfg80211, but we
  54. * do need some indirection for that here.
  55. */
  56. enum rx_mgmt_action {
  57. /* no action required */
  58. RX_MGMT_NONE,
  59. /* caller must call cfg80211_send_rx_auth() */
  60. RX_MGMT_CFG80211_AUTH,
  61. /* caller must call cfg80211_send_rx_assoc() */
  62. RX_MGMT_CFG80211_ASSOC,
  63. /* caller must call cfg80211_send_deauth() */
  64. RX_MGMT_CFG80211_DEAUTH,
  65. /* caller must call cfg80211_send_disassoc() */
  66. RX_MGMT_CFG80211_DISASSOC,
  67. /* caller must call cfg80211_auth_timeout() & free work */
  68. RX_MGMT_CFG80211_AUTH_TO,
  69. /* caller must call cfg80211_assoc_timeout() & free work */
  70. RX_MGMT_CFG80211_ASSOC_TO,
  71. };
  72. /* utils */
  73. static inline void ASSERT_MGD_MTX(struct ieee80211_if_managed *ifmgd)
  74. {
  75. WARN_ON(!mutex_is_locked(&ifmgd->mtx));
  76. }
  77. /*
  78. * We can have multiple work items (and connection probing)
  79. * scheduling this timer, but we need to take care to only
  80. * reschedule it when it should fire _earlier_ than it was
  81. * asked for before, or if it's not pending right now. This
  82. * function ensures that. Note that it then is required to
  83. * run this function for all timeouts after the first one
  84. * has happened -- the work that runs from this timer will
  85. * do that.
  86. */
  87. static void run_again(struct ieee80211_if_managed *ifmgd,
  88. unsigned long timeout)
  89. {
  90. ASSERT_MGD_MTX(ifmgd);
  91. if (!timer_pending(&ifmgd->timer) ||
  92. time_before(timeout, ifmgd->timer.expires))
  93. mod_timer(&ifmgd->timer, timeout);
  94. }
  95. static void mod_beacon_timer(struct ieee80211_sub_if_data *sdata)
  96. {
  97. if (sdata->local->hw.flags & IEEE80211_HW_BEACON_FILTER)
  98. return;
  99. mod_timer(&sdata->u.mgd.bcn_mon_timer,
  100. round_jiffies_up(jiffies + IEEE80211_BEACON_LOSS_TIME));
  101. }
  102. static int ecw2cw(int ecw)
  103. {
  104. return (1 << ecw) - 1;
  105. }
  106. static int ieee80211_compatible_rates(struct ieee80211_bss *bss,
  107. struct ieee80211_supported_band *sband,
  108. u32 *rates)
  109. {
  110. int i, j, count;
  111. *rates = 0;
  112. count = 0;
  113. for (i = 0; i < bss->supp_rates_len; i++) {
  114. int rate = (bss->supp_rates[i] & 0x7F) * 5;
  115. for (j = 0; j < sband->n_bitrates; j++)
  116. if (sband->bitrates[j].bitrate == rate) {
  117. *rates |= BIT(j);
  118. count++;
  119. break;
  120. }
  121. }
  122. return count;
  123. }
  124. /*
  125. * ieee80211_enable_ht should be called only after the operating band
  126. * has been determined as ht configuration depends on the hw's
  127. * HT abilities for a specific band.
  128. */
  129. static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
  130. struct ieee80211_ht_info *hti,
  131. const u8 *bssid, u16 ap_ht_cap_flags)
  132. {
  133. struct ieee80211_local *local = sdata->local;
  134. struct ieee80211_supported_band *sband;
  135. struct sta_info *sta;
  136. u32 changed = 0;
  137. u16 ht_opmode;
  138. bool enable_ht = true, ht_changed;
  139. enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
  140. sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
  141. /* HT is not supported */
  142. if (!sband->ht_cap.ht_supported)
  143. enable_ht = false;
  144. /* check that channel matches the right operating channel */
  145. if (local->hw.conf.channel->center_freq !=
  146. ieee80211_channel_to_frequency(hti->control_chan))
  147. enable_ht = false;
  148. if (enable_ht) {
  149. channel_type = NL80211_CHAN_HT20;
  150. if (!(ap_ht_cap_flags & IEEE80211_HT_CAP_40MHZ_INTOLERANT) &&
  151. (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) &&
  152. (hti->ht_param & IEEE80211_HT_PARAM_CHAN_WIDTH_ANY)) {
  153. switch(hti->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
  154. case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
  155. if (!(local->hw.conf.channel->flags &
  156. IEEE80211_CHAN_NO_HT40PLUS))
  157. channel_type = NL80211_CHAN_HT40PLUS;
  158. break;
  159. case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
  160. if (!(local->hw.conf.channel->flags &
  161. IEEE80211_CHAN_NO_HT40MINUS))
  162. channel_type = NL80211_CHAN_HT40MINUS;
  163. break;
  164. }
  165. }
  166. }
  167. ht_changed = conf_is_ht(&local->hw.conf) != enable_ht ||
  168. channel_type != local->hw.conf.channel_type;
  169. local->oper_channel_type = channel_type;
  170. if (ht_changed) {
  171. /* channel_type change automatically detected */
  172. ieee80211_hw_config(local, 0);
  173. rcu_read_lock();
  174. sta = sta_info_get(local, bssid);
  175. if (sta)
  176. rate_control_rate_update(local, sband, sta,
  177. IEEE80211_RC_HT_CHANGED);
  178. rcu_read_unlock();
  179. }
  180. /* disable HT */
  181. if (!enable_ht)
  182. return 0;
  183. ht_opmode = le16_to_cpu(hti->operation_mode);
  184. /* if bss configuration changed store the new one */
  185. if (!sdata->ht_opmode_valid ||
  186. sdata->vif.bss_conf.ht_operation_mode != ht_opmode) {
  187. changed |= BSS_CHANGED_HT;
  188. sdata->vif.bss_conf.ht_operation_mode = ht_opmode;
  189. sdata->ht_opmode_valid = true;
  190. }
  191. return changed;
  192. }
  193. /* frame sending functions */
  194. static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
  195. struct ieee80211_mgd_work *wk)
  196. {
  197. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  198. struct ieee80211_local *local = sdata->local;
  199. struct sk_buff *skb;
  200. struct ieee80211_mgmt *mgmt;
  201. u8 *pos;
  202. const u8 *ies, *ht_ie;
  203. int i, len, count, rates_len, supp_rates_len;
  204. u16 capab;
  205. int wmm = 0;
  206. struct ieee80211_supported_band *sband;
  207. u32 rates = 0;
  208. skb = dev_alloc_skb(local->hw.extra_tx_headroom +
  209. sizeof(*mgmt) + 200 + wk->ie_len +
  210. wk->ssid_len);
  211. if (!skb) {
  212. printk(KERN_DEBUG "%s: failed to allocate buffer for assoc "
  213. "frame\n", sdata->dev->name);
  214. return;
  215. }
  216. skb_reserve(skb, local->hw.extra_tx_headroom);
  217. sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
  218. capab = ifmgd->capab;
  219. if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ) {
  220. if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE))
  221. capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
  222. if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE))
  223. capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
  224. }
  225. if (wk->bss->cbss.capability & WLAN_CAPABILITY_PRIVACY)
  226. capab |= WLAN_CAPABILITY_PRIVACY;
  227. if (wk->bss->wmm_used)
  228. wmm = 1;
  229. /* get all rates supported by the device and the AP as
  230. * some APs don't like getting a superset of their rates
  231. * in the association request (e.g. D-Link DAP 1353 in
  232. * b-only mode) */
  233. rates_len = ieee80211_compatible_rates(wk->bss, sband, &rates);
  234. if ((wk->bss->cbss.capability & WLAN_CAPABILITY_SPECTRUM_MGMT) &&
  235. (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT))
  236. capab |= WLAN_CAPABILITY_SPECTRUM_MGMT;
  237. mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
  238. memset(mgmt, 0, 24);
  239. memcpy(mgmt->da, wk->bss->cbss.bssid, ETH_ALEN);
  240. memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
  241. memcpy(mgmt->bssid, wk->bss->cbss.bssid, ETH_ALEN);
  242. if (!is_zero_ether_addr(wk->prev_bssid)) {
  243. skb_put(skb, 10);
  244. mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  245. IEEE80211_STYPE_REASSOC_REQ);
  246. mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab);
  247. mgmt->u.reassoc_req.listen_interval =
  248. cpu_to_le16(local->hw.conf.listen_interval);
  249. memcpy(mgmt->u.reassoc_req.current_ap, wk->prev_bssid,
  250. ETH_ALEN);
  251. } else {
  252. skb_put(skb, 4);
  253. mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  254. IEEE80211_STYPE_ASSOC_REQ);
  255. mgmt->u.assoc_req.capab_info = cpu_to_le16(capab);
  256. mgmt->u.assoc_req.listen_interval =
  257. cpu_to_le16(local->hw.conf.listen_interval);
  258. }
  259. /* SSID */
  260. ies = pos = skb_put(skb, 2 + wk->ssid_len);
  261. *pos++ = WLAN_EID_SSID;
  262. *pos++ = wk->ssid_len;
  263. memcpy(pos, wk->ssid, wk->ssid_len);
  264. /* add all rates which were marked to be used above */
  265. supp_rates_len = rates_len;
  266. if (supp_rates_len > 8)
  267. supp_rates_len = 8;
  268. len = sband->n_bitrates;
  269. pos = skb_put(skb, supp_rates_len + 2);
  270. *pos++ = WLAN_EID_SUPP_RATES;
  271. *pos++ = supp_rates_len;
  272. count = 0;
  273. for (i = 0; i < sband->n_bitrates; i++) {
  274. if (BIT(i) & rates) {
  275. int rate = sband->bitrates[i].bitrate;
  276. *pos++ = (u8) (rate / 5);
  277. if (++count == 8)
  278. break;
  279. }
  280. }
  281. if (rates_len > count) {
  282. pos = skb_put(skb, rates_len - count + 2);
  283. *pos++ = WLAN_EID_EXT_SUPP_RATES;
  284. *pos++ = rates_len - count;
  285. for (i++; i < sband->n_bitrates; i++) {
  286. if (BIT(i) & rates) {
  287. int rate = sband->bitrates[i].bitrate;
  288. *pos++ = (u8) (rate / 5);
  289. }
  290. }
  291. }
  292. if (capab & WLAN_CAPABILITY_SPECTRUM_MGMT) {
  293. /* 1. power capabilities */
  294. pos = skb_put(skb, 4);
  295. *pos++ = WLAN_EID_PWR_CAPABILITY;
  296. *pos++ = 2;
  297. *pos++ = 0; /* min tx power */
  298. *pos++ = local->hw.conf.channel->max_power; /* max tx power */
  299. /* 2. supported channels */
  300. /* TODO: get this in reg domain format */
  301. pos = skb_put(skb, 2 * sband->n_channels + 2);
  302. *pos++ = WLAN_EID_SUPPORTED_CHANNELS;
  303. *pos++ = 2 * sband->n_channels;
  304. for (i = 0; i < sband->n_channels; i++) {
  305. *pos++ = ieee80211_frequency_to_channel(
  306. sband->channels[i].center_freq);
  307. *pos++ = 1; /* one channel in the subband*/
  308. }
  309. }
  310. if (wk->ie_len && wk->ie) {
  311. pos = skb_put(skb, wk->ie_len);
  312. memcpy(pos, wk->ie, wk->ie_len);
  313. }
  314. if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED)) {
  315. pos = skb_put(skb, 9);
  316. *pos++ = WLAN_EID_VENDOR_SPECIFIC;
  317. *pos++ = 7; /* len */
  318. *pos++ = 0x00; /* Microsoft OUI 00:50:F2 */
  319. *pos++ = 0x50;
  320. *pos++ = 0xf2;
  321. *pos++ = 2; /* WME */
  322. *pos++ = 0; /* WME info */
  323. *pos++ = 1; /* WME ver */
  324. *pos++ = 0;
  325. }
  326. /* wmm support is a must to HT */
  327. /*
  328. * IEEE802.11n does not allow TKIP/WEP as pairwise
  329. * ciphers in HT mode. We still associate in non-ht
  330. * mode (11a/b/g) if any one of these ciphers is
  331. * configured as pairwise.
  332. */
  333. if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) &&
  334. sband->ht_cap.ht_supported &&
  335. (ht_ie = ieee80211_bss_get_ie(&wk->bss->cbss, WLAN_EID_HT_INFORMATION)) &&
  336. ht_ie[1] >= sizeof(struct ieee80211_ht_info) &&
  337. (!(ifmgd->flags & IEEE80211_STA_DISABLE_11N))) {
  338. struct ieee80211_ht_info *ht_info =
  339. (struct ieee80211_ht_info *)(ht_ie + 2);
  340. u16 cap = sband->ht_cap.cap;
  341. __le16 tmp;
  342. u32 flags = local->hw.conf.channel->flags;
  343. switch (ht_info->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
  344. case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
  345. if (flags & IEEE80211_CHAN_NO_HT40PLUS) {
  346. cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
  347. cap &= ~IEEE80211_HT_CAP_SGI_40;
  348. }
  349. break;
  350. case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
  351. if (flags & IEEE80211_CHAN_NO_HT40MINUS) {
  352. cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
  353. cap &= ~IEEE80211_HT_CAP_SGI_40;
  354. }
  355. break;
  356. }
  357. tmp = cpu_to_le16(cap);
  358. pos = skb_put(skb, sizeof(struct ieee80211_ht_cap)+2);
  359. *pos++ = WLAN_EID_HT_CAPABILITY;
  360. *pos++ = sizeof(struct ieee80211_ht_cap);
  361. memset(pos, 0, sizeof(struct ieee80211_ht_cap));
  362. memcpy(pos, &tmp, sizeof(u16));
  363. pos += sizeof(u16);
  364. /* TODO: needs a define here for << 2 */
  365. *pos++ = sband->ht_cap.ampdu_factor |
  366. (sband->ht_cap.ampdu_density << 2);
  367. memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs));
  368. }
  369. ieee80211_tx_skb(sdata, skb, 0);
  370. }
  371. static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
  372. const u8 *bssid, u16 stype, u16 reason,
  373. void *cookie)
  374. {
  375. struct ieee80211_local *local = sdata->local;
  376. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  377. struct sk_buff *skb;
  378. struct ieee80211_mgmt *mgmt;
  379. skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt));
  380. if (!skb) {
  381. printk(KERN_DEBUG "%s: failed to allocate buffer for "
  382. "deauth/disassoc frame\n", sdata->dev->name);
  383. return;
  384. }
  385. skb_reserve(skb, local->hw.extra_tx_headroom);
  386. mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
  387. memset(mgmt, 0, 24);
  388. memcpy(mgmt->da, bssid, ETH_ALEN);
  389. memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
  390. memcpy(mgmt->bssid, bssid, ETH_ALEN);
  391. mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype);
  392. skb_put(skb, 2);
  393. /* u.deauth.reason_code == u.disassoc.reason_code */
  394. mgmt->u.deauth.reason_code = cpu_to_le16(reason);
  395. if (stype == IEEE80211_STYPE_DEAUTH)
  396. cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len, cookie);
  397. else
  398. cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len, cookie);
  399. ieee80211_tx_skb(sdata, skb, ifmgd->flags & IEEE80211_STA_MFP_ENABLED);
  400. }
  401. void ieee80211_send_pspoll(struct ieee80211_local *local,
  402. struct ieee80211_sub_if_data *sdata)
  403. {
  404. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  405. struct ieee80211_pspoll *pspoll;
  406. struct sk_buff *skb;
  407. u16 fc;
  408. skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll));
  409. if (!skb) {
  410. printk(KERN_DEBUG "%s: failed to allocate buffer for "
  411. "pspoll frame\n", sdata->dev->name);
  412. return;
  413. }
  414. skb_reserve(skb, local->hw.extra_tx_headroom);
  415. pspoll = (struct ieee80211_pspoll *) skb_put(skb, sizeof(*pspoll));
  416. memset(pspoll, 0, sizeof(*pspoll));
  417. fc = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL | IEEE80211_FCTL_PM;
  418. pspoll->frame_control = cpu_to_le16(fc);
  419. pspoll->aid = cpu_to_le16(ifmgd->aid);
  420. /* aid in PS-Poll has its two MSBs each set to 1 */
  421. pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14);
  422. memcpy(pspoll->bssid, ifmgd->bssid, ETH_ALEN);
  423. memcpy(pspoll->ta, sdata->dev->dev_addr, ETH_ALEN);
  424. ieee80211_tx_skb(sdata, skb, 0);
  425. }
  426. void ieee80211_send_nullfunc(struct ieee80211_local *local,
  427. struct ieee80211_sub_if_data *sdata,
  428. int powersave)
  429. {
  430. struct sk_buff *skb;
  431. struct ieee80211_hdr *nullfunc;
  432. __le16 fc;
  433. if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
  434. return;
  435. skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24);
  436. if (!skb) {
  437. printk(KERN_DEBUG "%s: failed to allocate buffer for nullfunc "
  438. "frame\n", sdata->dev->name);
  439. return;
  440. }
  441. skb_reserve(skb, local->hw.extra_tx_headroom);
  442. nullfunc = (struct ieee80211_hdr *) skb_put(skb, 24);
  443. memset(nullfunc, 0, 24);
  444. fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC |
  445. IEEE80211_FCTL_TODS);
  446. if (powersave)
  447. fc |= cpu_to_le16(IEEE80211_FCTL_PM);
  448. nullfunc->frame_control = fc;
  449. memcpy(nullfunc->addr1, sdata->u.mgd.bssid, ETH_ALEN);
  450. memcpy(nullfunc->addr2, sdata->dev->dev_addr, ETH_ALEN);
  451. memcpy(nullfunc->addr3, sdata->u.mgd.bssid, ETH_ALEN);
  452. ieee80211_tx_skb(sdata, skb, 0);
  453. }
  454. /* spectrum management related things */
  455. static void ieee80211_chswitch_work(struct work_struct *work)
  456. {
  457. struct ieee80211_sub_if_data *sdata =
  458. container_of(work, struct ieee80211_sub_if_data, u.mgd.chswitch_work);
  459. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  460. if (!netif_running(sdata->dev))
  461. return;
  462. mutex_lock(&ifmgd->mtx);
  463. if (!ifmgd->associated)
  464. goto out;
  465. sdata->local->oper_channel = sdata->local->csa_channel;
  466. ieee80211_hw_config(sdata->local, IEEE80211_CONF_CHANGE_CHANNEL);
  467. /* XXX: shouldn't really modify cfg80211-owned data! */
  468. ifmgd->associated->cbss.channel = sdata->local->oper_channel;
  469. ieee80211_wake_queues_by_reason(&sdata->local->hw,
  470. IEEE80211_QUEUE_STOP_REASON_CSA);
  471. out:
  472. ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED;
  473. mutex_unlock(&ifmgd->mtx);
  474. }
  475. static void ieee80211_chswitch_timer(unsigned long data)
  476. {
  477. struct ieee80211_sub_if_data *sdata =
  478. (struct ieee80211_sub_if_data *) data;
  479. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  480. if (sdata->local->quiescing) {
  481. set_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running);
  482. return;
  483. }
  484. ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work);
  485. }
  486. void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
  487. struct ieee80211_channel_sw_ie *sw_elem,
  488. struct ieee80211_bss *bss)
  489. {
  490. struct ieee80211_channel *new_ch;
  491. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  492. int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num);
  493. ASSERT_MGD_MTX(ifmgd);
  494. if (!ifmgd->associated)
  495. return;
  496. if (sdata->local->scanning)
  497. return;
  498. /* Disregard subsequent beacons if we are already running a timer
  499. processing a CSA */
  500. if (ifmgd->flags & IEEE80211_STA_CSA_RECEIVED)
  501. return;
  502. new_ch = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq);
  503. if (!new_ch || new_ch->flags & IEEE80211_CHAN_DISABLED)
  504. return;
  505. sdata->local->csa_channel = new_ch;
  506. if (sw_elem->count <= 1) {
  507. ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work);
  508. } else {
  509. ieee80211_stop_queues_by_reason(&sdata->local->hw,
  510. IEEE80211_QUEUE_STOP_REASON_CSA);
  511. ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
  512. mod_timer(&ifmgd->chswitch_timer,
  513. jiffies +
  514. msecs_to_jiffies(sw_elem->count *
  515. bss->cbss.beacon_interval));
  516. }
  517. }
  518. static void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
  519. u16 capab_info, u8 *pwr_constr_elem,
  520. u8 pwr_constr_elem_len)
  521. {
  522. struct ieee80211_conf *conf = &sdata->local->hw.conf;
  523. if (!(capab_info & WLAN_CAPABILITY_SPECTRUM_MGMT))
  524. return;
  525. /* Power constraint IE length should be 1 octet */
  526. if (pwr_constr_elem_len != 1)
  527. return;
  528. if ((*pwr_constr_elem <= conf->channel->max_power) &&
  529. (*pwr_constr_elem != sdata->local->power_constr_level)) {
  530. sdata->local->power_constr_level = *pwr_constr_elem;
  531. ieee80211_hw_config(sdata->local, 0);
  532. }
  533. }
  534. /* powersave */
  535. static void ieee80211_enable_ps(struct ieee80211_local *local,
  536. struct ieee80211_sub_if_data *sdata)
  537. {
  538. struct ieee80211_conf *conf = &local->hw.conf;
  539. /*
  540. * If we are scanning right now then the parameters will
  541. * take effect when scan finishes.
  542. */
  543. if (local->scanning)
  544. return;
  545. if (conf->dynamic_ps_timeout > 0 &&
  546. !(local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)) {
  547. mod_timer(&local->dynamic_ps_timer, jiffies +
  548. msecs_to_jiffies(conf->dynamic_ps_timeout));
  549. } else {
  550. if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)
  551. ieee80211_send_nullfunc(local, sdata, 1);
  552. conf->flags |= IEEE80211_CONF_PS;
  553. ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
  554. }
  555. }
  556. static void ieee80211_change_ps(struct ieee80211_local *local)
  557. {
  558. struct ieee80211_conf *conf = &local->hw.conf;
  559. if (local->ps_sdata) {
  560. ieee80211_enable_ps(local, local->ps_sdata);
  561. } else if (conf->flags & IEEE80211_CONF_PS) {
  562. conf->flags &= ~IEEE80211_CONF_PS;
  563. ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
  564. del_timer_sync(&local->dynamic_ps_timer);
  565. cancel_work_sync(&local->dynamic_ps_enable_work);
  566. }
  567. }
  568. /* need to hold RTNL or interface lock */
  569. void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency)
  570. {
  571. struct ieee80211_sub_if_data *sdata, *found = NULL;
  572. int count = 0;
  573. if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) {
  574. local->ps_sdata = NULL;
  575. return;
  576. }
  577. list_for_each_entry(sdata, &local->interfaces, list) {
  578. if (!netif_running(sdata->dev))
  579. continue;
  580. if (sdata->vif.type != NL80211_IFTYPE_STATION)
  581. continue;
  582. found = sdata;
  583. count++;
  584. }
  585. if (count == 1 && found->u.mgd.powersave &&
  586. found->u.mgd.associated && list_empty(&found->u.mgd.work_list) &&
  587. !(found->u.mgd.flags & (IEEE80211_STA_BEACON_POLL |
  588. IEEE80211_STA_CONNECTION_POLL))) {
  589. s32 beaconint_us;
  590. if (latency < 0)
  591. latency = pm_qos_requirement(PM_QOS_NETWORK_LATENCY);
  592. beaconint_us = ieee80211_tu_to_usec(
  593. found->vif.bss_conf.beacon_int);
  594. if (beaconint_us > latency) {
  595. local->ps_sdata = NULL;
  596. } else {
  597. u8 dtimper = found->vif.bss_conf.dtim_period;
  598. int maxslp = 1;
  599. if (dtimper > 1)
  600. maxslp = min_t(int, dtimper,
  601. latency / beaconint_us);
  602. local->hw.conf.max_sleep_period = maxslp;
  603. local->ps_sdata = found;
  604. }
  605. } else {
  606. local->ps_sdata = NULL;
  607. }
  608. ieee80211_change_ps(local);
  609. }
  610. void ieee80211_dynamic_ps_disable_work(struct work_struct *work)
  611. {
  612. struct ieee80211_local *local =
  613. container_of(work, struct ieee80211_local,
  614. dynamic_ps_disable_work);
  615. if (local->hw.conf.flags & IEEE80211_CONF_PS) {
  616. local->hw.conf.flags &= ~IEEE80211_CONF_PS;
  617. ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
  618. }
  619. ieee80211_wake_queues_by_reason(&local->hw,
  620. IEEE80211_QUEUE_STOP_REASON_PS);
  621. }
  622. void ieee80211_dynamic_ps_enable_work(struct work_struct *work)
  623. {
  624. struct ieee80211_local *local =
  625. container_of(work, struct ieee80211_local,
  626. dynamic_ps_enable_work);
  627. struct ieee80211_sub_if_data *sdata = local->ps_sdata;
  628. /* can only happen when PS was just disabled anyway */
  629. if (!sdata)
  630. return;
  631. if (local->hw.conf.flags & IEEE80211_CONF_PS)
  632. return;
  633. if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)
  634. ieee80211_send_nullfunc(local, sdata, 1);
  635. local->hw.conf.flags |= IEEE80211_CONF_PS;
  636. ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
  637. }
  638. void ieee80211_dynamic_ps_timer(unsigned long data)
  639. {
  640. struct ieee80211_local *local = (void *) data;
  641. if (local->quiescing || local->suspended)
  642. return;
  643. ieee80211_queue_work(&local->hw, &local->dynamic_ps_enable_work);
  644. }
  645. /* MLME */
  646. static void ieee80211_sta_wmm_params(struct ieee80211_local *local,
  647. struct ieee80211_if_managed *ifmgd,
  648. u8 *wmm_param, size_t wmm_param_len)
  649. {
  650. struct ieee80211_tx_queue_params params;
  651. size_t left;
  652. int count;
  653. u8 *pos;
  654. if (!(ifmgd->flags & IEEE80211_STA_WMM_ENABLED))
  655. return;
  656. if (!wmm_param)
  657. return;
  658. if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1)
  659. return;
  660. count = wmm_param[6] & 0x0f;
  661. if (count == ifmgd->wmm_last_param_set)
  662. return;
  663. ifmgd->wmm_last_param_set = count;
  664. pos = wmm_param + 8;
  665. left = wmm_param_len - 8;
  666. memset(&params, 0, sizeof(params));
  667. local->wmm_acm = 0;
  668. for (; left >= 4; left -= 4, pos += 4) {
  669. int aci = (pos[0] >> 5) & 0x03;
  670. int acm = (pos[0] >> 4) & 0x01;
  671. int queue;
  672. switch (aci) {
  673. case 1: /* AC_BK */
  674. queue = 3;
  675. if (acm)
  676. local->wmm_acm |= BIT(1) | BIT(2); /* BK/- */
  677. break;
  678. case 2: /* AC_VI */
  679. queue = 1;
  680. if (acm)
  681. local->wmm_acm |= BIT(4) | BIT(5); /* CL/VI */
  682. break;
  683. case 3: /* AC_VO */
  684. queue = 0;
  685. if (acm)
  686. local->wmm_acm |= BIT(6) | BIT(7); /* VO/NC */
  687. break;
  688. case 0: /* AC_BE */
  689. default:
  690. queue = 2;
  691. if (acm)
  692. local->wmm_acm |= BIT(0) | BIT(3); /* BE/EE */
  693. break;
  694. }
  695. params.aifs = pos[0] & 0x0f;
  696. params.cw_max = ecw2cw((pos[1] & 0xf0) >> 4);
  697. params.cw_min = ecw2cw(pos[1] & 0x0f);
  698. params.txop = get_unaligned_le16(pos + 2);
  699. #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
  700. printk(KERN_DEBUG "%s: WMM queue=%d aci=%d acm=%d aifs=%d "
  701. "cWmin=%d cWmax=%d txop=%d\n",
  702. wiphy_name(local->hw.wiphy), queue, aci, acm,
  703. params.aifs, params.cw_min, params.cw_max, params.txop);
  704. #endif
  705. if (drv_conf_tx(local, queue, &params) && local->ops->conf_tx)
  706. printk(KERN_DEBUG "%s: failed to set TX queue "
  707. "parameters for queue %d\n",
  708. wiphy_name(local->hw.wiphy), queue);
  709. }
  710. }
  711. static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
  712. u16 capab, bool erp_valid, u8 erp)
  713. {
  714. struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
  715. u32 changed = 0;
  716. bool use_protection;
  717. bool use_short_preamble;
  718. bool use_short_slot;
  719. if (erp_valid) {
  720. use_protection = (erp & WLAN_ERP_USE_PROTECTION) != 0;
  721. use_short_preamble = (erp & WLAN_ERP_BARKER_PREAMBLE) == 0;
  722. } else {
  723. use_protection = false;
  724. use_short_preamble = !!(capab & WLAN_CAPABILITY_SHORT_PREAMBLE);
  725. }
  726. use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME);
  727. if (use_protection != bss_conf->use_cts_prot) {
  728. bss_conf->use_cts_prot = use_protection;
  729. changed |= BSS_CHANGED_ERP_CTS_PROT;
  730. }
  731. if (use_short_preamble != bss_conf->use_short_preamble) {
  732. bss_conf->use_short_preamble = use_short_preamble;
  733. changed |= BSS_CHANGED_ERP_PREAMBLE;
  734. }
  735. if (use_short_slot != bss_conf->use_short_slot) {
  736. bss_conf->use_short_slot = use_short_slot;
  737. changed |= BSS_CHANGED_ERP_SLOT;
  738. }
  739. return changed;
  740. }
  741. static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
  742. struct ieee80211_mgd_work *wk,
  743. u32 bss_info_changed)
  744. {
  745. struct ieee80211_local *local = sdata->local;
  746. struct ieee80211_bss *bss = wk->bss;
  747. bss_info_changed |= BSS_CHANGED_ASSOC;
  748. /* set timing information */
  749. sdata->vif.bss_conf.beacon_int = bss->cbss.beacon_interval;
  750. sdata->vif.bss_conf.timestamp = bss->cbss.tsf;
  751. sdata->vif.bss_conf.dtim_period = bss->dtim_period;
  752. bss_info_changed |= BSS_CHANGED_BEACON_INT;
  753. bss_info_changed |= ieee80211_handle_bss_capability(sdata,
  754. bss->cbss.capability, bss->has_erp_value, bss->erp_value);
  755. sdata->u.mgd.associated = bss;
  756. sdata->u.mgd.old_associate_work = wk;
  757. memcpy(sdata->u.mgd.bssid, bss->cbss.bssid, ETH_ALEN);
  758. /* just to be sure */
  759. sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL |
  760. IEEE80211_STA_BEACON_POLL);
  761. /*
  762. * Always handle WMM once after association regardless
  763. * of the first value the AP uses. Setting -1 here has
  764. * that effect because the AP values is an unsigned
  765. * 4-bit value.
  766. */
  767. sdata->u.mgd.wmm_last_param_set = -1;
  768. ieee80211_led_assoc(local, 1);
  769. sdata->vif.bss_conf.assoc = 1;
  770. /*
  771. * For now just always ask the driver to update the basic rateset
  772. * when we have associated, we aren't checking whether it actually
  773. * changed or not.
  774. */
  775. bss_info_changed |= BSS_CHANGED_BASIC_RATES;
  776. /* And the BSSID changed - we're associated now */
  777. bss_info_changed |= BSS_CHANGED_BSSID;
  778. ieee80211_bss_info_change_notify(sdata, bss_info_changed);
  779. mutex_lock(&local->iflist_mtx);
  780. ieee80211_recalc_ps(local, -1);
  781. mutex_unlock(&local->iflist_mtx);
  782. netif_tx_start_all_queues(sdata->dev);
  783. netif_carrier_on(sdata->dev);
  784. }
  785. static enum rx_mgmt_action __must_check
  786. ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata,
  787. struct ieee80211_mgd_work *wk)
  788. {
  789. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  790. struct ieee80211_local *local = sdata->local;
  791. wk->tries++;
  792. if (wk->tries > IEEE80211_AUTH_MAX_TRIES) {
  793. printk(KERN_DEBUG "%s: direct probe to AP %pM timed out\n",
  794. sdata->dev->name, wk->bss->cbss.bssid);
  795. /*
  796. * Most likely AP is not in the range so remove the
  797. * bss struct for that AP.
  798. */
  799. cfg80211_unlink_bss(local->hw.wiphy, &wk->bss->cbss);
  800. /*
  801. * We might have a pending scan which had no chance to run yet
  802. * due to work needing to be done. Hence, queue the STAs work
  803. * again for that.
  804. */
  805. ieee80211_queue_work(&local->hw, &ifmgd->work);
  806. return RX_MGMT_CFG80211_AUTH_TO;
  807. }
  808. printk(KERN_DEBUG "%s: direct probe to AP %pM (try %d)\n",
  809. sdata->dev->name, wk->bss->cbss.bssid,
  810. wk->tries);
  811. /*
  812. * Direct probe is sent to broadcast address as some APs
  813. * will not answer to direct packet in unassociated state.
  814. */
  815. ieee80211_send_probe_req(sdata, NULL, wk->ssid, wk->ssid_len, NULL, 0);
  816. wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
  817. run_again(ifmgd, wk->timeout);
  818. return RX_MGMT_NONE;
  819. }
  820. static enum rx_mgmt_action __must_check
  821. ieee80211_authenticate(struct ieee80211_sub_if_data *sdata,
  822. struct ieee80211_mgd_work *wk)
  823. {
  824. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  825. struct ieee80211_local *local = sdata->local;
  826. wk->tries++;
  827. if (wk->tries > IEEE80211_AUTH_MAX_TRIES) {
  828. printk(KERN_DEBUG "%s: authentication with AP %pM"
  829. " timed out\n",
  830. sdata->dev->name, wk->bss->cbss.bssid);
  831. /*
  832. * Most likely AP is not in the range so remove the
  833. * bss struct for that AP.
  834. */
  835. cfg80211_unlink_bss(local->hw.wiphy, &wk->bss->cbss);
  836. /*
  837. * We might have a pending scan which had no chance to run yet
  838. * due to work needing to be done. Hence, queue the STAs work
  839. * again for that.
  840. */
  841. ieee80211_queue_work(&local->hw, &ifmgd->work);
  842. return RX_MGMT_CFG80211_AUTH_TO;
  843. }
  844. printk(KERN_DEBUG "%s: authenticate with AP %pM (try %d)\n",
  845. sdata->dev->name, wk->bss->cbss.bssid, wk->tries);
  846. ieee80211_send_auth(sdata, 1, wk->auth_alg, wk->ie, wk->ie_len,
  847. wk->bss->cbss.bssid, NULL, 0, 0);
  848. wk->auth_transaction = 2;
  849. wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
  850. run_again(ifmgd, wk->timeout);
  851. return RX_MGMT_NONE;
  852. }
  853. static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
  854. bool deauth)
  855. {
  856. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  857. struct ieee80211_local *local = sdata->local;
  858. struct sta_info *sta;
  859. u32 changed = 0, config_changed = 0;
  860. u8 bssid[ETH_ALEN];
  861. ASSERT_MGD_MTX(ifmgd);
  862. if (WARN_ON(!ifmgd->associated))
  863. return;
  864. memcpy(bssid, ifmgd->associated->cbss.bssid, ETH_ALEN);
  865. ifmgd->associated = NULL;
  866. memset(ifmgd->bssid, 0, ETH_ALEN);
  867. if (deauth) {
  868. kfree(ifmgd->old_associate_work);
  869. ifmgd->old_associate_work = NULL;
  870. } else {
  871. struct ieee80211_mgd_work *wk = ifmgd->old_associate_work;
  872. wk->state = IEEE80211_MGD_STATE_IDLE;
  873. list_add(&wk->list, &ifmgd->work_list);
  874. }
  875. /*
  876. * we need to commit the associated = NULL change because the
  877. * scan code uses that to determine whether this iface should
  878. * go to/wake up from powersave or not -- and could otherwise
  879. * wake the queues erroneously.
  880. */
  881. smp_mb();
  882. /*
  883. * Thus, we can only afterwards stop the queues -- to account
  884. * for the case where another CPU is finishing a scan at this
  885. * time -- we don't want the scan code to enable queues.
  886. */
  887. netif_tx_stop_all_queues(sdata->dev);
  888. netif_carrier_off(sdata->dev);
  889. rcu_read_lock();
  890. sta = sta_info_get(local, bssid);
  891. if (sta)
  892. ieee80211_sta_tear_down_BA_sessions(sta);
  893. rcu_read_unlock();
  894. changed |= ieee80211_reset_erp_info(sdata);
  895. ieee80211_led_assoc(local, 0);
  896. changed |= BSS_CHANGED_ASSOC;
  897. sdata->vif.bss_conf.assoc = false;
  898. ieee80211_set_wmm_default(sdata);
  899. ieee80211_recalc_idle(local);
  900. /* channel(_type) changes are handled by ieee80211_hw_config */
  901. local->oper_channel_type = NL80211_CHAN_NO_HT;
  902. /* on the next assoc, re-program HT parameters */
  903. sdata->ht_opmode_valid = false;
  904. local->power_constr_level = 0;
  905. del_timer_sync(&local->dynamic_ps_timer);
  906. cancel_work_sync(&local->dynamic_ps_enable_work);
  907. if (local->hw.conf.flags & IEEE80211_CONF_PS) {
  908. local->hw.conf.flags &= ~IEEE80211_CONF_PS;
  909. config_changed |= IEEE80211_CONF_CHANGE_PS;
  910. }
  911. ieee80211_hw_config(local, config_changed);
  912. /* And the BSSID changed -- not very interesting here */
  913. changed |= BSS_CHANGED_BSSID;
  914. ieee80211_bss_info_change_notify(sdata, changed);
  915. rcu_read_lock();
  916. sta = sta_info_get(local, bssid);
  917. if (!sta) {
  918. rcu_read_unlock();
  919. return;
  920. }
  921. sta_info_unlink(&sta);
  922. rcu_read_unlock();
  923. sta_info_destroy(sta);
  924. }
  925. static enum rx_mgmt_action __must_check
  926. ieee80211_associate(struct ieee80211_sub_if_data *sdata,
  927. struct ieee80211_mgd_work *wk)
  928. {
  929. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  930. struct ieee80211_local *local = sdata->local;
  931. wk->tries++;
  932. if (wk->tries > IEEE80211_ASSOC_MAX_TRIES) {
  933. printk(KERN_DEBUG "%s: association with AP %pM"
  934. " timed out\n",
  935. sdata->dev->name, wk->bss->cbss.bssid);
  936. /*
  937. * Most likely AP is not in the range so remove the
  938. * bss struct for that AP.
  939. */
  940. cfg80211_unlink_bss(local->hw.wiphy, &wk->bss->cbss);
  941. /*
  942. * We might have a pending scan which had no chance to run yet
  943. * due to work needing to be done. Hence, queue the STAs work
  944. * again for that.
  945. */
  946. ieee80211_queue_work(&local->hw, &ifmgd->work);
  947. return RX_MGMT_CFG80211_ASSOC_TO;
  948. }
  949. printk(KERN_DEBUG "%s: associate with AP %pM (try %d)\n",
  950. sdata->dev->name, wk->bss->cbss.bssid, wk->tries);
  951. ieee80211_send_assoc(sdata, wk);
  952. wk->timeout = jiffies + IEEE80211_ASSOC_TIMEOUT;
  953. run_again(ifmgd, wk->timeout);
  954. return RX_MGMT_NONE;
  955. }
  956. void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
  957. struct ieee80211_hdr *hdr)
  958. {
  959. /*
  960. * We can postpone the mgd.timer whenever receiving unicast frames
  961. * from AP because we know that the connection is working both ways
  962. * at that time. But multicast frames (and hence also beacons) must
  963. * be ignored here, because we need to trigger the timer during
  964. * data idle periods for sending the periodic probe request to the
  965. * AP we're connected to.
  966. */
  967. if (is_multicast_ether_addr(hdr->addr1))
  968. return;
  969. mod_timer(&sdata->u.mgd.conn_mon_timer,
  970. round_jiffies_up(jiffies + IEEE80211_CONNECTION_IDLE_TIME));
  971. }
  972. static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata)
  973. {
  974. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  975. const u8 *ssid;
  976. ssid = ieee80211_bss_get_ie(&ifmgd->associated->cbss, WLAN_EID_SSID);
  977. ieee80211_send_probe_req(sdata, ifmgd->associated->cbss.bssid,
  978. ssid + 2, ssid[1], NULL, 0);
  979. ifmgd->probe_send_count++;
  980. ifmgd->probe_timeout = jiffies + IEEE80211_PROBE_WAIT;
  981. run_again(ifmgd, ifmgd->probe_timeout);
  982. }
  983. static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data *sdata,
  984. bool beacon)
  985. {
  986. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  987. bool already = false;
  988. if (!netif_running(sdata->dev))
  989. return;
  990. if (sdata->local->scanning)
  991. return;
  992. mutex_lock(&ifmgd->mtx);
  993. if (!ifmgd->associated)
  994. goto out;
  995. #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
  996. if (beacon && net_ratelimit())
  997. printk(KERN_DEBUG "%s: detected beacon loss from AP "
  998. "- sending probe request\n", sdata->dev->name);
  999. #endif
  1000. /*
  1001. * The driver/our work has already reported this event or the
  1002. * connection monitoring has kicked in and we have already sent
  1003. * a probe request. Or maybe the AP died and the driver keeps
  1004. * reporting until we disassociate...
  1005. *
  1006. * In either case we have to ignore the current call to this
  1007. * function (except for setting the correct probe reason bit)
  1008. * because otherwise we would reset the timer every time and
  1009. * never check whether we received a probe response!
  1010. */
  1011. if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL |
  1012. IEEE80211_STA_CONNECTION_POLL))
  1013. already = true;
  1014. if (beacon)
  1015. ifmgd->flags |= IEEE80211_STA_BEACON_POLL;
  1016. else
  1017. ifmgd->flags |= IEEE80211_STA_CONNECTION_POLL;
  1018. if (already)
  1019. goto out;
  1020. mutex_lock(&sdata->local->iflist_mtx);
  1021. ieee80211_recalc_ps(sdata->local, -1);
  1022. mutex_unlock(&sdata->local->iflist_mtx);
  1023. ifmgd->probe_send_count = 0;
  1024. ieee80211_mgd_probe_ap_send(sdata);
  1025. out:
  1026. mutex_unlock(&ifmgd->mtx);
  1027. }
  1028. void ieee80211_beacon_loss_work(struct work_struct *work)
  1029. {
  1030. struct ieee80211_sub_if_data *sdata =
  1031. container_of(work, struct ieee80211_sub_if_data,
  1032. u.mgd.beacon_loss_work);
  1033. ieee80211_mgd_probe_ap(sdata, true);
  1034. }
  1035. void ieee80211_beacon_loss(struct ieee80211_vif *vif)
  1036. {
  1037. struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
  1038. ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.beacon_loss_work);
  1039. }
  1040. EXPORT_SYMBOL(ieee80211_beacon_loss);
  1041. static void ieee80211_auth_completed(struct ieee80211_sub_if_data *sdata,
  1042. struct ieee80211_mgd_work *wk)
  1043. {
  1044. wk->state = IEEE80211_MGD_STATE_IDLE;
  1045. printk(KERN_DEBUG "%s: authenticated\n", sdata->dev->name);
  1046. }
  1047. static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata,
  1048. struct ieee80211_mgd_work *wk,
  1049. struct ieee80211_mgmt *mgmt,
  1050. size_t len)
  1051. {
  1052. u8 *pos;
  1053. struct ieee802_11_elems elems;
  1054. pos = mgmt->u.auth.variable;
  1055. ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
  1056. if (!elems.challenge)
  1057. return;
  1058. ieee80211_send_auth(sdata, 3, wk->auth_alg,
  1059. elems.challenge - 2, elems.challenge_len + 2,
  1060. wk->bss->cbss.bssid,
  1061. wk->key, wk->key_len, wk->key_idx);
  1062. wk->auth_transaction = 4;
  1063. }
  1064. static enum rx_mgmt_action __must_check
  1065. ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
  1066. struct ieee80211_mgd_work *wk,
  1067. struct ieee80211_mgmt *mgmt, size_t len)
  1068. {
  1069. u16 auth_alg, auth_transaction, status_code;
  1070. if (wk->state != IEEE80211_MGD_STATE_AUTH)
  1071. return RX_MGMT_NONE;
  1072. if (len < 24 + 6)
  1073. return RX_MGMT_NONE;
  1074. if (memcmp(wk->bss->cbss.bssid, mgmt->sa, ETH_ALEN) != 0)
  1075. return RX_MGMT_NONE;
  1076. if (memcmp(wk->bss->cbss.bssid, mgmt->bssid, ETH_ALEN) != 0)
  1077. return RX_MGMT_NONE;
  1078. auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg);
  1079. auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction);
  1080. status_code = le16_to_cpu(mgmt->u.auth.status_code);
  1081. if (auth_alg != wk->auth_alg ||
  1082. auth_transaction != wk->auth_transaction)
  1083. return RX_MGMT_NONE;
  1084. if (status_code != WLAN_STATUS_SUCCESS) {
  1085. list_del(&wk->list);
  1086. kfree(wk);
  1087. return RX_MGMT_CFG80211_AUTH;
  1088. }
  1089. switch (wk->auth_alg) {
  1090. case WLAN_AUTH_OPEN:
  1091. case WLAN_AUTH_LEAP:
  1092. case WLAN_AUTH_FT:
  1093. ieee80211_auth_completed(sdata, wk);
  1094. return RX_MGMT_CFG80211_AUTH;
  1095. case WLAN_AUTH_SHARED_KEY:
  1096. if (wk->auth_transaction == 4) {
  1097. ieee80211_auth_completed(sdata, wk);
  1098. return RX_MGMT_CFG80211_AUTH;
  1099. } else
  1100. ieee80211_auth_challenge(sdata, wk, mgmt, len);
  1101. break;
  1102. }
  1103. return RX_MGMT_NONE;
  1104. }
  1105. static enum rx_mgmt_action __must_check
  1106. ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
  1107. struct ieee80211_mgd_work *wk,
  1108. struct ieee80211_mgmt *mgmt, size_t len)
  1109. {
  1110. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  1111. const u8 *bssid = NULL;
  1112. u16 reason_code;
  1113. if (len < 24 + 2)
  1114. return RX_MGMT_NONE;
  1115. ASSERT_MGD_MTX(ifmgd);
  1116. if (wk)
  1117. bssid = wk->bss->cbss.bssid;
  1118. else
  1119. bssid = ifmgd->associated->cbss.bssid;
  1120. reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
  1121. printk(KERN_DEBUG "%s: deauthenticated from %pM (Reason: %u)\n",
  1122. sdata->dev->name, bssid, reason_code);
  1123. if (!wk) {
  1124. ieee80211_set_disassoc(sdata, true);
  1125. } else {
  1126. list_del(&wk->list);
  1127. kfree(wk);
  1128. }
  1129. return RX_MGMT_CFG80211_DEAUTH;
  1130. }
  1131. static enum rx_mgmt_action __must_check
  1132. ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
  1133. struct ieee80211_mgmt *mgmt, size_t len)
  1134. {
  1135. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  1136. u16 reason_code;
  1137. if (len < 24 + 2)
  1138. return RX_MGMT_NONE;
  1139. ASSERT_MGD_MTX(ifmgd);
  1140. if (WARN_ON(!ifmgd->associated))
  1141. return RX_MGMT_NONE;
  1142. if (WARN_ON(memcmp(ifmgd->associated->cbss.bssid, mgmt->sa, ETH_ALEN)))
  1143. return RX_MGMT_NONE;
  1144. reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
  1145. printk(KERN_DEBUG "%s: disassociated from %pM (Reason: %u)\n",
  1146. sdata->dev->name, mgmt->sa, reason_code);
  1147. ieee80211_set_disassoc(sdata, false);
  1148. return RX_MGMT_CFG80211_DISASSOC;
  1149. }
  1150. static enum rx_mgmt_action __must_check
  1151. ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
  1152. struct ieee80211_mgd_work *wk,
  1153. struct ieee80211_mgmt *mgmt, size_t len,
  1154. bool reassoc)
  1155. {
  1156. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  1157. struct ieee80211_local *local = sdata->local;
  1158. struct ieee80211_supported_band *sband;
  1159. struct sta_info *sta;
  1160. u32 rates, basic_rates;
  1161. u16 capab_info, status_code, aid;
  1162. struct ieee802_11_elems elems;
  1163. struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
  1164. u8 *pos;
  1165. u32 changed = 0;
  1166. int i, j;
  1167. bool have_higher_than_11mbit = false, newsta = false;
  1168. u16 ap_ht_cap_flags;
  1169. /*
  1170. * AssocResp and ReassocResp have identical structure, so process both
  1171. * of them in this function.
  1172. */
  1173. if (len < 24 + 6)
  1174. return RX_MGMT_NONE;
  1175. if (memcmp(wk->bss->cbss.bssid, mgmt->sa, ETH_ALEN) != 0)
  1176. return RX_MGMT_NONE;
  1177. capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info);
  1178. status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code);
  1179. aid = le16_to_cpu(mgmt->u.assoc_resp.aid);
  1180. printk(KERN_DEBUG "%s: RX %sssocResp from %pM (capab=0x%x "
  1181. "status=%d aid=%d)\n",
  1182. sdata->dev->name, reassoc ? "Rea" : "A", mgmt->sa,
  1183. capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14))));
  1184. pos = mgmt->u.assoc_resp.variable;
  1185. ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
  1186. if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY &&
  1187. elems.timeout_int && elems.timeout_int_len == 5 &&
  1188. elems.timeout_int[0] == WLAN_TIMEOUT_ASSOC_COMEBACK) {
  1189. u32 tu, ms;
  1190. tu = get_unaligned_le32(elems.timeout_int + 1);
  1191. ms = tu * 1024 / 1000;
  1192. printk(KERN_DEBUG "%s: AP rejected association temporarily; "
  1193. "comeback duration %u TU (%u ms)\n",
  1194. sdata->dev->name, tu, ms);
  1195. wk->timeout = jiffies + msecs_to_jiffies(ms);
  1196. if (ms > IEEE80211_ASSOC_TIMEOUT)
  1197. run_again(ifmgd, jiffies + msecs_to_jiffies(ms));
  1198. return RX_MGMT_NONE;
  1199. }
  1200. if (status_code != WLAN_STATUS_SUCCESS) {
  1201. printk(KERN_DEBUG "%s: AP denied association (code=%d)\n",
  1202. sdata->dev->name, status_code);
  1203. wk->state = IEEE80211_MGD_STATE_IDLE;
  1204. return RX_MGMT_CFG80211_ASSOC;
  1205. }
  1206. if ((aid & (BIT(15) | BIT(14))) != (BIT(15) | BIT(14)))
  1207. printk(KERN_DEBUG "%s: invalid aid value %d; bits 15:14 not "
  1208. "set\n", sdata->dev->name, aid);
  1209. aid &= ~(BIT(15) | BIT(14));
  1210. if (!elems.supp_rates) {
  1211. printk(KERN_DEBUG "%s: no SuppRates element in AssocResp\n",
  1212. sdata->dev->name);
  1213. return RX_MGMT_NONE;
  1214. }
  1215. printk(KERN_DEBUG "%s: associated\n", sdata->dev->name);
  1216. ifmgd->aid = aid;
  1217. rcu_read_lock();
  1218. /* Add STA entry for the AP */
  1219. sta = sta_info_get(local, wk->bss->cbss.bssid);
  1220. if (!sta) {
  1221. newsta = true;
  1222. rcu_read_unlock();
  1223. sta = sta_info_alloc(sdata, wk->bss->cbss.bssid, GFP_KERNEL);
  1224. if (!sta) {
  1225. printk(KERN_DEBUG "%s: failed to alloc STA entry for"
  1226. " the AP\n", sdata->dev->name);
  1227. return RX_MGMT_NONE;
  1228. }
  1229. set_sta_flags(sta, WLAN_STA_AUTH | WLAN_STA_ASSOC |
  1230. WLAN_STA_ASSOC_AP);
  1231. if (!(ifmgd->flags & IEEE80211_STA_CONTROL_PORT))
  1232. set_sta_flags(sta, WLAN_STA_AUTHORIZED);
  1233. rcu_read_lock();
  1234. }
  1235. rates = 0;
  1236. basic_rates = 0;
  1237. sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
  1238. for (i = 0; i < elems.supp_rates_len; i++) {
  1239. int rate = (elems.supp_rates[i] & 0x7f) * 5;
  1240. bool is_basic = !!(elems.supp_rates[i] & 0x80);
  1241. if (rate > 110)
  1242. have_higher_than_11mbit = true;
  1243. for (j = 0; j < sband->n_bitrates; j++) {
  1244. if (sband->bitrates[j].bitrate == rate) {
  1245. rates |= BIT(j);
  1246. if (is_basic)
  1247. basic_rates |= BIT(j);
  1248. break;
  1249. }
  1250. }
  1251. }
  1252. for (i = 0; i < elems.ext_supp_rates_len; i++) {
  1253. int rate = (elems.ext_supp_rates[i] & 0x7f) * 5;
  1254. bool is_basic = !!(elems.ext_supp_rates[i] & 0x80);
  1255. if (rate > 110)
  1256. have_higher_than_11mbit = true;
  1257. for (j = 0; j < sband->n_bitrates; j++) {
  1258. if (sband->bitrates[j].bitrate == rate) {
  1259. rates |= BIT(j);
  1260. if (is_basic)
  1261. basic_rates |= BIT(j);
  1262. break;
  1263. }
  1264. }
  1265. }
  1266. sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
  1267. sdata->vif.bss_conf.basic_rates = basic_rates;
  1268. /* cf. IEEE 802.11 9.2.12 */
  1269. if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ &&
  1270. have_higher_than_11mbit)
  1271. sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE;
  1272. else
  1273. sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE;
  1274. if (elems.ht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_11N))
  1275. ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
  1276. elems.ht_cap_elem, &sta->sta.ht_cap);
  1277. ap_ht_cap_flags = sta->sta.ht_cap.cap;
  1278. rate_control_rate_init(sta);
  1279. if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED)
  1280. set_sta_flags(sta, WLAN_STA_MFP);
  1281. if (elems.wmm_param)
  1282. set_sta_flags(sta, WLAN_STA_WME);
  1283. if (newsta) {
  1284. int err = sta_info_insert(sta);
  1285. if (err) {
  1286. printk(KERN_DEBUG "%s: failed to insert STA entry for"
  1287. " the AP (error %d)\n", sdata->dev->name, err);
  1288. rcu_read_unlock();
  1289. return RX_MGMT_NONE;
  1290. }
  1291. }
  1292. rcu_read_unlock();
  1293. if (elems.wmm_param)
  1294. ieee80211_sta_wmm_params(local, ifmgd, elems.wmm_param,
  1295. elems.wmm_param_len);
  1296. else
  1297. ieee80211_set_wmm_default(sdata);
  1298. if (elems.ht_info_elem && elems.wmm_param &&
  1299. (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) &&
  1300. !(ifmgd->flags & IEEE80211_STA_DISABLE_11N))
  1301. changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem,
  1302. wk->bss->cbss.bssid,
  1303. ap_ht_cap_flags);
  1304. /* delete work item -- must be before set_associated for PS */
  1305. list_del(&wk->list);
  1306. /* set AID and assoc capability,
  1307. * ieee80211_set_associated() will tell the driver */
  1308. bss_conf->aid = aid;
  1309. bss_conf->assoc_capability = capab_info;
  1310. /* this will take ownership of wk */
  1311. ieee80211_set_associated(sdata, wk, changed);
  1312. /*
  1313. * Start timer to probe the connection to the AP now.
  1314. * Also start the timer that will detect beacon loss.
  1315. */
  1316. ieee80211_sta_rx_notify(sdata, (struct ieee80211_hdr *)mgmt);
  1317. mod_beacon_timer(sdata);
  1318. return RX_MGMT_CFG80211_ASSOC;
  1319. }
  1320. static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
  1321. struct ieee80211_mgmt *mgmt,
  1322. size_t len,
  1323. struct ieee80211_rx_status *rx_status,
  1324. struct ieee802_11_elems *elems,
  1325. bool beacon)
  1326. {
  1327. struct ieee80211_local *local = sdata->local;
  1328. int freq;
  1329. struct ieee80211_bss *bss;
  1330. struct ieee80211_channel *channel;
  1331. if (elems->ds_params && elems->ds_params_len == 1)
  1332. freq = ieee80211_channel_to_frequency(elems->ds_params[0]);
  1333. else
  1334. freq = rx_status->freq;
  1335. channel = ieee80211_get_channel(local->hw.wiphy, freq);
  1336. if (!channel || channel->flags & IEEE80211_CHAN_DISABLED)
  1337. return;
  1338. bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems,
  1339. channel, beacon);
  1340. if (bss)
  1341. ieee80211_rx_bss_put(local, bss);
  1342. if (!sdata->u.mgd.associated)
  1343. return;
  1344. if (elems->ch_switch_elem && (elems->ch_switch_elem_len == 3) &&
  1345. (memcmp(mgmt->bssid, sdata->u.mgd.associated->cbss.bssid,
  1346. ETH_ALEN) == 0)) {
  1347. struct ieee80211_channel_sw_ie *sw_elem =
  1348. (struct ieee80211_channel_sw_ie *)elems->ch_switch_elem;
  1349. ieee80211_sta_process_chanswitch(sdata, sw_elem, bss);
  1350. }
  1351. }
  1352. static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
  1353. struct ieee80211_mgd_work *wk,
  1354. struct ieee80211_mgmt *mgmt, size_t len,
  1355. struct ieee80211_rx_status *rx_status)
  1356. {
  1357. struct ieee80211_if_managed *ifmgd;
  1358. size_t baselen;
  1359. struct ieee802_11_elems elems;
  1360. ifmgd = &sdata->u.mgd;
  1361. ASSERT_MGD_MTX(ifmgd);
  1362. if (memcmp(mgmt->da, sdata->dev->dev_addr, ETH_ALEN))
  1363. return; /* ignore ProbeResp to foreign address */
  1364. baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
  1365. if (baselen > len)
  1366. return;
  1367. ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
  1368. &elems);
  1369. ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false);
  1370. /* direct probe may be part of the association flow */
  1371. if (wk && wk->state == IEEE80211_MGD_STATE_PROBE) {
  1372. printk(KERN_DEBUG "%s: direct probe responded\n",
  1373. sdata->dev->name);
  1374. wk->tries = 0;
  1375. wk->state = IEEE80211_MGD_STATE_AUTH;
  1376. WARN_ON(ieee80211_authenticate(sdata, wk) != RX_MGMT_NONE);
  1377. }
  1378. if (ifmgd->associated &&
  1379. memcmp(mgmt->bssid, ifmgd->associated->cbss.bssid, ETH_ALEN) == 0 &&
  1380. ifmgd->flags & (IEEE80211_STA_BEACON_POLL |
  1381. IEEE80211_STA_CONNECTION_POLL)) {
  1382. ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL |
  1383. IEEE80211_STA_BEACON_POLL);
  1384. mutex_lock(&sdata->local->iflist_mtx);
  1385. ieee80211_recalc_ps(sdata->local, -1);
  1386. mutex_unlock(&sdata->local->iflist_mtx);
  1387. /*
  1388. * We've received a probe response, but are not sure whether
  1389. * we have or will be receiving any beacons or data, so let's
  1390. * schedule the timers again, just in case.
  1391. */
  1392. mod_beacon_timer(sdata);
  1393. mod_timer(&ifmgd->conn_mon_timer,
  1394. round_jiffies_up(jiffies +
  1395. IEEE80211_CONNECTION_IDLE_TIME));
  1396. }
  1397. }
  1398. /*
  1399. * This is the canonical list of information elements we care about,
  1400. * the filter code also gives us all changes to the Microsoft OUI
  1401. * (00:50:F2) vendor IE which is used for WMM which we need to track.
  1402. *
  1403. * We implement beacon filtering in software since that means we can
  1404. * avoid processing the frame here and in cfg80211, and userspace
  1405. * will not be able to tell whether the hardware supports it or not.
  1406. *
  1407. * XXX: This list needs to be dynamic -- userspace needs to be able to
  1408. * add items it requires. It also needs to be able to tell us to
  1409. * look out for other vendor IEs.
  1410. */
  1411. static const u64 care_about_ies =
  1412. (1ULL << WLAN_EID_COUNTRY) |
  1413. (1ULL << WLAN_EID_ERP_INFO) |
  1414. (1ULL << WLAN_EID_CHANNEL_SWITCH) |
  1415. (1ULL << WLAN_EID_PWR_CONSTRAINT) |
  1416. (1ULL << WLAN_EID_HT_CAPABILITY) |
  1417. (1ULL << WLAN_EID_HT_INFORMATION);
  1418. static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
  1419. struct ieee80211_mgmt *mgmt,
  1420. size_t len,
  1421. struct ieee80211_rx_status *rx_status)
  1422. {
  1423. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  1424. size_t baselen;
  1425. struct ieee802_11_elems elems;
  1426. struct ieee80211_local *local = sdata->local;
  1427. u32 changed = 0;
  1428. bool erp_valid, directed_tim = false;
  1429. u8 erp_value = 0;
  1430. u32 ncrc;
  1431. u8 *bssid;
  1432. ASSERT_MGD_MTX(ifmgd);
  1433. /* Process beacon from the current BSS */
  1434. baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt;
  1435. if (baselen > len)
  1436. return;
  1437. if (rx_status->freq != local->hw.conf.channel->center_freq)
  1438. return;
  1439. /*
  1440. * We might have received a number of frames, among them a
  1441. * disassoc frame and a beacon...
  1442. */
  1443. if (!ifmgd->associated)
  1444. return;
  1445. bssid = ifmgd->associated->cbss.bssid;
  1446. /*
  1447. * And in theory even frames from a different AP we were just
  1448. * associated to a split-second ago!
  1449. */
  1450. if (memcmp(bssid, mgmt->bssid, ETH_ALEN) != 0)
  1451. return;
  1452. if (ifmgd->flags & IEEE80211_STA_BEACON_POLL) {
  1453. #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
  1454. if (net_ratelimit()) {
  1455. printk(KERN_DEBUG "%s: cancelling probereq poll due "
  1456. "to a received beacon\n", sdata->dev->name);
  1457. }
  1458. #endif
  1459. ifmgd->flags &= ~IEEE80211_STA_BEA