diff options
Diffstat (limited to 'net/mac80211/mlme.c')
-rw-r--r-- | net/mac80211/mlme.c | 1048 |
1 files changed, 566 insertions, 482 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 4d2b582dd055..d7c371e36bf0 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -78,7 +78,7 @@ static void ieee80211_send_probe_req(struct net_device *dev, u8 *dst, | |||
78 | static struct ieee80211_sta_bss * | 78 | static struct ieee80211_sta_bss * |
79 | ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int freq, | 79 | ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int freq, |
80 | u8 *ssid, u8 ssid_len); | 80 | u8 *ssid, u8 ssid_len); |
81 | static void ieee80211_rx_bss_put(struct net_device *dev, | 81 | static void ieee80211_rx_bss_put(struct ieee80211_local *local, |
82 | struct ieee80211_sta_bss *bss); | 82 | struct ieee80211_sta_bss *bss); |
83 | static int ieee80211_sta_find_ibss(struct net_device *dev, | 83 | static int ieee80211_sta_find_ibss(struct net_device *dev, |
84 | struct ieee80211_if_sta *ifsta); | 84 | struct ieee80211_if_sta *ifsta); |
@@ -87,6 +87,7 @@ static int ieee80211_sta_start_scan(struct net_device *dev, | |||
87 | u8 *ssid, size_t ssid_len); | 87 | u8 *ssid, size_t ssid_len); |
88 | static int ieee80211_sta_config_auth(struct net_device *dev, | 88 | static int ieee80211_sta_config_auth(struct net_device *dev, |
89 | struct ieee80211_if_sta *ifsta); | 89 | struct ieee80211_if_sta *ifsta); |
90 | static void sta_rx_agg_session_timer_expired(unsigned long data); | ||
90 | 91 | ||
91 | 92 | ||
92 | void ieee802_11_parse_elems(u8 *start, size_t len, | 93 | void ieee802_11_parse_elems(u8 *start, size_t len, |
@@ -203,6 +204,25 @@ void ieee802_11_parse_elems(u8 *start, size_t len, | |||
203 | elems->perr = pos; | 204 | elems->perr = pos; |
204 | elems->perr_len = elen; | 205 | elems->perr_len = elen; |
205 | break; | 206 | break; |
207 | case WLAN_EID_CHANNEL_SWITCH: | ||
208 | elems->ch_switch_elem = pos; | ||
209 | elems->ch_switch_elem_len = elen; | ||
210 | break; | ||
211 | case WLAN_EID_QUIET: | ||
212 | if (!elems->quiet_elem) { | ||
213 | elems->quiet_elem = pos; | ||
214 | elems->quiet_elem_len = elen; | ||
215 | } | ||
216 | elems->num_of_quiet_elem++; | ||
217 | break; | ||
218 | case WLAN_EID_COUNTRY: | ||
219 | elems->country_elem = pos; | ||
220 | elems->country_elem_len = elen; | ||
221 | break; | ||
222 | case WLAN_EID_PWR_CONSTRAINT: | ||
223 | elems->pwr_constr_elem = pos; | ||
224 | elems->pwr_constr_elem_len = elen; | ||
225 | break; | ||
206 | default: | 226 | default: |
207 | break; | 227 | break; |
208 | } | 228 | } |
@@ -256,19 +276,8 @@ static void ieee80211_sta_def_wmm_params(struct net_device *dev, | |||
256 | qparam.cw_max = 1023; | 276 | qparam.cw_max = 1023; |
257 | qparam.txop = 0; | 277 | qparam.txop = 0; |
258 | 278 | ||
259 | for (i = IEEE80211_TX_QUEUE_DATA0; i < NUM_TX_DATA_QUEUES; i++) | 279 | for (i = 0; i < local_to_hw(local)->queues; i++) |
260 | local->ops->conf_tx(local_to_hw(local), | 280 | local->ops->conf_tx(local_to_hw(local), i, &qparam); |
261 | i + IEEE80211_TX_QUEUE_DATA0, | ||
262 | &qparam); | ||
263 | |||
264 | if (ibss) { | ||
265 | /* IBSS uses different parameters for Beacon sending */ | ||
266 | qparam.cw_min++; | ||
267 | qparam.cw_min *= 2; | ||
268 | qparam.cw_min--; | ||
269 | local->ops->conf_tx(local_to_hw(local), | ||
270 | IEEE80211_TX_QUEUE_BEACON, &qparam); | ||
271 | } | ||
272 | } | 281 | } |
273 | } | 282 | } |
274 | 283 | ||
@@ -282,6 +291,12 @@ static void ieee80211_sta_wmm_params(struct net_device *dev, | |||
282 | int count; | 291 | int count; |
283 | u8 *pos; | 292 | u8 *pos; |
284 | 293 | ||
294 | if (!(ifsta->flags & IEEE80211_STA_WMM_ENABLED)) | ||
295 | return; | ||
296 | |||
297 | if (!wmm_param) | ||
298 | return; | ||
299 | |||
285 | if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1) | 300 | if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1) |
286 | return; | 301 | return; |
287 | count = wmm_param[6] & 0x0f; | 302 | count = wmm_param[6] & 0x0f; |
@@ -305,37 +320,33 @@ static void ieee80211_sta_wmm_params(struct net_device *dev, | |||
305 | 320 | ||
306 | switch (aci) { | 321 | switch (aci) { |
307 | case 1: | 322 | case 1: |
308 | queue = IEEE80211_TX_QUEUE_DATA3; | 323 | queue = 3; |
309 | if (acm) { | 324 | if (acm) |
310 | local->wmm_acm |= BIT(0) | BIT(3); | 325 | local->wmm_acm |= BIT(0) | BIT(3); |
311 | } | ||
312 | break; | 326 | break; |
313 | case 2: | 327 | case 2: |
314 | queue = IEEE80211_TX_QUEUE_DATA1; | 328 | queue = 1; |
315 | if (acm) { | 329 | if (acm) |
316 | local->wmm_acm |= BIT(4) | BIT(5); | 330 | local->wmm_acm |= BIT(4) | BIT(5); |
317 | } | ||
318 | break; | 331 | break; |
319 | case 3: | 332 | case 3: |
320 | queue = IEEE80211_TX_QUEUE_DATA0; | 333 | queue = 0; |
321 | if (acm) { | 334 | if (acm) |
322 | local->wmm_acm |= BIT(6) | BIT(7); | 335 | local->wmm_acm |= BIT(6) | BIT(7); |
323 | } | ||
324 | break; | 336 | break; |
325 | case 0: | 337 | case 0: |
326 | default: | 338 | default: |
327 | queue = IEEE80211_TX_QUEUE_DATA2; | 339 | queue = 2; |
328 | if (acm) { | 340 | if (acm) |
329 | local->wmm_acm |= BIT(1) | BIT(2); | 341 | local->wmm_acm |= BIT(1) | BIT(2); |
330 | } | ||
331 | break; | 342 | break; |
332 | } | 343 | } |
333 | 344 | ||
334 | params.aifs = pos[0] & 0x0f; | 345 | params.aifs = pos[0] & 0x0f; |
335 | params.cw_max = ecw2cw((pos[1] & 0xf0) >> 4); | 346 | params.cw_max = ecw2cw((pos[1] & 0xf0) >> 4); |
336 | params.cw_min = ecw2cw(pos[1] & 0x0f); | 347 | params.cw_min = ecw2cw(pos[1] & 0x0f); |
337 | params.txop = pos[2] | (pos[3] << 8); | 348 | params.txop = get_unaligned_le16(pos + 2); |
338 | #ifdef CONFIG_MAC80211_DEBUG | 349 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
339 | printk(KERN_DEBUG "%s: WMM queue=%d aci=%d acm=%d aifs=%d " | 350 | printk(KERN_DEBUG "%s: WMM queue=%d aci=%d acm=%d aifs=%d " |
340 | "cWmin=%d cWmax=%d txop=%d\n", | 351 | "cWmin=%d cWmax=%d txop=%d\n", |
341 | dev->name, queue, aci, acm, params.aifs, params.cw_min, | 352 | dev->name, queue, aci, acm, params.aifs, params.cw_min, |
@@ -355,11 +366,14 @@ static u32 ieee80211_handle_protect_preamb(struct ieee80211_sub_if_data *sdata, | |||
355 | bool use_short_preamble) | 366 | bool use_short_preamble) |
356 | { | 367 | { |
357 | struct ieee80211_bss_conf *bss_conf = &sdata->bss_conf; | 368 | struct ieee80211_bss_conf *bss_conf = &sdata->bss_conf; |
369 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | ||
358 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 370 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
359 | DECLARE_MAC_BUF(mac); | 371 | DECLARE_MAC_BUF(mac); |
372 | #endif | ||
360 | u32 changed = 0; | 373 | u32 changed = 0; |
361 | 374 | ||
362 | if (use_protection != bss_conf->use_cts_prot) { | 375 | if (use_protection != bss_conf->use_cts_prot) { |
376 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | ||
363 | if (net_ratelimit()) { | 377 | if (net_ratelimit()) { |
364 | printk(KERN_DEBUG "%s: CTS protection %s (BSSID=" | 378 | printk(KERN_DEBUG "%s: CTS protection %s (BSSID=" |
365 | "%s)\n", | 379 | "%s)\n", |
@@ -367,11 +381,13 @@ static u32 ieee80211_handle_protect_preamb(struct ieee80211_sub_if_data *sdata, | |||
367 | use_protection ? "enabled" : "disabled", | 381 | use_protection ? "enabled" : "disabled", |
368 | print_mac(mac, ifsta->bssid)); | 382 | print_mac(mac, ifsta->bssid)); |
369 | } | 383 | } |
384 | #endif | ||
370 | bss_conf->use_cts_prot = use_protection; | 385 | bss_conf->use_cts_prot = use_protection; |
371 | changed |= BSS_CHANGED_ERP_CTS_PROT; | 386 | changed |= BSS_CHANGED_ERP_CTS_PROT; |
372 | } | 387 | } |
373 | 388 | ||
374 | if (use_short_preamble != bss_conf->use_short_preamble) { | 389 | if (use_short_preamble != bss_conf->use_short_preamble) { |
390 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | ||
375 | if (net_ratelimit()) { | 391 | if (net_ratelimit()) { |
376 | printk(KERN_DEBUG "%s: switched to %s barker preamble" | 392 | printk(KERN_DEBUG "%s: switched to %s barker preamble" |
377 | " (BSSID=%s)\n", | 393 | " (BSSID=%s)\n", |
@@ -379,6 +395,7 @@ static u32 ieee80211_handle_protect_preamb(struct ieee80211_sub_if_data *sdata, | |||
379 | use_short_preamble ? "short" : "long", | 395 | use_short_preamble ? "short" : "long", |
380 | print_mac(mac, ifsta->bssid)); | 396 | print_mac(mac, ifsta->bssid)); |
381 | } | 397 | } |
398 | #endif | ||
382 | bss_conf->use_short_preamble = use_short_preamble; | 399 | bss_conf->use_short_preamble = use_short_preamble; |
383 | changed |= BSS_CHANGED_ERP_PREAMBLE; | 400 | changed |= BSS_CHANGED_ERP_PREAMBLE; |
384 | } | 401 | } |
@@ -537,7 +554,7 @@ static void ieee80211_set_associated(struct net_device *dev, | |||
537 | 554 | ||
538 | changed |= ieee80211_handle_bss_capability(sdata, bss); | 555 | changed |= ieee80211_handle_bss_capability(sdata, bss); |
539 | 556 | ||
540 | ieee80211_rx_bss_put(dev, bss); | 557 | ieee80211_rx_bss_put(local, bss); |
541 | } | 558 | } |
542 | 559 | ||
543 | if (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) { | 560 | if (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) { |
@@ -547,16 +564,15 @@ static void ieee80211_set_associated(struct net_device *dev, | |||
547 | sdata->bss_conf.ht_bss_conf = &conf->ht_bss_conf; | 564 | sdata->bss_conf.ht_bss_conf = &conf->ht_bss_conf; |
548 | } | 565 | } |
549 | 566 | ||
550 | netif_carrier_on(dev); | ||
551 | ifsta->flags |= IEEE80211_STA_PREV_BSSID_SET; | 567 | ifsta->flags |= IEEE80211_STA_PREV_BSSID_SET; |
552 | memcpy(ifsta->prev_bssid, sdata->u.sta.bssid, ETH_ALEN); | 568 | memcpy(ifsta->prev_bssid, sdata->u.sta.bssid, ETH_ALEN); |
553 | memcpy(wrqu.ap_addr.sa_data, sdata->u.sta.bssid, ETH_ALEN); | 569 | memcpy(wrqu.ap_addr.sa_data, sdata->u.sta.bssid, ETH_ALEN); |
554 | ieee80211_sta_send_associnfo(dev, ifsta); | 570 | ieee80211_sta_send_associnfo(dev, ifsta); |
555 | } else { | 571 | } else { |
572 | netif_carrier_off(dev); | ||
556 | ieee80211_sta_tear_down_BA_sessions(dev, ifsta->bssid); | 573 | ieee80211_sta_tear_down_BA_sessions(dev, ifsta->bssid); |
557 | ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; | 574 | ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; |
558 | netif_carrier_off(dev); | 575 | changed |= ieee80211_reset_erp_info(dev); |
559 | ieee80211_reset_erp_info(dev); | ||
560 | 576 | ||
561 | sdata->bss_conf.assoc_ht = 0; | 577 | sdata->bss_conf.assoc_ht = 0; |
562 | sdata->bss_conf.ht_conf = NULL; | 578 | sdata->bss_conf.ht_conf = NULL; |
@@ -569,6 +585,10 @@ static void ieee80211_set_associated(struct net_device *dev, | |||
569 | 585 | ||
570 | sdata->bss_conf.assoc = assoc; | 586 | sdata->bss_conf.assoc = assoc; |
571 | ieee80211_bss_info_change_notify(sdata, changed); | 587 | ieee80211_bss_info_change_notify(sdata, changed); |
588 | |||
589 | if (assoc) | ||
590 | netif_carrier_on(dev); | ||
591 | |||
572 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; | 592 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
573 | wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); | 593 | wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); |
574 | } | 594 | } |
@@ -586,7 +606,7 @@ void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb, | |||
586 | int encrypt) | 606 | int encrypt) |
587 | { | 607 | { |
588 | struct ieee80211_sub_if_data *sdata; | 608 | struct ieee80211_sub_if_data *sdata; |
589 | struct ieee80211_tx_packet_data *pkt_data; | 609 | struct ieee80211_tx_info *info; |
590 | 610 | ||
591 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 611 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
592 | skb->dev = sdata->local->mdev; | 612 | skb->dev = sdata->local->mdev; |
@@ -594,11 +614,11 @@ void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb, | |||
594 | skb_set_network_header(skb, 0); | 614 | skb_set_network_header(skb, 0); |
595 | skb_set_transport_header(skb, 0); | 615 | skb_set_transport_header(skb, 0); |
596 | 616 | ||
597 | pkt_data = (struct ieee80211_tx_packet_data *) skb->cb; | 617 | info = IEEE80211_SKB_CB(skb); |
598 | memset(pkt_data, 0, sizeof(struct ieee80211_tx_packet_data)); | 618 | memset(info, 0, sizeof(struct ieee80211_tx_info)); |
599 | pkt_data->ifindex = sdata->dev->ifindex; | 619 | info->control.ifindex = sdata->dev->ifindex; |
600 | if (!encrypt) | 620 | if (!encrypt) |
601 | pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT; | 621 | info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; |
602 | 622 | ||
603 | dev_queue_xmit(skb); | 623 | dev_queue_xmit(skb); |
604 | } | 624 | } |
@@ -727,9 +747,8 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
727 | if (bss) { | 747 | if (bss) { |
728 | if (bss->capability & WLAN_CAPABILITY_PRIVACY) | 748 | if (bss->capability & WLAN_CAPABILITY_PRIVACY) |
729 | capab |= WLAN_CAPABILITY_PRIVACY; | 749 | capab |= WLAN_CAPABILITY_PRIVACY; |
730 | if (bss->wmm_ie) { | 750 | if (bss->wmm_ie) |
731 | wmm = 1; | 751 | wmm = 1; |
732 | } | ||
733 | 752 | ||
734 | /* get all rates supported by the device and the AP as | 753 | /* get all rates supported by the device and the AP as |
735 | * some APs don't like getting a superset of their rates | 754 | * some APs don't like getting a superset of their rates |
@@ -737,7 +756,11 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
737 | * b-only mode) */ | 756 | * b-only mode) */ |
738 | rates_len = ieee80211_compatible_rates(bss, sband, &rates); | 757 | rates_len = ieee80211_compatible_rates(bss, sband, &rates); |
739 | 758 | ||
740 | ieee80211_rx_bss_put(dev, bss); | 759 | if ((bss->capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && |
760 | (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)) | ||
761 | capab |= WLAN_CAPABILITY_SPECTRUM_MGMT; | ||
762 | |||
763 | ieee80211_rx_bss_put(local, bss); | ||
741 | } else { | 764 | } else { |
742 | rates = ~0; | 765 | rates = ~0; |
743 | rates_len = sband->n_bitrates; | 766 | rates_len = sband->n_bitrates; |
@@ -804,6 +827,26 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
804 | } | 827 | } |
805 | } | 828 | } |
806 | 829 | ||
830 | if (capab & WLAN_CAPABILITY_SPECTRUM_MGMT) { | ||
831 | /* 1. power capabilities */ | ||
832 | pos = skb_put(skb, 4); | ||
833 | *pos++ = WLAN_EID_PWR_CAPABILITY; | ||
834 | *pos++ = 2; | ||
835 | *pos++ = 0; /* min tx power */ | ||
836 | *pos++ = local->hw.conf.channel->max_power; /* max tx power */ | ||
837 | |||
838 | /* 2. supported channels */ | ||
839 | /* TODO: get this in reg domain format */ | ||
840 | pos = skb_put(skb, 2 * sband->n_channels + 2); | ||
841 | *pos++ = WLAN_EID_SUPPORTED_CHANNELS; | ||
842 | *pos++ = 2 * sband->n_channels; | ||
843 | for (i = 0; i < sband->n_channels; i++) { | ||
844 | *pos++ = ieee80211_frequency_to_channel( | ||
845 | sband->channels[i].center_freq); | ||
846 | *pos++ = 1; /* one channel in the subband*/ | ||
847 | } | ||
848 | } | ||
849 | |||
807 | if (ifsta->extra_ie) { | 850 | if (ifsta->extra_ie) { |
808 | pos = skb_put(skb, ifsta->extra_ie_len); | 851 | pos = skb_put(skb, ifsta->extra_ie_len); |
809 | memcpy(pos, ifsta->extra_ie, ifsta->extra_ie_len); | 852 | memcpy(pos, ifsta->extra_ie, ifsta->extra_ie_len); |
@@ -821,9 +864,32 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
821 | *pos++ = 1; /* WME ver */ | 864 | *pos++ = 1; /* WME ver */ |
822 | *pos++ = 0; | 865 | *pos++ = 0; |
823 | } | 866 | } |
867 | |||
824 | /* wmm support is a must to HT */ | 868 | /* wmm support is a must to HT */ |
825 | if (wmm && sband->ht_info.ht_supported) { | 869 | if (wmm && (ifsta->flags & IEEE80211_STA_WMM_ENABLED) && |
826 | __le16 tmp = cpu_to_le16(sband->ht_info.cap); | 870 | sband->ht_info.ht_supported && bss->ht_add_ie) { |
871 | struct ieee80211_ht_addt_info *ht_add_info = | ||
872 | (struct ieee80211_ht_addt_info *)bss->ht_add_ie; | ||
873 | u16 cap = sband->ht_info.cap; | ||
874 | __le16 tmp; | ||
875 | u32 flags = local->hw.conf.channel->flags; | ||
876 | |||
877 | switch (ht_add_info->ht_param & IEEE80211_HT_IE_CHA_SEC_OFFSET) { | ||
878 | case IEEE80211_HT_IE_CHA_SEC_ABOVE: | ||
879 | if (flags & IEEE80211_CHAN_NO_FAT_ABOVE) { | ||
880 | cap &= ~IEEE80211_HT_CAP_SUP_WIDTH; | ||
881 | cap &= ~IEEE80211_HT_CAP_SGI_40; | ||
882 | } | ||
883 | break; | ||
884 | case IEEE80211_HT_IE_CHA_SEC_BELOW: | ||
885 | if (flags & IEEE80211_CHAN_NO_FAT_BELOW) { | ||
886 | cap &= ~IEEE80211_HT_CAP_SUP_WIDTH; | ||
887 | cap &= ~IEEE80211_HT_CAP_SGI_40; | ||
888 | } | ||
889 | break; | ||
890 | } | ||
891 | |||
892 | tmp = cpu_to_le16(cap); | ||
827 | pos = skb_put(skb, sizeof(struct ieee80211_ht_cap)+2); | 893 | pos = skb_put(skb, sizeof(struct ieee80211_ht_cap)+2); |
828 | *pos++ = WLAN_EID_HT_CAPABILITY; | 894 | *pos++ = WLAN_EID_HT_CAPABILITY; |
829 | *pos++ = sizeof(struct ieee80211_ht_cap); | 895 | *pos++ = sizeof(struct ieee80211_ht_cap); |
@@ -926,7 +992,7 @@ static int ieee80211_privacy_mismatch(struct net_device *dev, | |||
926 | wep_privacy = !!ieee80211_sta_wep_configured(dev); | 992 | wep_privacy = !!ieee80211_sta_wep_configured(dev); |
927 | privacy_invoked = !!(ifsta->flags & IEEE80211_STA_PRIVACY_INVOKED); | 993 | privacy_invoked = !!(ifsta->flags & IEEE80211_STA_PRIVACY_INVOKED); |
928 | 994 | ||
929 | ieee80211_rx_bss_put(dev, bss); | 995 | ieee80211_rx_bss_put(local, bss); |
930 | 996 | ||
931 | if ((bss_privacy == wep_privacy) || (bss_privacy == privacy_invoked)) | 997 | if ((bss_privacy == wep_privacy) || (bss_privacy == privacy_invoked)) |
932 | return 0; | 998 | return 0; |
@@ -1118,14 +1184,10 @@ static void ieee80211_auth_challenge(struct net_device *dev, | |||
1118 | u8 *pos; | 1184 | u8 *pos; |
1119 | struct ieee802_11_elems elems; | 1185 | struct ieee802_11_elems elems; |
1120 | 1186 | ||
1121 | printk(KERN_DEBUG "%s: replying to auth challenge\n", dev->name); | ||
1122 | pos = mgmt->u.auth.variable; | 1187 | pos = mgmt->u.auth.variable; |
1123 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); | 1188 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); |
1124 | if (!elems.challenge) { | 1189 | if (!elems.challenge) |
1125 | printk(KERN_DEBUG "%s: no challenge IE in shared key auth " | ||
1126 | "frame\n", dev->name); | ||
1127 | return; | 1190 | return; |
1128 | } | ||
1129 | ieee80211_send_auth(dev, ifsta, 3, elems.challenge - 2, | 1191 | ieee80211_send_auth(dev, ifsta, 3, elems.challenge - 2, |
1130 | elems.challenge_len + 2, 1); | 1192 | elems.challenge_len + 2, 1); |
1131 | } | 1193 | } |
@@ -1141,8 +1203,8 @@ static void ieee80211_send_addba_resp(struct net_device *dev, u8 *da, u16 tid, | |||
1141 | struct ieee80211_mgmt *mgmt; | 1203 | struct ieee80211_mgmt *mgmt; |
1142 | u16 capab; | 1204 | u16 capab; |
1143 | 1205 | ||
1144 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom + 1 + | 1206 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom); |
1145 | sizeof(mgmt->u.action.u.addba_resp)); | 1207 | |
1146 | if (!skb) { | 1208 | if (!skb) { |
1147 | printk(KERN_DEBUG "%s: failed to allocate buffer " | 1209 | printk(KERN_DEBUG "%s: failed to allocate buffer " |
1148 | "for addba resp frame\n", dev->name); | 1210 | "for addba resp frame\n", dev->name); |
@@ -1190,9 +1252,7 @@ void ieee80211_send_addba_request(struct net_device *dev, const u8 *da, | |||
1190 | struct ieee80211_mgmt *mgmt; | 1252 | struct ieee80211_mgmt *mgmt; |
1191 | u16 capab; | 1253 | u16 capab; |
1192 | 1254 | ||
1193 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom + 1 + | 1255 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom); |
1194 | sizeof(mgmt->u.action.u.addba_req)); | ||
1195 | |||
1196 | 1256 | ||
1197 | if (!skb) { | 1257 | if (!skb) { |
1198 | printk(KERN_ERR "%s: failed to allocate buffer " | 1258 | printk(KERN_ERR "%s: failed to allocate buffer " |
@@ -1293,7 +1353,7 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev, | |||
1293 | 1353 | ||
1294 | 1354 | ||
1295 | /* examine state machine */ | 1355 | /* examine state machine */ |
1296 | spin_lock_bh(&sta->ampdu_mlme.ampdu_rx); | 1356 | spin_lock_bh(&sta->lock); |
1297 | 1357 | ||
1298 | if (sta->ampdu_mlme.tid_state_rx[tid] != HT_AGG_STATE_IDLE) { | 1358 | if (sta->ampdu_mlme.tid_state_rx[tid] != HT_AGG_STATE_IDLE) { |
1299 | #ifdef CONFIG_MAC80211_HT_DEBUG | 1359 | #ifdef CONFIG_MAC80211_HT_DEBUG |
@@ -1309,9 +1369,11 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev, | |||
1309 | sta->ampdu_mlme.tid_rx[tid] = | 1369 | sta->ampdu_mlme.tid_rx[tid] = |
1310 | kmalloc(sizeof(struct tid_ampdu_rx), GFP_ATOMIC); | 1370 | kmalloc(sizeof(struct tid_ampdu_rx), GFP_ATOMIC); |
1311 | if (!sta->ampdu_mlme.tid_rx[tid]) { | 1371 | if (!sta->ampdu_mlme.tid_rx[tid]) { |
1372 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1312 | if (net_ratelimit()) | 1373 | if (net_ratelimit()) |
1313 | printk(KERN_ERR "allocate rx mlme to tid %d failed\n", | 1374 | printk(KERN_ERR "allocate rx mlme to tid %d failed\n", |
1314 | tid); | 1375 | tid); |
1376 | #endif | ||
1315 | goto end; | 1377 | goto end; |
1316 | } | 1378 | } |
1317 | /* rx timer */ | 1379 | /* rx timer */ |
@@ -1327,9 +1389,11 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev, | |||
1327 | tid_agg_rx->reorder_buf = | 1389 | tid_agg_rx->reorder_buf = |
1328 | kmalloc(buf_size * sizeof(struct sk_buff *), GFP_ATOMIC); | 1390 | kmalloc(buf_size * sizeof(struct sk_buff *), GFP_ATOMIC); |
1329 | if (!tid_agg_rx->reorder_buf) { | 1391 | if (!tid_agg_rx->reorder_buf) { |
1392 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1330 | if (net_ratelimit()) | 1393 | if (net_ratelimit()) |
1331 | printk(KERN_ERR "can not allocate reordering buffer " | 1394 | printk(KERN_ERR "can not allocate reordering buffer " |
1332 | "to tid %d\n", tid); | 1395 | "to tid %d\n", tid); |
1396 | #endif | ||
1333 | kfree(sta->ampdu_mlme.tid_rx[tid]); | 1397 | kfree(sta->ampdu_mlme.tid_rx[tid]); |
1334 | goto end; | 1398 | goto end; |
1335 | } | 1399 | } |
@@ -1360,7 +1424,7 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev, | |||
1360 | tid_agg_rx->stored_mpdu_num = 0; | 1424 | tid_agg_rx->stored_mpdu_num = 0; |
1361 | status = WLAN_STATUS_SUCCESS; | 1425 | status = WLAN_STATUS_SUCCESS; |
1362 | end: | 1426 | end: |
1363 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_rx); | 1427 | spin_unlock_bh(&sta->lock); |
1364 | 1428 | ||
1365 | end_no_lock: | 1429 | end_no_lock: |
1366 | ieee80211_send_addba_resp(sta->sdata->dev, sta->addr, tid, | 1430 | ieee80211_send_addba_resp(sta->sdata->dev, sta->addr, tid, |
@@ -1392,18 +1456,16 @@ static void ieee80211_sta_process_addba_resp(struct net_device *dev, | |||
1392 | 1456 | ||
1393 | state = &sta->ampdu_mlme.tid_state_tx[tid]; | 1457 | state = &sta->ampdu_mlme.tid_state_tx[tid]; |
1394 | 1458 | ||
1395 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); | 1459 | spin_lock_bh(&sta->lock); |
1396 | 1460 | ||
1397 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { | 1461 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { |
1398 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1462 | spin_unlock_bh(&sta->lock); |
1399 | printk(KERN_DEBUG "state not HT_ADDBA_REQUESTED_MSK:" | ||
1400 | "%d\n", *state); | ||
1401 | goto addba_resp_exit; | 1463 | goto addba_resp_exit; |
1402 | } | 1464 | } |
1403 | 1465 | ||
1404 | if (mgmt->u.action.u.addba_resp.dialog_token != | 1466 | if (mgmt->u.action.u.addba_resp.dialog_token != |
1405 | sta->ampdu_mlme.tid_tx[tid]->dialog_token) { | 1467 | sta->ampdu_mlme.tid_tx[tid]->dialog_token) { |
1406 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1468 | spin_unlock_bh(&sta->lock); |
1407 | #ifdef CONFIG_MAC80211_HT_DEBUG | 1469 | #ifdef CONFIG_MAC80211_HT_DEBUG |
1408 | printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid); | 1470 | printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid); |
1409 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | 1471 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
@@ -1416,26 +1478,18 @@ static void ieee80211_sta_process_addba_resp(struct net_device *dev, | |||
1416 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | 1478 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
1417 | if (le16_to_cpu(mgmt->u.action.u.addba_resp.status) | 1479 | if (le16_to_cpu(mgmt->u.action.u.addba_resp.status) |
1418 | == WLAN_STATUS_SUCCESS) { | 1480 | == WLAN_STATUS_SUCCESS) { |
1419 | if (*state & HT_ADDBA_RECEIVED_MSK) | ||
1420 | printk(KERN_DEBUG "double addBA response\n"); | ||
1421 | |||
1422 | *state |= HT_ADDBA_RECEIVED_MSK; | 1481 | *state |= HT_ADDBA_RECEIVED_MSK; |
1423 | sta->ampdu_mlme.addba_req_num[tid] = 0; | 1482 | sta->ampdu_mlme.addba_req_num[tid] = 0; |
1424 | 1483 | ||
1425 | if (*state == HT_AGG_STATE_OPERATIONAL) { | 1484 | if (*state == HT_AGG_STATE_OPERATIONAL) |
1426 | printk(KERN_DEBUG "Aggregation on for tid %d \n", tid); | ||
1427 | ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); | 1485 | ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); |
1428 | } | ||
1429 | 1486 | ||
1430 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1487 | spin_unlock_bh(&sta->lock); |
1431 | printk(KERN_DEBUG "recipient accepted agg: tid %d \n", tid); | ||
1432 | } else { | 1488 | } else { |
1433 | printk(KERN_DEBUG "recipient rejected agg: tid %d \n", tid); | ||
1434 | |||
1435 | sta->ampdu_mlme.addba_req_num[tid]++; | 1489 | sta->ampdu_mlme.addba_req_num[tid]++; |
1436 | /* this will allow the state check in stop_BA_session */ | 1490 | /* this will allow the state check in stop_BA_session */ |
1437 | *state = HT_AGG_STATE_OPERATIONAL; | 1491 | *state = HT_AGG_STATE_OPERATIONAL; |
1438 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1492 | spin_unlock_bh(&sta->lock); |
1439 | ieee80211_stop_tx_ba_session(hw, sta->addr, tid, | 1493 | ieee80211_stop_tx_ba_session(hw, sta->addr, tid, |
1440 | WLAN_BACK_INITIATOR); | 1494 | WLAN_BACK_INITIATOR); |
1441 | } | 1495 | } |
@@ -1454,8 +1508,7 @@ void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid, | |||
1454 | struct ieee80211_mgmt *mgmt; | 1508 | struct ieee80211_mgmt *mgmt; |
1455 | u16 params; | 1509 | u16 params; |
1456 | 1510 | ||
1457 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom + 1 + | 1511 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom); |
1458 | sizeof(mgmt->u.action.u.delba)); | ||
1459 | 1512 | ||
1460 | if (!skb) { | 1513 | if (!skb) { |
1461 | printk(KERN_ERR "%s: failed to allocate buffer " | 1514 | printk(KERN_ERR "%s: failed to allocate buffer " |
@@ -1488,6 +1541,35 @@ void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid, | |||
1488 | ieee80211_sta_tx(dev, skb, 0); | 1541 | ieee80211_sta_tx(dev, skb, 0); |
1489 | } | 1542 | } |
1490 | 1543 | ||
1544 | void ieee80211_send_bar(struct net_device *dev, u8 *ra, u16 tid, u16 ssn) | ||
1545 | { | ||
1546 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
1547 | struct sk_buff *skb; | ||
1548 | struct ieee80211_bar *bar; | ||
1549 | u16 bar_control = 0; | ||
1550 | |||
1551 | skb = dev_alloc_skb(sizeof(*bar) + local->hw.extra_tx_headroom); | ||
1552 | if (!skb) { | ||
1553 | printk(KERN_ERR "%s: failed to allocate buffer for " | ||
1554 | "bar frame\n", dev->name); | ||
1555 | return; | ||
1556 | } | ||
1557 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
1558 | bar = (struct ieee80211_bar *)skb_put(skb, sizeof(*bar)); | ||
1559 | memset(bar, 0, sizeof(*bar)); | ||
1560 | bar->frame_control = IEEE80211_FC(IEEE80211_FTYPE_CTL, | ||
1561 | IEEE80211_STYPE_BACK_REQ); | ||
1562 | memcpy(bar->ra, ra, ETH_ALEN); | ||
1563 | memcpy(bar->ta, dev->dev_addr, ETH_ALEN); | ||
1564 | bar_control |= (u16)IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL; | ||
1565 | bar_control |= (u16)IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA; | ||
1566 | bar_control |= (u16)(tid << 12); | ||
1567 | bar->control = cpu_to_le16(bar_control); | ||
1568 | bar->start_seq_num = cpu_to_le16(ssn); | ||
1569 | |||
1570 | ieee80211_sta_tx(dev, skb, 0); | ||
1571 | } | ||
1572 | |||
1491 | void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *ra, u16 tid, | 1573 | void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *ra, u16 tid, |
1492 | u16 initiator, u16 reason) | 1574 | u16 initiator, u16 reason) |
1493 | { | 1575 | { |
@@ -1506,17 +1588,17 @@ void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *ra, u16 tid, | |||
1506 | } | 1588 | } |
1507 | 1589 | ||
1508 | /* check if TID is in operational state */ | 1590 | /* check if TID is in operational state */ |
1509 | spin_lock_bh(&sta->ampdu_mlme.ampdu_rx); | 1591 | spin_lock_bh(&sta->lock); |
1510 | if (sta->ampdu_mlme.tid_state_rx[tid] | 1592 | if (sta->ampdu_mlme.tid_state_rx[tid] |
1511 | != HT_AGG_STATE_OPERATIONAL) { | 1593 | != HT_AGG_STATE_OPERATIONAL) { |
1512 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_rx); | 1594 | spin_unlock_bh(&sta->lock); |
1513 | rcu_read_unlock(); | 1595 | rcu_read_unlock(); |
1514 | return; | 1596 | return; |
1515 | } | 1597 | } |
1516 | sta->ampdu_mlme.tid_state_rx[tid] = | 1598 | sta->ampdu_mlme.tid_state_rx[tid] = |
1517 | HT_AGG_STATE_REQ_STOP_BA_MSK | | 1599 | HT_AGG_STATE_REQ_STOP_BA_MSK | |
1518 | (initiator << HT_AGG_STATE_INITIATOR_SHIFT); | 1600 | (initiator << HT_AGG_STATE_INITIATOR_SHIFT); |
1519 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_rx); | 1601 | spin_unlock_bh(&sta->lock); |
1520 | 1602 | ||
1521 | /* stop HW Rx aggregation. ampdu_action existence | 1603 | /* stop HW Rx aggregation. ampdu_action existence |
1522 | * already verified in session init so we add the BUG_ON */ | 1604 | * already verified in session init so we add the BUG_ON */ |
@@ -1531,7 +1613,7 @@ void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *ra, u16 tid, | |||
1531 | ra, tid, NULL); | 1613 | ra, tid, NULL); |
1532 | if (ret) | 1614 | if (ret) |
1533 | printk(KERN_DEBUG "HW problem - can not stop rx " | 1615 | printk(KERN_DEBUG "HW problem - can not stop rx " |
1534 | "aggergation for tid %d\n", tid); | 1616 | "aggregation for tid %d\n", tid); |
1535 | 1617 | ||
1536 | /* shutdown timer has not expired */ | 1618 | /* shutdown timer has not expired */ |
1537 | if (initiator != WLAN_BACK_TIMER) | 1619 | if (initiator != WLAN_BACK_TIMER) |
@@ -1593,10 +1675,10 @@ static void ieee80211_sta_process_delba(struct net_device *dev, | |||
1593 | ieee80211_sta_stop_rx_ba_session(dev, sta->addr, tid, | 1675 | ieee80211_sta_stop_rx_ba_session(dev, sta->addr, tid, |
1594 | WLAN_BACK_INITIATOR, 0); | 1676 | WLAN_BACK_INITIATOR, 0); |
1595 | else { /* WLAN_BACK_RECIPIENT */ | 1677 | else { /* WLAN_BACK_RECIPIENT */ |
1596 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); | 1678 | spin_lock_bh(&sta->lock); |
1597 | sta->ampdu_mlme.tid_state_tx[tid] = | 1679 | sta->ampdu_mlme.tid_state_tx[tid] = |
1598 | HT_AGG_STATE_OPERATIONAL; | 1680 | HT_AGG_STATE_OPERATIONAL; |
1599 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1681 | spin_unlock_bh(&sta->lock); |
1600 | ieee80211_stop_tx_ba_session(&local->hw, sta->addr, tid, | 1682 | ieee80211_stop_tx_ba_session(&local->hw, sta->addr, tid, |
1601 | WLAN_BACK_RECIPIENT); | 1683 | WLAN_BACK_RECIPIENT); |
1602 | } | 1684 | } |
@@ -1633,20 +1715,24 @@ void sta_addba_resp_timer_expired(unsigned long data) | |||
1633 | 1715 | ||
1634 | state = &sta->ampdu_mlme.tid_state_tx[tid]; | 1716 | state = &sta->ampdu_mlme.tid_state_tx[tid]; |
1635 | /* check if the TID waits for addBA response */ | 1717 | /* check if the TID waits for addBA response */ |
1636 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); | 1718 | spin_lock_bh(&sta->lock); |
1637 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { | 1719 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { |
1638 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1720 | spin_unlock_bh(&sta->lock); |
1639 | *state = HT_AGG_STATE_IDLE; | 1721 | *state = HT_AGG_STATE_IDLE; |
1722 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1640 | printk(KERN_DEBUG "timer expired on tid %d but we are not " | 1723 | printk(KERN_DEBUG "timer expired on tid %d but we are not " |
1641 | "expecting addBA response there", tid); | 1724 | "expecting addBA response there", tid); |
1725 | #endif | ||
1642 | goto timer_expired_exit; | 1726 | goto timer_expired_exit; |
1643 | } | 1727 | } |
1644 | 1728 | ||
1729 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1645 | printk(KERN_DEBUG "addBA response timer expired on tid %d\n", tid); | 1730 | printk(KERN_DEBUG "addBA response timer expired on tid %d\n", tid); |
1731 | #endif | ||
1646 | 1732 | ||
1647 | /* go through the state check in stop_BA_session */ | 1733 | /* go through the state check in stop_BA_session */ |
1648 | *state = HT_AGG_STATE_OPERATIONAL; | 1734 | *state = HT_AGG_STATE_OPERATIONAL; |
1649 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1735 | spin_unlock_bh(&sta->lock); |
1650 | ieee80211_stop_tx_ba_session(hw, temp_sta->addr, tid, | 1736 | ieee80211_stop_tx_ba_session(hw, temp_sta->addr, tid, |
1651 | WLAN_BACK_INITIATOR); | 1737 | WLAN_BACK_INITIATOR); |
1652 | 1738 | ||
@@ -1659,7 +1745,7 @@ timer_expired_exit: | |||
1659 | * resetting it after each frame that arrives from the originator. | 1745 | * resetting it after each frame that arrives from the originator. |
1660 | * if this timer expires ieee80211_sta_stop_rx_ba_session will be executed. | 1746 | * if this timer expires ieee80211_sta_stop_rx_ba_session will be executed. |
1661 | */ | 1747 | */ |
1662 | void sta_rx_agg_session_timer_expired(unsigned long data) | 1748 | static void sta_rx_agg_session_timer_expired(unsigned long data) |
1663 | { | 1749 | { |
1664 | /* not an elegant detour, but there is no choice as the timer passes | 1750 | /* not an elegant detour, but there is no choice as the timer passes |
1665 | * only one argument, and various sta_info are needed here, so init | 1751 | * only one argument, and various sta_info are needed here, so init |
@@ -1670,7 +1756,9 @@ void sta_rx_agg_session_timer_expired(unsigned long data) | |||
1670 | struct sta_info *sta = container_of(timer_to_id, struct sta_info, | 1756 | struct sta_info *sta = container_of(timer_to_id, struct sta_info, |
1671 | timer_to_tid[0]); | 1757 | timer_to_tid[0]); |
1672 | 1758 | ||
1759 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1673 | printk(KERN_DEBUG "rx session timer expired on tid %d\n", (u16)*ptid); | 1760 | printk(KERN_DEBUG "rx session timer expired on tid %d\n", (u16)*ptid); |
1761 | #endif | ||
1674 | ieee80211_sta_stop_rx_ba_session(sta->sdata->dev, sta->addr, | 1762 | ieee80211_sta_stop_rx_ba_session(sta->sdata->dev, sta->addr, |
1675 | (u16)*ptid, WLAN_BACK_TIMER, | 1763 | (u16)*ptid, WLAN_BACK_TIMER, |
1676 | WLAN_REASON_QSTA_TIMEOUT); | 1764 | WLAN_REASON_QSTA_TIMEOUT); |
@@ -1690,6 +1778,71 @@ void ieee80211_sta_tear_down_BA_sessions(struct net_device *dev, u8 *addr) | |||
1690 | } | 1778 | } |
1691 | } | 1779 | } |
1692 | 1780 | ||
1781 | static void ieee80211_send_refuse_measurement_request(struct net_device *dev, | ||
1782 | struct ieee80211_msrment_ie *request_ie, | ||
1783 | const u8 *da, const u8 *bssid, | ||
1784 | u8 dialog_token) | ||
1785 | { | ||
1786 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
1787 | struct sk_buff *skb; | ||
1788 | struct ieee80211_mgmt *msr_report; | ||
1789 | |||
1790 | skb = dev_alloc_skb(sizeof(*msr_report) + local->hw.extra_tx_headroom + | ||
1791 | sizeof(struct ieee80211_msrment_ie)); | ||
1792 | |||
1793 | if (!skb) { | ||
1794 | printk(KERN_ERR "%s: failed to allocate buffer for " | ||
1795 | "measurement report frame\n", dev->name); | ||
1796 | return; | ||
1797 | } | ||
1798 | |||
1799 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
1800 | msr_report = (struct ieee80211_mgmt *)skb_put(skb, 24); | ||
1801 | memset(msr_report, 0, 24); | ||
1802 | memcpy(msr_report->da, da, ETH_ALEN); | ||
1803 | memcpy(msr_report->sa, dev->dev_addr, ETH_ALEN); | ||
1804 | memcpy(msr_report->bssid, bssid, ETH_ALEN); | ||
1805 | msr_report->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, | ||
1806 | IEEE80211_STYPE_ACTION); | ||
1807 | |||
1808 | skb_put(skb, 1 + sizeof(msr_report->u.action.u.measurement)); | ||
1809 | msr_report->u.action.category = WLAN_CATEGORY_SPECTRUM_MGMT; | ||
1810 | msr_report->u.action.u.measurement.action_code = | ||
1811 | WLAN_ACTION_SPCT_MSR_RPRT; | ||
1812 | msr_report->u.action.u.measurement.dialog_token = dialog_token; | ||
1813 | |||
1814 | msr_report->u.action.u.measurement.element_id = WLAN_EID_MEASURE_REPORT; | ||
1815 | msr_report->u.action.u.measurement.length = | ||
1816 | sizeof(struct ieee80211_msrment_ie); | ||
1817 | |||
1818 | memset(&msr_report->u.action.u.measurement.msr_elem, 0, | ||
1819 | sizeof(struct ieee80211_msrment_ie)); | ||
1820 | msr_report->u.action.u.measurement.msr_elem.token = request_ie->token; | ||
1821 | msr_report->u.action.u.measurement.msr_elem.mode |= | ||
1822 | IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED; | ||
1823 | msr_report->u.action.u.measurement.msr_elem.type = request_ie->type; | ||
1824 | |||
1825 | ieee80211_sta_tx(dev, skb, 0); | ||
1826 | } | ||
1827 | |||
1828 | static void ieee80211_sta_process_measurement_req(struct net_device *dev, | ||
1829 | struct ieee80211_mgmt *mgmt, | ||
1830 | size_t len) | ||
1831 | { | ||
1832 | /* | ||
1833 | * Ignoring measurement request is spec violation. | ||
1834 | * Mandatory measurements must be reported optional | ||
1835 | * measurements might be refused or reported incapable | ||
1836 | * For now just refuse | ||
1837 | * TODO: Answer basic measurement as unmeasured | ||
1838 | */ | ||
1839 | ieee80211_send_refuse_measurement_request(dev, | ||
1840 | &mgmt->u.action.u.measurement.msr_elem, | ||
1841 | mgmt->sa, mgmt->bssid, | ||
1842 | mgmt->u.action.u.measurement.dialog_token); | ||
1843 | } | ||
1844 | |||
1845 | |||
1693 | static void ieee80211_rx_mgmt_auth(struct net_device *dev, | 1846 | static void ieee80211_rx_mgmt_auth(struct net_device *dev, |
1694 | struct ieee80211_if_sta *ifsta, | 1847 | struct ieee80211_if_sta *ifsta, |
1695 | struct ieee80211_mgmt *mgmt, | 1848 | struct ieee80211_mgmt *mgmt, |
@@ -1700,73 +1853,41 @@ static void ieee80211_rx_mgmt_auth(struct net_device *dev, | |||
1700 | DECLARE_MAC_BUF(mac); | 1853 | DECLARE_MAC_BUF(mac); |
1701 | 1854 | ||
1702 | if (ifsta->state != IEEE80211_AUTHENTICATE && | 1855 | if (ifsta->state != IEEE80211_AUTHENTICATE && |
1703 | sdata->vif.type != IEEE80211_IF_TYPE_IBSS) { | 1856 | sdata->vif.type != IEEE80211_IF_TYPE_IBSS) |
1704 | printk(KERN_DEBUG "%s: authentication frame received from " | ||
1705 | "%s, but not in authenticate state - ignored\n", | ||
1706 | dev->name, print_mac(mac, mgmt->sa)); | ||
1707 | return; | 1857 | return; |
1708 | } | ||
1709 | 1858 | ||
1710 | if (len < 24 + 6) { | 1859 | if (len < 24 + 6) |
1711 | printk(KERN_DEBUG "%s: too short (%zd) authentication frame " | ||
1712 | "received from %s - ignored\n", | ||
1713 | dev->name, len, print_mac(mac, mgmt->sa)); | ||
1714 | return; | 1860 | return; |
1715 | } | ||
1716 | 1861 | ||
1717 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && | 1862 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && |
1718 | memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) { | 1863 | memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) |
1719 | printk(KERN_DEBUG "%s: authentication frame received from " | ||
1720 | "unknown AP (SA=%s BSSID=%s) - " | ||
1721 | "ignored\n", dev->name, print_mac(mac, mgmt->sa), | ||
1722 | print_mac(mac, mgmt->bssid)); | ||
1723 | return; | 1864 | return; |
1724 | } | ||
1725 | 1865 | ||
1726 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && | 1866 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && |
1727 | memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) { | 1867 | memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) |
1728 | printk(KERN_DEBUG "%s: authentication frame received from " | ||
1729 | "unknown BSSID (SA=%s BSSID=%s) - " | ||
1730 | "ignored\n", dev->name, print_mac(mac, mgmt->sa), | ||
1731 | print_mac(mac, mgmt->bssid)); | ||
1732 | return; | 1868 | return; |
1733 | } | ||
1734 | 1869 | ||
1735 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); | 1870 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); |
1736 | auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); | 1871 | auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); |
1737 | status_code = le16_to_cpu(mgmt->u.auth.status_code); | 1872 | status_code = le16_to_cpu(mgmt->u.auth.status_code); |
1738 | 1873 | ||
1739 | printk(KERN_DEBUG "%s: RX authentication from %s (alg=%d " | ||
1740 | "transaction=%d status=%d)\n", | ||
1741 | dev->name, print_mac(mac, mgmt->sa), auth_alg, | ||
1742 | auth_transaction, status_code); | ||
1743 | |||
1744 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS) { | 1874 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS) { |
1745 | /* IEEE 802.11 standard does not require authentication in IBSS | 1875 | /* |
1876 | * IEEE 802.11 standard does not require authentication in IBSS | ||
1746 | * networks and most implementations do not seem to use it. | 1877 | * networks and most implementations do not seem to use it. |
1747 | * However, try to reply to authentication attempts if someone | 1878 | * However, try to reply to authentication attempts if someone |
1748 | * has actually implemented this. | 1879 | * has actually implemented this. |
1749 | * TODO: Could implement shared key authentication. */ | 1880 | */ |
1750 | if (auth_alg != WLAN_AUTH_OPEN || auth_transaction != 1) { | 1881 | if (auth_alg != WLAN_AUTH_OPEN || auth_transaction != 1) |
1751 | printk(KERN_DEBUG "%s: unexpected IBSS authentication " | ||
1752 | "frame (alg=%d transaction=%d)\n", | ||
1753 | dev->name, auth_alg, auth_transaction); | ||
1754 | return; | 1882 | return; |
1755 | } | ||
1756 | ieee80211_send_auth(dev, ifsta, 2, NULL, 0, 0); | 1883 | ieee80211_send_auth(dev, ifsta, 2, NULL, 0, 0); |
1757 | } | 1884 | } |
1758 | 1885 | ||
1759 | if (auth_alg != ifsta->auth_alg || | 1886 | if (auth_alg != ifsta->auth_alg || |
1760 | auth_transaction != ifsta->auth_transaction) { | 1887 | auth_transaction != ifsta->auth_transaction) |
1761 | printk(KERN_DEBUG "%s: unexpected authentication frame " | ||
1762 | "(alg=%d transaction=%d)\n", | ||
1763 | dev->name, auth_alg, auth_transaction); | ||
1764 | return; | 1888 | return; |
1765 | } | ||
1766 | 1889 | ||
1767 | if (status_code != WLAN_STATUS_SUCCESS) { | 1890 | if (status_code != WLAN_STATUS_SUCCESS) { |
1768 | printk(KERN_DEBUG "%s: AP denied authentication (auth_alg=%d " | ||
1769 | "code=%d)\n", dev->name, ifsta->auth_alg, status_code); | ||
1770 | if (status_code == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { | 1891 | if (status_code == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { |
1771 | u8 algs[3]; | 1892 | u8 algs[3]; |
1772 | const int num_algs = ARRAY_SIZE(algs); | 1893 | const int num_algs = ARRAY_SIZE(algs); |
@@ -1795,9 +1916,6 @@ static void ieee80211_rx_mgmt_auth(struct net_device *dev, | |||
1795 | !ieee80211_sta_wep_configured(dev)) | 1916 | !ieee80211_sta_wep_configured(dev)) |
1796 | continue; | 1917 | continue; |
1797 | ifsta->auth_alg = algs[pos]; | 1918 | ifsta->auth_alg = algs[pos]; |
1798 | printk(KERN_DEBUG "%s: set auth_alg=%d for " | ||
1799 | "next try\n", | ||
1800 | dev->name, ifsta->auth_alg); | ||
1801 | break; | 1919 | break; |
1802 | } | 1920 | } |
1803 | } | 1921 | } |
@@ -1827,30 +1945,16 @@ static void ieee80211_rx_mgmt_deauth(struct net_device *dev, | |||
1827 | u16 reason_code; | 1945 | u16 reason_code; |
1828 | DECLARE_MAC_BUF(mac); | 1946 | DECLARE_MAC_BUF(mac); |
1829 | 1947 | ||
1830 | if (len < 24 + 2) { | 1948 | if (len < 24 + 2) |
1831 | printk(KERN_DEBUG "%s: too short (%zd) deauthentication frame " | ||
1832 | "received from %s - ignored\n", | ||
1833 | dev->name, len, print_mac(mac, mgmt->sa)); | ||
1834 | return; | 1949 | return; |
1835 | } | ||
1836 | 1950 | ||
1837 | if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) { | 1951 | if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN)) |
1838 | printk(KERN_DEBUG "%s: deauthentication frame received from " | ||
1839 | "unknown AP (SA=%s BSSID=%s) - " | ||
1840 | "ignored\n", dev->name, print_mac(mac, mgmt->sa), | ||
1841 | print_mac(mac, mgmt->bssid)); | ||
1842 | return; | 1952 | return; |
1843 | } | ||
1844 | 1953 | ||
1845 | reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); | 1954 | reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); |
1846 | 1955 | ||
1847 | printk(KERN_DEBUG "%s: RX deauthentication from %s" | 1956 | if (ifsta->flags & IEEE80211_STA_AUTHENTICATED) |
1848 | " (reason=%d)\n", | ||
1849 | dev->name, print_mac(mac, mgmt->sa), reason_code); | ||
1850 | |||
1851 | if (ifsta->flags & IEEE80211_STA_AUTHENTICATED) { | ||
1852 | printk(KERN_DEBUG "%s: deauthenticated\n", dev->name); | 1957 | printk(KERN_DEBUG "%s: deauthenticated\n", dev->name); |
1853 | } | ||
1854 | 1958 | ||
1855 | if (ifsta->state == IEEE80211_AUTHENTICATE || | 1959 | if (ifsta->state == IEEE80211_AUTHENTICATE || |
1856 | ifsta->state == IEEE80211_ASSOCIATE || | 1960 | ifsta->state == IEEE80211_ASSOCIATE || |
@@ -1873,27 +1977,14 @@ static void ieee80211_rx_mgmt_disassoc(struct net_device *dev, | |||
1873 | u16 reason_code; | 1977 | u16 reason_code; |
1874 | DECLARE_MAC_BUF(mac); | 1978 | DECLARE_MAC_BUF(mac); |
1875 | 1979 | ||
1876 | if (len < 24 + 2) { | 1980 | if (len < 24 + 2) |
1877 | printk(KERN_DEBUG "%s: too short (%zd) disassociation frame " | ||
1878 | "received from %s - ignored\n", | ||
1879 | dev->name, len, print_mac(mac, mgmt->sa)); | ||
1880 | return; | 1981 | return; |
1881 | } | ||
1882 | 1982 | ||
1883 | if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) { | 1983 | if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN)) |
1884 | printk(KERN_DEBUG "%s: disassociation frame received from " | ||
1885 | "unknown AP (SA=%s BSSID=%s) - " | ||
1886 | "ignored\n", dev->name, print_mac(mac, mgmt->sa), | ||
1887 | print_mac(mac, mgmt->bssid)); | ||
1888 | return; | 1984 | return; |
1889 | } | ||
1890 | 1985 | ||
1891 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); | 1986 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); |
1892 | 1987 | ||
1893 | printk(KERN_DEBUG "%s: RX disassociation from %s" | ||
1894 | " (reason=%d)\n", | ||
1895 | dev->name, print_mac(mac, mgmt->sa), reason_code); | ||
1896 | |||
1897 | if (ifsta->flags & IEEE80211_STA_ASSOCIATED) | 1988 | if (ifsta->flags & IEEE80211_STA_ASSOCIATED) |
1898 | printk(KERN_DEBUG "%s: disassociated\n", dev->name); | 1989 | printk(KERN_DEBUG "%s: disassociated\n", dev->name); |
1899 | 1990 | ||
@@ -1929,27 +2020,14 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1929 | /* AssocResp and ReassocResp have identical structure, so process both | 2020 | /* AssocResp and ReassocResp have identical structure, so process both |
1930 | * of them in this function. */ | 2021 | * of them in this function. */ |
1931 | 2022 | ||
1932 | if (ifsta->state != IEEE80211_ASSOCIATE) { | 2023 | if (ifsta->state != IEEE80211_ASSOCIATE) |
1933 | printk(KERN_DEBUG "%s: association frame received from " | ||
1934 | "%s, but not in associate state - ignored\n", | ||
1935 | dev->name, print_mac(mac, mgmt->sa)); | ||
1936 | return; | 2024 | return; |
1937 | } | ||
1938 | 2025 | ||
1939 | if (len < 24 + 6) { | 2026 | if (len < 24 + 6) |
1940 | printk(KERN_DEBUG "%s: too short (%zd) association frame " | ||
1941 | "received from %s - ignored\n", | ||
1942 | dev->name, len, print_mac(mac, mgmt->sa)); | ||
1943 | return; | 2027 | return; |
1944 | } | ||
1945 | 2028 | ||
1946 | if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) { | 2029 | if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) |
1947 | printk(KERN_DEBUG "%s: association frame received from " | ||
1948 | "unknown AP (SA=%s BSSID=%s) - " | ||
1949 | "ignored\n", dev->name, print_mac(mac, mgmt->sa), | ||
1950 | print_mac(mac, mgmt->bssid)); | ||
1951 | return; | 2030 | return; |
1952 | } | ||
1953 | 2031 | ||
1954 | capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); | 2032 | capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); |
1955 | status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); | 2033 | status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); |
@@ -2013,10 +2091,10 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
2013 | local->hw.conf.channel->center_freq, | 2091 | local->hw.conf.channel->center_freq, |
2014 | ifsta->ssid, ifsta->ssid_len); | 2092 | ifsta->ssid, ifsta->ssid_len); |
2015 | if (bss) { | 2093 | if (bss) { |
2016 | sta->last_rssi = bss->rssi; | ||
2017 | sta->last_signal = bss->signal; | 2094 | sta->last_signal = bss->signal; |
2095 | sta->last_qual = bss->qual; | ||
2018 | sta->last_noise = bss->noise; | 2096 | sta->last_noise = bss->noise; |
2019 | ieee80211_rx_bss_put(dev, bss); | 2097 | ieee80211_rx_bss_put(local, bss); |
2020 | } | 2098 | } |
2021 | 2099 | ||
2022 | err = sta_info_insert(sta); | 2100 | err = sta_info_insert(sta); |
@@ -2038,8 +2116,8 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
2038 | * to between the sta_info_alloc() and sta_info_insert() above. | 2116 | * to between the sta_info_alloc() and sta_info_insert() above. |
2039 | */ | 2117 | */ |
2040 | 2118 | ||
2041 | sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_AP | | 2119 | set_sta_flags(sta, WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_AP | |
2042 | WLAN_STA_AUTHORIZED; | 2120 | WLAN_STA_AUTHORIZED); |
2043 | 2121 | ||
2044 | rates = 0; | 2122 | rates = 0; |
2045 | basic_rates = 0; | 2123 | basic_rates = 0; |
@@ -2083,7 +2161,8 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
2083 | else | 2161 | else |
2084 | sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; | 2162 | sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; |
2085 | 2163 | ||
2086 | if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param) { | 2164 | if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param && |
2165 | (ifsta->flags & IEEE80211_STA_WMM_ENABLED)) { | ||
2087 | struct ieee80211_ht_bss_info bss_info; | 2166 | struct ieee80211_ht_bss_info bss_info; |
2088 | ieee80211_ht_cap_ie_to_ht_info( | 2167 | ieee80211_ht_cap_ie_to_ht_info( |
2089 | (struct ieee80211_ht_cap *) | 2168 | (struct ieee80211_ht_cap *) |
@@ -2096,8 +2175,8 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
2096 | 2175 | ||
2097 | rate_control_rate_init(sta, local); | 2176 | rate_control_rate_init(sta, local); |
2098 | 2177 | ||
2099 | if (elems.wmm_param && (ifsta->flags & IEEE80211_STA_WMM_ENABLED)) { | 2178 | if (elems.wmm_param) { |
2100 | sta->flags |= WLAN_STA_WME; | 2179 | set_sta_flags(sta, WLAN_STA_WME); |
2101 | rcu_read_unlock(); | 2180 | rcu_read_unlock(); |
2102 | ieee80211_sta_wmm_params(dev, ifsta, elems.wmm_param, | 2181 | ieee80211_sta_wmm_params(dev, ifsta, elems.wmm_param, |
2103 | elems.wmm_param_len); | 2182 | elems.wmm_param_len); |
@@ -2133,10 +2212,9 @@ static void __ieee80211_rx_bss_hash_add(struct net_device *dev, | |||
2133 | 2212 | ||
2134 | 2213 | ||
2135 | /* Caller must hold local->sta_bss_lock */ | 2214 | /* Caller must hold local->sta_bss_lock */ |
2136 | static void __ieee80211_rx_bss_hash_del(struct net_device *dev, | 2215 | static void __ieee80211_rx_bss_hash_del(struct ieee80211_local *local, |
2137 | struct ieee80211_sta_bss *bss) | 2216 | struct ieee80211_sta_bss *bss) |
2138 | { | 2217 | { |
2139 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
2140 | struct ieee80211_sta_bss *b, *prev = NULL; | 2218 | struct ieee80211_sta_bss *b, *prev = NULL; |
2141 | b = local->sta_bss_hash[STA_HASH(bss->bssid)]; | 2219 | b = local->sta_bss_hash[STA_HASH(bss->bssid)]; |
2142 | while (b) { | 2220 | while (b) { |
@@ -2281,45 +2359,42 @@ static void ieee80211_rx_bss_free(struct ieee80211_sta_bss *bss) | |||
2281 | kfree(bss->rsn_ie); | 2359 | kfree(bss->rsn_ie); |
2282 | kfree(bss->wmm_ie); | 2360 | kfree(bss->wmm_ie); |
2283 | kfree(bss->ht_ie); | 2361 | kfree(bss->ht_ie); |
2362 | kfree(bss->ht_add_ie); | ||
2284 | kfree(bss_mesh_id(bss)); | 2363 | kfree(bss_mesh_id(bss)); |
2285 | kfree(bss_mesh_cfg(bss)); | 2364 | kfree(bss_mesh_cfg(bss)); |
2286 | kfree(bss); | 2365 | kfree(bss); |
2287 | } | 2366 | } |
2288 | 2367 | ||
2289 | 2368 | ||
2290 | static void ieee80211_rx_bss_put(struct net_device *dev, | 2369 | static void ieee80211_rx_bss_put(struct ieee80211_local *local, |
2291 | struct ieee80211_sta_bss *bss) | 2370 | struct ieee80211_sta_bss *bss) |
2292 | { | 2371 | { |
2293 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
2294 | |||
2295 | local_bh_disable(); | 2372 | local_bh_disable(); |
2296 | if (!atomic_dec_and_lock(&bss->users, &local->sta_bss_lock)) { | 2373 | if (!atomic_dec_and_lock(&bss->users, &local->sta_bss_lock)) { |
2297 | local_bh_enable(); | 2374 | local_bh_enable(); |
2298 | return; | 2375 | return; |
2299 | } | 2376 | } |
2300 | 2377 | ||
2301 | __ieee80211_rx_bss_hash_del(dev, bss); | 2378 | __ieee80211_rx_bss_hash_del(local, bss); |
2302 | list_del(&bss->list); | 2379 | list_del(&bss->list); |
2303 | spin_unlock_bh(&local->sta_bss_lock); | 2380 | spin_unlock_bh(&local->sta_bss_lock); |
2304 | ieee80211_rx_bss_free(bss); | 2381 | ieee80211_rx_bss_free(bss); |
2305 | } | 2382 | } |
2306 | 2383 | ||
2307 | 2384 | ||
2308 | void ieee80211_rx_bss_list_init(struct net_device *dev) | 2385 | void ieee80211_rx_bss_list_init(struct ieee80211_local *local) |
2309 | { | 2386 | { |
2310 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
2311 | spin_lock_init(&local->sta_bss_lock); | 2387 | spin_lock_init(&local->sta_bss_lock); |
2312 | INIT_LIST_HEAD(&local->sta_bss_list); | 2388 | INIT_LIST_HEAD(&local->sta_bss_list); |
2313 | } | 2389 | } |
2314 | 2390 | ||
2315 | 2391 | ||
2316 | void ieee80211_rx_bss_list_deinit(struct net_device *dev) | 2392 | void ieee80211_rx_bss_list_deinit(struct ieee80211_local *local) |
2317 | { | 2393 | { |
2318 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
2319 | struct ieee80211_sta_bss *bss, *tmp; | 2394 | struct ieee80211_sta_bss *bss, *tmp; |
2320 | 2395 | ||
2321 | list_for_each_entry_safe(bss, tmp, &local->sta_bss_list, list) | 2396 | list_for_each_entry_safe(bss, tmp, &local->sta_bss_list, list) |
2322 | ieee80211_rx_bss_put(dev, bss); | 2397 | ieee80211_rx_bss_put(local, bss); |
2323 | } | 2398 | } |
2324 | 2399 | ||
2325 | 2400 | ||
@@ -2331,8 +2406,6 @@ static int ieee80211_sta_join_ibss(struct net_device *dev, | |||
2331 | int res, rates, i, j; | 2406 | int res, rates, i, j; |
2332 | struct sk_buff *skb; | 2407 | struct sk_buff *skb; |
2333 | struct ieee80211_mgmt *mgmt; | 2408 | struct ieee80211_mgmt *mgmt; |
2334 | struct ieee80211_tx_control control; | ||
2335 | struct rate_selection ratesel; | ||
2336 | u8 *pos; | 2409 | u8 *pos; |
2337 | struct ieee80211_sub_if_data *sdata; | 2410 | struct ieee80211_sub_if_data *sdata; |
2338 | struct ieee80211_supported_band *sband; | 2411 | struct ieee80211_supported_band *sband; |
@@ -2350,7 +2423,7 @@ static int ieee80211_sta_join_ibss(struct net_device *dev, | |||
2350 | local->ops->reset_tsf(local_to_hw(local)); | 2423 | local->ops->reset_tsf(local_to_hw(local)); |
2351 | } | 2424 | } |
2352 | memcpy(ifsta->bssid, bss->bssid, ETH_ALEN); | 2425 | memcpy(ifsta->bssid, bss->bssid, ETH_ALEN); |
2353 | res = ieee80211_if_config(dev); | 2426 | res = ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID); |
2354 | if (res) | 2427 | if (res) |
2355 | return res; | 2428 | return res; |
2356 | 2429 | ||
@@ -2364,24 +2437,22 @@ static int ieee80211_sta_join_ibss(struct net_device *dev, | |||
2364 | if (res) | 2437 | if (res) |
2365 | return res; | 2438 | return res; |
2366 | 2439 | ||
2367 | /* Set beacon template */ | 2440 | /* Build IBSS probe response */ |
2368 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); | 2441 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); |
2369 | do { | 2442 | if (skb) { |
2370 | if (!skb) | ||
2371 | break; | ||
2372 | |||
2373 | skb_reserve(skb, local->hw.extra_tx_headroom); | 2443 | skb_reserve(skb, local->hw.extra_tx_headroom); |
2374 | 2444 | ||
2375 | mgmt = (struct ieee80211_mgmt *) | 2445 | mgmt = (struct ieee80211_mgmt *) |
2376 | skb_put(skb, 24 + sizeof(mgmt->u.beacon)); | 2446 | skb_put(skb, 24 + sizeof(mgmt->u.beacon)); |
2377 | memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); | 2447 | memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); |
2378 | mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, | 2448 | mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, |
2379 | IEEE80211_STYPE_BEACON); | 2449 | IEEE80211_STYPE_PROBE_RESP); |
2380 | memset(mgmt->da, 0xff, ETH_ALEN); | 2450 | memset(mgmt->da, 0xff, ETH_ALEN); |
2381 | memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN); | 2451 | memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN); |
2382 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); | 2452 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); |
2383 | mgmt->u.beacon.beacon_int = | 2453 | mgmt->u.beacon.beacon_int = |
2384 | cpu_to_le16(local->hw.conf.beacon_int); | 2454 | cpu_to_le16(local->hw.conf.beacon_int); |
2455 | mgmt->u.beacon.timestamp = cpu_to_le64(bss->timestamp); | ||
2385 | mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability); | 2456 | mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability); |
2386 | 2457 | ||
2387 | pos = skb_put(skb, 2 + ifsta->ssid_len); | 2458 | pos = skb_put(skb, 2 + ifsta->ssid_len); |
@@ -2419,60 +2490,22 @@ static int ieee80211_sta_join_ibss(struct net_device *dev, | |||
2419 | memcpy(pos, &bss->supp_rates[8], rates); | 2490 | memcpy(pos, &bss->supp_rates[8], rates); |
2420 | } | 2491 | } |
2421 | 2492 | ||
2422 | memset(&control, 0, sizeof(control)); | 2493 | ifsta->probe_resp = skb; |
2423 | rate_control_get_rate(dev, sband, skb, &ratesel); | ||
2424 | if (!ratesel.rate) { | ||
2425 | printk(KERN_DEBUG "%s: Failed to determine TX rate " | ||
2426 | "for IBSS beacon\n", dev->name); | ||
2427 | break; | ||
2428 | } | ||
2429 | control.vif = &sdata->vif; | ||
2430 | control.tx_rate = ratesel.rate; | ||
2431 | if (sdata->bss_conf.use_short_preamble && | ||
2432 | ratesel.rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) | ||
2433 | control.flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; | ||
2434 | control.antenna_sel_tx = local->hw.conf.antenna_sel_tx; | ||
2435 | control.flags |= IEEE80211_TXCTL_NO_ACK; | ||
2436 | control.retry_limit = 1; | ||
2437 | |||
2438 | ifsta->probe_resp = skb_copy(skb, GFP_ATOMIC); | ||
2439 | if (ifsta->probe_resp) { | ||
2440 | mgmt = (struct ieee80211_mgmt *) | ||
2441 | ifsta->probe_resp->data; | ||
2442 | mgmt->frame_control = | ||
2443 | IEEE80211_FC(IEEE80211_FTYPE_MGMT, | ||
2444 | IEEE80211_STYPE_PROBE_RESP); | ||
2445 | } else { | ||
2446 | printk(KERN_DEBUG "%s: Could not allocate ProbeResp " | ||
2447 | "template for IBSS\n", dev->name); | ||
2448 | } | ||
2449 | |||
2450 | if (local->ops->beacon_update && | ||
2451 | local->ops->beacon_update(local_to_hw(local), | ||
2452 | skb, &control) == 0) { | ||
2453 | printk(KERN_DEBUG "%s: Configured IBSS beacon " | ||
2454 | "template\n", dev->name); | ||
2455 | skb = NULL; | ||
2456 | } | ||
2457 | |||
2458 | rates = 0; | ||
2459 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
2460 | for (i = 0; i < bss->supp_rates_len; i++) { | ||
2461 | int bitrate = (bss->supp_rates[i] & 0x7f) * 5; | ||
2462 | for (j = 0; j < sband->n_bitrates; j++) | ||
2463 | if (sband->bitrates[j].bitrate == bitrate) | ||
2464 | rates |= BIT(j); | ||
2465 | } | ||
2466 | ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates; | ||
2467 | 2494 | ||
2468 | ieee80211_sta_def_wmm_params(dev, bss, 1); | 2495 | ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON); |
2469 | } while (0); | 2496 | } |
2470 | 2497 | ||
2471 | if (skb) { | 2498 | rates = 0; |
2472 | printk(KERN_DEBUG "%s: Failed to configure IBSS beacon " | 2499 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
2473 | "template\n", dev->name); | 2500 | for (i = 0; i < bss->supp_rates_len; i++) { |
2474 | dev_kfree_skb(skb); | 2501 | int bitrate = (bss->supp_rates[i] & 0x7f) * 5; |
2502 | for (j = 0; j < sband->n_bitrates; j++) | ||
2503 | if (sband->bitrates[j].bitrate == bitrate) | ||
2504 | rates |= BIT(j); | ||
2475 | } | 2505 | } |
2506 | ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates; | ||
2507 | |||
2508 | ieee80211_sta_def_wmm_params(dev, bss, 1); | ||
2476 | 2509 | ||
2477 | ifsta->state = IEEE80211_IBSS_JOINED; | 2510 | ifsta->state = IEEE80211_IBSS_JOINED; |
2478 | mod_timer(&ifsta->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL); | 2511 | mod_timer(&ifsta->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL); |
@@ -2525,11 +2558,10 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2525 | struct ieee80211_mgmt *mgmt, | 2558 | struct ieee80211_mgmt *mgmt, |
2526 | size_t len, | 2559 | size_t len, |
2527 | struct ieee80211_rx_status *rx_status, | 2560 | struct ieee80211_rx_status *rx_status, |
2561 | struct ieee802_11_elems *elems, | ||
2528 | int beacon) | 2562 | int beacon) |
2529 | { | 2563 | { |
2530 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 2564 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
2531 | struct ieee802_11_elems elems; | ||
2532 | size_t baselen; | ||
2533 | int freq, clen; | 2565 | int freq, clen; |
2534 | struct ieee80211_sta_bss *bss; | 2566 | struct ieee80211_sta_bss *bss; |
2535 | struct sta_info *sta; | 2567 | struct sta_info *sta; |
@@ -2542,35 +2574,24 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2542 | if (!beacon && memcmp(mgmt->da, dev->dev_addr, ETH_ALEN)) | 2574 | if (!beacon && memcmp(mgmt->da, dev->dev_addr, ETH_ALEN)) |
2543 | return; /* ignore ProbeResp to foreign address */ | 2575 | return; /* ignore ProbeResp to foreign address */ |
2544 | 2576 | ||
2545 | #if 0 | ||
2546 | printk(KERN_DEBUG "%s: RX %s from %s to %s\n", | ||
2547 | dev->name, beacon ? "Beacon" : "Probe Response", | ||
2548 | print_mac(mac, mgmt->sa), print_mac(mac2, mgmt->da)); | ||
2549 | #endif | ||
2550 | |||
2551 | baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; | ||
2552 | if (baselen > len) | ||
2553 | return; | ||
2554 | |||
2555 | beacon_timestamp = le64_to_cpu(mgmt->u.beacon.timestamp); | 2577 | beacon_timestamp = le64_to_cpu(mgmt->u.beacon.timestamp); |
2556 | ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems); | ||
2557 | 2578 | ||
2558 | if (ieee80211_vif_is_mesh(&sdata->vif) && elems.mesh_id && | 2579 | if (ieee80211_vif_is_mesh(&sdata->vif) && elems->mesh_id && |
2559 | elems.mesh_config && mesh_matches_local(&elems, dev)) { | 2580 | elems->mesh_config && mesh_matches_local(elems, dev)) { |
2560 | u64 rates = ieee80211_sta_get_rates(local, &elems, | 2581 | u64 rates = ieee80211_sta_get_rates(local, elems, |
2561 | rx_status->band); | 2582 | rx_status->band); |
2562 | 2583 | ||
2563 | mesh_neighbour_update(mgmt->sa, rates, dev, | 2584 | mesh_neighbour_update(mgmt->sa, rates, dev, |
2564 | mesh_peer_accepts_plinks(&elems, dev)); | 2585 | mesh_peer_accepts_plinks(elems, dev)); |
2565 | } | 2586 | } |
2566 | 2587 | ||
2567 | rcu_read_lock(); | 2588 | rcu_read_lock(); |
2568 | 2589 | ||
2569 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && elems.supp_rates && | 2590 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && elems->supp_rates && |
2570 | memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0 && | 2591 | memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0 && |
2571 | (sta = sta_info_get(local, mgmt->sa))) { | 2592 | (sta = sta_info_get(local, mgmt->sa))) { |
2572 | u64 prev_rates; | 2593 | u64 prev_rates; |
2573 | u64 supp_rates = ieee80211_sta_get_rates(local, &elems, | 2594 | u64 supp_rates = ieee80211_sta_get_rates(local, elems, |
2574 | rx_status->band); | 2595 | rx_status->band); |
2575 | 2596 | ||
2576 | prev_rates = sta->supp_rates[rx_status->band]; | 2597 | prev_rates = sta->supp_rates[rx_status->band]; |
@@ -2582,21 +2603,12 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2582 | sta->supp_rates[rx_status->band] = | 2603 | sta->supp_rates[rx_status->band] = |
2583 | sdata->u.sta.supp_rates_bits[rx_status->band]; | 2604 | sdata->u.sta.supp_rates_bits[rx_status->band]; |
2584 | } | 2605 | } |
2585 | if (sta->supp_rates[rx_status->band] != prev_rates) { | ||
2586 | printk(KERN_DEBUG "%s: updated supp_rates set for " | ||
2587 | "%s based on beacon info (0x%llx & 0x%llx -> " | ||
2588 | "0x%llx)\n", | ||
2589 | dev->name, print_mac(mac, sta->addr), | ||
2590 | (unsigned long long) prev_rates, | ||
2591 | (unsigned long long) supp_rates, | ||
2592 | (unsigned long long) sta->supp_rates[rx_status->band]); | ||
2593 | } | ||
2594 | } | 2606 | } |
2595 | 2607 | ||
2596 | rcu_read_unlock(); | 2608 | rcu_read_unlock(); |
2597 | 2609 | ||
2598 | if (elems.ds_params && elems.ds_params_len == 1) | 2610 | if (elems->ds_params && elems->ds_params_len == 1) |
2599 | freq = ieee80211_channel_to_frequency(elems.ds_params[0]); | 2611 | freq = ieee80211_channel_to_frequency(elems->ds_params[0]); |
2600 | else | 2612 | else |
2601 | freq = rx_status->freq; | 2613 | freq = rx_status->freq; |
2602 | 2614 | ||
@@ -2606,23 +2618,23 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2606 | return; | 2618 | return; |
2607 | 2619 | ||
2608 | #ifdef CONFIG_MAC80211_MESH | 2620 | #ifdef CONFIG_MAC80211_MESH |
2609 | if (elems.mesh_config) | 2621 | if (elems->mesh_config) |
2610 | bss = ieee80211_rx_mesh_bss_get(dev, elems.mesh_id, | 2622 | bss = ieee80211_rx_mesh_bss_get(dev, elems->mesh_id, |
2611 | elems.mesh_id_len, elems.mesh_config, freq); | 2623 | elems->mesh_id_len, elems->mesh_config, freq); |
2612 | else | 2624 | else |
2613 | #endif | 2625 | #endif |
2614 | bss = ieee80211_rx_bss_get(dev, mgmt->bssid, freq, | 2626 | bss = ieee80211_rx_bss_get(dev, mgmt->bssid, freq, |
2615 | elems.ssid, elems.ssid_len); | 2627 | elems->ssid, elems->ssid_len); |
2616 | if (!bss) { | 2628 | if (!bss) { |
2617 | #ifdef CONFIG_MAC80211_MESH | 2629 | #ifdef CONFIG_MAC80211_MESH |
2618 | if (elems.mesh_config) | 2630 | if (elems->mesh_config) |
2619 | bss = ieee80211_rx_mesh_bss_add(dev, elems.mesh_id, | 2631 | bss = ieee80211_rx_mesh_bss_add(dev, elems->mesh_id, |
2620 | elems.mesh_id_len, elems.mesh_config, | 2632 | elems->mesh_id_len, elems->mesh_config, |
2621 | elems.mesh_config_len, freq); | 2633 | elems->mesh_config_len, freq); |
2622 | else | 2634 | else |
2623 | #endif | 2635 | #endif |
2624 | bss = ieee80211_rx_bss_add(dev, mgmt->bssid, freq, | 2636 | bss = ieee80211_rx_bss_add(dev, mgmt->bssid, freq, |
2625 | elems.ssid, elems.ssid_len); | 2637 | elems->ssid, elems->ssid_len); |
2626 | if (!bss) | 2638 | if (!bss) |
2627 | return; | 2639 | return; |
2628 | } else { | 2640 | } else { |
@@ -2635,46 +2647,66 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2635 | } | 2647 | } |
2636 | 2648 | ||
2637 | /* save the ERP value so that it is available at association time */ | 2649 | /* save the ERP value so that it is available at association time */ |
2638 | if (elems.erp_info && elems.erp_info_len >= 1) { | 2650 | if (elems->erp_info && elems->erp_info_len >= 1) { |
2639 | bss->erp_value = elems.erp_info[0]; | 2651 | bss->erp_value = elems->erp_info[0]; |
2640 | bss->has_erp_value = 1; | 2652 | bss->has_erp_value = 1; |
2641 | } | 2653 | } |
2642 | 2654 | ||
2643 | if (elems.ht_cap_elem && | 2655 | if (elems->ht_cap_elem && |
2644 | (!bss->ht_ie || bss->ht_ie_len != elems.ht_cap_elem_len || | 2656 | (!bss->ht_ie || bss->ht_ie_len != elems->ht_cap_elem_len || |
2645 | memcmp(bss->ht_ie, elems.ht_cap_elem, elems.ht_cap_elem_len))) { | 2657 | memcmp(bss->ht_ie, elems->ht_cap_elem, elems->ht_cap_elem_len))) { |
2646 | kfree(bss->ht_ie); | 2658 | kfree(bss->ht_ie); |
2647 | bss->ht_ie = kmalloc(elems.ht_cap_elem_len + 2, GFP_ATOMIC); | 2659 | bss->ht_ie = kmalloc(elems->ht_cap_elem_len + 2, GFP_ATOMIC); |
2648 | if (bss->ht_ie) { | 2660 | if (bss->ht_ie) { |
2649 | memcpy(bss->ht_ie, elems.ht_cap_elem - 2, | 2661 | memcpy(bss->ht_ie, elems->ht_cap_elem - 2, |
2650 | elems.ht_cap_elem_len + 2); | 2662 | elems->ht_cap_elem_len + 2); |
2651 | bss->ht_ie_len = elems.ht_cap_elem_len + 2; | 2663 | bss->ht_ie_len = elems->ht_cap_elem_len + 2; |
2652 | } else | 2664 | } else |
2653 | bss->ht_ie_len = 0; | 2665 | bss->ht_ie_len = 0; |
2654 | } else if (!elems.ht_cap_elem && bss->ht_ie) { | 2666 | } else if (!elems->ht_cap_elem && bss->ht_ie) { |
2655 | kfree(bss->ht_ie); | 2667 | kfree(bss->ht_ie); |
2656 | bss->ht_ie = NULL; | 2668 | bss->ht_ie = NULL; |
2657 | bss->ht_ie_len = 0; | 2669 | bss->ht_ie_len = 0; |
2658 | } | 2670 | } |
2659 | 2671 | ||
2672 | if (elems->ht_info_elem && | ||
2673 | (!bss->ht_add_ie || | ||
2674 | bss->ht_add_ie_len != elems->ht_info_elem_len || | ||
2675 | memcmp(bss->ht_add_ie, elems->ht_info_elem, | ||
2676 | elems->ht_info_elem_len))) { | ||
2677 | kfree(bss->ht_add_ie); | ||
2678 | bss->ht_add_ie = | ||
2679 | kmalloc(elems->ht_info_elem_len + 2, GFP_ATOMIC); | ||
2680 | if (bss->ht_add_ie) { | ||
2681 | memcpy(bss->ht_add_ie, elems->ht_info_elem - 2, | ||
2682 | elems->ht_info_elem_len + 2); | ||
2683 | bss->ht_add_ie_len = elems->ht_info_elem_len + 2; | ||
2684 | } else | ||
2685 | bss->ht_add_ie_len = 0; | ||
2686 | } else if (!elems->ht_info_elem && bss->ht_add_ie) { | ||
2687 | kfree(bss->ht_add_ie); | ||
2688 | bss->ht_add_ie = NULL; | ||
2689 | bss->ht_add_ie_len = 0; | ||
2690 | } | ||
2691 | |||
2660 | bss->beacon_int = le16_to_cpu(mgmt->u.beacon.beacon_int); | 2692 | bss->beacon_int = le16_to_cpu(mgmt->u.beacon.beacon_int); |
2661 | bss->capability = le16_to_cpu(mgmt->u.beacon.capab_info); | 2693 | bss->capability = le16_to_cpu(mgmt->u.beacon.capab_info); |
2662 | 2694 | ||
2663 | bss->supp_rates_len = 0; | 2695 | bss->supp_rates_len = 0; |
2664 | if (elems.supp_rates) { | 2696 | if (elems->supp_rates) { |
2665 | clen = IEEE80211_MAX_SUPP_RATES - bss->supp_rates_len; | 2697 | clen = IEEE80211_MAX_SUPP_RATES - bss->supp_rates_len; |
2666 | if (clen > elems.supp_rates_len) | 2698 | if (clen > elems->supp_rates_len) |
2667 | clen = elems.supp_rates_len; | 2699 | clen = elems->supp_rates_len; |
2668 | memcpy(&bss->supp_rates[bss->supp_rates_len], elems.supp_rates, | 2700 | memcpy(&bss->supp_rates[bss->supp_rates_len], elems->supp_rates, |
2669 | clen); | 2701 | clen); |
2670 | bss->supp_rates_len += clen; | 2702 | bss->supp_rates_len += clen; |
2671 | } | 2703 | } |
2672 | if (elems.ext_supp_rates) { | 2704 | if (elems->ext_supp_rates) { |
2673 | clen = IEEE80211_MAX_SUPP_RATES - bss->supp_rates_len; | 2705 | clen = IEEE80211_MAX_SUPP_RATES - bss->supp_rates_len; |
2674 | if (clen > elems.ext_supp_rates_len) | 2706 | if (clen > elems->ext_supp_rates_len) |
2675 | clen = elems.ext_supp_rates_len; | 2707 | clen = elems->ext_supp_rates_len; |
2676 | memcpy(&bss->supp_rates[bss->supp_rates_len], | 2708 | memcpy(&bss->supp_rates[bss->supp_rates_len], |
2677 | elems.ext_supp_rates, clen); | 2709 | elems->ext_supp_rates, clen); |
2678 | bss->supp_rates_len += clen; | 2710 | bss->supp_rates_len += clen; |
2679 | } | 2711 | } |
2680 | 2712 | ||
@@ -2682,9 +2714,9 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2682 | 2714 | ||
2683 | bss->timestamp = beacon_timestamp; | 2715 | bss->timestamp = beacon_timestamp; |
2684 | bss->last_update = jiffies; | 2716 | bss->last_update = jiffies; |
2685 | bss->rssi = rx_status->ssi; | ||
2686 | bss->signal = rx_status->signal; | 2717 | bss->signal = rx_status->signal; |
2687 | bss->noise = rx_status->noise; | 2718 | bss->noise = rx_status->noise; |
2719 | bss->qual = rx_status->qual; | ||
2688 | if (!beacon && !bss->probe_resp) | 2720 | if (!beacon && !bss->probe_resp) |
2689 | bss->probe_resp = true; | 2721 | bss->probe_resp = true; |
2690 | 2722 | ||
@@ -2694,37 +2726,37 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2694 | */ | 2726 | */ |
2695 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && | 2727 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && |
2696 | bss->probe_resp && beacon) { | 2728 | bss->probe_resp && beacon) { |
2697 | ieee80211_rx_bss_put(dev, bss); | 2729 | ieee80211_rx_bss_put(local, bss); |
2698 | return; | 2730 | return; |
2699 | } | 2731 | } |
2700 | 2732 | ||
2701 | if (elems.wpa && | 2733 | if (elems->wpa && |
2702 | (!bss->wpa_ie || bss->wpa_ie_len != elems.wpa_len || | 2734 | (!bss->wpa_ie || bss->wpa_ie_len != elems->wpa_len || |
2703 | memcmp(bss->wpa_ie, elems.wpa, elems.wpa_len))) { | 2735 | memcmp(bss->wpa_ie, elems->wpa, elems->wpa_len))) { |
2704 | kfree(bss->wpa_ie); | 2736 | kfree(bss->wpa_ie); |
2705 | bss->wpa_ie = kmalloc(elems.wpa_len + 2, GFP_ATOMIC); | 2737 | bss->wpa_ie = kmalloc(elems->wpa_len + 2, GFP_ATOMIC); |
2706 | if (bss->wpa_ie) { | 2738 | if (bss->wpa_ie) { |
2707 | memcpy(bss->wpa_ie, elems.wpa - 2, elems.wpa_len + 2); | 2739 | memcpy(bss->wpa_ie, elems->wpa - 2, elems->wpa_len + 2); |
2708 | bss->wpa_ie_len = elems.wpa_len + 2; | 2740 | bss->wpa_ie_len = elems->wpa_len + 2; |
2709 | } else | 2741 | } else |
2710 | bss->wpa_ie_len = 0; | 2742 | bss->wpa_ie_len = 0; |
2711 | } else if (!elems.wpa && bss->wpa_ie) { | 2743 | } else if (!elems->wpa && bss->wpa_ie) { |
2712 | kfree(bss->wpa_ie); | 2744 | kfree(bss->wpa_ie); |
2713 | bss->wpa_ie = NULL; | 2745 | bss->wpa_ie = NULL; |
2714 | bss->wpa_ie_len = 0; | 2746 | bss->wpa_ie_len = 0; |
2715 | } | 2747 | } |
2716 | 2748 | ||
2717 | if (elems.rsn && | 2749 | if (elems->rsn && |
2718 | (!bss->rsn_ie || bss->rsn_ie_len != elems.rsn_len || | 2750 | (!bss->rsn_ie || bss->rsn_ie_len != elems->rsn_len || |
2719 | memcmp(bss->rsn_ie, elems.rsn, elems.rsn_len))) { | 2751 | memcmp(bss->rsn_ie, elems->rsn, elems->rsn_len))) { |
2720 | kfree(bss->rsn_ie); | 2752 | kfree(bss->rsn_ie); |
2721 | bss->rsn_ie = kmalloc(elems.rsn_len + 2, GFP_ATOMIC); | 2753 | bss->rsn_ie = kmalloc(elems->rsn_len + 2, GFP_ATOMIC); |
2722 | if (bss->rsn_ie) { | 2754 | if (bss->rsn_ie) { |
2723 | memcpy(bss->rsn_ie, elems.rsn - 2, elems.rsn_len + 2); | 2755 | memcpy(bss->rsn_ie, elems->rsn - 2, elems->rsn_len + 2); |
2724 | bss->rsn_ie_len = elems.rsn_len + 2; | 2756 | bss->rsn_ie_len = elems->rsn_len + 2; |
2725 | } else | 2757 | } else |
2726 | bss->rsn_ie_len = 0; | 2758 | bss->rsn_ie_len = 0; |
2727 | } else if (!elems.rsn && bss->rsn_ie) { | 2759 | } else if (!elems->rsn && bss->rsn_ie) { |
2728 | kfree(bss->rsn_ie); | 2760 | kfree(bss->rsn_ie); |
2729 | bss->rsn_ie = NULL; | 2761 | bss->rsn_ie = NULL; |
2730 | bss->rsn_ie_len = 0; | 2762 | bss->rsn_ie_len = 0; |
@@ -2744,20 +2776,21 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2744 | * inclusion of the WMM Parameters in beacons, however, is optional. | 2776 | * inclusion of the WMM Parameters in beacons, however, is optional. |
2745 | */ | 2777 | */ |
2746 | 2778 | ||
2747 | if (elems.wmm_param && | 2779 | if (elems->wmm_param && |
2748 | (!bss->wmm_ie || bss->wmm_ie_len != elems.wmm_param_len || | 2780 | (!bss->wmm_ie || bss->wmm_ie_len != elems->wmm_param_len || |
2749 | memcmp(bss->wmm_ie, elems.wmm_param, elems.wmm_param_len))) { | 2781 | memcmp(bss->wmm_ie, elems->wmm_param, elems->wmm_param_len))) { |
2750 | kfree(bss->wmm_ie); | 2782 | kfree(bss->wmm_ie); |
2751 | bss->wmm_ie = kmalloc(elems.wmm_param_len + 2, GFP_ATOMIC); | 2783 | bss->wmm_ie = kmalloc(elems->wmm_param_len + 2, GFP_ATOMIC); |
2752 | if (bss->wmm_ie) { | 2784 | if (bss->wmm_ie) { |
2753 | memcpy(bss->wmm_ie, elems.wmm_param - 2, | 2785 | memcpy(bss->wmm_ie, elems->wmm_param - 2, |
2754 | elems.wmm_param_len + 2); | 2786 | elems->wmm_param_len + 2); |
2755 | bss->wmm_ie_len = elems.wmm_param_len + 2; | 2787 | bss->wmm_ie_len = elems->wmm_param_len + 2; |
2756 | } else | 2788 | } else |
2757 | bss->wmm_ie_len = 0; | 2789 | bss->wmm_ie_len = 0; |
2758 | } else if (elems.wmm_info && | 2790 | } else if (elems->wmm_info && |
2759 | (!bss->wmm_ie || bss->wmm_ie_len != elems.wmm_info_len || | 2791 | (!bss->wmm_ie || bss->wmm_ie_len != elems->wmm_info_len || |
2760 | memcmp(bss->wmm_ie, elems.wmm_info, elems.wmm_info_len))) { | 2792 | memcmp(bss->wmm_ie, elems->wmm_info, |
2793 | elems->wmm_info_len))) { | ||
2761 | /* As for certain AP's Fifth bit is not set in WMM IE in | 2794 | /* As for certain AP's Fifth bit is not set in WMM IE in |
2762 | * beacon frames.So while parsing the beacon frame the | 2795 | * beacon frames.So while parsing the beacon frame the |
2763 | * wmm_info structure is used instead of wmm_param. | 2796 | * wmm_info structure is used instead of wmm_param. |
@@ -2767,14 +2800,14 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2767 | * n-band association. | 2800 | * n-band association. |
2768 | */ | 2801 | */ |
2769 | kfree(bss->wmm_ie); | 2802 | kfree(bss->wmm_ie); |
2770 | bss->wmm_ie = kmalloc(elems.wmm_info_len + 2, GFP_ATOMIC); | 2803 | bss->wmm_ie = kmalloc(elems->wmm_info_len + 2, GFP_ATOMIC); |
2771 | if (bss->wmm_ie) { | 2804 | if (bss->wmm_ie) { |
2772 | memcpy(bss->wmm_ie, elems.wmm_info - 2, | 2805 | memcpy(bss->wmm_ie, elems->wmm_info - 2, |
2773 | elems.wmm_info_len + 2); | 2806 | elems->wmm_info_len + 2); |
2774 | bss->wmm_ie_len = elems.wmm_info_len + 2; | 2807 | bss->wmm_ie_len = elems->wmm_info_len + 2; |
2775 | } else | 2808 | } else |
2776 | bss->wmm_ie_len = 0; | 2809 | bss->wmm_ie_len = 0; |
2777 | } else if (!elems.wmm_param && !elems.wmm_info && bss->wmm_ie) { | 2810 | } else if (!elems->wmm_param && !elems->wmm_info && bss->wmm_ie) { |
2778 | kfree(bss->wmm_ie); | 2811 | kfree(bss->wmm_ie); |
2779 | bss->wmm_ie = NULL; | 2812 | bss->wmm_ie = NULL; |
2780 | bss->wmm_ie_len = 0; | 2813 | bss->wmm_ie_len = 0; |
@@ -2785,8 +2818,9 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2785 | !local->sta_sw_scanning && !local->sta_hw_scanning && | 2818 | !local->sta_sw_scanning && !local->sta_hw_scanning && |
2786 | bss->capability & WLAN_CAPABILITY_IBSS && | 2819 | bss->capability & WLAN_CAPABILITY_IBSS && |
2787 | bss->freq == local->oper_channel->center_freq && | 2820 | bss->freq == local->oper_channel->center_freq && |
2788 | elems.ssid_len == sdata->u.sta.ssid_len && | 2821 | elems->ssid_len == sdata->u.sta.ssid_len && |
2789 | memcmp(elems.ssid, sdata->u.sta.ssid, sdata->u.sta.ssid_len) == 0) { | 2822 | memcmp(elems->ssid, sdata->u.sta.ssid, |
2823 | sdata->u.sta.ssid_len) == 0) { | ||
2790 | if (rx_status->flag & RX_FLAG_TSFT) { | 2824 | if (rx_status->flag & RX_FLAG_TSFT) { |
2791 | /* in order for correct IBSS merging we need mactime | 2825 | /* in order for correct IBSS merging we need mactime |
2792 | * | 2826 | * |
@@ -2824,18 +2858,18 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2824 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 2858 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
2825 | if (beacon_timestamp > rx_timestamp) { | 2859 | if (beacon_timestamp > rx_timestamp) { |
2826 | #ifndef CONFIG_MAC80211_IBSS_DEBUG | 2860 | #ifndef CONFIG_MAC80211_IBSS_DEBUG |
2827 | if (net_ratelimit()) | 2861 | printk(KERN_DEBUG "%s: beacon TSF higher than " |
2862 | "local TSF - IBSS merge with BSSID %s\n", | ||
2863 | dev->name, print_mac(mac, mgmt->bssid)); | ||
2828 | #endif | 2864 | #endif |
2829 | printk(KERN_DEBUG "%s: beacon TSF higher than " | ||
2830 | "local TSF - IBSS merge with BSSID %s\n", | ||
2831 | dev->name, print_mac(mac, mgmt->bssid)); | ||
2832 | ieee80211_sta_join_ibss(dev, &sdata->u.sta, bss); | 2865 | ieee80211_sta_join_ibss(dev, &sdata->u.sta, bss); |
2833 | ieee80211_ibss_add_sta(dev, NULL, | 2866 | ieee80211_ibss_add_sta(dev, NULL, |
2834 | mgmt->bssid, mgmt->sa); | 2867 | mgmt->bssid, mgmt->sa, |
2868 | BIT(rx_status->rate_idx)); | ||
2835 | } | 2869 | } |
2836 | } | 2870 | } |
2837 | 2871 | ||
2838 | ieee80211_rx_bss_put(dev, bss); | 2872 | ieee80211_rx_bss_put(local, bss); |
2839 | } | 2873 | } |
2840 | 2874 | ||
2841 | 2875 | ||
@@ -2844,7 +2878,17 @@ static void ieee80211_rx_mgmt_probe_resp(struct net_device *dev, | |||
2844 | size_t len, | 2878 | size_t len, |
2845 | struct ieee80211_rx_status *rx_status) | 2879 | struct ieee80211_rx_status *rx_status) |
2846 | { | 2880 | { |
2847 | ieee80211_rx_bss_info(dev, mgmt, len, rx_status, 0); | 2881 | size_t baselen; |
2882 | struct ieee802_11_elems elems; | ||
2883 | |||
2884 | baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; | ||
2885 | if (baselen > len) | ||
2886 | return; | ||
2887 | |||
2888 | ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, | ||
2889 | &elems); | ||
2890 | |||
2891 | ieee80211_rx_bss_info(dev, mgmt, len, rx_status, &elems, 0); | ||
2848 | } | 2892 | } |
2849 | 2893 | ||
2850 | 2894 | ||
@@ -2861,7 +2905,14 @@ static void ieee80211_rx_mgmt_beacon(struct net_device *dev, | |||
2861 | struct ieee80211_conf *conf = &local->hw.conf; | 2905 | struct ieee80211_conf *conf = &local->hw.conf; |
2862 | u32 changed = 0; | 2906 | u32 changed = 0; |
2863 | 2907 | ||
2864 | ieee80211_rx_bss_info(dev, mgmt, len, rx_status, 1); | 2908 | /* Process beacon from the current BSS */ |
2909 | baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; | ||
2910 | if (baselen > len) | ||
2911 | return; | ||
2912 | |||
2913 | ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems); | ||
2914 | |||
2915 | ieee80211_rx_bss_info(dev, mgmt, len, rx_status, &elems, 1); | ||
2865 | 2916 | ||
2866 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 2917 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2867 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA) | 2918 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA) |
@@ -2872,17 +2923,8 @@ static void ieee80211_rx_mgmt_beacon(struct net_device *dev, | |||
2872 | memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) | 2923 | memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) |
2873 | return; | 2924 | return; |
2874 | 2925 | ||
2875 | /* Process beacon from the current BSS */ | 2926 | ieee80211_sta_wmm_params(dev, ifsta, elems.wmm_param, |
2876 | baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; | 2927 | elems.wmm_param_len); |
2877 | if (baselen > len) | ||
2878 | return; | ||
2879 | |||
2880 | ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems); | ||
2881 | |||
2882 | if (elems.wmm_param && (ifsta->flags & IEEE80211_STA_WMM_ENABLED)) { | ||
2883 | ieee80211_sta_wmm_params(dev, ifsta, elems.wmm_param, | ||
2884 | elems.wmm_param_len); | ||
2885 | } | ||
2886 | 2928 | ||
2887 | /* Do not send changes to driver if we are scanning. This removes | 2929 | /* Do not send changes to driver if we are scanning. This removes |
2888 | * requirement that driver's bss_info_changed function needs to be | 2930 | * requirement that driver's bss_info_changed function needs to be |
@@ -2959,11 +3001,11 @@ static void ieee80211_rx_mgmt_probe_req(struct net_device *dev, | |||
2959 | pos = mgmt->u.probe_req.variable; | 3001 | pos = mgmt->u.probe_req.variable; |
2960 | if (pos[0] != WLAN_EID_SSID || | 3002 | if (pos[0] != WLAN_EID_SSID || |
2961 | pos + 2 + pos[1] > end) { | 3003 | pos + 2 + pos[1] > end) { |
2962 | if (net_ratelimit()) { | 3004 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
2963 | printk(KERN_DEBUG "%s: Invalid SSID IE in ProbeReq " | 3005 | printk(KERN_DEBUG "%s: Invalid SSID IE in ProbeReq " |
2964 | "from %s\n", | 3006 | "from %s\n", |
2965 | dev->name, print_mac(mac, mgmt->sa)); | 3007 | dev->name, print_mac(mac, mgmt->sa)); |
2966 | } | 3008 | #endif |
2967 | return; | 3009 | return; |
2968 | } | 3010 | } |
2969 | if (pos[1] != 0 && | 3011 | if (pos[1] != 0 && |
@@ -2994,11 +3036,24 @@ static void ieee80211_rx_mgmt_action(struct net_device *dev, | |||
2994 | struct ieee80211_rx_status *rx_status) | 3036 | struct ieee80211_rx_status *rx_status) |
2995 | { | 3037 | { |
2996 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 3038 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
3039 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
2997 | 3040 | ||
2998 | if (len < IEEE80211_MIN_ACTION_SIZE) | 3041 | if (len < IEEE80211_MIN_ACTION_SIZE) |
2999 | return; | 3042 | return; |
3000 | 3043 | ||
3001 | switch (mgmt->u.action.category) { | 3044 | switch (mgmt->u.action.category) { |
3045 | case WLAN_CATEGORY_SPECTRUM_MGMT: | ||
3046 | if (local->hw.conf.channel->band != IEEE80211_BAND_5GHZ) | ||
3047 | break; | ||
3048 | switch (mgmt->u.action.u.chan_switch.action_code) { | ||
3049 | case WLAN_ACTION_SPCT_MSR_REQ: | ||
3050 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
3051 | sizeof(mgmt->u.action.u.measurement))) | ||
3052 | break; | ||
3053 | ieee80211_sta_process_measurement_req(dev, mgmt, len); | ||
3054 | break; | ||
3055 | } | ||
3056 | break; | ||
3002 | case WLAN_CATEGORY_BACK: | 3057 | case WLAN_CATEGORY_BACK: |
3003 | switch (mgmt->u.action.u.addba_req.action_code) { | 3058 | switch (mgmt->u.action.u.addba_req.action_code) { |
3004 | case WLAN_ACTION_ADDBA_REQ: | 3059 | case WLAN_ACTION_ADDBA_REQ: |
@@ -3019,11 +3074,6 @@ static void ieee80211_rx_mgmt_action(struct net_device *dev, | |||
3019 | break; | 3074 | break; |
3020 | ieee80211_sta_process_delba(dev, mgmt, len); | 3075 | ieee80211_sta_process_delba(dev, mgmt, len); |
3021 | break; | 3076 | break; |
3022 | default: | ||
3023 | if (net_ratelimit()) | ||
3024 | printk(KERN_DEBUG "%s: Rx unknown A-MPDU action\n", | ||
3025 | dev->name); | ||
3026 | break; | ||
3027 | } | 3077 | } |
3028 | break; | 3078 | break; |
3029 | case PLINK_CATEGORY: | 3079 | case PLINK_CATEGORY: |
@@ -3034,11 +3084,6 @@ static void ieee80211_rx_mgmt_action(struct net_device *dev, | |||
3034 | if (ieee80211_vif_is_mesh(&sdata->vif)) | 3084 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
3035 | mesh_rx_path_sel_frame(dev, mgmt, len); | 3085 | mesh_rx_path_sel_frame(dev, mgmt, len); |
3036 | break; | 3086 | break; |
3037 | default: | ||
3038 | if (net_ratelimit()) | ||
3039 | printk(KERN_DEBUG "%s: Rx unknown action frame - " | ||
3040 | "category=%d\n", dev->name, mgmt->u.action.category); | ||
3041 | break; | ||
3042 | } | 3087 | } |
3043 | } | 3088 | } |
3044 | 3089 | ||
@@ -3074,11 +3119,6 @@ void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb, | |||
3074 | skb_queue_tail(&ifsta->skb_queue, skb); | 3119 | skb_queue_tail(&ifsta->skb_queue, skb); |
3075 | queue_work(local->hw.workqueue, &ifsta->work); | 3120 | queue_work(local->hw.workqueue, &ifsta->work); |
3076 | return; | 3121 | return; |
3077 | default: | ||
3078 | printk(KERN_DEBUG "%s: received unknown management frame - " | ||
3079 | "stype=%d\n", dev->name, | ||
3080 | (fc & IEEE80211_FCTL_STYPE) >> 4); | ||
3081 | break; | ||
3082 | } | 3122 | } |
3083 | 3123 | ||
3084 | fail: | 3124 | fail: |
@@ -3142,33 +3182,32 @@ ieee80211_sta_rx_scan(struct net_device *dev, struct sk_buff *skb, | |||
3142 | struct ieee80211_rx_status *rx_status) | 3182 | struct ieee80211_rx_status *rx_status) |
3143 | { | 3183 | { |
3144 | struct ieee80211_mgmt *mgmt; | 3184 | struct ieee80211_mgmt *mgmt; |
3145 | u16 fc; | 3185 | __le16 fc; |
3146 | 3186 | ||
3147 | if (skb->len < 2) | 3187 | if (skb->len < 2) |
3148 | return RX_DROP_UNUSABLE; | 3188 | return RX_DROP_UNUSABLE; |
3149 | 3189 | ||
3150 | mgmt = (struct ieee80211_mgmt *) skb->data; | 3190 | mgmt = (struct ieee80211_mgmt *) skb->data; |
3151 | fc = le16_to_cpu(mgmt->frame_control); | 3191 | fc = mgmt->frame_control; |
3152 | 3192 | ||
3153 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) | 3193 | if (ieee80211_is_ctl(fc)) |
3154 | return RX_CONTINUE; | 3194 | return RX_CONTINUE; |
3155 | 3195 | ||
3156 | if (skb->len < 24) | 3196 | if (skb->len < 24) |
3157 | return RX_DROP_MONITOR; | 3197 | return RX_DROP_MONITOR; |
3158 | 3198 | ||
3159 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { | 3199 | if (ieee80211_is_probe_resp(fc)) { |
3160 | if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP) { | 3200 | ieee80211_rx_mgmt_probe_resp(dev, mgmt, skb->len, rx_status); |
3161 | ieee80211_rx_mgmt_probe_resp(dev, mgmt, | 3201 | dev_kfree_skb(skb); |
3162 | skb->len, rx_status); | 3202 | return RX_QUEUED; |
3163 | dev_kfree_skb(skb); | 3203 | } |
3164 | return RX_QUEUED; | 3204 | |
3165 | } else if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON) { | 3205 | if (ieee80211_is_beacon(fc)) { |
3166 | ieee80211_rx_mgmt_beacon(dev, mgmt, skb->len, | 3206 | ieee80211_rx_mgmt_beacon(dev, mgmt, skb->len, rx_status); |
3167 | rx_status); | 3207 | dev_kfree_skb(skb); |
3168 | dev_kfree_skb(skb); | 3208 | return RX_QUEUED; |
3169 | return RX_QUEUED; | ||
3170 | } | ||
3171 | } | 3209 | } |
3210 | |||
3172 | return RX_CONTINUE; | 3211 | return RX_CONTINUE; |
3173 | } | 3212 | } |
3174 | 3213 | ||
@@ -3208,8 +3247,10 @@ static void ieee80211_sta_expire(struct net_device *dev, unsigned long exp_time) | |||
3208 | spin_lock_irqsave(&local->sta_lock, flags); | 3247 | spin_lock_irqsave(&local->sta_lock, flags); |
3209 | list_for_each_entry_safe(sta, tmp, &local->sta_list, list) | 3248 | list_for_each_entry_safe(sta, tmp, &local->sta_list, list) |
3210 | if (time_after(jiffies, sta->last_rx + exp_time)) { | 3249 | if (time_after(jiffies, sta->last_rx + exp_time)) { |
3250 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | ||
3211 | printk(KERN_DEBUG "%s: expiring inactive STA %s\n", | 3251 | printk(KERN_DEBUG "%s: expiring inactive STA %s\n", |
3212 | dev->name, print_mac(mac, sta->addr)); | 3252 | dev->name, print_mac(mac, sta->addr)); |
3253 | #endif | ||
3213 | __sta_info_unlink(&sta); | 3254 | __sta_info_unlink(&sta); |
3214 | if (sta) | 3255 | if (sta) |
3215 | list_add(&sta->list, &tmp_list); | 3256 | list_add(&sta->list, &tmp_list); |
@@ -3248,7 +3289,7 @@ static void ieee80211_mesh_housekeeping(struct net_device *dev, | |||
3248 | 3289 | ||
3249 | free_plinks = mesh_plink_availables(sdata); | 3290 | free_plinks = mesh_plink_availables(sdata); |
3250 | if (free_plinks != sdata->u.sta.accepting_plinks) | 3291 | if (free_plinks != sdata->u.sta.accepting_plinks) |
3251 | ieee80211_if_config_beacon(dev); | 3292 | ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON); |
3252 | 3293 | ||
3253 | mod_timer(&ifsta->timer, jiffies + | 3294 | mod_timer(&ifsta->timer, jiffies + |
3254 | IEEE80211_MESH_HOUSEKEEPING_INTERVAL); | 3295 | IEEE80211_MESH_HOUSEKEEPING_INTERVAL); |
@@ -3292,13 +3333,10 @@ void ieee80211_sta_work(struct work_struct *work) | |||
3292 | if (local->sta_sw_scanning || local->sta_hw_scanning) | 3333 | if (local->sta_sw_scanning || local->sta_hw_scanning) |
3293 | return; | 3334 | return; |
3294 | 3335 | ||
3295 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA && | 3336 | if (WARN_ON(sdata->vif.type != IEEE80211_IF_TYPE_STA && |
3296 | sdata->vif.type != IEEE80211_IF_TYPE_IBSS && | 3337 | sdata->vif.type != IEEE80211_IF_TYPE_IBSS && |
3297 | sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) { | 3338 | sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT)) |
3298 | printk(KERN_DEBUG "%s: ieee80211_sta_work: non-STA interface " | ||
3299 | "(type=%d)\n", dev->name, sdata->vif.type); | ||
3300 | return; | 3339 | return; |
3301 | } | ||
3302 | ifsta = &sdata->u.sta; | 3340 | ifsta = &sdata->u.sta; |
3303 | 3341 | ||
3304 | while ((skb = skb_dequeue(&ifsta->skb_queue))) | 3342 | while ((skb = skb_dequeue(&ifsta->skb_queue))) |
@@ -3352,8 +3390,7 @@ void ieee80211_sta_work(struct work_struct *work) | |||
3352 | break; | 3390 | break; |
3353 | #endif | 3391 | #endif |
3354 | default: | 3392 | default: |
3355 | printk(KERN_DEBUG "ieee80211_sta_work: Unknown state %d\n", | 3393 | WARN_ON(1); |
3356 | ifsta->state); | ||
3357 | break; | 3394 | break; |
3358 | } | 3395 | } |
3359 | 3396 | ||
@@ -3388,8 +3425,6 @@ static void ieee80211_sta_reset_auth(struct net_device *dev, | |||
3388 | ifsta->auth_alg = WLAN_AUTH_LEAP; | 3425 | ifsta->auth_alg = WLAN_AUTH_LEAP; |
3389 | else | 3426 | else |
3390 | ifsta->auth_alg = WLAN_AUTH_OPEN; | 3427 | ifsta->auth_alg = WLAN_AUTH_OPEN; |
3391 | printk(KERN_DEBUG "%s: Initial auth_alg=%d\n", dev->name, | ||
3392 | ifsta->auth_alg); | ||
3393 | ifsta->auth_transaction = -1; | 3428 | ifsta->auth_transaction = -1; |
3394 | ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; | 3429 | ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; |
3395 | ifsta->auth_tries = ifsta->assoc_tries = 0; | 3430 | ifsta->auth_tries = ifsta->assoc_tries = 0; |
@@ -3478,9 +3513,9 @@ static int ieee80211_sta_config_auth(struct net_device *dev, | |||
3478 | !ieee80211_sta_match_ssid(ifsta, bss->ssid, bss->ssid_len)) | 3513 | !ieee80211_sta_match_ssid(ifsta, bss->ssid, bss->ssid_len)) |
3479 | continue; | 3514 | continue; |
3480 | 3515 | ||
3481 | if (!selected || top_rssi < bss->rssi) { | 3516 | if (!selected || top_rssi < bss->signal) { |
3482 | selected = bss; | 3517 | selected = bss; |
3483 | top_rssi = bss->rssi; | 3518 | top_rssi = bss->signal; |
3484 | } | 3519 | } |
3485 | } | 3520 | } |
3486 | if (selected) | 3521 | if (selected) |
@@ -3494,7 +3529,7 @@ static int ieee80211_sta_config_auth(struct net_device *dev, | |||
3494 | selected->ssid_len); | 3529 | selected->ssid_len); |
3495 | ieee80211_sta_set_bssid(dev, selected->bssid); | 3530 | ieee80211_sta_set_bssid(dev, selected->bssid); |
3496 | ieee80211_sta_def_wmm_params(dev, selected, 0); | 3531 | ieee80211_sta_def_wmm_params(dev, selected, 0); |
3497 | ieee80211_rx_bss_put(dev, selected); | 3532 | ieee80211_rx_bss_put(local, selected); |
3498 | ifsta->state = IEEE80211_AUTHENTICATE; | 3533 | ifsta->state = IEEE80211_AUTHENTICATE; |
3499 | ieee80211_sta_reset_auth(dev, ifsta); | 3534 | ieee80211_sta_reset_auth(dev, ifsta); |
3500 | return 0; | 3535 | return 0; |
@@ -3553,14 +3588,16 @@ static int ieee80211_sta_create_ibss(struct net_device *dev, | |||
3553 | sband = local->hw.wiphy->bands[bss->band]; | 3588 | sband = local->hw.wiphy->bands[bss->band]; |
3554 | 3589 | ||
3555 | if (local->hw.conf.beacon_int == 0) | 3590 | if (local->hw.conf.beacon_int == 0) |
3556 | local->hw.conf.beacon_int = 10000; | 3591 | local->hw.conf.beacon_int = 100; |
3557 | bss->beacon_int = local->hw.conf.beacon_int; | 3592 | bss->beacon_int = local->hw.conf.beacon_int; |
3558 | bss->last_update = jiffies; | 3593 | bss->last_update = jiffies; |
3559 | bss->capability = WLAN_CAPABILITY_IBSS; | 3594 | bss->capability = WLAN_CAPABILITY_IBSS; |
3560 | if (sdata->default_key) { | 3595 | |
3596 | if (sdata->default_key) | ||
3561 | bss->capability |= WLAN_CAPABILITY_PRIVACY; | 3597 | bss->capability |= WLAN_CAPABILITY_PRIVACY; |
3562 | } else | 3598 | else |
3563 | sdata->drop_unencrypted = 0; | 3599 | sdata->drop_unencrypted = 0; |
3600 | |||
3564 | bss->supp_rates_len = sband->n_bitrates; | 3601 | bss->supp_rates_len = sband->n_bitrates; |
3565 | pos = bss->supp_rates; | 3602 | pos = bss->supp_rates; |
3566 | for (i = 0; i < sband->n_bitrates; i++) { | 3603 | for (i = 0; i < sband->n_bitrates; i++) { |
@@ -3569,7 +3606,7 @@ static int ieee80211_sta_create_ibss(struct net_device *dev, | |||
3569 | } | 3606 | } |
3570 | 3607 | ||
3571 | ret = ieee80211_sta_join_ibss(dev, ifsta, bss); | 3608 | ret = ieee80211_sta_join_ibss(dev, ifsta, bss); |
3572 | ieee80211_rx_bss_put(dev, bss); | 3609 | ieee80211_rx_bss_put(local, bss); |
3573 | return ret; | 3610 | return ret; |
3574 | } | 3611 | } |
3575 | 3612 | ||
@@ -3611,8 +3648,10 @@ static int ieee80211_sta_find_ibss(struct net_device *dev, | |||
3611 | spin_unlock_bh(&local->sta_bss_lock); | 3648 | spin_unlock_bh(&local->sta_bss_lock); |
3612 | 3649 | ||
3613 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 3650 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
3614 | printk(KERN_DEBUG " sta_find_ibss: selected %s current " | 3651 | if (found) |
3615 | "%s\n", print_mac(mac, bssid), print_mac(mac2, ifsta->bssid)); | 3652 | printk(KERN_DEBUG " sta_find_ibss: selected %s current " |
3653 | "%s\n", print_mac(mac, bssid), | ||
3654 | print_mac(mac2, ifsta->bssid)); | ||
3616 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 3655 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
3617 | if (found && memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0 && | 3656 | if (found && memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0 && |
3618 | (bss = ieee80211_rx_bss_get(dev, bssid, | 3657 | (bss = ieee80211_rx_bss_get(dev, bssid, |
@@ -3623,7 +3662,7 @@ static int ieee80211_sta_find_ibss(struct net_device *dev, | |||
3623 | " based on configured SSID\n", | 3662 | " based on configured SSID\n", |
3624 | dev->name, print_mac(mac, bssid)); | 3663 | dev->name, print_mac(mac, bssid)); |
3625 | ret = ieee80211_sta_join_ibss(dev, ifsta, bss); | 3664 | ret = ieee80211_sta_join_ibss(dev, ifsta, bss); |
3626 | ieee80211_rx_bss_put(dev, bss); | 3665 | ieee80211_rx_bss_put(local, bss); |
3627 | return ret; | 3666 | return ret; |
3628 | } | 3667 | } |
3629 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 3668 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
@@ -3674,28 +3713,45 @@ int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len) | |||
3674 | { | 3713 | { |
3675 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 3714 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
3676 | struct ieee80211_if_sta *ifsta; | 3715 | struct ieee80211_if_sta *ifsta; |
3716 | int res; | ||
3677 | 3717 | ||
3678 | if (len > IEEE80211_MAX_SSID_LEN) | 3718 | if (len > IEEE80211_MAX_SSID_LEN) |
3679 | return -EINVAL; | 3719 | return -EINVAL; |
3680 | 3720 | ||
3681 | ifsta = &sdata->u.sta; | 3721 | ifsta = &sdata->u.sta; |
3682 | 3722 | ||
3683 | if (ifsta->ssid_len != len || memcmp(ifsta->ssid, ssid, len) != 0) | 3723 | if (ifsta->ssid_len != len || memcmp(ifsta->ssid, ssid, len) != 0) { |
3724 | memset(ifsta->ssid, 0, sizeof(ifsta->ssid)); | ||
3725 | memcpy(ifsta->ssid, ssid, len); | ||
3726 | ifsta->ssid_len = len; | ||
3684 | ifsta->flags &= ~IEEE80211_STA_PREV_BSSID_SET; | 3727 | ifsta->flags &= ~IEEE80211_STA_PREV_BSSID_SET; |
3685 | memcpy(ifsta->ssid, ssid, len); | 3728 | |
3686 | memset(ifsta->ssid + len, 0, IEEE80211_MAX_SSID_LEN - len); | 3729 | res = 0; |
3687 | ifsta->ssid_len = len; | 3730 | /* |
3731 | * Hack! MLME code needs to be cleaned up to have different | ||
3732 | * entry points for configuration and internal selection change | ||
3733 | */ | ||
3734 | if (netif_running(sdata->dev)) | ||
3735 | res = ieee80211_if_config(sdata, IEEE80211_IFCC_SSID); | ||
3736 | if (res) { | ||
3737 | printk(KERN_DEBUG "%s: Failed to config new SSID to " | ||
3738 | "the low-level driver\n", dev->name); | ||
3739 | return res; | ||
3740 | } | ||
3741 | } | ||
3688 | 3742 | ||
3689 | if (len) | 3743 | if (len) |
3690 | ifsta->flags |= IEEE80211_STA_SSID_SET; | 3744 | ifsta->flags |= IEEE80211_STA_SSID_SET; |
3691 | else | 3745 | else |
3692 | ifsta->flags &= ~IEEE80211_STA_SSID_SET; | 3746 | ifsta->flags &= ~IEEE80211_STA_SSID_SET; |
3747 | |||
3693 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && | 3748 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && |
3694 | !(ifsta->flags & IEEE80211_STA_BSSID_SET)) { | 3749 | !(ifsta->flags & IEEE80211_STA_BSSID_SET)) { |
3695 | ifsta->ibss_join_req = jiffies; | 3750 | ifsta->ibss_join_req = jiffies; |
3696 | ifsta->state = IEEE80211_IBSS_SEARCH; | 3751 | ifsta->state = IEEE80211_IBSS_SEARCH; |
3697 | return ieee80211_sta_find_ibss(dev, ifsta); | 3752 | return ieee80211_sta_find_ibss(dev, ifsta); |
3698 | } | 3753 | } |
3754 | |||
3699 | return 0; | 3755 | return 0; |
3700 | } | 3756 | } |
3701 | 3757 | ||
@@ -3721,7 +3777,12 @@ int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid) | |||
3721 | 3777 | ||
3722 | if (memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0) { | 3778 | if (memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0) { |
3723 | memcpy(ifsta->bssid, bssid, ETH_ALEN); | 3779 | memcpy(ifsta->bssid, bssid, ETH_ALEN); |
3724 | res = ieee80211_if_config(dev); | 3780 | res = 0; |
3781 | /* | ||
3782 | * Hack! See also ieee80211_sta_set_ssid. | ||
3783 | */ | ||
3784 | if (netif_running(sdata->dev)) | ||
3785 | res = ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID); | ||
3725 | if (res) { | 3786 | if (res) { |
3726 | printk(KERN_DEBUG "%s: Failed to config new BSSID to " | 3787 | printk(KERN_DEBUG "%s: Failed to config new BSSID to " |
3727 | "the low-level driver\n", dev->name); | 3788 | "the low-level driver\n", dev->name); |
@@ -3744,7 +3805,7 @@ static void ieee80211_send_nullfunc(struct ieee80211_local *local, | |||
3744 | { | 3805 | { |
3745 | struct sk_buff *skb; | 3806 | struct sk_buff *skb; |
3746 | struct ieee80211_hdr *nullfunc; | 3807 | struct ieee80211_hdr *nullfunc; |
3747 | u16 fc; | 3808 | __le16 fc; |
3748 | 3809 | ||
3749 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24); | 3810 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24); |
3750 | if (!skb) { | 3811 | if (!skb) { |
@@ -3756,11 +3817,11 @@ static void ieee80211_send_nullfunc(struct ieee80211_local *local, | |||
3756 | 3817 | ||
3757 | nullfunc = (struct ieee80211_hdr *) skb_put(skb, 24); | 3818 | nullfunc = (struct ieee80211_hdr *) skb_put(skb, 24); |
3758 | memset(nullfunc, 0, 24); | 3819 | memset(nullfunc, 0, 24); |
3759 | fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC | | 3820 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC | |
3760 | IEEE80211_FCTL_TODS; | 3821 | IEEE80211_FCTL_TODS); |
3761 | if (powersave) | 3822 | if (powersave) |
3762 | fc |= IEEE80211_FCTL_PM; | 3823 | fc |= cpu_to_le16(IEEE80211_FCTL_PM); |
3763 | nullfunc->frame_control = cpu_to_le16(fc); | 3824 | nullfunc->frame_control = fc; |
3764 | memcpy(nullfunc->addr1, sdata->u.sta.bssid, ETH_ALEN); | 3825 | memcpy(nullfunc->addr1, sdata->u.sta.bssid, ETH_ALEN); |
3765 | memcpy(nullfunc->addr2, sdata->dev->dev_addr, ETH_ALEN); | 3826 | memcpy(nullfunc->addr2, sdata->dev->dev_addr, ETH_ALEN); |
3766 | memcpy(nullfunc->addr3, sdata->u.sta.bssid, ETH_ALEN); | 3827 | memcpy(nullfunc->addr3, sdata->u.sta.bssid, ETH_ALEN); |
@@ -3808,6 +3869,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw) | |||
3808 | 3869 | ||
3809 | 3870 | ||
3810 | netif_tx_lock_bh(local->mdev); | 3871 | netif_tx_lock_bh(local->mdev); |
3872 | netif_addr_lock(local->mdev); | ||
3811 | local->filter_flags &= ~FIF_BCN_PRBRESP_PROMISC; | 3873 | local->filter_flags &= ~FIF_BCN_PRBRESP_PROMISC; |
3812 | local->ops->configure_filter(local_to_hw(local), | 3874 | local->ops->configure_filter(local_to_hw(local), |
3813 | FIF_BCN_PRBRESP_PROMISC, | 3875 | FIF_BCN_PRBRESP_PROMISC, |
@@ -3815,15 +3877,11 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw) | |||
3815 | local->mdev->mc_count, | 3877 | local->mdev->mc_count, |
3816 | local->mdev->mc_list); | 3878 | local->mdev->mc_list); |
3817 | 3879 | ||
3880 | netif_addr_unlock(local->mdev); | ||
3818 | netif_tx_unlock_bh(local->mdev); | 3881 | netif_tx_unlock_bh(local->mdev); |
3819 | 3882 | ||
3820 | rcu_read_lock(); | 3883 | rcu_read_lock(); |
3821 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 3884 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
3822 | |||
3823 | /* No need to wake the master device. */ | ||
3824 | if (sdata->dev == local->mdev) | ||
3825 | continue; | ||
3826 | |||
3827 | /* Tell AP we're back */ | 3885 | /* Tell AP we're back */ |
3828 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA && | 3886 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA && |
3829 | sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED) | 3887 | sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED) |
@@ -3989,12 +4047,6 @@ static int ieee80211_sta_start_scan(struct net_device *dev, | |||
3989 | 4047 | ||
3990 | rcu_read_lock(); | 4048 | rcu_read_lock(); |
3991 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 4049 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
3992 | |||
3993 | /* Don't stop the master interface, otherwise we can't transmit | ||
3994 | * probes! */ | ||
3995 | if (sdata->dev == local->mdev) | ||
3996 | continue; | ||
3997 | |||
3998 | netif_stop_queue(sdata->dev); | 4050 | netif_stop_queue(sdata->dev); |
3999 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA && | 4051 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA && |
4000 | (sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED)) | 4052 | (sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED)) |
@@ -4012,14 +4064,14 @@ static int ieee80211_sta_start_scan(struct net_device *dev, | |||
4012 | local->scan_band = IEEE80211_BAND_2GHZ; | 4064 | local->scan_band = IEEE80211_BAND_2GHZ; |
4013 | local->scan_dev = dev; | 4065 | local->scan_dev = dev; |
4014 | 4066 | ||
4015 | netif_tx_lock_bh(local->mdev); | 4067 | netif_addr_lock_bh(local->mdev); |
4016 | local->filter_flags |= FIF_BCN_PRBRESP_PROMISC; | 4068 | local->filter_flags |= FIF_BCN_PRBRESP_PROMISC; |
4017 | local->ops->configure_filter(local_to_hw(local), | 4069 | local->ops->configure_filter(local_to_hw(local), |
4018 | FIF_BCN_PRBRESP_PROMISC, | 4070 | FIF_BCN_PRBRESP_PROMISC, |
4019 | &local->filter_flags, | 4071 | &local->filter_flags, |
4020 | local->mdev->mc_count, | 4072 | local->mdev->mc_count, |
4021 | local->mdev->mc_list); | 4073 | local->mdev->mc_list); |
4022 | netif_tx_unlock_bh(local->mdev); | 4074 | netif_addr_unlock_bh(local->mdev); |
4023 | 4075 | ||
4024 | /* TODO: start scan as soon as all nullfunc frames are ACKed */ | 4076 | /* TODO: start scan as soon as all nullfunc frames are ACKed */ |
4025 | queue_delayed_work(local->hw.workqueue, &local->scan_work, | 4077 | queue_delayed_work(local->hw.workqueue, &local->scan_work, |
@@ -4054,6 +4106,7 @@ int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len) | |||
4054 | 4106 | ||
4055 | static char * | 4107 | static char * |
4056 | ieee80211_sta_scan_result(struct net_device *dev, | 4108 | ieee80211_sta_scan_result(struct net_device *dev, |
4109 | struct iw_request_info *info, | ||
4057 | struct ieee80211_sta_bss *bss, | 4110 | struct ieee80211_sta_bss *bss, |
4058 | char *current_ev, char *end_buf) | 4111 | char *current_ev, char *end_buf) |
4059 | { | 4112 | { |
@@ -4068,7 +4121,7 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4068 | iwe.cmd = SIOCGIWAP; | 4121 | iwe.cmd = SIOCGIWAP; |
4069 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; | 4122 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; |
4070 | memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN); | 4123 | memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN); |
4071 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4124 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, |
4072 | IW_EV_ADDR_LEN); | 4125 | IW_EV_ADDR_LEN); |
4073 | 4126 | ||
4074 | memset(&iwe, 0, sizeof(iwe)); | 4127 | memset(&iwe, 0, sizeof(iwe)); |
@@ -4076,13 +4129,13 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4076 | if (bss_mesh_cfg(bss)) { | 4129 | if (bss_mesh_cfg(bss)) { |
4077 | iwe.u.data.length = bss_mesh_id_len(bss); | 4130 | iwe.u.data.length = bss_mesh_id_len(bss); |
4078 | iwe.u.data.flags = 1; | 4131 | iwe.u.data.flags = 1; |
4079 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, | 4132 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4080 | bss_mesh_id(bss)); | 4133 | &iwe, bss_mesh_id(bss)); |
4081 | } else { | 4134 | } else { |
4082 | iwe.u.data.length = bss->ssid_len; | 4135 | iwe.u.data.length = bss->ssid_len; |
4083 | iwe.u.data.flags = 1; | 4136 | iwe.u.data.flags = 1; |
4084 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, | 4137 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4085 | bss->ssid); | 4138 | &iwe, bss->ssid); |
4086 | } | 4139 | } |
4087 | 4140 | ||
4088 | if (bss->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS) | 4141 | if (bss->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS) |
@@ -4095,30 +4148,30 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4095 | iwe.u.mode = IW_MODE_MASTER; | 4148 | iwe.u.mode = IW_MODE_MASTER; |
4096 | else | 4149 | else |
4097 | iwe.u.mode = IW_MODE_ADHOC; | 4150 | iwe.u.mode = IW_MODE_ADHOC; |
4098 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4151 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, |
4099 | IW_EV_UINT_LEN); | 4152 | &iwe, IW_EV_UINT_LEN); |
4100 | } | 4153 | } |
4101 | 4154 | ||
4102 | memset(&iwe, 0, sizeof(iwe)); | 4155 | memset(&iwe, 0, sizeof(iwe)); |
4103 | iwe.cmd = SIOCGIWFREQ; | 4156 | iwe.cmd = SIOCGIWFREQ; |
4104 | iwe.u.freq.m = ieee80211_frequency_to_channel(bss->freq); | 4157 | iwe.u.freq.m = ieee80211_frequency_to_channel(bss->freq); |
4105 | iwe.u.freq.e = 0; | 4158 | iwe.u.freq.e = 0; |
4106 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4159 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, |
4107 | IW_EV_FREQ_LEN); | 4160 | IW_EV_FREQ_LEN); |
4108 | 4161 | ||
4109 | memset(&iwe, 0, sizeof(iwe)); | 4162 | memset(&iwe, 0, sizeof(iwe)); |
4110 | iwe.cmd = SIOCGIWFREQ; | 4163 | iwe.cmd = SIOCGIWFREQ; |
4111 | iwe.u.freq.m = bss->freq; | 4164 | iwe.u.freq.m = bss->freq; |
4112 | iwe.u.freq.e = 6; | 4165 | iwe.u.freq.e = 6; |
4113 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4166 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, |
4114 | IW_EV_FREQ_LEN); | 4167 | IW_EV_FREQ_LEN); |
4115 | memset(&iwe, 0, sizeof(iwe)); | 4168 | memset(&iwe, 0, sizeof(iwe)); |
4116 | iwe.cmd = IWEVQUAL; | 4169 | iwe.cmd = IWEVQUAL; |
4117 | iwe.u.qual.qual = bss->signal; | 4170 | iwe.u.qual.qual = bss->qual; |
4118 | iwe.u.qual.level = bss->rssi; | 4171 | iwe.u.qual.level = bss->signal; |
4119 | iwe.u.qual.noise = bss->noise; | 4172 | iwe.u.qual.noise = bss->noise; |
4120 | iwe.u.qual.updated = local->wstats_flags; | 4173 | iwe.u.qual.updated = local->wstats_flags; |
4121 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4174 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, |
4122 | IW_EV_QUAL_LEN); | 4175 | IW_EV_QUAL_LEN); |
4123 | 4176 | ||
4124 | memset(&iwe, 0, sizeof(iwe)); | 4177 | memset(&iwe, 0, sizeof(iwe)); |
@@ -4128,27 +4181,36 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4128 | else | 4181 | else |
4129 | iwe.u.data.flags = IW_ENCODE_DISABLED; | 4182 | iwe.u.data.flags = IW_ENCODE_DISABLED; |
4130 | iwe.u.data.length = 0; | 4183 | iwe.u.data.length = 0; |
4131 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, ""); | 4184 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4185 | &iwe, ""); | ||
4132 | 4186 | ||
4133 | if (bss && bss->wpa_ie) { | 4187 | if (bss && bss->wpa_ie) { |
4134 | memset(&iwe, 0, sizeof(iwe)); | 4188 | memset(&iwe, 0, sizeof(iwe)); |
4135 | iwe.cmd = IWEVGENIE; | 4189 | iwe.cmd = IWEVGENIE; |
4136 | iwe.u.data.length = bss->wpa_ie_len; | 4190 | iwe.u.data.length = bss->wpa_ie_len; |
4137 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, | 4191 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4138 | bss->wpa_ie); | 4192 | &iwe, bss->wpa_ie); |
4139 | } | 4193 | } |
4140 | 4194 | ||
4141 | if (bss && bss->rsn_ie) { | 4195 | if (bss && bss->rsn_ie) { |
4142 | memset(&iwe, 0, sizeof(iwe)); | 4196 | memset(&iwe, 0, sizeof(iwe)); |
4143 | iwe.cmd = IWEVGENIE; | 4197 | iwe.cmd = IWEVGENIE; |
4144 | iwe.u.data.length = bss->rsn_ie_len; | 4198 | iwe.u.data.length = bss->rsn_ie_len; |
4145 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, | 4199 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4146 | bss->rsn_ie); | 4200 | &iwe, bss->rsn_ie); |
4201 | } | ||
4202 | |||
4203 | if (bss && bss->ht_ie) { | ||
4204 | memset(&iwe, 0, sizeof(iwe)); | ||
4205 | iwe.cmd = IWEVGENIE; | ||
4206 | iwe.u.data.length = bss->ht_ie_len; | ||
4207 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
4208 | &iwe, bss->ht_ie); | ||
4147 | } | 4209 | } |
4148 | 4210 | ||
4149 | if (bss && bss->supp_rates_len > 0) { | 4211 | if (bss && bss->supp_rates_len > 0) { |
4150 | /* display all supported rates in readable format */ | 4212 | /* display all supported rates in readable format */ |
4151 | char *p = current_ev + IW_EV_LCP_LEN; | 4213 | char *p = current_ev + iwe_stream_lcp_len(info); |
4152 | int i; | 4214 | int i; |
4153 | 4215 | ||
4154 | memset(&iwe, 0, sizeof(iwe)); | 4216 | memset(&iwe, 0, sizeof(iwe)); |
@@ -4159,7 +4221,7 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4159 | for (i = 0; i < bss->supp_rates_len; i++) { | 4221 | for (i = 0; i < bss->supp_rates_len; i++) { |
4160 | iwe.u.bitrate.value = ((bss->supp_rates[i] & | 4222 | iwe.u.bitrate.value = ((bss->supp_rates[i] & |
4161 | 0x7f) * 500000); | 4223 | 0x7f) * 500000); |
4162 | p = iwe_stream_add_value(current_ev, p, | 4224 | p = iwe_stream_add_value(info, current_ev, p, |
4163 | end_buf, &iwe, IW_EV_PARAM_LEN); | 4225 | end_buf, &iwe, IW_EV_PARAM_LEN); |
4164 | } | 4226 | } |
4165 | current_ev = p; | 4227 | current_ev = p; |
@@ -4173,8 +4235,16 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4173 | iwe.cmd = IWEVCUSTOM; | 4235 | iwe.cmd = IWEVCUSTOM; |
4174 | sprintf(buf, "tsf=%016llx", (unsigned long long)(bss->timestamp)); | 4236 | sprintf(buf, "tsf=%016llx", (unsigned long long)(bss->timestamp)); |
4175 | iwe.u.data.length = strlen(buf); | 4237 | iwe.u.data.length = strlen(buf); |
4176 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4238 | current_ev = iwe_stream_add_point(info, current_ev, |
4239 | end_buf, | ||
4177 | &iwe, buf); | 4240 | &iwe, buf); |
4241 | memset(&iwe, 0, sizeof(iwe)); | ||
4242 | iwe.cmd = IWEVCUSTOM; | ||
4243 | sprintf(buf, " Last beacon: %dms ago", | ||
4244 | jiffies_to_msecs(jiffies - bss->last_update)); | ||
4245 | iwe.u.data.length = strlen(buf); | ||
4246 | current_ev = iwe_stream_add_point(info, current_ev, | ||
4247 | end_buf, &iwe, buf); | ||
4178 | kfree(buf); | 4248 | kfree(buf); |
4179 | } | 4249 | } |
4180 | } | 4250 | } |
@@ -4188,31 +4258,36 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4188 | iwe.cmd = IWEVCUSTOM; | 4258 | iwe.cmd = IWEVCUSTOM; |
4189 | sprintf(buf, "Mesh network (version %d)", cfg[0]); | 4259 | sprintf(buf, "Mesh network (version %d)", cfg[0]); |
4190 | iwe.u.data.length = strlen(buf); | 4260 | iwe.u.data.length = strlen(buf); |
4191 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4261 | current_ev = iwe_stream_add_point(info, current_ev, |
4262 | end_buf, | ||
4192 | &iwe, buf); | 4263 | &iwe, buf); |
4193 | sprintf(buf, "Path Selection Protocol ID: " | 4264 | sprintf(buf, "Path Selection Protocol ID: " |
4194 | "0x%02X%02X%02X%02X", cfg[1], cfg[2], cfg[3], | 4265 | "0x%02X%02X%02X%02X", cfg[1], cfg[2], cfg[3], |
4195 | cfg[4]); | 4266 | cfg[4]); |
4196 | iwe.u.data.length = strlen(buf); | 4267 | iwe.u.data.length = strlen(buf); |
4197 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4268 | current_ev = iwe_stream_add_point(info, current_ev, |
4269 | end_buf, | ||
4198 | &iwe, buf); | 4270 | &iwe, buf); |
4199 | sprintf(buf, "Path Selection Metric ID: " | 4271 | sprintf(buf, "Path Selection Metric ID: " |
4200 | "0x%02X%02X%02X%02X", cfg[5], cfg[6], cfg[7], | 4272 | "0x%02X%02X%02X%02X", cfg[5], cfg[6], cfg[7], |
4201 | cfg[8]); | 4273 | cfg[8]); |
4202 | iwe.u.data.length = strlen(buf); | 4274 | iwe.u.data.length = strlen(buf); |
4203 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4275 | current_ev = iwe_stream_add_point(info, current_ev, |
4276 | end_buf, | ||
4204 | &iwe, buf); | 4277 | &iwe, buf); |
4205 | sprintf(buf, "Congestion Control Mode ID: " | 4278 | sprintf(buf, "Congestion Control Mode ID: " |
4206 | "0x%02X%02X%02X%02X", cfg[9], cfg[10], | 4279 | "0x%02X%02X%02X%02X", cfg[9], cfg[10], |
4207 | cfg[11], cfg[12]); | 4280 | cfg[11], cfg[12]); |
4208 | iwe.u.data.length = strlen(buf); | 4281 | iwe.u.data.length = strlen(buf); |
4209 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4282 | current_ev = iwe_stream_add_point(info, current_ev, |
4283 | end_buf, | ||
4210 | &iwe, buf); | 4284 | &iwe, buf); |
4211 | sprintf(buf, "Channel Precedence: " | 4285 | sprintf(buf, "Channel Precedence: " |
4212 | "0x%02X%02X%02X%02X", cfg[13], cfg[14], | 4286 | "0x%02X%02X%02X%02X", cfg[13], cfg[14], |
4213 | cfg[15], cfg[16]); | 4287 | cfg[15], cfg[16]); |
4214 | iwe.u.data.length = strlen(buf); | 4288 | iwe.u.data.length = strlen(buf); |
4215 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4289 | current_ev = iwe_stream_add_point(info, current_ev, |
4290 | end_buf, | ||
4216 | &iwe, buf); | 4291 | &iwe, buf); |
4217 | kfree(buf); | 4292 | kfree(buf); |
4218 | } | 4293 | } |
@@ -4222,7 +4297,9 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4222 | } | 4297 | } |
4223 | 4298 | ||
4224 | 4299 | ||
4225 | int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len) | 4300 | int ieee80211_sta_scan_results(struct net_device *dev, |
4301 | struct iw_request_info *info, | ||
4302 | char *buf, size_t len) | ||
4226 | { | 4303 | { |
4227 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 4304 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
4228 | char *current_ev = buf; | 4305 | char *current_ev = buf; |
@@ -4235,8 +4312,8 @@ int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len) | |||
4235 | spin_unlock_bh(&local->sta_bss_lock); | 4312 | spin_unlock_bh(&local->sta_bss_lock); |
4236 | return -E2BIG; | 4313 | return -E2BIG; |
4237 | } | 4314 | } |
4238 | current_ev = ieee80211_sta_scan_result(dev, bss, current_ev, | 4315 | current_ev = ieee80211_sta_scan_result(dev, info, bss, |
4239 | end_buf); | 4316 | current_ev, end_buf); |
4240 | } | 4317 | } |
4241 | spin_unlock_bh(&local->sta_bss_lock); | 4318 | spin_unlock_bh(&local->sta_bss_lock); |
4242 | return current_ev - buf; | 4319 | return current_ev - buf; |
@@ -4247,6 +4324,7 @@ int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len) | |||
4247 | { | 4324 | { |
4248 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 4325 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
4249 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 4326 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
4327 | |||
4250 | kfree(ifsta->extra_ie); | 4328 | kfree(ifsta->extra_ie); |
4251 | if (len == 0) { | 4329 | if (len == 0) { |
4252 | ifsta->extra_ie = NULL; | 4330 | ifsta->extra_ie = NULL; |
@@ -4264,14 +4342,15 @@ int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len) | |||
4264 | } | 4342 | } |
4265 | 4343 | ||
4266 | 4344 | ||
4267 | struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev, | 4345 | struct sta_info *ieee80211_ibss_add_sta(struct net_device *dev, |
4268 | struct sk_buff *skb, u8 *bssid, | 4346 | struct sk_buff *skb, u8 *bssid, |
4269 | u8 *addr) | 4347 | u8 *addr, u64 supp_rates) |
4270 | { | 4348 | { |
4271 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 4349 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
4272 | struct sta_info *sta; | 4350 | struct sta_info *sta; |
4273 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 4351 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
4274 | DECLARE_MAC_BUF(mac); | 4352 | DECLARE_MAC_BUF(mac); |
4353 | int band = local->hw.conf.channel->band; | ||
4275 | 4354 | ||
4276 | /* TODO: Could consider removing the least recently used entry and | 4355 | /* TODO: Could consider removing the least recently used entry and |
4277 | * allow new one to be added. */ | 4356 | * allow new one to be added. */ |
@@ -4283,17 +4362,24 @@ struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev, | |||
4283 | return NULL; | 4362 | return NULL; |
4284 | } | 4363 | } |
4285 | 4364 | ||
4365 | if (compare_ether_addr(bssid, sdata->u.sta.bssid)) | ||
4366 | return NULL; | ||
4367 | |||
4368 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | ||
4286 | printk(KERN_DEBUG "%s: Adding new IBSS station %s (dev=%s)\n", | 4369 | printk(KERN_DEBUG "%s: Adding new IBSS station %s (dev=%s)\n", |
4287 | wiphy_name(local->hw.wiphy), print_mac(mac, addr), dev->name); | 4370 | wiphy_name(local->hw.wiphy), print_mac(mac, addr), dev->name); |
4371 | #endif | ||
4288 | 4372 | ||
4289 | sta = sta_info_alloc(sdata, addr, GFP_ATOMIC); | 4373 | sta = sta_info_alloc(sdata, addr, GFP_ATOMIC); |
4290 | if (!sta) | 4374 | if (!sta) |
4291 | return NULL; | 4375 | return NULL; |
4292 | 4376 | ||
4293 | sta->flags |= WLAN_STA_AUTHORIZED; | 4377 | set_sta_flags(sta, WLAN_STA_AUTHORIZED); |
4294 | 4378 | ||
4295 | sta->supp_rates[local->hw.conf.channel->band] = | 4379 | if (supp_rates) |
4296 | sdata->u.sta.supp_rates_bits[local->hw.conf.channel->band]; | 4380 | sta->supp_rates[band] = supp_rates; |
4381 | else | ||
4382 | sta->supp_rates[band] = sdata->u.sta.supp_rates_bits[band]; | ||
4297 | 4383 | ||
4298 | rate_control_rate_init(sta, local); | 4384 | rate_control_rate_init(sta, local); |
4299 | 4385 | ||
@@ -4309,7 +4395,7 @@ int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason) | |||
4309 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 4395 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
4310 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 4396 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
4311 | 4397 | ||
4312 | printk(KERN_DEBUG "%s: deauthenticate(reason=%d)\n", | 4398 | printk(KERN_DEBUG "%s: deauthenticating by local choice (reason=%d)\n", |
4313 | dev->name, reason); | 4399 | dev->name, reason); |
4314 | 4400 | ||
4315 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA && | 4401 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA && |
@@ -4327,7 +4413,7 @@ int ieee80211_sta_disassociate(struct net_device *dev, u16 reason) | |||
4327 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 4413 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
4328 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 4414 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
4329 | 4415 | ||
4330 | printk(KERN_DEBUG "%s: disassociate(reason=%d)\n", | 4416 | printk(KERN_DEBUG "%s: disassociating by local choice (reason=%d)\n", |
4331 | dev->name, reason); | 4417 | dev->name, reason); |
4332 | 4418 | ||
4333 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA) | 4419 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA) |
@@ -4351,12 +4437,10 @@ void ieee80211_notify_mac(struct ieee80211_hw *hw, | |||
4351 | case IEEE80211_NOTIFY_RE_ASSOC: | 4437 | case IEEE80211_NOTIFY_RE_ASSOC: |
4352 | rcu_read_lock(); | 4438 | rcu_read_lock(); |
4353 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 4439 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
4440 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA) | ||
4441 | continue; | ||
4354 | 4442 | ||
4355 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA) { | 4443 | ieee80211_sta_req_auth(sdata->dev, &sdata->u.sta); |
4356 | ieee80211_sta_req_auth(sdata->dev, | ||
4357 | &sdata->u.sta); | ||
4358 | } | ||
4359 | |||
4360 | } | 4444 | } |
4361 | rcu_read_unlock(); | 4445 | rcu_read_unlock(); |
4362 | break; | 4446 | break; |