diff options
Diffstat (limited to 'net/mac80211/mlme.c')
-rw-r--r-- | net/mac80211/mlme.c | 1035 |
1 files changed, 557 insertions, 478 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index b404537c0bcd..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) { |
@@ -555,7 +572,7 @@ static void ieee80211_set_associated(struct net_device *dev, | |||
555 | netif_carrier_off(dev); | 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 | ieee80211_reset_erp_info(dev); | 575 | changed |= ieee80211_reset_erp_info(dev); |
559 | 576 | ||
560 | sdata->bss_conf.assoc_ht = 0; | 577 | sdata->bss_conf.assoc_ht = 0; |
561 | sdata->bss_conf.ht_conf = NULL; | 578 | sdata->bss_conf.ht_conf = NULL; |
@@ -589,7 +606,7 @@ void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb, | |||
589 | int encrypt) | 606 | int encrypt) |
590 | { | 607 | { |
591 | struct ieee80211_sub_if_data *sdata; | 608 | struct ieee80211_sub_if_data *sdata; |
592 | struct ieee80211_tx_packet_data *pkt_data; | 609 | struct ieee80211_tx_info *info; |
593 | 610 | ||
594 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 611 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
595 | skb->dev = sdata->local->mdev; | 612 | skb->dev = sdata->local->mdev; |
@@ -597,11 +614,11 @@ void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb, | |||
597 | skb_set_network_header(skb, 0); | 614 | skb_set_network_header(skb, 0); |
598 | skb_set_transport_header(skb, 0); | 615 | skb_set_transport_header(skb, 0); |
599 | 616 | ||
600 | pkt_data = (struct ieee80211_tx_packet_data *) skb->cb; | 617 | info = IEEE80211_SKB_CB(skb); |
601 | memset(pkt_data, 0, sizeof(struct ieee80211_tx_packet_data)); | 618 | memset(info, 0, sizeof(struct ieee80211_tx_info)); |
602 | pkt_data->ifindex = sdata->dev->ifindex; | 619 | info->control.ifindex = sdata->dev->ifindex; |
603 | if (!encrypt) | 620 | if (!encrypt) |
604 | pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT; | 621 | info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; |
605 | 622 | ||
606 | dev_queue_xmit(skb); | 623 | dev_queue_xmit(skb); |
607 | } | 624 | } |
@@ -730,9 +747,8 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
730 | if (bss) { | 747 | if (bss) { |
731 | if (bss->capability & WLAN_CAPABILITY_PRIVACY) | 748 | if (bss->capability & WLAN_CAPABILITY_PRIVACY) |
732 | capab |= WLAN_CAPABILITY_PRIVACY; | 749 | capab |= WLAN_CAPABILITY_PRIVACY; |
733 | if (bss->wmm_ie) { | 750 | if (bss->wmm_ie) |
734 | wmm = 1; | 751 | wmm = 1; |
735 | } | ||
736 | 752 | ||
737 | /* get all rates supported by the device and the AP as | 753 | /* get all rates supported by the device and the AP as |
738 | * some APs don't like getting a superset of their rates | 754 | * some APs don't like getting a superset of their rates |
@@ -740,7 +756,11 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
740 | * b-only mode) */ | 756 | * b-only mode) */ |
741 | rates_len = ieee80211_compatible_rates(bss, sband, &rates); | 757 | rates_len = ieee80211_compatible_rates(bss, sband, &rates); |
742 | 758 | ||
743 | 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); | ||
744 | } else { | 764 | } else { |
745 | rates = ~0; | 765 | rates = ~0; |
746 | rates_len = sband->n_bitrates; | 766 | rates_len = sband->n_bitrates; |
@@ -807,6 +827,26 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
807 | } | 827 | } |
808 | } | 828 | } |
809 | 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 | |||
810 | if (ifsta->extra_ie) { | 850 | if (ifsta->extra_ie) { |
811 | pos = skb_put(skb, ifsta->extra_ie_len); | 851 | pos = skb_put(skb, ifsta->extra_ie_len); |
812 | memcpy(pos, ifsta->extra_ie, ifsta->extra_ie_len); | 852 | memcpy(pos, ifsta->extra_ie, ifsta->extra_ie_len); |
@@ -824,9 +864,32 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
824 | *pos++ = 1; /* WME ver */ | 864 | *pos++ = 1; /* WME ver */ |
825 | *pos++ = 0; | 865 | *pos++ = 0; |
826 | } | 866 | } |
867 | |||
827 | /* wmm support is a must to HT */ | 868 | /* wmm support is a must to HT */ |
828 | if (wmm && sband->ht_info.ht_supported) { | 869 | if (wmm && (ifsta->flags & IEEE80211_STA_WMM_ENABLED) && |
829 | __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); | ||
830 | pos = skb_put(skb, sizeof(struct ieee80211_ht_cap)+2); | 893 | pos = skb_put(skb, sizeof(struct ieee80211_ht_cap)+2); |
831 | *pos++ = WLAN_EID_HT_CAPABILITY; | 894 | *pos++ = WLAN_EID_HT_CAPABILITY; |
832 | *pos++ = sizeof(struct ieee80211_ht_cap); | 895 | *pos++ = sizeof(struct ieee80211_ht_cap); |
@@ -929,7 +992,7 @@ static int ieee80211_privacy_mismatch(struct net_device *dev, | |||
929 | wep_privacy = !!ieee80211_sta_wep_configured(dev); | 992 | wep_privacy = !!ieee80211_sta_wep_configured(dev); |
930 | privacy_invoked = !!(ifsta->flags & IEEE80211_STA_PRIVACY_INVOKED); | 993 | privacy_invoked = !!(ifsta->flags & IEEE80211_STA_PRIVACY_INVOKED); |
931 | 994 | ||
932 | ieee80211_rx_bss_put(dev, bss); | 995 | ieee80211_rx_bss_put(local, bss); |
933 | 996 | ||
934 | if ((bss_privacy == wep_privacy) || (bss_privacy == privacy_invoked)) | 997 | if ((bss_privacy == wep_privacy) || (bss_privacy == privacy_invoked)) |
935 | return 0; | 998 | return 0; |
@@ -1121,14 +1184,10 @@ static void ieee80211_auth_challenge(struct net_device *dev, | |||
1121 | u8 *pos; | 1184 | u8 *pos; |
1122 | struct ieee802_11_elems elems; | 1185 | struct ieee802_11_elems elems; |
1123 | 1186 | ||
1124 | printk(KERN_DEBUG "%s: replying to auth challenge\n", dev->name); | ||
1125 | pos = mgmt->u.auth.variable; | 1187 | pos = mgmt->u.auth.variable; |
1126 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); | 1188 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); |
1127 | if (!elems.challenge) { | 1189 | if (!elems.challenge) |
1128 | printk(KERN_DEBUG "%s: no challenge IE in shared key auth " | ||
1129 | "frame\n", dev->name); | ||
1130 | return; | 1190 | return; |
1131 | } | ||
1132 | ieee80211_send_auth(dev, ifsta, 3, elems.challenge - 2, | 1191 | ieee80211_send_auth(dev, ifsta, 3, elems.challenge - 2, |
1133 | elems.challenge_len + 2, 1); | 1192 | elems.challenge_len + 2, 1); |
1134 | } | 1193 | } |
@@ -1144,8 +1203,8 @@ static void ieee80211_send_addba_resp(struct net_device *dev, u8 *da, u16 tid, | |||
1144 | struct ieee80211_mgmt *mgmt; | 1203 | struct ieee80211_mgmt *mgmt; |
1145 | u16 capab; | 1204 | u16 capab; |
1146 | 1205 | ||
1147 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom + 1 + | 1206 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom); |
1148 | sizeof(mgmt->u.action.u.addba_resp)); | 1207 | |
1149 | if (!skb) { | 1208 | if (!skb) { |
1150 | printk(KERN_DEBUG "%s: failed to allocate buffer " | 1209 | printk(KERN_DEBUG "%s: failed to allocate buffer " |
1151 | "for addba resp frame\n", dev->name); | 1210 | "for addba resp frame\n", dev->name); |
@@ -1193,9 +1252,7 @@ void ieee80211_send_addba_request(struct net_device *dev, const u8 *da, | |||
1193 | struct ieee80211_mgmt *mgmt; | 1252 | struct ieee80211_mgmt *mgmt; |
1194 | u16 capab; | 1253 | u16 capab; |
1195 | 1254 | ||
1196 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom + 1 + | 1255 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom); |
1197 | sizeof(mgmt->u.action.u.addba_req)); | ||
1198 | |||
1199 | 1256 | ||
1200 | if (!skb) { | 1257 | if (!skb) { |
1201 | printk(KERN_ERR "%s: failed to allocate buffer " | 1258 | printk(KERN_ERR "%s: failed to allocate buffer " |
@@ -1296,7 +1353,7 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev, | |||
1296 | 1353 | ||
1297 | 1354 | ||
1298 | /* examine state machine */ | 1355 | /* examine state machine */ |
1299 | spin_lock_bh(&sta->ampdu_mlme.ampdu_rx); | 1356 | spin_lock_bh(&sta->lock); |
1300 | 1357 | ||
1301 | 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) { |
1302 | #ifdef CONFIG_MAC80211_HT_DEBUG | 1359 | #ifdef CONFIG_MAC80211_HT_DEBUG |
@@ -1312,9 +1369,11 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev, | |||
1312 | sta->ampdu_mlme.tid_rx[tid] = | 1369 | sta->ampdu_mlme.tid_rx[tid] = |
1313 | kmalloc(sizeof(struct tid_ampdu_rx), GFP_ATOMIC); | 1370 | kmalloc(sizeof(struct tid_ampdu_rx), GFP_ATOMIC); |
1314 | if (!sta->ampdu_mlme.tid_rx[tid]) { | 1371 | if (!sta->ampdu_mlme.tid_rx[tid]) { |
1372 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1315 | if (net_ratelimit()) | 1373 | if (net_ratelimit()) |
1316 | printk(KERN_ERR "allocate rx mlme to tid %d failed\n", | 1374 | printk(KERN_ERR "allocate rx mlme to tid %d failed\n", |
1317 | tid); | 1375 | tid); |
1376 | #endif | ||
1318 | goto end; | 1377 | goto end; |
1319 | } | 1378 | } |
1320 | /* rx timer */ | 1379 | /* rx timer */ |
@@ -1330,9 +1389,11 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev, | |||
1330 | tid_agg_rx->reorder_buf = | 1389 | tid_agg_rx->reorder_buf = |
1331 | kmalloc(buf_size * sizeof(struct sk_buff *), GFP_ATOMIC); | 1390 | kmalloc(buf_size * sizeof(struct sk_buff *), GFP_ATOMIC); |
1332 | if (!tid_agg_rx->reorder_buf) { | 1391 | if (!tid_agg_rx->reorder_buf) { |
1392 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1333 | if (net_ratelimit()) | 1393 | if (net_ratelimit()) |
1334 | printk(KERN_ERR "can not allocate reordering buffer " | 1394 | printk(KERN_ERR "can not allocate reordering buffer " |
1335 | "to tid %d\n", tid); | 1395 | "to tid %d\n", tid); |
1396 | #endif | ||
1336 | kfree(sta->ampdu_mlme.tid_rx[tid]); | 1397 | kfree(sta->ampdu_mlme.tid_rx[tid]); |
1337 | goto end; | 1398 | goto end; |
1338 | } | 1399 | } |
@@ -1363,7 +1424,7 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev, | |||
1363 | tid_agg_rx->stored_mpdu_num = 0; | 1424 | tid_agg_rx->stored_mpdu_num = 0; |
1364 | status = WLAN_STATUS_SUCCESS; | 1425 | status = WLAN_STATUS_SUCCESS; |
1365 | end: | 1426 | end: |
1366 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_rx); | 1427 | spin_unlock_bh(&sta->lock); |
1367 | 1428 | ||
1368 | end_no_lock: | 1429 | end_no_lock: |
1369 | ieee80211_send_addba_resp(sta->sdata->dev, sta->addr, tid, | 1430 | ieee80211_send_addba_resp(sta->sdata->dev, sta->addr, tid, |
@@ -1395,18 +1456,16 @@ static void ieee80211_sta_process_addba_resp(struct net_device *dev, | |||
1395 | 1456 | ||
1396 | state = &sta->ampdu_mlme.tid_state_tx[tid]; | 1457 | state = &sta->ampdu_mlme.tid_state_tx[tid]; |
1397 | 1458 | ||
1398 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); | 1459 | spin_lock_bh(&sta->lock); |
1399 | 1460 | ||
1400 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { | 1461 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { |
1401 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1462 | spin_unlock_bh(&sta->lock); |
1402 | printk(KERN_DEBUG "state not HT_ADDBA_REQUESTED_MSK:" | ||
1403 | "%d\n", *state); | ||
1404 | goto addba_resp_exit; | 1463 | goto addba_resp_exit; |
1405 | } | 1464 | } |
1406 | 1465 | ||
1407 | if (mgmt->u.action.u.addba_resp.dialog_token != | 1466 | if (mgmt->u.action.u.addba_resp.dialog_token != |
1408 | sta->ampdu_mlme.tid_tx[tid]->dialog_token) { | 1467 | sta->ampdu_mlme.tid_tx[tid]->dialog_token) { |
1409 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1468 | spin_unlock_bh(&sta->lock); |
1410 | #ifdef CONFIG_MAC80211_HT_DEBUG | 1469 | #ifdef CONFIG_MAC80211_HT_DEBUG |
1411 | printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid); | 1470 | printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid); |
1412 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | 1471 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
@@ -1419,26 +1478,18 @@ static void ieee80211_sta_process_addba_resp(struct net_device *dev, | |||
1419 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | 1478 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
1420 | if (le16_to_cpu(mgmt->u.action.u.addba_resp.status) | 1479 | if (le16_to_cpu(mgmt->u.action.u.addba_resp.status) |
1421 | == WLAN_STATUS_SUCCESS) { | 1480 | == WLAN_STATUS_SUCCESS) { |
1422 | if (*state & HT_ADDBA_RECEIVED_MSK) | ||
1423 | printk(KERN_DEBUG "double addBA response\n"); | ||
1424 | |||
1425 | *state |= HT_ADDBA_RECEIVED_MSK; | 1481 | *state |= HT_ADDBA_RECEIVED_MSK; |
1426 | sta->ampdu_mlme.addba_req_num[tid] = 0; | 1482 | sta->ampdu_mlme.addba_req_num[tid] = 0; |
1427 | 1483 | ||
1428 | if (*state == HT_AGG_STATE_OPERATIONAL) { | 1484 | if (*state == HT_AGG_STATE_OPERATIONAL) |
1429 | printk(KERN_DEBUG "Aggregation on for tid %d \n", tid); | ||
1430 | ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); | 1485 | ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); |
1431 | } | ||
1432 | 1486 | ||
1433 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1487 | spin_unlock_bh(&sta->lock); |
1434 | printk(KERN_DEBUG "recipient accepted agg: tid %d \n", tid); | ||
1435 | } else { | 1488 | } else { |
1436 | printk(KERN_DEBUG "recipient rejected agg: tid %d \n", tid); | ||
1437 | |||
1438 | sta->ampdu_mlme.addba_req_num[tid]++; | 1489 | sta->ampdu_mlme.addba_req_num[tid]++; |
1439 | /* this will allow the state check in stop_BA_session */ | 1490 | /* this will allow the state check in stop_BA_session */ |
1440 | *state = HT_AGG_STATE_OPERATIONAL; | 1491 | *state = HT_AGG_STATE_OPERATIONAL; |
1441 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1492 | spin_unlock_bh(&sta->lock); |
1442 | ieee80211_stop_tx_ba_session(hw, sta->addr, tid, | 1493 | ieee80211_stop_tx_ba_session(hw, sta->addr, tid, |
1443 | WLAN_BACK_INITIATOR); | 1494 | WLAN_BACK_INITIATOR); |
1444 | } | 1495 | } |
@@ -1457,8 +1508,7 @@ void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid, | |||
1457 | struct ieee80211_mgmt *mgmt; | 1508 | struct ieee80211_mgmt *mgmt; |
1458 | u16 params; | 1509 | u16 params; |
1459 | 1510 | ||
1460 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom + 1 + | 1511 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom); |
1461 | sizeof(mgmt->u.action.u.delba)); | ||
1462 | 1512 | ||
1463 | if (!skb) { | 1513 | if (!skb) { |
1464 | printk(KERN_ERR "%s: failed to allocate buffer " | 1514 | printk(KERN_ERR "%s: failed to allocate buffer " |
@@ -1491,6 +1541,35 @@ void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid, | |||
1491 | ieee80211_sta_tx(dev, skb, 0); | 1541 | ieee80211_sta_tx(dev, skb, 0); |
1492 | } | 1542 | } |
1493 | 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 | |||
1494 | 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, |
1495 | u16 initiator, u16 reason) | 1574 | u16 initiator, u16 reason) |
1496 | { | 1575 | { |
@@ -1509,17 +1588,17 @@ void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *ra, u16 tid, | |||
1509 | } | 1588 | } |
1510 | 1589 | ||
1511 | /* check if TID is in operational state */ | 1590 | /* check if TID is in operational state */ |
1512 | spin_lock_bh(&sta->ampdu_mlme.ampdu_rx); | 1591 | spin_lock_bh(&sta->lock); |
1513 | if (sta->ampdu_mlme.tid_state_rx[tid] | 1592 | if (sta->ampdu_mlme.tid_state_rx[tid] |
1514 | != HT_AGG_STATE_OPERATIONAL) { | 1593 | != HT_AGG_STATE_OPERATIONAL) { |
1515 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_rx); | 1594 | spin_unlock_bh(&sta->lock); |
1516 | rcu_read_unlock(); | 1595 | rcu_read_unlock(); |
1517 | return; | 1596 | return; |
1518 | } | 1597 | } |
1519 | sta->ampdu_mlme.tid_state_rx[tid] = | 1598 | sta->ampdu_mlme.tid_state_rx[tid] = |
1520 | HT_AGG_STATE_REQ_STOP_BA_MSK | | 1599 | HT_AGG_STATE_REQ_STOP_BA_MSK | |
1521 | (initiator << HT_AGG_STATE_INITIATOR_SHIFT); | 1600 | (initiator << HT_AGG_STATE_INITIATOR_SHIFT); |
1522 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_rx); | 1601 | spin_unlock_bh(&sta->lock); |
1523 | 1602 | ||
1524 | /* stop HW Rx aggregation. ampdu_action existence | 1603 | /* stop HW Rx aggregation. ampdu_action existence |
1525 | * already verified in session init so we add the BUG_ON */ | 1604 | * already verified in session init so we add the BUG_ON */ |
@@ -1534,7 +1613,7 @@ void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *ra, u16 tid, | |||
1534 | ra, tid, NULL); | 1613 | ra, tid, NULL); |
1535 | if (ret) | 1614 | if (ret) |
1536 | printk(KERN_DEBUG "HW problem - can not stop rx " | 1615 | printk(KERN_DEBUG "HW problem - can not stop rx " |
1537 | "aggergation for tid %d\n", tid); | 1616 | "aggregation for tid %d\n", tid); |
1538 | 1617 | ||
1539 | /* shutdown timer has not expired */ | 1618 | /* shutdown timer has not expired */ |
1540 | if (initiator != WLAN_BACK_TIMER) | 1619 | if (initiator != WLAN_BACK_TIMER) |
@@ -1596,10 +1675,10 @@ static void ieee80211_sta_process_delba(struct net_device *dev, | |||
1596 | ieee80211_sta_stop_rx_ba_session(dev, sta->addr, tid, | 1675 | ieee80211_sta_stop_rx_ba_session(dev, sta->addr, tid, |
1597 | WLAN_BACK_INITIATOR, 0); | 1676 | WLAN_BACK_INITIATOR, 0); |
1598 | else { /* WLAN_BACK_RECIPIENT */ | 1677 | else { /* WLAN_BACK_RECIPIENT */ |
1599 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); | 1678 | spin_lock_bh(&sta->lock); |
1600 | sta->ampdu_mlme.tid_state_tx[tid] = | 1679 | sta->ampdu_mlme.tid_state_tx[tid] = |
1601 | HT_AGG_STATE_OPERATIONAL; | 1680 | HT_AGG_STATE_OPERATIONAL; |
1602 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1681 | spin_unlock_bh(&sta->lock); |
1603 | ieee80211_stop_tx_ba_session(&local->hw, sta->addr, tid, | 1682 | ieee80211_stop_tx_ba_session(&local->hw, sta->addr, tid, |
1604 | WLAN_BACK_RECIPIENT); | 1683 | WLAN_BACK_RECIPIENT); |
1605 | } | 1684 | } |
@@ -1636,20 +1715,24 @@ void sta_addba_resp_timer_expired(unsigned long data) | |||
1636 | 1715 | ||
1637 | state = &sta->ampdu_mlme.tid_state_tx[tid]; | 1716 | state = &sta->ampdu_mlme.tid_state_tx[tid]; |
1638 | /* check if the TID waits for addBA response */ | 1717 | /* check if the TID waits for addBA response */ |
1639 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); | 1718 | spin_lock_bh(&sta->lock); |
1640 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { | 1719 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { |
1641 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1720 | spin_unlock_bh(&sta->lock); |
1642 | *state = HT_AGG_STATE_IDLE; | 1721 | *state = HT_AGG_STATE_IDLE; |
1722 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1643 | 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 " |
1644 | "expecting addBA response there", tid); | 1724 | "expecting addBA response there", tid); |
1725 | #endif | ||
1645 | goto timer_expired_exit; | 1726 | goto timer_expired_exit; |
1646 | } | 1727 | } |
1647 | 1728 | ||
1729 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1648 | 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 | ||
1649 | 1732 | ||
1650 | /* go through the state check in stop_BA_session */ | 1733 | /* go through the state check in stop_BA_session */ |
1651 | *state = HT_AGG_STATE_OPERATIONAL; | 1734 | *state = HT_AGG_STATE_OPERATIONAL; |
1652 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | 1735 | spin_unlock_bh(&sta->lock); |
1653 | ieee80211_stop_tx_ba_session(hw, temp_sta->addr, tid, | 1736 | ieee80211_stop_tx_ba_session(hw, temp_sta->addr, tid, |
1654 | WLAN_BACK_INITIATOR); | 1737 | WLAN_BACK_INITIATOR); |
1655 | 1738 | ||
@@ -1662,7 +1745,7 @@ timer_expired_exit: | |||
1662 | * resetting it after each frame that arrives from the originator. | 1745 | * resetting it after each frame that arrives from the originator. |
1663 | * 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. |
1664 | */ | 1747 | */ |
1665 | void sta_rx_agg_session_timer_expired(unsigned long data) | 1748 | static void sta_rx_agg_session_timer_expired(unsigned long data) |
1666 | { | 1749 | { |
1667 | /* 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 |
1668 | * 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 |
@@ -1673,7 +1756,9 @@ void sta_rx_agg_session_timer_expired(unsigned long data) | |||
1673 | 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, |
1674 | timer_to_tid[0]); | 1757 | timer_to_tid[0]); |
1675 | 1758 | ||
1759 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1676 | 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 | ||
1677 | ieee80211_sta_stop_rx_ba_session(sta->sdata->dev, sta->addr, | 1762 | ieee80211_sta_stop_rx_ba_session(sta->sdata->dev, sta->addr, |
1678 | (u16)*ptid, WLAN_BACK_TIMER, | 1763 | (u16)*ptid, WLAN_BACK_TIMER, |
1679 | WLAN_REASON_QSTA_TIMEOUT); | 1764 | WLAN_REASON_QSTA_TIMEOUT); |
@@ -1693,6 +1778,71 @@ void ieee80211_sta_tear_down_BA_sessions(struct net_device *dev, u8 *addr) | |||
1693 | } | 1778 | } |
1694 | } | 1779 | } |
1695 | 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 | |||
1696 | static void ieee80211_rx_mgmt_auth(struct net_device *dev, | 1846 | static void ieee80211_rx_mgmt_auth(struct net_device *dev, |
1697 | struct ieee80211_if_sta *ifsta, | 1847 | struct ieee80211_if_sta *ifsta, |
1698 | struct ieee80211_mgmt *mgmt, | 1848 | struct ieee80211_mgmt *mgmt, |
@@ -1703,73 +1853,41 @@ static void ieee80211_rx_mgmt_auth(struct net_device *dev, | |||
1703 | DECLARE_MAC_BUF(mac); | 1853 | DECLARE_MAC_BUF(mac); |
1704 | 1854 | ||
1705 | if (ifsta->state != IEEE80211_AUTHENTICATE && | 1855 | if (ifsta->state != IEEE80211_AUTHENTICATE && |
1706 | sdata->vif.type != IEEE80211_IF_TYPE_IBSS) { | 1856 | sdata->vif.type != IEEE80211_IF_TYPE_IBSS) |
1707 | printk(KERN_DEBUG "%s: authentication frame received from " | ||
1708 | "%s, but not in authenticate state - ignored\n", | ||
1709 | dev->name, print_mac(mac, mgmt->sa)); | ||
1710 | return; | 1857 | return; |
1711 | } | ||
1712 | 1858 | ||
1713 | if (len < 24 + 6) { | 1859 | if (len < 24 + 6) |
1714 | printk(KERN_DEBUG "%s: too short (%zd) authentication frame " | ||
1715 | "received from %s - ignored\n", | ||
1716 | dev->name, len, print_mac(mac, mgmt->sa)); | ||
1717 | return; | 1860 | return; |
1718 | } | ||
1719 | 1861 | ||
1720 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && | 1862 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && |
1721 | memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) { | 1863 | memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) |
1722 | printk(KERN_DEBUG "%s: authentication frame received from " | ||
1723 | "unknown AP (SA=%s BSSID=%s) - " | ||
1724 | "ignored\n", dev->name, print_mac(mac, mgmt->sa), | ||
1725 | print_mac(mac, mgmt->bssid)); | ||
1726 | return; | 1864 | return; |
1727 | } | ||
1728 | 1865 | ||
1729 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && | 1866 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && |
1730 | memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) { | 1867 | memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) |
1731 | printk(KERN_DEBUG "%s: authentication frame received from " | ||
1732 | "unknown BSSID (SA=%s BSSID=%s) - " | ||
1733 | "ignored\n", dev->name, print_mac(mac, mgmt->sa), | ||
1734 | print_mac(mac, mgmt->bssid)); | ||
1735 | return; | 1868 | return; |
1736 | } | ||
1737 | 1869 | ||
1738 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); | 1870 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); |
1739 | auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); | 1871 | auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); |
1740 | status_code = le16_to_cpu(mgmt->u.auth.status_code); | 1872 | status_code = le16_to_cpu(mgmt->u.auth.status_code); |
1741 | 1873 | ||
1742 | printk(KERN_DEBUG "%s: RX authentication from %s (alg=%d " | ||
1743 | "transaction=%d status=%d)\n", | ||
1744 | dev->name, print_mac(mac, mgmt->sa), auth_alg, | ||
1745 | auth_transaction, status_code); | ||
1746 | |||
1747 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS) { | 1874 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS) { |
1748 | /* IEEE 802.11 standard does not require authentication in IBSS | 1875 | /* |
1876 | * IEEE 802.11 standard does not require authentication in IBSS | ||
1749 | * networks and most implementations do not seem to use it. | 1877 | * networks and most implementations do not seem to use it. |
1750 | * However, try to reply to authentication attempts if someone | 1878 | * However, try to reply to authentication attempts if someone |
1751 | * has actually implemented this. | 1879 | * has actually implemented this. |
1752 | * TODO: Could implement shared key authentication. */ | 1880 | */ |
1753 | if (auth_alg != WLAN_AUTH_OPEN || auth_transaction != 1) { | 1881 | if (auth_alg != WLAN_AUTH_OPEN || auth_transaction != 1) |
1754 | printk(KERN_DEBUG "%s: unexpected IBSS authentication " | ||
1755 | "frame (alg=%d transaction=%d)\n", | ||
1756 | dev->name, auth_alg, auth_transaction); | ||
1757 | return; | 1882 | return; |
1758 | } | ||
1759 | ieee80211_send_auth(dev, ifsta, 2, NULL, 0, 0); | 1883 | ieee80211_send_auth(dev, ifsta, 2, NULL, 0, 0); |
1760 | } | 1884 | } |
1761 | 1885 | ||
1762 | if (auth_alg != ifsta->auth_alg || | 1886 | if (auth_alg != ifsta->auth_alg || |
1763 | auth_transaction != ifsta->auth_transaction) { | 1887 | auth_transaction != ifsta->auth_transaction) |
1764 | printk(KERN_DEBUG "%s: unexpected authentication frame " | ||
1765 | "(alg=%d transaction=%d)\n", | ||
1766 | dev->name, auth_alg, auth_transaction); | ||
1767 | return; | 1888 | return; |
1768 | } | ||
1769 | 1889 | ||
1770 | if (status_code != WLAN_STATUS_SUCCESS) { | 1890 | if (status_code != WLAN_STATUS_SUCCESS) { |
1771 | printk(KERN_DEBUG "%s: AP denied authentication (auth_alg=%d " | ||
1772 | "code=%d)\n", dev->name, ifsta->auth_alg, status_code); | ||
1773 | if (status_code == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { | 1891 | if (status_code == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { |
1774 | u8 algs[3]; | 1892 | u8 algs[3]; |
1775 | const int num_algs = ARRAY_SIZE(algs); | 1893 | const int num_algs = ARRAY_SIZE(algs); |
@@ -1798,9 +1916,6 @@ static void ieee80211_rx_mgmt_auth(struct net_device *dev, | |||
1798 | !ieee80211_sta_wep_configured(dev)) | 1916 | !ieee80211_sta_wep_configured(dev)) |
1799 | continue; | 1917 | continue; |
1800 | ifsta->auth_alg = algs[pos]; | 1918 | ifsta->auth_alg = algs[pos]; |
1801 | printk(KERN_DEBUG "%s: set auth_alg=%d for " | ||
1802 | "next try\n", | ||
1803 | dev->name, ifsta->auth_alg); | ||
1804 | break; | 1919 | break; |
1805 | } | 1920 | } |
1806 | } | 1921 | } |
@@ -1830,30 +1945,16 @@ static void ieee80211_rx_mgmt_deauth(struct net_device *dev, | |||
1830 | u16 reason_code; | 1945 | u16 reason_code; |
1831 | DECLARE_MAC_BUF(mac); | 1946 | DECLARE_MAC_BUF(mac); |
1832 | 1947 | ||
1833 | if (len < 24 + 2) { | 1948 | if (len < 24 + 2) |
1834 | printk(KERN_DEBUG "%s: too short (%zd) deauthentication frame " | ||
1835 | "received from %s - ignored\n", | ||
1836 | dev->name, len, print_mac(mac, mgmt->sa)); | ||
1837 | return; | 1949 | return; |
1838 | } | ||
1839 | 1950 | ||
1840 | if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) { | 1951 | if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN)) |
1841 | printk(KERN_DEBUG "%s: deauthentication frame received from " | ||
1842 | "unknown AP (SA=%s BSSID=%s) - " | ||
1843 | "ignored\n", dev->name, print_mac(mac, mgmt->sa), | ||
1844 | print_mac(mac, mgmt->bssid)); | ||
1845 | return; | 1952 | return; |
1846 | } | ||
1847 | 1953 | ||
1848 | reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); | 1954 | reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); |
1849 | 1955 | ||
1850 | printk(KERN_DEBUG "%s: RX deauthentication from %s" | 1956 | if (ifsta->flags & IEEE80211_STA_AUTHENTICATED) |
1851 | " (reason=%d)\n", | ||
1852 | dev->name, print_mac(mac, mgmt->sa), reason_code); | ||
1853 | |||
1854 | if (ifsta->flags & IEEE80211_STA_AUTHENTICATED) { | ||
1855 | printk(KERN_DEBUG "%s: deauthenticated\n", dev->name); | 1957 | printk(KERN_DEBUG "%s: deauthenticated\n", dev->name); |
1856 | } | ||
1857 | 1958 | ||
1858 | if (ifsta->state == IEEE80211_AUTHENTICATE || | 1959 | if (ifsta->state == IEEE80211_AUTHENTICATE || |
1859 | ifsta->state == IEEE80211_ASSOCIATE || | 1960 | ifsta->state == IEEE80211_ASSOCIATE || |
@@ -1876,27 +1977,14 @@ static void ieee80211_rx_mgmt_disassoc(struct net_device *dev, | |||
1876 | u16 reason_code; | 1977 | u16 reason_code; |
1877 | DECLARE_MAC_BUF(mac); | 1978 | DECLARE_MAC_BUF(mac); |
1878 | 1979 | ||
1879 | if (len < 24 + 2) { | 1980 | if (len < 24 + 2) |
1880 | printk(KERN_DEBUG "%s: too short (%zd) disassociation frame " | ||
1881 | "received from %s - ignored\n", | ||
1882 | dev->name, len, print_mac(mac, mgmt->sa)); | ||
1883 | return; | 1981 | return; |
1884 | } | ||
1885 | 1982 | ||
1886 | if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) { | 1983 | if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN)) |
1887 | printk(KERN_DEBUG "%s: disassociation frame received from " | ||
1888 | "unknown AP (SA=%s BSSID=%s) - " | ||
1889 | "ignored\n", dev->name, print_mac(mac, mgmt->sa), | ||
1890 | print_mac(mac, mgmt->bssid)); | ||
1891 | return; | 1984 | return; |
1892 | } | ||
1893 | 1985 | ||
1894 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); | 1986 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); |
1895 | 1987 | ||
1896 | printk(KERN_DEBUG "%s: RX disassociation from %s" | ||
1897 | " (reason=%d)\n", | ||
1898 | dev->name, print_mac(mac, mgmt->sa), reason_code); | ||
1899 | |||
1900 | if (ifsta->flags & IEEE80211_STA_ASSOCIATED) | 1988 | if (ifsta->flags & IEEE80211_STA_ASSOCIATED) |
1901 | printk(KERN_DEBUG "%s: disassociated\n", dev->name); | 1989 | printk(KERN_DEBUG "%s: disassociated\n", dev->name); |
1902 | 1990 | ||
@@ -1932,27 +2020,14 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1932 | /* AssocResp and ReassocResp have identical structure, so process both | 2020 | /* AssocResp and ReassocResp have identical structure, so process both |
1933 | * of them in this function. */ | 2021 | * of them in this function. */ |
1934 | 2022 | ||
1935 | if (ifsta->state != IEEE80211_ASSOCIATE) { | 2023 | if (ifsta->state != IEEE80211_ASSOCIATE) |
1936 | printk(KERN_DEBUG "%s: association frame received from " | ||
1937 | "%s, but not in associate state - ignored\n", | ||
1938 | dev->name, print_mac(mac, mgmt->sa)); | ||
1939 | return; | 2024 | return; |
1940 | } | ||
1941 | 2025 | ||
1942 | if (len < 24 + 6) { | 2026 | if (len < 24 + 6) |
1943 | printk(KERN_DEBUG "%s: too short (%zd) association frame " | ||
1944 | "received from %s - ignored\n", | ||
1945 | dev->name, len, print_mac(mac, mgmt->sa)); | ||
1946 | return; | 2027 | return; |
1947 | } | ||
1948 | 2028 | ||
1949 | if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) { | 2029 | if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) |
1950 | printk(KERN_DEBUG "%s: association frame received from " | ||
1951 | "unknown AP (SA=%s BSSID=%s) - " | ||
1952 | "ignored\n", dev->name, print_mac(mac, mgmt->sa), | ||
1953 | print_mac(mac, mgmt->bssid)); | ||
1954 | return; | 2030 | return; |
1955 | } | ||
1956 | 2031 | ||
1957 | capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); | 2032 | capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); |
1958 | status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); | 2033 | status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); |
@@ -2016,10 +2091,10 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
2016 | local->hw.conf.channel->center_freq, | 2091 | local->hw.conf.channel->center_freq, |
2017 | ifsta->ssid, ifsta->ssid_len); | 2092 | ifsta->ssid, ifsta->ssid_len); |
2018 | if (bss) { | 2093 | if (bss) { |
2019 | sta->last_rssi = bss->rssi; | ||
2020 | sta->last_signal = bss->signal; | 2094 | sta->last_signal = bss->signal; |
2095 | sta->last_qual = bss->qual; | ||
2021 | sta->last_noise = bss->noise; | 2096 | sta->last_noise = bss->noise; |
2022 | ieee80211_rx_bss_put(dev, bss); | 2097 | ieee80211_rx_bss_put(local, bss); |
2023 | } | 2098 | } |
2024 | 2099 | ||
2025 | err = sta_info_insert(sta); | 2100 | err = sta_info_insert(sta); |
@@ -2041,8 +2116,8 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
2041 | * to between the sta_info_alloc() and sta_info_insert() above. | 2116 | * to between the sta_info_alloc() and sta_info_insert() above. |
2042 | */ | 2117 | */ |
2043 | 2118 | ||
2044 | 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 | |
2045 | WLAN_STA_AUTHORIZED; | 2120 | WLAN_STA_AUTHORIZED); |
2046 | 2121 | ||
2047 | rates = 0; | 2122 | rates = 0; |
2048 | basic_rates = 0; | 2123 | basic_rates = 0; |
@@ -2086,7 +2161,8 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
2086 | else | 2161 | else |
2087 | sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; | 2162 | sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; |
2088 | 2163 | ||
2089 | 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)) { | ||
2090 | struct ieee80211_ht_bss_info bss_info; | 2166 | struct ieee80211_ht_bss_info bss_info; |
2091 | ieee80211_ht_cap_ie_to_ht_info( | 2167 | ieee80211_ht_cap_ie_to_ht_info( |
2092 | (struct ieee80211_ht_cap *) | 2168 | (struct ieee80211_ht_cap *) |
@@ -2099,8 +2175,8 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
2099 | 2175 | ||
2100 | rate_control_rate_init(sta, local); | 2176 | rate_control_rate_init(sta, local); |
2101 | 2177 | ||
2102 | if (elems.wmm_param && (ifsta->flags & IEEE80211_STA_WMM_ENABLED)) { | 2178 | if (elems.wmm_param) { |
2103 | sta->flags |= WLAN_STA_WME; | 2179 | set_sta_flags(sta, WLAN_STA_WME); |
2104 | rcu_read_unlock(); | 2180 | rcu_read_unlock(); |
2105 | ieee80211_sta_wmm_params(dev, ifsta, elems.wmm_param, | 2181 | ieee80211_sta_wmm_params(dev, ifsta, elems.wmm_param, |
2106 | elems.wmm_param_len); | 2182 | elems.wmm_param_len); |
@@ -2136,10 +2212,9 @@ static void __ieee80211_rx_bss_hash_add(struct net_device *dev, | |||
2136 | 2212 | ||
2137 | 2213 | ||
2138 | /* Caller must hold local->sta_bss_lock */ | 2214 | /* Caller must hold local->sta_bss_lock */ |
2139 | static void __ieee80211_rx_bss_hash_del(struct net_device *dev, | 2215 | static void __ieee80211_rx_bss_hash_del(struct ieee80211_local *local, |
2140 | struct ieee80211_sta_bss *bss) | 2216 | struct ieee80211_sta_bss *bss) |
2141 | { | 2217 | { |
2142 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
2143 | struct ieee80211_sta_bss *b, *prev = NULL; | 2218 | struct ieee80211_sta_bss *b, *prev = NULL; |
2144 | b = local->sta_bss_hash[STA_HASH(bss->bssid)]; | 2219 | b = local->sta_bss_hash[STA_HASH(bss->bssid)]; |
2145 | while (b) { | 2220 | while (b) { |
@@ -2284,45 +2359,42 @@ static void ieee80211_rx_bss_free(struct ieee80211_sta_bss *bss) | |||
2284 | kfree(bss->rsn_ie); | 2359 | kfree(bss->rsn_ie); |
2285 | kfree(bss->wmm_ie); | 2360 | kfree(bss->wmm_ie); |
2286 | kfree(bss->ht_ie); | 2361 | kfree(bss->ht_ie); |
2362 | kfree(bss->ht_add_ie); | ||
2287 | kfree(bss_mesh_id(bss)); | 2363 | kfree(bss_mesh_id(bss)); |
2288 | kfree(bss_mesh_cfg(bss)); | 2364 | kfree(bss_mesh_cfg(bss)); |
2289 | kfree(bss); | 2365 | kfree(bss); |
2290 | } | 2366 | } |
2291 | 2367 | ||
2292 | 2368 | ||
2293 | static void ieee80211_rx_bss_put(struct net_device *dev, | 2369 | static void ieee80211_rx_bss_put(struct ieee80211_local *local, |
2294 | struct ieee80211_sta_bss *bss) | 2370 | struct ieee80211_sta_bss *bss) |
2295 | { | 2371 | { |
2296 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
2297 | |||
2298 | local_bh_disable(); | 2372 | local_bh_disable(); |
2299 | if (!atomic_dec_and_lock(&bss->users, &local->sta_bss_lock)) { | 2373 | if (!atomic_dec_and_lock(&bss->users, &local->sta_bss_lock)) { |
2300 | local_bh_enable(); | 2374 | local_bh_enable(); |
2301 | return; | 2375 | return; |
2302 | } | 2376 | } |
2303 | 2377 | ||
2304 | __ieee80211_rx_bss_hash_del(dev, bss); | 2378 | __ieee80211_rx_bss_hash_del(local, bss); |
2305 | list_del(&bss->list); | 2379 | list_del(&bss->list); |
2306 | spin_unlock_bh(&local->sta_bss_lock); | 2380 | spin_unlock_bh(&local->sta_bss_lock); |
2307 | ieee80211_rx_bss_free(bss); | 2381 | ieee80211_rx_bss_free(bss); |
2308 | } | 2382 | } |
2309 | 2383 | ||
2310 | 2384 | ||
2311 | void ieee80211_rx_bss_list_init(struct net_device *dev) | 2385 | void ieee80211_rx_bss_list_init(struct ieee80211_local *local) |
2312 | { | 2386 | { |
2313 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
2314 | spin_lock_init(&local->sta_bss_lock); | 2387 | spin_lock_init(&local->sta_bss_lock); |
2315 | INIT_LIST_HEAD(&local->sta_bss_list); | 2388 | INIT_LIST_HEAD(&local->sta_bss_list); |
2316 | } | 2389 | } |
2317 | 2390 | ||
2318 | 2391 | ||
2319 | void ieee80211_rx_bss_list_deinit(struct net_device *dev) | 2392 | void ieee80211_rx_bss_list_deinit(struct ieee80211_local *local) |
2320 | { | 2393 | { |
2321 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
2322 | struct ieee80211_sta_bss *bss, *tmp; | 2394 | struct ieee80211_sta_bss *bss, *tmp; |
2323 | 2395 | ||
2324 | 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) |
2325 | ieee80211_rx_bss_put(dev, bss); | 2397 | ieee80211_rx_bss_put(local, bss); |
2326 | } | 2398 | } |
2327 | 2399 | ||
2328 | 2400 | ||
@@ -2334,8 +2406,6 @@ static int ieee80211_sta_join_ibss(struct net_device *dev, | |||
2334 | int res, rates, i, j; | 2406 | int res, rates, i, j; |
2335 | struct sk_buff *skb; | 2407 | struct sk_buff *skb; |
2336 | struct ieee80211_mgmt *mgmt; | 2408 | struct ieee80211_mgmt *mgmt; |
2337 | struct ieee80211_tx_control control; | ||
2338 | struct rate_selection ratesel; | ||
2339 | u8 *pos; | 2409 | u8 *pos; |
2340 | struct ieee80211_sub_if_data *sdata; | 2410 | struct ieee80211_sub_if_data *sdata; |
2341 | struct ieee80211_supported_band *sband; | 2411 | struct ieee80211_supported_band *sband; |
@@ -2353,7 +2423,7 @@ static int ieee80211_sta_join_ibss(struct net_device *dev, | |||
2353 | local->ops->reset_tsf(local_to_hw(local)); | 2423 | local->ops->reset_tsf(local_to_hw(local)); |
2354 | } | 2424 | } |
2355 | memcpy(ifsta->bssid, bss->bssid, ETH_ALEN); | 2425 | memcpy(ifsta->bssid, bss->bssid, ETH_ALEN); |
2356 | res = ieee80211_if_config(dev); | 2426 | res = ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID); |
2357 | if (res) | 2427 | if (res) |
2358 | return res; | 2428 | return res; |
2359 | 2429 | ||
@@ -2367,24 +2437,22 @@ static int ieee80211_sta_join_ibss(struct net_device *dev, | |||
2367 | if (res) | 2437 | if (res) |
2368 | return res; | 2438 | return res; |
2369 | 2439 | ||
2370 | /* Set beacon template */ | 2440 | /* Build IBSS probe response */ |
2371 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); | 2441 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); |
2372 | do { | 2442 | if (skb) { |
2373 | if (!skb) | ||
2374 | break; | ||
2375 | |||
2376 | skb_reserve(skb, local->hw.extra_tx_headroom); | 2443 | skb_reserve(skb, local->hw.extra_tx_headroom); |
2377 | 2444 | ||
2378 | mgmt = (struct ieee80211_mgmt *) | 2445 | mgmt = (struct ieee80211_mgmt *) |
2379 | skb_put(skb, 24 + sizeof(mgmt->u.beacon)); | 2446 | skb_put(skb, 24 + sizeof(mgmt->u.beacon)); |
2380 | memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); | 2447 | memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); |
2381 | mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, | 2448 | mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, |
2382 | IEEE80211_STYPE_BEACON); | 2449 | IEEE80211_STYPE_PROBE_RESP); |
2383 | memset(mgmt->da, 0xff, ETH_ALEN); | 2450 | memset(mgmt->da, 0xff, ETH_ALEN); |
2384 | memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN); | 2451 | memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN); |
2385 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); | 2452 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); |
2386 | mgmt->u.beacon.beacon_int = | 2453 | mgmt->u.beacon.beacon_int = |
2387 | 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); | ||
2388 | mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability); | 2456 | mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability); |
2389 | 2457 | ||
2390 | pos = skb_put(skb, 2 + ifsta->ssid_len); | 2458 | pos = skb_put(skb, 2 + ifsta->ssid_len); |
@@ -2422,60 +2490,22 @@ static int ieee80211_sta_join_ibss(struct net_device *dev, | |||
2422 | memcpy(pos, &bss->supp_rates[8], rates); | 2490 | memcpy(pos, &bss->supp_rates[8], rates); |
2423 | } | 2491 | } |
2424 | 2492 | ||
2425 | memset(&control, 0, sizeof(control)); | 2493 | ifsta->probe_resp = skb; |
2426 | rate_control_get_rate(dev, sband, skb, &ratesel); | ||
2427 | if (!ratesel.rate) { | ||
2428 | printk(KERN_DEBUG "%s: Failed to determine TX rate " | ||
2429 | "for IBSS beacon\n", dev->name); | ||
2430 | break; | ||
2431 | } | ||
2432 | control.vif = &sdata->vif; | ||
2433 | control.tx_rate = ratesel.rate; | ||
2434 | if (sdata->bss_conf.use_short_preamble && | ||
2435 | ratesel.rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) | ||
2436 | control.flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; | ||
2437 | control.antenna_sel_tx = local->hw.conf.antenna_sel_tx; | ||
2438 | control.flags |= IEEE80211_TXCTL_NO_ACK; | ||
2439 | control.retry_limit = 1; | ||
2440 | |||
2441 | ifsta->probe_resp = skb_copy(skb, GFP_ATOMIC); | ||
2442 | if (ifsta->probe_resp) { | ||
2443 | mgmt = (struct ieee80211_mgmt *) | ||
2444 | ifsta->probe_resp->data; | ||
2445 | mgmt->frame_control = | ||
2446 | IEEE80211_FC(IEEE80211_FTYPE_MGMT, | ||
2447 | IEEE80211_STYPE_PROBE_RESP); | ||
2448 | } else { | ||
2449 | printk(KERN_DEBUG "%s: Could not allocate ProbeResp " | ||
2450 | "template for IBSS\n", dev->name); | ||
2451 | } | ||
2452 | |||
2453 | if (local->ops->beacon_update && | ||
2454 | local->ops->beacon_update(local_to_hw(local), | ||
2455 | skb, &control) == 0) { | ||
2456 | printk(KERN_DEBUG "%s: Configured IBSS beacon " | ||
2457 | "template\n", dev->name); | ||
2458 | skb = NULL; | ||
2459 | } | ||
2460 | |||
2461 | rates = 0; | ||
2462 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
2463 | for (i = 0; i < bss->supp_rates_len; i++) { | ||
2464 | int bitrate = (bss->supp_rates[i] & 0x7f) * 5; | ||
2465 | for (j = 0; j < sband->n_bitrates; j++) | ||
2466 | if (sband->bitrates[j].bitrate == bitrate) | ||
2467 | rates |= BIT(j); | ||
2468 | } | ||
2469 | ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates; | ||
2470 | 2494 | ||
2471 | ieee80211_sta_def_wmm_params(dev, bss, 1); | 2495 | ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON); |
2472 | } while (0); | 2496 | } |
2473 | 2497 | ||
2474 | if (skb) { | 2498 | rates = 0; |
2475 | printk(KERN_DEBUG "%s: Failed to configure IBSS beacon " | 2499 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
2476 | "template\n", dev->name); | 2500 | for (i = 0; i < bss->supp_rates_len; i++) { |
2477 | 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); | ||
2478 | } | 2505 | } |
2506 | ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates; | ||
2507 | |||
2508 | ieee80211_sta_def_wmm_params(dev, bss, 1); | ||
2479 | 2509 | ||
2480 | ifsta->state = IEEE80211_IBSS_JOINED; | 2510 | ifsta->state = IEEE80211_IBSS_JOINED; |
2481 | mod_timer(&ifsta->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL); | 2511 | mod_timer(&ifsta->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL); |
@@ -2528,11 +2558,10 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2528 | struct ieee80211_mgmt *mgmt, | 2558 | struct ieee80211_mgmt *mgmt, |
2529 | size_t len, | 2559 | size_t len, |
2530 | struct ieee80211_rx_status *rx_status, | 2560 | struct ieee80211_rx_status *rx_status, |
2561 | struct ieee802_11_elems *elems, | ||
2531 | int beacon) | 2562 | int beacon) |
2532 | { | 2563 | { |
2533 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 2564 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
2534 | struct ieee802_11_elems elems; | ||
2535 | size_t baselen; | ||
2536 | int freq, clen; | 2565 | int freq, clen; |
2537 | struct ieee80211_sta_bss *bss; | 2566 | struct ieee80211_sta_bss *bss; |
2538 | struct sta_info *sta; | 2567 | struct sta_info *sta; |
@@ -2545,35 +2574,24 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2545 | if (!beacon && memcmp(mgmt->da, dev->dev_addr, ETH_ALEN)) | 2574 | if (!beacon && memcmp(mgmt->da, dev->dev_addr, ETH_ALEN)) |
2546 | return; /* ignore ProbeResp to foreign address */ | 2575 | return; /* ignore ProbeResp to foreign address */ |
2547 | 2576 | ||
2548 | #if 0 | ||
2549 | printk(KERN_DEBUG "%s: RX %s from %s to %s\n", | ||
2550 | dev->name, beacon ? "Beacon" : "Probe Response", | ||
2551 | print_mac(mac, mgmt->sa), print_mac(mac2, mgmt->da)); | ||
2552 | #endif | ||
2553 | |||
2554 | baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; | ||
2555 | if (baselen > len) | ||
2556 | return; | ||
2557 | |||
2558 | beacon_timestamp = le64_to_cpu(mgmt->u.beacon.timestamp); | 2577 | beacon_timestamp = le64_to_cpu(mgmt->u.beacon.timestamp); |
2559 | ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems); | ||
2560 | 2578 | ||
2561 | if (ieee80211_vif_is_mesh(&sdata->vif) && elems.mesh_id && | 2579 | if (ieee80211_vif_is_mesh(&sdata->vif) && elems->mesh_id && |
2562 | elems.mesh_config && mesh_matches_local(&elems, dev)) { | 2580 | elems->mesh_config && mesh_matches_local(elems, dev)) { |
2563 | u64 rates = ieee80211_sta_get_rates(local, &elems, | 2581 | u64 rates = ieee80211_sta_get_rates(local, elems, |
2564 | rx_status->band); | 2582 | rx_status->band); |
2565 | 2583 | ||
2566 | mesh_neighbour_update(mgmt->sa, rates, dev, | 2584 | mesh_neighbour_update(mgmt->sa, rates, dev, |
2567 | mesh_peer_accepts_plinks(&elems, dev)); | 2585 | mesh_peer_accepts_plinks(elems, dev)); |
2568 | } | 2586 | } |
2569 | 2587 | ||
2570 | rcu_read_lock(); | 2588 | rcu_read_lock(); |
2571 | 2589 | ||
2572 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && elems.supp_rates && | 2590 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && elems->supp_rates && |
2573 | memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0 && | 2591 | memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0 && |
2574 | (sta = sta_info_get(local, mgmt->sa))) { | 2592 | (sta = sta_info_get(local, mgmt->sa))) { |
2575 | u64 prev_rates; | 2593 | u64 prev_rates; |
2576 | u64 supp_rates = ieee80211_sta_get_rates(local, &elems, | 2594 | u64 supp_rates = ieee80211_sta_get_rates(local, elems, |
2577 | rx_status->band); | 2595 | rx_status->band); |
2578 | 2596 | ||
2579 | prev_rates = sta->supp_rates[rx_status->band]; | 2597 | prev_rates = sta->supp_rates[rx_status->band]; |
@@ -2585,21 +2603,12 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2585 | sta->supp_rates[rx_status->band] = | 2603 | sta->supp_rates[rx_status->band] = |
2586 | sdata->u.sta.supp_rates_bits[rx_status->band]; | 2604 | sdata->u.sta.supp_rates_bits[rx_status->band]; |
2587 | } | 2605 | } |
2588 | if (sta->supp_rates[rx_status->band] != prev_rates) { | ||
2589 | printk(KERN_DEBUG "%s: updated supp_rates set for " | ||
2590 | "%s based on beacon info (0x%llx & 0x%llx -> " | ||
2591 | "0x%llx)\n", | ||
2592 | dev->name, print_mac(mac, sta->addr), | ||
2593 | (unsigned long long) prev_rates, | ||
2594 | (unsigned long long) supp_rates, | ||
2595 | (unsigned long long) sta->supp_rates[rx_status->band]); | ||
2596 | } | ||
2597 | } | 2606 | } |
2598 | 2607 | ||
2599 | rcu_read_unlock(); | 2608 | rcu_read_unlock(); |
2600 | 2609 | ||
2601 | if (elems.ds_params && elems.ds_params_len == 1) | 2610 | if (elems->ds_params && elems->ds_params_len == 1) |
2602 | freq = ieee80211_channel_to_frequency(elems.ds_params[0]); | 2611 | freq = ieee80211_channel_to_frequency(elems->ds_params[0]); |
2603 | else | 2612 | else |
2604 | freq = rx_status->freq; | 2613 | freq = rx_status->freq; |
2605 | 2614 | ||
@@ -2609,23 +2618,23 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2609 | return; | 2618 | return; |
2610 | 2619 | ||
2611 | #ifdef CONFIG_MAC80211_MESH | 2620 | #ifdef CONFIG_MAC80211_MESH |
2612 | if (elems.mesh_config) | 2621 | if (elems->mesh_config) |
2613 | bss = ieee80211_rx_mesh_bss_get(dev, elems.mesh_id, | 2622 | bss = ieee80211_rx_mesh_bss_get(dev, elems->mesh_id, |
2614 | elems.mesh_id_len, elems.mesh_config, freq); | 2623 | elems->mesh_id_len, elems->mesh_config, freq); |
2615 | else | 2624 | else |
2616 | #endif | 2625 | #endif |
2617 | bss = ieee80211_rx_bss_get(dev, mgmt->bssid, freq, | 2626 | bss = ieee80211_rx_bss_get(dev, mgmt->bssid, freq, |
2618 | elems.ssid, elems.ssid_len); | 2627 | elems->ssid, elems->ssid_len); |
2619 | if (!bss) { | 2628 | if (!bss) { |
2620 | #ifdef CONFIG_MAC80211_MESH | 2629 | #ifdef CONFIG_MAC80211_MESH |
2621 | if (elems.mesh_config) | 2630 | if (elems->mesh_config) |
2622 | bss = ieee80211_rx_mesh_bss_add(dev, elems.mesh_id, | 2631 | bss = ieee80211_rx_mesh_bss_add(dev, elems->mesh_id, |
2623 | elems.mesh_id_len, elems.mesh_config, | 2632 | elems->mesh_id_len, elems->mesh_config, |
2624 | elems.mesh_config_len, freq); | 2633 | elems->mesh_config_len, freq); |
2625 | else | 2634 | else |
2626 | #endif | 2635 | #endif |
2627 | bss = ieee80211_rx_bss_add(dev, mgmt->bssid, freq, | 2636 | bss = ieee80211_rx_bss_add(dev, mgmt->bssid, freq, |
2628 | elems.ssid, elems.ssid_len); | 2637 | elems->ssid, elems->ssid_len); |
2629 | if (!bss) | 2638 | if (!bss) |
2630 | return; | 2639 | return; |
2631 | } else { | 2640 | } else { |
@@ -2638,46 +2647,66 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2638 | } | 2647 | } |
2639 | 2648 | ||
2640 | /* 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 */ |
2641 | if (elems.erp_info && elems.erp_info_len >= 1) { | 2650 | if (elems->erp_info && elems->erp_info_len >= 1) { |
2642 | bss->erp_value = elems.erp_info[0]; | 2651 | bss->erp_value = elems->erp_info[0]; |
2643 | bss->has_erp_value = 1; | 2652 | bss->has_erp_value = 1; |
2644 | } | 2653 | } |
2645 | 2654 | ||
2646 | if (elems.ht_cap_elem && | 2655 | if (elems->ht_cap_elem && |
2647 | (!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 || |
2648 | 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))) { |
2649 | kfree(bss->ht_ie); | 2658 | kfree(bss->ht_ie); |
2650 | 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); |
2651 | if (bss->ht_ie) { | 2660 | if (bss->ht_ie) { |
2652 | memcpy(bss->ht_ie, elems.ht_cap_elem - 2, | 2661 | memcpy(bss->ht_ie, elems->ht_cap_elem - 2, |
2653 | elems.ht_cap_elem_len + 2); | 2662 | elems->ht_cap_elem_len + 2); |
2654 | bss->ht_ie_len = elems.ht_cap_elem_len + 2; | 2663 | bss->ht_ie_len = elems->ht_cap_elem_len + 2; |
2655 | } else | 2664 | } else |
2656 | bss->ht_ie_len = 0; | 2665 | bss->ht_ie_len = 0; |
2657 | } else if (!elems.ht_cap_elem && bss->ht_ie) { | 2666 | } else if (!elems->ht_cap_elem && bss->ht_ie) { |
2658 | kfree(bss->ht_ie); | 2667 | kfree(bss->ht_ie); |
2659 | bss->ht_ie = NULL; | 2668 | bss->ht_ie = NULL; |
2660 | bss->ht_ie_len = 0; | 2669 | bss->ht_ie_len = 0; |
2661 | } | 2670 | } |
2662 | 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 | |||
2663 | bss->beacon_int = le16_to_cpu(mgmt->u.beacon.beacon_int); | 2692 | bss->beacon_int = le16_to_cpu(mgmt->u.beacon.beacon_int); |
2664 | bss->capability = le16_to_cpu(mgmt->u.beacon.capab_info); | 2693 | bss->capability = le16_to_cpu(mgmt->u.beacon.capab_info); |
2665 | 2694 | ||
2666 | bss->supp_rates_len = 0; | 2695 | bss->supp_rates_len = 0; |
2667 | if (elems.supp_rates) { | 2696 | if (elems->supp_rates) { |
2668 | clen = IEEE80211_MAX_SUPP_RATES - bss->supp_rates_len; | 2697 | clen = IEEE80211_MAX_SUPP_RATES - bss->supp_rates_len; |
2669 | if (clen > elems.supp_rates_len) | 2698 | if (clen > elems->supp_rates_len) |
2670 | clen = elems.supp_rates_len; | 2699 | clen = elems->supp_rates_len; |
2671 | memcpy(&bss->supp_rates[bss->supp_rates_len], elems.supp_rates, | 2700 | memcpy(&bss->supp_rates[bss->supp_rates_len], elems->supp_rates, |
2672 | clen); | 2701 | clen); |
2673 | bss->supp_rates_len += clen; | 2702 | bss->supp_rates_len += clen; |
2674 | } | 2703 | } |
2675 | if (elems.ext_supp_rates) { | 2704 | if (elems->ext_supp_rates) { |
2676 | clen = IEEE80211_MAX_SUPP_RATES - bss->supp_rates_len; | 2705 | clen = IEEE80211_MAX_SUPP_RATES - bss->supp_rates_len; |
2677 | if (clen > elems.ext_supp_rates_len) | 2706 | if (clen > elems->ext_supp_rates_len) |
2678 | clen = elems.ext_supp_rates_len; | 2707 | clen = elems->ext_supp_rates_len; |
2679 | memcpy(&bss->supp_rates[bss->supp_rates_len], | 2708 | memcpy(&bss->supp_rates[bss->supp_rates_len], |
2680 | elems.ext_supp_rates, clen); | 2709 | elems->ext_supp_rates, clen); |
2681 | bss->supp_rates_len += clen; | 2710 | bss->supp_rates_len += clen; |
2682 | } | 2711 | } |
2683 | 2712 | ||
@@ -2685,9 +2714,9 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2685 | 2714 | ||
2686 | bss->timestamp = beacon_timestamp; | 2715 | bss->timestamp = beacon_timestamp; |
2687 | bss->last_update = jiffies; | 2716 | bss->last_update = jiffies; |
2688 | bss->rssi = rx_status->ssi; | ||
2689 | bss->signal = rx_status->signal; | 2717 | bss->signal = rx_status->signal; |
2690 | bss->noise = rx_status->noise; | 2718 | bss->noise = rx_status->noise; |
2719 | bss->qual = rx_status->qual; | ||
2691 | if (!beacon && !bss->probe_resp) | 2720 | if (!beacon && !bss->probe_resp) |
2692 | bss->probe_resp = true; | 2721 | bss->probe_resp = true; |
2693 | 2722 | ||
@@ -2697,37 +2726,37 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2697 | */ | 2726 | */ |
2698 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && | 2727 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && |
2699 | bss->probe_resp && beacon) { | 2728 | bss->probe_resp && beacon) { |
2700 | ieee80211_rx_bss_put(dev, bss); | 2729 | ieee80211_rx_bss_put(local, bss); |
2701 | return; | 2730 | return; |
2702 | } | 2731 | } |
2703 | 2732 | ||
2704 | if (elems.wpa && | 2733 | if (elems->wpa && |
2705 | (!bss->wpa_ie || bss->wpa_ie_len != elems.wpa_len || | 2734 | (!bss->wpa_ie || bss->wpa_ie_len != elems->wpa_len || |
2706 | memcmp(bss->wpa_ie, elems.wpa, elems.wpa_len))) { | 2735 | memcmp(bss->wpa_ie, elems->wpa, elems->wpa_len))) { |
2707 | kfree(bss->wpa_ie); | 2736 | kfree(bss->wpa_ie); |
2708 | bss->wpa_ie = kmalloc(elems.wpa_len + 2, GFP_ATOMIC); | 2737 | bss->wpa_ie = kmalloc(elems->wpa_len + 2, GFP_ATOMIC); |
2709 | if (bss->wpa_ie) { | 2738 | if (bss->wpa_ie) { |
2710 | memcpy(bss->wpa_ie, elems.wpa - 2, elems.wpa_len + 2); | 2739 | memcpy(bss->wpa_ie, elems->wpa - 2, elems->wpa_len + 2); |
2711 | bss->wpa_ie_len = elems.wpa_len + 2; | 2740 | bss->wpa_ie_len = elems->wpa_len + 2; |
2712 | } else | 2741 | } else |
2713 | bss->wpa_ie_len = 0; | 2742 | bss->wpa_ie_len = 0; |
2714 | } else if (!elems.wpa && bss->wpa_ie) { | 2743 | } else if (!elems->wpa && bss->wpa_ie) { |
2715 | kfree(bss->wpa_ie); | 2744 | kfree(bss->wpa_ie); |
2716 | bss->wpa_ie = NULL; | 2745 | bss->wpa_ie = NULL; |
2717 | bss->wpa_ie_len = 0; | 2746 | bss->wpa_ie_len = 0; |
2718 | } | 2747 | } |
2719 | 2748 | ||
2720 | if (elems.rsn && | 2749 | if (elems->rsn && |
2721 | (!bss->rsn_ie || bss->rsn_ie_len != elems.rsn_len || | 2750 | (!bss->rsn_ie || bss->rsn_ie_len != elems->rsn_len || |
2722 | memcmp(bss->rsn_ie, elems.rsn, elems.rsn_len))) { | 2751 | memcmp(bss->rsn_ie, elems->rsn, elems->rsn_len))) { |
2723 | kfree(bss->rsn_ie); | 2752 | kfree(bss->rsn_ie); |
2724 | bss->rsn_ie = kmalloc(elems.rsn_len + 2, GFP_ATOMIC); | 2753 | bss->rsn_ie = kmalloc(elems->rsn_len + 2, GFP_ATOMIC); |
2725 | if (bss->rsn_ie) { | 2754 | if (bss->rsn_ie) { |
2726 | memcpy(bss->rsn_ie, elems.rsn - 2, elems.rsn_len + 2); | 2755 | memcpy(bss->rsn_ie, elems->rsn - 2, elems->rsn_len + 2); |
2727 | bss->rsn_ie_len = elems.rsn_len + 2; | 2756 | bss->rsn_ie_len = elems->rsn_len + 2; |
2728 | } else | 2757 | } else |
2729 | bss->rsn_ie_len = 0; | 2758 | bss->rsn_ie_len = 0; |
2730 | } else if (!elems.rsn && bss->rsn_ie) { | 2759 | } else if (!elems->rsn && bss->rsn_ie) { |
2731 | kfree(bss->rsn_ie); | 2760 | kfree(bss->rsn_ie); |
2732 | bss->rsn_ie = NULL; | 2761 | bss->rsn_ie = NULL; |
2733 | bss->rsn_ie_len = 0; | 2762 | bss->rsn_ie_len = 0; |
@@ -2747,20 +2776,21 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2747 | * inclusion of the WMM Parameters in beacons, however, is optional. | 2776 | * inclusion of the WMM Parameters in beacons, however, is optional. |
2748 | */ | 2777 | */ |
2749 | 2778 | ||
2750 | if (elems.wmm_param && | 2779 | if (elems->wmm_param && |
2751 | (!bss->wmm_ie || bss->wmm_ie_len != elems.wmm_param_len || | 2780 | (!bss->wmm_ie || bss->wmm_ie_len != elems->wmm_param_len || |
2752 | memcmp(bss->wmm_ie, elems.wmm_param, elems.wmm_param_len))) { | 2781 | memcmp(bss->wmm_ie, elems->wmm_param, elems->wmm_param_len))) { |
2753 | kfree(bss->wmm_ie); | 2782 | kfree(bss->wmm_ie); |
2754 | bss->wmm_ie = kmalloc(elems.wmm_param_len + 2, GFP_ATOMIC); | 2783 | bss->wmm_ie = kmalloc(elems->wmm_param_len + 2, GFP_ATOMIC); |
2755 | if (bss->wmm_ie) { | 2784 | if (bss->wmm_ie) { |
2756 | memcpy(bss->wmm_ie, elems.wmm_param - 2, | 2785 | memcpy(bss->wmm_ie, elems->wmm_param - 2, |
2757 | elems.wmm_param_len + 2); | 2786 | elems->wmm_param_len + 2); |
2758 | bss->wmm_ie_len = elems.wmm_param_len + 2; | 2787 | bss->wmm_ie_len = elems->wmm_param_len + 2; |
2759 | } else | 2788 | } else |
2760 | bss->wmm_ie_len = 0; | 2789 | bss->wmm_ie_len = 0; |
2761 | } else if (elems.wmm_info && | 2790 | } else if (elems->wmm_info && |
2762 | (!bss->wmm_ie || bss->wmm_ie_len != elems.wmm_info_len || | 2791 | (!bss->wmm_ie || bss->wmm_ie_len != elems->wmm_info_len || |
2763 | memcmp(bss->wmm_ie, elems.wmm_info, elems.wmm_info_len))) { | 2792 | memcmp(bss->wmm_ie, elems->wmm_info, |
2793 | elems->wmm_info_len))) { | ||
2764 | /* 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 |
2765 | * beacon frames.So while parsing the beacon frame the | 2795 | * beacon frames.So while parsing the beacon frame the |
2766 | * wmm_info structure is used instead of wmm_param. | 2796 | * wmm_info structure is used instead of wmm_param. |
@@ -2770,14 +2800,14 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2770 | * n-band association. | 2800 | * n-band association. |
2771 | */ | 2801 | */ |
2772 | kfree(bss->wmm_ie); | 2802 | kfree(bss->wmm_ie); |
2773 | bss->wmm_ie = kmalloc(elems.wmm_info_len + 2, GFP_ATOMIC); | 2803 | bss->wmm_ie = kmalloc(elems->wmm_info_len + 2, GFP_ATOMIC); |
2774 | if (bss->wmm_ie) { | 2804 | if (bss->wmm_ie) { |
2775 | memcpy(bss->wmm_ie, elems.wmm_info - 2, | 2805 | memcpy(bss->wmm_ie, elems->wmm_info - 2, |
2776 | elems.wmm_info_len + 2); | 2806 | elems->wmm_info_len + 2); |
2777 | bss->wmm_ie_len = elems.wmm_info_len + 2; | 2807 | bss->wmm_ie_len = elems->wmm_info_len + 2; |
2778 | } else | 2808 | } else |
2779 | bss->wmm_ie_len = 0; | 2809 | bss->wmm_ie_len = 0; |
2780 | } else if (!elems.wmm_param && !elems.wmm_info && bss->wmm_ie) { | 2810 | } else if (!elems->wmm_param && !elems->wmm_info && bss->wmm_ie) { |
2781 | kfree(bss->wmm_ie); | 2811 | kfree(bss->wmm_ie); |
2782 | bss->wmm_ie = NULL; | 2812 | bss->wmm_ie = NULL; |
2783 | bss->wmm_ie_len = 0; | 2813 | bss->wmm_ie_len = 0; |
@@ -2788,8 +2818,9 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2788 | !local->sta_sw_scanning && !local->sta_hw_scanning && | 2818 | !local->sta_sw_scanning && !local->sta_hw_scanning && |
2789 | bss->capability & WLAN_CAPABILITY_IBSS && | 2819 | bss->capability & WLAN_CAPABILITY_IBSS && |
2790 | bss->freq == local->oper_channel->center_freq && | 2820 | bss->freq == local->oper_channel->center_freq && |
2791 | elems.ssid_len == sdata->u.sta.ssid_len && | 2821 | elems->ssid_len == sdata->u.sta.ssid_len && |
2792 | 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) { | ||
2793 | if (rx_status->flag & RX_FLAG_TSFT) { | 2824 | if (rx_status->flag & RX_FLAG_TSFT) { |
2794 | /* in order for correct IBSS merging we need mactime | 2825 | /* in order for correct IBSS merging we need mactime |
2795 | * | 2826 | * |
@@ -2827,18 +2858,18 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2827 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 2858 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
2828 | if (beacon_timestamp > rx_timestamp) { | 2859 | if (beacon_timestamp > rx_timestamp) { |
2829 | #ifndef CONFIG_MAC80211_IBSS_DEBUG | 2860 | #ifndef CONFIG_MAC80211_IBSS_DEBUG |
2830 | 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)); | ||
2831 | #endif | 2864 | #endif |
2832 | printk(KERN_DEBUG "%s: beacon TSF higher than " | ||
2833 | "local TSF - IBSS merge with BSSID %s\n", | ||
2834 | dev->name, print_mac(mac, mgmt->bssid)); | ||
2835 | ieee80211_sta_join_ibss(dev, &sdata->u.sta, bss); | 2865 | ieee80211_sta_join_ibss(dev, &sdata->u.sta, bss); |
2836 | ieee80211_ibss_add_sta(dev, NULL, | 2866 | ieee80211_ibss_add_sta(dev, NULL, |
2837 | mgmt->bssid, mgmt->sa); | 2867 | mgmt->bssid, mgmt->sa, |
2868 | BIT(rx_status->rate_idx)); | ||
2838 | } | 2869 | } |
2839 | } | 2870 | } |
2840 | 2871 | ||
2841 | ieee80211_rx_bss_put(dev, bss); | 2872 | ieee80211_rx_bss_put(local, bss); |
2842 | } | 2873 | } |
2843 | 2874 | ||
2844 | 2875 | ||
@@ -2847,7 +2878,17 @@ static void ieee80211_rx_mgmt_probe_resp(struct net_device *dev, | |||
2847 | size_t len, | 2878 | size_t len, |
2848 | struct ieee80211_rx_status *rx_status) | 2879 | struct ieee80211_rx_status *rx_status) |
2849 | { | 2880 | { |
2850 | 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); | ||
2851 | } | 2892 | } |
2852 | 2893 | ||
2853 | 2894 | ||
@@ -2864,7 +2905,14 @@ static void ieee80211_rx_mgmt_beacon(struct net_device *dev, | |||
2864 | struct ieee80211_conf *conf = &local->hw.conf; | 2905 | struct ieee80211_conf *conf = &local->hw.conf; |
2865 | u32 changed = 0; | 2906 | u32 changed = 0; |
2866 | 2907 | ||
2867 | 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); | ||
2868 | 2916 | ||
2869 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 2917 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2870 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA) | 2918 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA) |
@@ -2875,17 +2923,8 @@ static void ieee80211_rx_mgmt_beacon(struct net_device *dev, | |||
2875 | memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) | 2923 | memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) |
2876 | return; | 2924 | return; |
2877 | 2925 | ||
2878 | /* Process beacon from the current BSS */ | 2926 | ieee80211_sta_wmm_params(dev, ifsta, elems.wmm_param, |
2879 | baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; | 2927 | elems.wmm_param_len); |
2880 | if (baselen > len) | ||
2881 | return; | ||
2882 | |||
2883 | ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems); | ||
2884 | |||
2885 | if (elems.wmm_param && (ifsta->flags & IEEE80211_STA_WMM_ENABLED)) { | ||
2886 | ieee80211_sta_wmm_params(dev, ifsta, elems.wmm_param, | ||
2887 | elems.wmm_param_len); | ||
2888 | } | ||
2889 | 2928 | ||
2890 | /* 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 |
2891 | * requirement that driver's bss_info_changed function needs to be | 2930 | * requirement that driver's bss_info_changed function needs to be |
@@ -2962,11 +3001,11 @@ static void ieee80211_rx_mgmt_probe_req(struct net_device *dev, | |||
2962 | pos = mgmt->u.probe_req.variable; | 3001 | pos = mgmt->u.probe_req.variable; |
2963 | if (pos[0] != WLAN_EID_SSID || | 3002 | if (pos[0] != WLAN_EID_SSID || |
2964 | pos + 2 + pos[1] > end) { | 3003 | pos + 2 + pos[1] > end) { |
2965 | if (net_ratelimit()) { | 3004 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
2966 | printk(KERN_DEBUG "%s: Invalid SSID IE in ProbeReq " | 3005 | printk(KERN_DEBUG "%s: Invalid SSID IE in ProbeReq " |
2967 | "from %s\n", | 3006 | "from %s\n", |
2968 | dev->name, print_mac(mac, mgmt->sa)); | 3007 | dev->name, print_mac(mac, mgmt->sa)); |
2969 | } | 3008 | #endif |
2970 | return; | 3009 | return; |
2971 | } | 3010 | } |
2972 | if (pos[1] != 0 && | 3011 | if (pos[1] != 0 && |
@@ -2997,11 +3036,24 @@ static void ieee80211_rx_mgmt_action(struct net_device *dev, | |||
2997 | struct ieee80211_rx_status *rx_status) | 3036 | struct ieee80211_rx_status *rx_status) |
2998 | { | 3037 | { |
2999 | 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); | ||
3000 | 3040 | ||
3001 | if (len < IEEE80211_MIN_ACTION_SIZE) | 3041 | if (len < IEEE80211_MIN_ACTION_SIZE) |
3002 | return; | 3042 | return; |
3003 | 3043 | ||
3004 | 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; | ||
3005 | case WLAN_CATEGORY_BACK: | 3057 | case WLAN_CATEGORY_BACK: |
3006 | switch (mgmt->u.action.u.addba_req.action_code) { | 3058 | switch (mgmt->u.action.u.addba_req.action_code) { |
3007 | case WLAN_ACTION_ADDBA_REQ: | 3059 | case WLAN_ACTION_ADDBA_REQ: |
@@ -3022,11 +3074,6 @@ static void ieee80211_rx_mgmt_action(struct net_device *dev, | |||
3022 | break; | 3074 | break; |
3023 | ieee80211_sta_process_delba(dev, mgmt, len); | 3075 | ieee80211_sta_process_delba(dev, mgmt, len); |
3024 | break; | 3076 | break; |
3025 | default: | ||
3026 | if (net_ratelimit()) | ||
3027 | printk(KERN_DEBUG "%s: Rx unknown A-MPDU action\n", | ||
3028 | dev->name); | ||
3029 | break; | ||
3030 | } | 3077 | } |
3031 | break; | 3078 | break; |
3032 | case PLINK_CATEGORY: | 3079 | case PLINK_CATEGORY: |
@@ -3037,11 +3084,6 @@ static void ieee80211_rx_mgmt_action(struct net_device *dev, | |||
3037 | if (ieee80211_vif_is_mesh(&sdata->vif)) | 3084 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
3038 | mesh_rx_path_sel_frame(dev, mgmt, len); | 3085 | mesh_rx_path_sel_frame(dev, mgmt, len); |
3039 | break; | 3086 | break; |
3040 | default: | ||
3041 | if (net_ratelimit()) | ||
3042 | printk(KERN_DEBUG "%s: Rx unknown action frame - " | ||
3043 | "category=%d\n", dev->name, mgmt->u.action.category); | ||
3044 | break; | ||
3045 | } | 3087 | } |
3046 | } | 3088 | } |
3047 | 3089 | ||
@@ -3077,11 +3119,6 @@ void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb, | |||
3077 | skb_queue_tail(&ifsta->skb_queue, skb); | 3119 | skb_queue_tail(&ifsta->skb_queue, skb); |
3078 | queue_work(local->hw.workqueue, &ifsta->work); | 3120 | queue_work(local->hw.workqueue, &ifsta->work); |
3079 | return; | 3121 | return; |
3080 | default: | ||
3081 | printk(KERN_DEBUG "%s: received unknown management frame - " | ||
3082 | "stype=%d\n", dev->name, | ||
3083 | (fc & IEEE80211_FCTL_STYPE) >> 4); | ||
3084 | break; | ||
3085 | } | 3122 | } |
3086 | 3123 | ||
3087 | fail: | 3124 | fail: |
@@ -3145,33 +3182,32 @@ ieee80211_sta_rx_scan(struct net_device *dev, struct sk_buff *skb, | |||
3145 | struct ieee80211_rx_status *rx_status) | 3182 | struct ieee80211_rx_status *rx_status) |
3146 | { | 3183 | { |
3147 | struct ieee80211_mgmt *mgmt; | 3184 | struct ieee80211_mgmt *mgmt; |
3148 | u16 fc; | 3185 | __le16 fc; |
3149 | 3186 | ||
3150 | if (skb->len < 2) | 3187 | if (skb->len < 2) |
3151 | return RX_DROP_UNUSABLE; | 3188 | return RX_DROP_UNUSABLE; |
3152 | 3189 | ||
3153 | mgmt = (struct ieee80211_mgmt *) skb->data; | 3190 | mgmt = (struct ieee80211_mgmt *) skb->data; |
3154 | fc = le16_to_cpu(mgmt->frame_control); | 3191 | fc = mgmt->frame_control; |
3155 | 3192 | ||
3156 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) | 3193 | if (ieee80211_is_ctl(fc)) |
3157 | return RX_CONTINUE; | 3194 | return RX_CONTINUE; |
3158 | 3195 | ||
3159 | if (skb->len < 24) | 3196 | if (skb->len < 24) |
3160 | return RX_DROP_MONITOR; | 3197 | return RX_DROP_MONITOR; |
3161 | 3198 | ||
3162 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { | 3199 | if (ieee80211_is_probe_resp(fc)) { |
3163 | if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP) { | 3200 | ieee80211_rx_mgmt_probe_resp(dev, mgmt, skb->len, rx_status); |
3164 | ieee80211_rx_mgmt_probe_resp(dev, mgmt, | 3201 | dev_kfree_skb(skb); |
3165 | skb->len, rx_status); | 3202 | return RX_QUEUED; |
3166 | dev_kfree_skb(skb); | 3203 | } |
3167 | return RX_QUEUED; | 3204 | |
3168 | } else if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON) { | 3205 | if (ieee80211_is_beacon(fc)) { |
3169 | ieee80211_rx_mgmt_beacon(dev, mgmt, skb->len, | 3206 | ieee80211_rx_mgmt_beacon(dev, mgmt, skb->len, rx_status); |
3170 | rx_status); | 3207 | dev_kfree_skb(skb); |
3171 | dev_kfree_skb(skb); | 3208 | return RX_QUEUED; |
3172 | return RX_QUEUED; | ||
3173 | } | ||
3174 | } | 3209 | } |
3210 | |||
3175 | return RX_CONTINUE; | 3211 | return RX_CONTINUE; |
3176 | } | 3212 | } |
3177 | 3213 | ||
@@ -3211,8 +3247,10 @@ static void ieee80211_sta_expire(struct net_device *dev, unsigned long exp_time) | |||
3211 | spin_lock_irqsave(&local->sta_lock, flags); | 3247 | spin_lock_irqsave(&local->sta_lock, flags); |
3212 | list_for_each_entry_safe(sta, tmp, &local->sta_list, list) | 3248 | list_for_each_entry_safe(sta, tmp, &local->sta_list, list) |
3213 | 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 | ||
3214 | printk(KERN_DEBUG "%s: expiring inactive STA %s\n", | 3251 | printk(KERN_DEBUG "%s: expiring inactive STA %s\n", |
3215 | dev->name, print_mac(mac, sta->addr)); | 3252 | dev->name, print_mac(mac, sta->addr)); |
3253 | #endif | ||
3216 | __sta_info_unlink(&sta); | 3254 | __sta_info_unlink(&sta); |
3217 | if (sta) | 3255 | if (sta) |
3218 | list_add(&sta->list, &tmp_list); | 3256 | list_add(&sta->list, &tmp_list); |
@@ -3251,7 +3289,7 @@ static void ieee80211_mesh_housekeeping(struct net_device *dev, | |||
3251 | 3289 | ||
3252 | free_plinks = mesh_plink_availables(sdata); | 3290 | free_plinks = mesh_plink_availables(sdata); |
3253 | if (free_plinks != sdata->u.sta.accepting_plinks) | 3291 | if (free_plinks != sdata->u.sta.accepting_plinks) |
3254 | ieee80211_if_config_beacon(dev); | 3292 | ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON); |
3255 | 3293 | ||
3256 | mod_timer(&ifsta->timer, jiffies + | 3294 | mod_timer(&ifsta->timer, jiffies + |
3257 | IEEE80211_MESH_HOUSEKEEPING_INTERVAL); | 3295 | IEEE80211_MESH_HOUSEKEEPING_INTERVAL); |
@@ -3295,13 +3333,10 @@ void ieee80211_sta_work(struct work_struct *work) | |||
3295 | if (local->sta_sw_scanning || local->sta_hw_scanning) | 3333 | if (local->sta_sw_scanning || local->sta_hw_scanning) |
3296 | return; | 3334 | return; |
3297 | 3335 | ||
3298 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA && | 3336 | if (WARN_ON(sdata->vif.type != IEEE80211_IF_TYPE_STA && |
3299 | sdata->vif.type != IEEE80211_IF_TYPE_IBSS && | 3337 | sdata->vif.type != IEEE80211_IF_TYPE_IBSS && |
3300 | sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) { | 3338 | sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT)) |
3301 | printk(KERN_DEBUG "%s: ieee80211_sta_work: non-STA interface " | ||
3302 | "(type=%d)\n", dev->name, sdata->vif.type); | ||
3303 | return; | 3339 | return; |
3304 | } | ||
3305 | ifsta = &sdata->u.sta; | 3340 | ifsta = &sdata->u.sta; |
3306 | 3341 | ||
3307 | while ((skb = skb_dequeue(&ifsta->skb_queue))) | 3342 | while ((skb = skb_dequeue(&ifsta->skb_queue))) |
@@ -3355,8 +3390,7 @@ void ieee80211_sta_work(struct work_struct *work) | |||
3355 | break; | 3390 | break; |
3356 | #endif | 3391 | #endif |
3357 | default: | 3392 | default: |
3358 | printk(KERN_DEBUG "ieee80211_sta_work: Unknown state %d\n", | 3393 | WARN_ON(1); |
3359 | ifsta->state); | ||
3360 | break; | 3394 | break; |
3361 | } | 3395 | } |
3362 | 3396 | ||
@@ -3391,8 +3425,6 @@ static void ieee80211_sta_reset_auth(struct net_device *dev, | |||
3391 | ifsta->auth_alg = WLAN_AUTH_LEAP; | 3425 | ifsta->auth_alg = WLAN_AUTH_LEAP; |
3392 | else | 3426 | else |
3393 | ifsta->auth_alg = WLAN_AUTH_OPEN; | 3427 | ifsta->auth_alg = WLAN_AUTH_OPEN; |
3394 | printk(KERN_DEBUG "%s: Initial auth_alg=%d\n", dev->name, | ||
3395 | ifsta->auth_alg); | ||
3396 | ifsta->auth_transaction = -1; | 3428 | ifsta->auth_transaction = -1; |
3397 | ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; | 3429 | ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; |
3398 | ifsta->auth_tries = ifsta->assoc_tries = 0; | 3430 | ifsta->auth_tries = ifsta->assoc_tries = 0; |
@@ -3481,9 +3513,9 @@ static int ieee80211_sta_config_auth(struct net_device *dev, | |||
3481 | !ieee80211_sta_match_ssid(ifsta, bss->ssid, bss->ssid_len)) | 3513 | !ieee80211_sta_match_ssid(ifsta, bss->ssid, bss->ssid_len)) |
3482 | continue; | 3514 | continue; |
3483 | 3515 | ||
3484 | if (!selected || top_rssi < bss->rssi) { | 3516 | if (!selected || top_rssi < bss->signal) { |
3485 | selected = bss; | 3517 | selected = bss; |
3486 | top_rssi = bss->rssi; | 3518 | top_rssi = bss->signal; |
3487 | } | 3519 | } |
3488 | } | 3520 | } |
3489 | if (selected) | 3521 | if (selected) |
@@ -3497,7 +3529,7 @@ static int ieee80211_sta_config_auth(struct net_device *dev, | |||
3497 | selected->ssid_len); | 3529 | selected->ssid_len); |
3498 | ieee80211_sta_set_bssid(dev, selected->bssid); | 3530 | ieee80211_sta_set_bssid(dev, selected->bssid); |
3499 | ieee80211_sta_def_wmm_params(dev, selected, 0); | 3531 | ieee80211_sta_def_wmm_params(dev, selected, 0); |
3500 | ieee80211_rx_bss_put(dev, selected); | 3532 | ieee80211_rx_bss_put(local, selected); |
3501 | ifsta->state = IEEE80211_AUTHENTICATE; | 3533 | ifsta->state = IEEE80211_AUTHENTICATE; |
3502 | ieee80211_sta_reset_auth(dev, ifsta); | 3534 | ieee80211_sta_reset_auth(dev, ifsta); |
3503 | return 0; | 3535 | return 0; |
@@ -3556,14 +3588,16 @@ static int ieee80211_sta_create_ibss(struct net_device *dev, | |||
3556 | sband = local->hw.wiphy->bands[bss->band]; | 3588 | sband = local->hw.wiphy->bands[bss->band]; |
3557 | 3589 | ||
3558 | if (local->hw.conf.beacon_int == 0) | 3590 | if (local->hw.conf.beacon_int == 0) |
3559 | local->hw.conf.beacon_int = 10000; | 3591 | local->hw.conf.beacon_int = 100; |
3560 | bss->beacon_int = local->hw.conf.beacon_int; | 3592 | bss->beacon_int = local->hw.conf.beacon_int; |
3561 | bss->last_update = jiffies; | 3593 | bss->last_update = jiffies; |
3562 | bss->capability = WLAN_CAPABILITY_IBSS; | 3594 | bss->capability = WLAN_CAPABILITY_IBSS; |
3563 | if (sdata->default_key) { | 3595 | |
3596 | if (sdata->default_key) | ||
3564 | bss->capability |= WLAN_CAPABILITY_PRIVACY; | 3597 | bss->capability |= WLAN_CAPABILITY_PRIVACY; |
3565 | } else | 3598 | else |
3566 | sdata->drop_unencrypted = 0; | 3599 | sdata->drop_unencrypted = 0; |
3600 | |||
3567 | bss->supp_rates_len = sband->n_bitrates; | 3601 | bss->supp_rates_len = sband->n_bitrates; |
3568 | pos = bss->supp_rates; | 3602 | pos = bss->supp_rates; |
3569 | for (i = 0; i < sband->n_bitrates; i++) { | 3603 | for (i = 0; i < sband->n_bitrates; i++) { |
@@ -3572,7 +3606,7 @@ static int ieee80211_sta_create_ibss(struct net_device *dev, | |||
3572 | } | 3606 | } |
3573 | 3607 | ||
3574 | ret = ieee80211_sta_join_ibss(dev, ifsta, bss); | 3608 | ret = ieee80211_sta_join_ibss(dev, ifsta, bss); |
3575 | ieee80211_rx_bss_put(dev, bss); | 3609 | ieee80211_rx_bss_put(local, bss); |
3576 | return ret; | 3610 | return ret; |
3577 | } | 3611 | } |
3578 | 3612 | ||
@@ -3628,7 +3662,7 @@ static int ieee80211_sta_find_ibss(struct net_device *dev, | |||
3628 | " based on configured SSID\n", | 3662 | " based on configured SSID\n", |
3629 | dev->name, print_mac(mac, bssid)); | 3663 | dev->name, print_mac(mac, bssid)); |
3630 | ret = ieee80211_sta_join_ibss(dev, ifsta, bss); | 3664 | ret = ieee80211_sta_join_ibss(dev, ifsta, bss); |
3631 | ieee80211_rx_bss_put(dev, bss); | 3665 | ieee80211_rx_bss_put(local, bss); |
3632 | return ret; | 3666 | return ret; |
3633 | } | 3667 | } |
3634 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 3668 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
@@ -3679,28 +3713,45 @@ int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len) | |||
3679 | { | 3713 | { |
3680 | 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); |
3681 | struct ieee80211_if_sta *ifsta; | 3715 | struct ieee80211_if_sta *ifsta; |
3716 | int res; | ||
3682 | 3717 | ||
3683 | if (len > IEEE80211_MAX_SSID_LEN) | 3718 | if (len > IEEE80211_MAX_SSID_LEN) |
3684 | return -EINVAL; | 3719 | return -EINVAL; |
3685 | 3720 | ||
3686 | ifsta = &sdata->u.sta; | 3721 | ifsta = &sdata->u.sta; |
3687 | 3722 | ||
3688 | 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; | ||
3689 | ifsta->flags &= ~IEEE80211_STA_PREV_BSSID_SET; | 3727 | ifsta->flags &= ~IEEE80211_STA_PREV_BSSID_SET; |
3690 | memcpy(ifsta->ssid, ssid, len); | 3728 | |
3691 | memset(ifsta->ssid + len, 0, IEEE80211_MAX_SSID_LEN - len); | 3729 | res = 0; |
3692 | 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 | } | ||
3693 | 3742 | ||
3694 | if (len) | 3743 | if (len) |
3695 | ifsta->flags |= IEEE80211_STA_SSID_SET; | 3744 | ifsta->flags |= IEEE80211_STA_SSID_SET; |
3696 | else | 3745 | else |
3697 | ifsta->flags &= ~IEEE80211_STA_SSID_SET; | 3746 | ifsta->flags &= ~IEEE80211_STA_SSID_SET; |
3747 | |||
3698 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && | 3748 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && |
3699 | !(ifsta->flags & IEEE80211_STA_BSSID_SET)) { | 3749 | !(ifsta->flags & IEEE80211_STA_BSSID_SET)) { |
3700 | ifsta->ibss_join_req = jiffies; | 3750 | ifsta->ibss_join_req = jiffies; |
3701 | ifsta->state = IEEE80211_IBSS_SEARCH; | 3751 | ifsta->state = IEEE80211_IBSS_SEARCH; |
3702 | return ieee80211_sta_find_ibss(dev, ifsta); | 3752 | return ieee80211_sta_find_ibss(dev, ifsta); |
3703 | } | 3753 | } |
3754 | |||
3704 | return 0; | 3755 | return 0; |
3705 | } | 3756 | } |
3706 | 3757 | ||
@@ -3726,7 +3777,12 @@ int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid) | |||
3726 | 3777 | ||
3727 | if (memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0) { | 3778 | if (memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0) { |
3728 | memcpy(ifsta->bssid, bssid, ETH_ALEN); | 3779 | memcpy(ifsta->bssid, bssid, ETH_ALEN); |
3729 | 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); | ||
3730 | if (res) { | 3786 | if (res) { |
3731 | printk(KERN_DEBUG "%s: Failed to config new BSSID to " | 3787 | printk(KERN_DEBUG "%s: Failed to config new BSSID to " |
3732 | "the low-level driver\n", dev->name); | 3788 | "the low-level driver\n", dev->name); |
@@ -3749,7 +3805,7 @@ static void ieee80211_send_nullfunc(struct ieee80211_local *local, | |||
3749 | { | 3805 | { |
3750 | struct sk_buff *skb; | 3806 | struct sk_buff *skb; |
3751 | struct ieee80211_hdr *nullfunc; | 3807 | struct ieee80211_hdr *nullfunc; |
3752 | u16 fc; | 3808 | __le16 fc; |
3753 | 3809 | ||
3754 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24); | 3810 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24); |
3755 | if (!skb) { | 3811 | if (!skb) { |
@@ -3761,11 +3817,11 @@ static void ieee80211_send_nullfunc(struct ieee80211_local *local, | |||
3761 | 3817 | ||
3762 | nullfunc = (struct ieee80211_hdr *) skb_put(skb, 24); | 3818 | nullfunc = (struct ieee80211_hdr *) skb_put(skb, 24); |
3763 | memset(nullfunc, 0, 24); | 3819 | memset(nullfunc, 0, 24); |
3764 | fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC | | 3820 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC | |
3765 | IEEE80211_FCTL_TODS; | 3821 | IEEE80211_FCTL_TODS); |
3766 | if (powersave) | 3822 | if (powersave) |
3767 | fc |= IEEE80211_FCTL_PM; | 3823 | fc |= cpu_to_le16(IEEE80211_FCTL_PM); |
3768 | nullfunc->frame_control = cpu_to_le16(fc); | 3824 | nullfunc->frame_control = fc; |
3769 | memcpy(nullfunc->addr1, sdata->u.sta.bssid, ETH_ALEN); | 3825 | memcpy(nullfunc->addr1, sdata->u.sta.bssid, ETH_ALEN); |
3770 | memcpy(nullfunc->addr2, sdata->dev->dev_addr, ETH_ALEN); | 3826 | memcpy(nullfunc->addr2, sdata->dev->dev_addr, ETH_ALEN); |
3771 | memcpy(nullfunc->addr3, sdata->u.sta.bssid, ETH_ALEN); | 3827 | memcpy(nullfunc->addr3, sdata->u.sta.bssid, ETH_ALEN); |
@@ -3813,6 +3869,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw) | |||
3813 | 3869 | ||
3814 | 3870 | ||
3815 | netif_tx_lock_bh(local->mdev); | 3871 | netif_tx_lock_bh(local->mdev); |
3872 | netif_addr_lock(local->mdev); | ||
3816 | local->filter_flags &= ~FIF_BCN_PRBRESP_PROMISC; | 3873 | local->filter_flags &= ~FIF_BCN_PRBRESP_PROMISC; |
3817 | local->ops->configure_filter(local_to_hw(local), | 3874 | local->ops->configure_filter(local_to_hw(local), |
3818 | FIF_BCN_PRBRESP_PROMISC, | 3875 | FIF_BCN_PRBRESP_PROMISC, |
@@ -3820,15 +3877,11 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw) | |||
3820 | local->mdev->mc_count, | 3877 | local->mdev->mc_count, |
3821 | local->mdev->mc_list); | 3878 | local->mdev->mc_list); |
3822 | 3879 | ||
3880 | netif_addr_unlock(local->mdev); | ||
3823 | netif_tx_unlock_bh(local->mdev); | 3881 | netif_tx_unlock_bh(local->mdev); |
3824 | 3882 | ||
3825 | rcu_read_lock(); | 3883 | rcu_read_lock(); |
3826 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 3884 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
3827 | |||
3828 | /* No need to wake the master device. */ | ||
3829 | if (sdata->dev == local->mdev) | ||
3830 | continue; | ||
3831 | |||
3832 | /* Tell AP we're back */ | 3885 | /* Tell AP we're back */ |
3833 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA && | 3886 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA && |
3834 | sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED) | 3887 | sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED) |
@@ -3994,12 +4047,6 @@ static int ieee80211_sta_start_scan(struct net_device *dev, | |||
3994 | 4047 | ||
3995 | rcu_read_lock(); | 4048 | rcu_read_lock(); |
3996 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 4049 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
3997 | |||
3998 | /* Don't stop the master interface, otherwise we can't transmit | ||
3999 | * probes! */ | ||
4000 | if (sdata->dev == local->mdev) | ||
4001 | continue; | ||
4002 | |||
4003 | netif_stop_queue(sdata->dev); | 4050 | netif_stop_queue(sdata->dev); |
4004 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA && | 4051 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA && |
4005 | (sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED)) | 4052 | (sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED)) |
@@ -4017,14 +4064,14 @@ static int ieee80211_sta_start_scan(struct net_device *dev, | |||
4017 | local->scan_band = IEEE80211_BAND_2GHZ; | 4064 | local->scan_band = IEEE80211_BAND_2GHZ; |
4018 | local->scan_dev = dev; | 4065 | local->scan_dev = dev; |
4019 | 4066 | ||
4020 | netif_tx_lock_bh(local->mdev); | 4067 | netif_addr_lock_bh(local->mdev); |
4021 | local->filter_flags |= FIF_BCN_PRBRESP_PROMISC; | 4068 | local->filter_flags |= FIF_BCN_PRBRESP_PROMISC; |
4022 | local->ops->configure_filter(local_to_hw(local), | 4069 | local->ops->configure_filter(local_to_hw(local), |
4023 | FIF_BCN_PRBRESP_PROMISC, | 4070 | FIF_BCN_PRBRESP_PROMISC, |
4024 | &local->filter_flags, | 4071 | &local->filter_flags, |
4025 | local->mdev->mc_count, | 4072 | local->mdev->mc_count, |
4026 | local->mdev->mc_list); | 4073 | local->mdev->mc_list); |
4027 | netif_tx_unlock_bh(local->mdev); | 4074 | netif_addr_unlock_bh(local->mdev); |
4028 | 4075 | ||
4029 | /* TODO: start scan as soon as all nullfunc frames are ACKed */ | 4076 | /* TODO: start scan as soon as all nullfunc frames are ACKed */ |
4030 | queue_delayed_work(local->hw.workqueue, &local->scan_work, | 4077 | queue_delayed_work(local->hw.workqueue, &local->scan_work, |
@@ -4059,6 +4106,7 @@ int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len) | |||
4059 | 4106 | ||
4060 | static char * | 4107 | static char * |
4061 | ieee80211_sta_scan_result(struct net_device *dev, | 4108 | ieee80211_sta_scan_result(struct net_device *dev, |
4109 | struct iw_request_info *info, | ||
4062 | struct ieee80211_sta_bss *bss, | 4110 | struct ieee80211_sta_bss *bss, |
4063 | char *current_ev, char *end_buf) | 4111 | char *current_ev, char *end_buf) |
4064 | { | 4112 | { |
@@ -4073,7 +4121,7 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4073 | iwe.cmd = SIOCGIWAP; | 4121 | iwe.cmd = SIOCGIWAP; |
4074 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; | 4122 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; |
4075 | memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN); | 4123 | memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN); |
4076 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4124 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, |
4077 | IW_EV_ADDR_LEN); | 4125 | IW_EV_ADDR_LEN); |
4078 | 4126 | ||
4079 | memset(&iwe, 0, sizeof(iwe)); | 4127 | memset(&iwe, 0, sizeof(iwe)); |
@@ -4081,13 +4129,13 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4081 | if (bss_mesh_cfg(bss)) { | 4129 | if (bss_mesh_cfg(bss)) { |
4082 | iwe.u.data.length = bss_mesh_id_len(bss); | 4130 | iwe.u.data.length = bss_mesh_id_len(bss); |
4083 | iwe.u.data.flags = 1; | 4131 | iwe.u.data.flags = 1; |
4084 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, | 4132 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4085 | bss_mesh_id(bss)); | 4133 | &iwe, bss_mesh_id(bss)); |
4086 | } else { | 4134 | } else { |
4087 | iwe.u.data.length = bss->ssid_len; | 4135 | iwe.u.data.length = bss->ssid_len; |
4088 | iwe.u.data.flags = 1; | 4136 | iwe.u.data.flags = 1; |
4089 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, | 4137 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4090 | bss->ssid); | 4138 | &iwe, bss->ssid); |
4091 | } | 4139 | } |
4092 | 4140 | ||
4093 | if (bss->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS) | 4141 | if (bss->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS) |
@@ -4100,30 +4148,30 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4100 | iwe.u.mode = IW_MODE_MASTER; | 4148 | iwe.u.mode = IW_MODE_MASTER; |
4101 | else | 4149 | else |
4102 | iwe.u.mode = IW_MODE_ADHOC; | 4150 | iwe.u.mode = IW_MODE_ADHOC; |
4103 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4151 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, |
4104 | IW_EV_UINT_LEN); | 4152 | &iwe, IW_EV_UINT_LEN); |
4105 | } | 4153 | } |
4106 | 4154 | ||
4107 | memset(&iwe, 0, sizeof(iwe)); | 4155 | memset(&iwe, 0, sizeof(iwe)); |
4108 | iwe.cmd = SIOCGIWFREQ; | 4156 | iwe.cmd = SIOCGIWFREQ; |
4109 | iwe.u.freq.m = ieee80211_frequency_to_channel(bss->freq); | 4157 | iwe.u.freq.m = ieee80211_frequency_to_channel(bss->freq); |
4110 | iwe.u.freq.e = 0; | 4158 | iwe.u.freq.e = 0; |
4111 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4159 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, |
4112 | IW_EV_FREQ_LEN); | 4160 | IW_EV_FREQ_LEN); |
4113 | 4161 | ||
4114 | memset(&iwe, 0, sizeof(iwe)); | 4162 | memset(&iwe, 0, sizeof(iwe)); |
4115 | iwe.cmd = SIOCGIWFREQ; | 4163 | iwe.cmd = SIOCGIWFREQ; |
4116 | iwe.u.freq.m = bss->freq; | 4164 | iwe.u.freq.m = bss->freq; |
4117 | iwe.u.freq.e = 6; | 4165 | iwe.u.freq.e = 6; |
4118 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4166 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, |
4119 | IW_EV_FREQ_LEN); | 4167 | IW_EV_FREQ_LEN); |
4120 | memset(&iwe, 0, sizeof(iwe)); | 4168 | memset(&iwe, 0, sizeof(iwe)); |
4121 | iwe.cmd = IWEVQUAL; | 4169 | iwe.cmd = IWEVQUAL; |
4122 | iwe.u.qual.qual = bss->signal; | 4170 | iwe.u.qual.qual = bss->qual; |
4123 | iwe.u.qual.level = bss->rssi; | 4171 | iwe.u.qual.level = bss->signal; |
4124 | iwe.u.qual.noise = bss->noise; | 4172 | iwe.u.qual.noise = bss->noise; |
4125 | iwe.u.qual.updated = local->wstats_flags; | 4173 | iwe.u.qual.updated = local->wstats_flags; |
4126 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4174 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, |
4127 | IW_EV_QUAL_LEN); | 4175 | IW_EV_QUAL_LEN); |
4128 | 4176 | ||
4129 | memset(&iwe, 0, sizeof(iwe)); | 4177 | memset(&iwe, 0, sizeof(iwe)); |
@@ -4133,27 +4181,36 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4133 | else | 4181 | else |
4134 | iwe.u.data.flags = IW_ENCODE_DISABLED; | 4182 | iwe.u.data.flags = IW_ENCODE_DISABLED; |
4135 | iwe.u.data.length = 0; | 4183 | iwe.u.data.length = 0; |
4136 | 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, ""); | ||
4137 | 4186 | ||
4138 | if (bss && bss->wpa_ie) { | 4187 | if (bss && bss->wpa_ie) { |
4139 | memset(&iwe, 0, sizeof(iwe)); | 4188 | memset(&iwe, 0, sizeof(iwe)); |
4140 | iwe.cmd = IWEVGENIE; | 4189 | iwe.cmd = IWEVGENIE; |
4141 | iwe.u.data.length = bss->wpa_ie_len; | 4190 | iwe.u.data.length = bss->wpa_ie_len; |
4142 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, | 4191 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4143 | bss->wpa_ie); | 4192 | &iwe, bss->wpa_ie); |
4144 | } | 4193 | } |
4145 | 4194 | ||
4146 | if (bss && bss->rsn_ie) { | 4195 | if (bss && bss->rsn_ie) { |
4147 | memset(&iwe, 0, sizeof(iwe)); | 4196 | memset(&iwe, 0, sizeof(iwe)); |
4148 | iwe.cmd = IWEVGENIE; | 4197 | iwe.cmd = IWEVGENIE; |
4149 | iwe.u.data.length = bss->rsn_ie_len; | 4198 | iwe.u.data.length = bss->rsn_ie_len; |
4150 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, | 4199 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4151 | 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); | ||
4152 | } | 4209 | } |
4153 | 4210 | ||
4154 | if (bss && bss->supp_rates_len > 0) { | 4211 | if (bss && bss->supp_rates_len > 0) { |
4155 | /* display all supported rates in readable format */ | 4212 | /* display all supported rates in readable format */ |
4156 | char *p = current_ev + IW_EV_LCP_LEN; | 4213 | char *p = current_ev + iwe_stream_lcp_len(info); |
4157 | int i; | 4214 | int i; |
4158 | 4215 | ||
4159 | memset(&iwe, 0, sizeof(iwe)); | 4216 | memset(&iwe, 0, sizeof(iwe)); |
@@ -4164,7 +4221,7 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4164 | for (i = 0; i < bss->supp_rates_len; i++) { | 4221 | for (i = 0; i < bss->supp_rates_len; i++) { |
4165 | iwe.u.bitrate.value = ((bss->supp_rates[i] & | 4222 | iwe.u.bitrate.value = ((bss->supp_rates[i] & |
4166 | 0x7f) * 500000); | 4223 | 0x7f) * 500000); |
4167 | p = iwe_stream_add_value(current_ev, p, | 4224 | p = iwe_stream_add_value(info, current_ev, p, |
4168 | end_buf, &iwe, IW_EV_PARAM_LEN); | 4225 | end_buf, &iwe, IW_EV_PARAM_LEN); |
4169 | } | 4226 | } |
4170 | current_ev = p; | 4227 | current_ev = p; |
@@ -4178,8 +4235,16 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4178 | iwe.cmd = IWEVCUSTOM; | 4235 | iwe.cmd = IWEVCUSTOM; |
4179 | sprintf(buf, "tsf=%016llx", (unsigned long long)(bss->timestamp)); | 4236 | sprintf(buf, "tsf=%016llx", (unsigned long long)(bss->timestamp)); |
4180 | iwe.u.data.length = strlen(buf); | 4237 | iwe.u.data.length = strlen(buf); |
4181 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4238 | current_ev = iwe_stream_add_point(info, current_ev, |
4239 | end_buf, | ||
4182 | &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); | ||
4183 | kfree(buf); | 4248 | kfree(buf); |
4184 | } | 4249 | } |
4185 | } | 4250 | } |
@@ -4193,31 +4258,36 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4193 | iwe.cmd = IWEVCUSTOM; | 4258 | iwe.cmd = IWEVCUSTOM; |
4194 | sprintf(buf, "Mesh network (version %d)", cfg[0]); | 4259 | sprintf(buf, "Mesh network (version %d)", cfg[0]); |
4195 | iwe.u.data.length = strlen(buf); | 4260 | iwe.u.data.length = strlen(buf); |
4196 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4261 | current_ev = iwe_stream_add_point(info, current_ev, |
4262 | end_buf, | ||
4197 | &iwe, buf); | 4263 | &iwe, buf); |
4198 | sprintf(buf, "Path Selection Protocol ID: " | 4264 | sprintf(buf, "Path Selection Protocol ID: " |
4199 | "0x%02X%02X%02X%02X", cfg[1], cfg[2], cfg[3], | 4265 | "0x%02X%02X%02X%02X", cfg[1], cfg[2], cfg[3], |
4200 | cfg[4]); | 4266 | cfg[4]); |
4201 | iwe.u.data.length = strlen(buf); | 4267 | iwe.u.data.length = strlen(buf); |
4202 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4268 | current_ev = iwe_stream_add_point(info, current_ev, |
4269 | end_buf, | ||
4203 | &iwe, buf); | 4270 | &iwe, buf); |
4204 | sprintf(buf, "Path Selection Metric ID: " | 4271 | sprintf(buf, "Path Selection Metric ID: " |
4205 | "0x%02X%02X%02X%02X", cfg[5], cfg[6], cfg[7], | 4272 | "0x%02X%02X%02X%02X", cfg[5], cfg[6], cfg[7], |
4206 | cfg[8]); | 4273 | cfg[8]); |
4207 | iwe.u.data.length = strlen(buf); | 4274 | iwe.u.data.length = strlen(buf); |
4208 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4275 | current_ev = iwe_stream_add_point(info, current_ev, |
4276 | end_buf, | ||
4209 | &iwe, buf); | 4277 | &iwe, buf); |
4210 | sprintf(buf, "Congestion Control Mode ID: " | 4278 | sprintf(buf, "Congestion Control Mode ID: " |
4211 | "0x%02X%02X%02X%02X", cfg[9], cfg[10], | 4279 | "0x%02X%02X%02X%02X", cfg[9], cfg[10], |
4212 | cfg[11], cfg[12]); | 4280 | cfg[11], cfg[12]); |
4213 | iwe.u.data.length = strlen(buf); | 4281 | iwe.u.data.length = strlen(buf); |
4214 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4282 | current_ev = iwe_stream_add_point(info, current_ev, |
4283 | end_buf, | ||
4215 | &iwe, buf); | 4284 | &iwe, buf); |
4216 | sprintf(buf, "Channel Precedence: " | 4285 | sprintf(buf, "Channel Precedence: " |
4217 | "0x%02X%02X%02X%02X", cfg[13], cfg[14], | 4286 | "0x%02X%02X%02X%02X", cfg[13], cfg[14], |
4218 | cfg[15], cfg[16]); | 4287 | cfg[15], cfg[16]); |
4219 | iwe.u.data.length = strlen(buf); | 4288 | iwe.u.data.length = strlen(buf); |
4220 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4289 | current_ev = iwe_stream_add_point(info, current_ev, |
4290 | end_buf, | ||
4221 | &iwe, buf); | 4291 | &iwe, buf); |
4222 | kfree(buf); | 4292 | kfree(buf); |
4223 | } | 4293 | } |
@@ -4227,7 +4297,9 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4227 | } | 4297 | } |
4228 | 4298 | ||
4229 | 4299 | ||
4230 | 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) | ||
4231 | { | 4303 | { |
4232 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 4304 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
4233 | char *current_ev = buf; | 4305 | char *current_ev = buf; |
@@ -4240,8 +4312,8 @@ int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len) | |||
4240 | spin_unlock_bh(&local->sta_bss_lock); | 4312 | spin_unlock_bh(&local->sta_bss_lock); |
4241 | return -E2BIG; | 4313 | return -E2BIG; |
4242 | } | 4314 | } |
4243 | current_ev = ieee80211_sta_scan_result(dev, bss, current_ev, | 4315 | current_ev = ieee80211_sta_scan_result(dev, info, bss, |
4244 | end_buf); | 4316 | current_ev, end_buf); |
4245 | } | 4317 | } |
4246 | spin_unlock_bh(&local->sta_bss_lock); | 4318 | spin_unlock_bh(&local->sta_bss_lock); |
4247 | return current_ev - buf; | 4319 | return current_ev - buf; |
@@ -4252,6 +4324,7 @@ int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len) | |||
4252 | { | 4324 | { |
4253 | 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); |
4254 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 4326 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
4327 | |||
4255 | kfree(ifsta->extra_ie); | 4328 | kfree(ifsta->extra_ie); |
4256 | if (len == 0) { | 4329 | if (len == 0) { |
4257 | ifsta->extra_ie = NULL; | 4330 | ifsta->extra_ie = NULL; |
@@ -4269,14 +4342,15 @@ int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len) | |||
4269 | } | 4342 | } |
4270 | 4343 | ||
4271 | 4344 | ||
4272 | struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev, | 4345 | struct sta_info *ieee80211_ibss_add_sta(struct net_device *dev, |
4273 | struct sk_buff *skb, u8 *bssid, | 4346 | struct sk_buff *skb, u8 *bssid, |
4274 | u8 *addr) | 4347 | u8 *addr, u64 supp_rates) |
4275 | { | 4348 | { |
4276 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 4349 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
4277 | struct sta_info *sta; | 4350 | struct sta_info *sta; |
4278 | 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); |
4279 | DECLARE_MAC_BUF(mac); | 4352 | DECLARE_MAC_BUF(mac); |
4353 | int band = local->hw.conf.channel->band; | ||
4280 | 4354 | ||
4281 | /* TODO: Could consider removing the least recently used entry and | 4355 | /* TODO: Could consider removing the least recently used entry and |
4282 | * allow new one to be added. */ | 4356 | * allow new one to be added. */ |
@@ -4288,17 +4362,24 @@ struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev, | |||
4288 | return NULL; | 4362 | return NULL; |
4289 | } | 4363 | } |
4290 | 4364 | ||
4365 | if (compare_ether_addr(bssid, sdata->u.sta.bssid)) | ||
4366 | return NULL; | ||
4367 | |||
4368 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | ||
4291 | 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", |
4292 | 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 | ||
4293 | 4372 | ||
4294 | sta = sta_info_alloc(sdata, addr, GFP_ATOMIC); | 4373 | sta = sta_info_alloc(sdata, addr, GFP_ATOMIC); |
4295 | if (!sta) | 4374 | if (!sta) |
4296 | return NULL; | 4375 | return NULL; |
4297 | 4376 | ||
4298 | sta->flags |= WLAN_STA_AUTHORIZED; | 4377 | set_sta_flags(sta, WLAN_STA_AUTHORIZED); |
4299 | 4378 | ||
4300 | sta->supp_rates[local->hw.conf.channel->band] = | 4379 | if (supp_rates) |
4301 | 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]; | ||
4302 | 4383 | ||
4303 | rate_control_rate_init(sta, local); | 4384 | rate_control_rate_init(sta, local); |
4304 | 4385 | ||
@@ -4314,7 +4395,7 @@ int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason) | |||
4314 | 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); |
4315 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 4396 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
4316 | 4397 | ||
4317 | printk(KERN_DEBUG "%s: deauthenticate(reason=%d)\n", | 4398 | printk(KERN_DEBUG "%s: deauthenticating by local choice (reason=%d)\n", |
4318 | dev->name, reason); | 4399 | dev->name, reason); |
4319 | 4400 | ||
4320 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA && | 4401 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA && |
@@ -4332,7 +4413,7 @@ int ieee80211_sta_disassociate(struct net_device *dev, u16 reason) | |||
4332 | 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); |
4333 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 4414 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
4334 | 4415 | ||
4335 | printk(KERN_DEBUG "%s: disassociate(reason=%d)\n", | 4416 | printk(KERN_DEBUG "%s: disassociating by local choice (reason=%d)\n", |
4336 | dev->name, reason); | 4417 | dev->name, reason); |
4337 | 4418 | ||
4338 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA) | 4419 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA) |
@@ -4356,12 +4437,10 @@ void ieee80211_notify_mac(struct ieee80211_hw *hw, | |||
4356 | case IEEE80211_NOTIFY_RE_ASSOC: | 4437 | case IEEE80211_NOTIFY_RE_ASSOC: |
4357 | rcu_read_lock(); | 4438 | rcu_read_lock(); |
4358 | 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; | ||
4359 | 4442 | ||
4360 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA) { | 4443 | ieee80211_sta_req_auth(sdata->dev, &sdata->u.sta); |
4361 | ieee80211_sta_req_auth(sdata->dev, | ||
4362 | &sdata->u.sta); | ||
4363 | } | ||
4364 | |||
4365 | } | 4444 | } |
4366 | rcu_read_unlock(); | 4445 | rcu_read_unlock(); |
4367 | break; | 4446 | break; |