diff options
Diffstat (limited to 'net/mac80211/mlme.c')
-rw-r--r-- | net/mac80211/mlme.c | 703 |
1 files changed, 376 insertions, 327 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 57967d32e5fd..fbb766afe599 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -55,10 +55,10 @@ static u8 *ieee80211_bss_get_ie(struct ieee80211_bss *bss, u8 ie) | |||
55 | { | 55 | { |
56 | u8 *end, *pos; | 56 | u8 *end, *pos; |
57 | 57 | ||
58 | pos = bss->ies; | 58 | pos = bss->cbss.information_elements; |
59 | if (pos == NULL) | 59 | if (pos == NULL) |
60 | return NULL; | 60 | return NULL; |
61 | end = pos + bss->ies_len; | 61 | end = pos + bss->cbss.len_information_elements; |
62 | 62 | ||
63 | while (pos + 1 < end) { | 63 | while (pos + 1 < end) { |
64 | if (pos + 2 + pos[1] > end) | 64 | if (pos + 2 + pos[1] > end) |
@@ -289,7 +289,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata, | |||
289 | local->hw.conf.channel->center_freq, | 289 | local->hw.conf.channel->center_freq, |
290 | ifsta->ssid, ifsta->ssid_len); | 290 | ifsta->ssid, ifsta->ssid_len); |
291 | if (bss) { | 291 | if (bss) { |
292 | if (bss->capability & WLAN_CAPABILITY_PRIVACY) | 292 | if (bss->cbss.capability & WLAN_CAPABILITY_PRIVACY) |
293 | capab |= WLAN_CAPABILITY_PRIVACY; | 293 | capab |= WLAN_CAPABILITY_PRIVACY; |
294 | if (bss->wmm_used) | 294 | if (bss->wmm_used) |
295 | wmm = 1; | 295 | wmm = 1; |
@@ -300,7 +300,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata, | |||
300 | * b-only mode) */ | 300 | * b-only mode) */ |
301 | rates_len = ieee80211_compatible_rates(bss, sband, &rates); | 301 | rates_len = ieee80211_compatible_rates(bss, sband, &rates); |
302 | 302 | ||
303 | if ((bss->capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && | 303 | if ((bss->cbss.capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && |
304 | (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)) | 304 | (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)) |
305 | capab |= WLAN_CAPABILITY_SPECTRUM_MGMT; | 305 | capab |= WLAN_CAPABILITY_SPECTRUM_MGMT; |
306 | 306 | ||
@@ -511,16 +511,50 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, | |||
511 | ieee80211_tx_skb(sdata, skb, ifsta->flags & IEEE80211_STA_MFP_ENABLED); | 511 | ieee80211_tx_skb(sdata, skb, ifsta->flags & IEEE80211_STA_MFP_ENABLED); |
512 | } | 512 | } |
513 | 513 | ||
514 | void ieee80211_send_pspoll(struct ieee80211_local *local, | ||
515 | struct ieee80211_sub_if_data *sdata) | ||
516 | { | ||
517 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | ||
518 | struct ieee80211_pspoll *pspoll; | ||
519 | struct sk_buff *skb; | ||
520 | u16 fc; | ||
521 | |||
522 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); | ||
523 | if (!skb) { | ||
524 | printk(KERN_DEBUG "%s: failed to allocate buffer for " | ||
525 | "pspoll frame\n", sdata->dev->name); | ||
526 | return; | ||
527 | } | ||
528 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
529 | |||
530 | pspoll = (struct ieee80211_pspoll *) skb_put(skb, sizeof(*pspoll)); | ||
531 | memset(pspoll, 0, sizeof(*pspoll)); | ||
532 | fc = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL | IEEE80211_FCTL_PM; | ||
533 | pspoll->frame_control = cpu_to_le16(fc); | ||
534 | pspoll->aid = cpu_to_le16(ifsta->aid); | ||
535 | |||
536 | /* aid in PS-Poll has its two MSBs each set to 1 */ | ||
537 | pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14); | ||
538 | |||
539 | memcpy(pspoll->bssid, ifsta->bssid, ETH_ALEN); | ||
540 | memcpy(pspoll->ta, sdata->dev->dev_addr, ETH_ALEN); | ||
541 | |||
542 | ieee80211_tx_skb(sdata, skb, 0); | ||
543 | |||
544 | return; | ||
545 | } | ||
546 | |||
514 | /* MLME */ | 547 | /* MLME */ |
515 | static void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, | 548 | static void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, |
516 | struct ieee80211_bss *bss) | 549 | const size_t supp_rates_len, |
550 | const u8 *supp_rates) | ||
517 | { | 551 | { |
518 | struct ieee80211_local *local = sdata->local; | 552 | struct ieee80211_local *local = sdata->local; |
519 | int i, have_higher_than_11mbit = 0; | 553 | int i, have_higher_than_11mbit = 0; |
520 | 554 | ||
521 | /* cf. IEEE 802.11 9.2.12 */ | 555 | /* cf. IEEE 802.11 9.2.12 */ |
522 | for (i = 0; i < bss->supp_rates_len; i++) | 556 | for (i = 0; i < supp_rates_len; i++) |
523 | if ((bss->supp_rates[i] & 0x7f) * 5 > 110) | 557 | if ((supp_rates[i] & 0x7f) * 5 > 110) |
524 | have_higher_than_11mbit = 1; | 558 | have_higher_than_11mbit = 1; |
525 | 559 | ||
526 | if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ && | 560 | if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ && |
@@ -611,7 +645,7 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local, | |||
611 | } | 645 | } |
612 | } | 646 | } |
613 | 647 | ||
614 | static bool check_tim(struct ieee802_11_elems *elems, u16 aid, bool *is_mc) | 648 | static bool ieee80211_check_tim(struct ieee802_11_elems *elems, u16 aid) |
615 | { | 649 | { |
616 | u8 mask; | 650 | u8 mask; |
617 | u8 index, indexn1, indexn2; | 651 | u8 index, indexn1, indexn2; |
@@ -621,9 +655,6 @@ static bool check_tim(struct ieee802_11_elems *elems, u16 aid, bool *is_mc) | |||
621 | index = aid / 8; | 655 | index = aid / 8; |
622 | mask = 1 << (aid & 7); | 656 | mask = 1 << (aid & 7); |
623 | 657 | ||
624 | if (tim->bitmap_ctrl & 0x01) | ||
625 | *is_mc = true; | ||
626 | |||
627 | indexn1 = tim->bitmap_ctrl & 0xfe; | 658 | indexn1 = tim->bitmap_ctrl & 0xfe; |
628 | indexn2 = elems->tim_len + indexn1 - 4; | 659 | indexn2 = elems->tim_len + indexn1 - 4; |
629 | 660 | ||
@@ -777,20 +808,17 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, | |||
777 | bss_info_changed |= BSS_CHANGED_ASSOC; | 808 | bss_info_changed |= BSS_CHANGED_ASSOC; |
778 | ifsta->flags |= IEEE80211_STA_ASSOCIATED; | 809 | ifsta->flags |= IEEE80211_STA_ASSOCIATED; |
779 | 810 | ||
780 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | ||
781 | return; | ||
782 | |||
783 | bss = ieee80211_rx_bss_get(local, ifsta->bssid, | 811 | bss = ieee80211_rx_bss_get(local, ifsta->bssid, |
784 | conf->channel->center_freq, | 812 | conf->channel->center_freq, |
785 | ifsta->ssid, ifsta->ssid_len); | 813 | ifsta->ssid, ifsta->ssid_len); |
786 | if (bss) { | 814 | if (bss) { |
787 | /* set timing information */ | 815 | /* set timing information */ |
788 | sdata->vif.bss_conf.beacon_int = bss->beacon_int; | 816 | sdata->vif.bss_conf.beacon_int = bss->cbss.beacon_interval; |
789 | sdata->vif.bss_conf.timestamp = bss->timestamp; | 817 | sdata->vif.bss_conf.timestamp = bss->cbss.tsf; |
790 | sdata->vif.bss_conf.dtim_period = bss->dtim_period; | 818 | sdata->vif.bss_conf.dtim_period = bss->dtim_period; |
791 | 819 | ||
792 | bss_info_changed |= ieee80211_handle_bss_capability(sdata, | 820 | bss_info_changed |= ieee80211_handle_bss_capability(sdata, |
793 | bss->capability, bss->has_erp_value, bss->erp_value); | 821 | bss->cbss.capability, bss->has_erp_value, bss->erp_value); |
794 | 822 | ||
795 | ieee80211_rx_bss_put(local, bss); | 823 | ieee80211_rx_bss_put(local, bss); |
796 | } | 824 | } |
@@ -840,6 +868,14 @@ static void ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata, | |||
840 | sdata->dev->name, ifsta->bssid); | 868 | sdata->dev->name, ifsta->bssid); |
841 | ifsta->state = IEEE80211_STA_MLME_DISABLED; | 869 | ifsta->state = IEEE80211_STA_MLME_DISABLED; |
842 | ieee80211_sta_send_apinfo(sdata, ifsta); | 870 | ieee80211_sta_send_apinfo(sdata, ifsta); |
871 | |||
872 | /* | ||
873 | * Most likely AP is not in the range so remove the | ||
874 | * bss information associated to the AP | ||
875 | */ | ||
876 | ieee80211_rx_bss_remove(sdata, ifsta->bssid, | ||
877 | sdata->local->hw.conf.channel->center_freq, | ||
878 | ifsta->ssid, ifsta->ssid_len); | ||
843 | return; | 879 | return; |
844 | } | 880 | } |
845 | 881 | ||
@@ -871,6 +907,9 @@ static void ieee80211_authenticate(struct ieee80211_sub_if_data *sdata, | |||
871 | sdata->dev->name, ifsta->bssid); | 907 | sdata->dev->name, ifsta->bssid); |
872 | ifsta->state = IEEE80211_STA_MLME_DISABLED; | 908 | ifsta->state = IEEE80211_STA_MLME_DISABLED; |
873 | ieee80211_sta_send_apinfo(sdata, ifsta); | 909 | ieee80211_sta_send_apinfo(sdata, ifsta); |
910 | ieee80211_rx_bss_remove(sdata, ifsta->bssid, | ||
911 | sdata->local->hw.conf.channel->center_freq, | ||
912 | ifsta->ssid, ifsta->ssid_len); | ||
874 | return; | 913 | return; |
875 | } | 914 | } |
876 | 915 | ||
@@ -913,7 +952,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
913 | netif_tx_stop_all_queues(sdata->dev); | 952 | netif_tx_stop_all_queues(sdata->dev); |
914 | netif_carrier_off(sdata->dev); | 953 | netif_carrier_off(sdata->dev); |
915 | 954 | ||
916 | ieee80211_sta_tear_down_BA_sessions(sdata, sta->sta.addr); | 955 | ieee80211_sta_tear_down_BA_sessions(sta); |
917 | 956 | ||
918 | if (self_disconnected) { | 957 | if (self_disconnected) { |
919 | if (deauth) | 958 | if (deauth) |
@@ -933,8 +972,12 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
933 | 972 | ||
934 | ieee80211_sta_send_apinfo(sdata, ifsta); | 973 | ieee80211_sta_send_apinfo(sdata, ifsta); |
935 | 974 | ||
936 | if (self_disconnected || reason == WLAN_REASON_DISASSOC_STA_HAS_LEFT) | 975 | if (self_disconnected || reason == WLAN_REASON_DISASSOC_STA_HAS_LEFT) { |
937 | ifsta->state = IEEE80211_STA_MLME_DISABLED; | 976 | ifsta->state = IEEE80211_STA_MLME_DISABLED; |
977 | ieee80211_rx_bss_remove(sdata, ifsta->bssid, | ||
978 | sdata->local->hw.conf.channel->center_freq, | ||
979 | ifsta->ssid, ifsta->ssid_len); | ||
980 | } | ||
938 | 981 | ||
939 | rcu_read_unlock(); | 982 | rcu_read_unlock(); |
940 | 983 | ||
@@ -995,7 +1038,7 @@ static int ieee80211_privacy_mismatch(struct ieee80211_sub_if_data *sdata, | |||
995 | if (!bss) | 1038 | if (!bss) |
996 | return 0; | 1039 | return 0; |
997 | 1040 | ||
998 | bss_privacy = !!(bss->capability & WLAN_CAPABILITY_PRIVACY); | 1041 | bss_privacy = !!(bss->cbss.capability & WLAN_CAPABILITY_PRIVACY); |
999 | wep_privacy = !!ieee80211_sta_wep_configured(sdata); | 1042 | wep_privacy = !!ieee80211_sta_wep_configured(sdata); |
1000 | privacy_invoked = !!(ifsta->flags & IEEE80211_STA_PRIVACY_INVOKED); | 1043 | privacy_invoked = !!(ifsta->flags & IEEE80211_STA_PRIVACY_INVOKED); |
1001 | 1044 | ||
@@ -1017,6 +1060,9 @@ static void ieee80211_associate(struct ieee80211_sub_if_data *sdata, | |||
1017 | sdata->dev->name, ifsta->bssid); | 1060 | sdata->dev->name, ifsta->bssid); |
1018 | ifsta->state = IEEE80211_STA_MLME_DISABLED; | 1061 | ifsta->state = IEEE80211_STA_MLME_DISABLED; |
1019 | ieee80211_sta_send_apinfo(sdata, ifsta); | 1062 | ieee80211_sta_send_apinfo(sdata, ifsta); |
1063 | ieee80211_rx_bss_remove(sdata, ifsta->bssid, | ||
1064 | sdata->local->hw.conf.channel->center_freq, | ||
1065 | ifsta->ssid, ifsta->ssid_len); | ||
1020 | return; | 1066 | return; |
1021 | } | 1067 | } |
1022 | 1068 | ||
@@ -1042,7 +1088,6 @@ static void ieee80211_associated(struct ieee80211_sub_if_data *sdata, | |||
1042 | struct ieee80211_local *local = sdata->local; | 1088 | struct ieee80211_local *local = sdata->local; |
1043 | struct sta_info *sta; | 1089 | struct sta_info *sta; |
1044 | int disassoc; | 1090 | int disassoc; |
1045 | bool remove_bss = false; | ||
1046 | 1091 | ||
1047 | /* TODO: start monitoring current AP signal quality and number of | 1092 | /* TODO: start monitoring current AP signal quality and number of |
1048 | * missed beacons. Scan other channels every now and then and search | 1093 | * missed beacons. Scan other channels every now and then and search |
@@ -1068,7 +1113,6 @@ static void ieee80211_associated(struct ieee80211_sub_if_data *sdata, | |||
1068 | "range\n", | 1113 | "range\n", |
1069 | sdata->dev->name, ifsta->bssid); | 1114 | sdata->dev->name, ifsta->bssid); |
1070 | disassoc = 1; | 1115 | disassoc = 1; |
1071 | remove_bss = true; | ||
1072 | } else | 1116 | } else |
1073 | ieee80211_send_probe_req(sdata, ifsta->bssid, | 1117 | ieee80211_send_probe_req(sdata, ifsta->bssid, |
1074 | ifsta->ssid, | 1118 | ifsta->ssid, |
@@ -1088,24 +1132,12 @@ static void ieee80211_associated(struct ieee80211_sub_if_data *sdata, | |||
1088 | 1132 | ||
1089 | rcu_read_unlock(); | 1133 | rcu_read_unlock(); |
1090 | 1134 | ||
1091 | if (disassoc) { | 1135 | if (disassoc) |
1092 | ieee80211_set_disassoc(sdata, ifsta, true, true, | 1136 | ieee80211_set_disassoc(sdata, ifsta, true, true, |
1093 | WLAN_REASON_PREV_AUTH_NOT_VALID); | 1137 | WLAN_REASON_PREV_AUTH_NOT_VALID); |
1094 | if (remove_bss) { | 1138 | else |
1095 | struct ieee80211_bss *bss; | ||
1096 | |||
1097 | bss = ieee80211_rx_bss_get(local, ifsta->bssid, | ||
1098 | local->hw.conf.channel->center_freq, | ||
1099 | ifsta->ssid, ifsta->ssid_len); | ||
1100 | if (bss) { | ||
1101 | atomic_dec(&bss->users); | ||
1102 | ieee80211_rx_bss_put(local, bss); | ||
1103 | } | ||
1104 | } | ||
1105 | } else { | ||
1106 | mod_timer(&ifsta->timer, jiffies + | 1139 | mod_timer(&ifsta->timer, jiffies + |
1107 | IEEE80211_MONITORING_INTERVAL); | 1140 | IEEE80211_MONITORING_INTERVAL); |
1108 | } | ||
1109 | } | 1141 | } |
1110 | 1142 | ||
1111 | 1143 | ||
@@ -1134,6 +1166,30 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, | |||
1134 | elems.challenge_len + 2, 1); | 1166 | elems.challenge_len + 2, 1); |
1135 | } | 1167 | } |
1136 | 1168 | ||
1169 | static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata, | ||
1170 | struct ieee80211_if_sta *ifsta, | ||
1171 | struct ieee80211_mgmt *mgmt, | ||
1172 | size_t len) | ||
1173 | { | ||
1174 | u16 auth_alg, auth_transaction, status_code; | ||
1175 | |||
1176 | if (len < 24 + 6) | ||
1177 | return; | ||
1178 | |||
1179 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); | ||
1180 | auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); | ||
1181 | status_code = le16_to_cpu(mgmt->u.auth.status_code); | ||
1182 | |||
1183 | /* | ||
1184 | * IEEE 802.11 standard does not require authentication in IBSS | ||
1185 | * networks and most implementations do not seem to use it. | ||
1186 | * However, try to reply to authentication attempts if someone | ||
1187 | * has actually implemented this. | ||
1188 | */ | ||
1189 | if (auth_alg == WLAN_AUTH_OPEN && auth_transaction == 1) | ||
1190 | ieee80211_send_auth(sdata, ifsta, 2, NULL, 0, 0); | ||
1191 | } | ||
1192 | |||
1137 | static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, | 1193 | static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, |
1138 | struct ieee80211_if_sta *ifsta, | 1194 | struct ieee80211_if_sta *ifsta, |
1139 | struct ieee80211_mgmt *mgmt, | 1195 | struct ieee80211_mgmt *mgmt, |
@@ -1141,37 +1197,22 @@ static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, | |||
1141 | { | 1197 | { |
1142 | u16 auth_alg, auth_transaction, status_code; | 1198 | u16 auth_alg, auth_transaction, status_code; |
1143 | 1199 | ||
1144 | if (ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE && | 1200 | if (ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE) |
1145 | sdata->vif.type != NL80211_IFTYPE_ADHOC) | ||
1146 | return; | 1201 | return; |
1147 | 1202 | ||
1148 | if (len < 24 + 6) | 1203 | if (len < 24 + 6) |
1149 | return; | 1204 | return; |
1150 | 1205 | ||
1151 | if (sdata->vif.type != NL80211_IFTYPE_ADHOC && | 1206 | if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) |
1152 | memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) | ||
1153 | return; | 1207 | return; |
1154 | 1208 | ||
1155 | if (sdata->vif.type != NL80211_IFTYPE_ADHOC && | 1209 | if (memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) |
1156 | memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) | ||
1157 | return; | 1210 | return; |
1158 | 1211 | ||
1159 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); | 1212 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); |
1160 | auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); | 1213 | auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); |
1161 | status_code = le16_to_cpu(mgmt->u.auth.status_code); | 1214 | status_code = le16_to_cpu(mgmt->u.auth.status_code); |
1162 | 1215 | ||
1163 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { | ||
1164 | /* | ||
1165 | * IEEE 802.11 standard does not require authentication in IBSS | ||
1166 | * networks and most implementations do not seem to use it. | ||
1167 | * However, try to reply to authentication attempts if someone | ||
1168 | * has actually implemented this. | ||
1169 | */ | ||
1170 | if (auth_alg != WLAN_AUTH_OPEN || auth_transaction != 1) | ||
1171 | return; | ||
1172 | ieee80211_send_auth(sdata, ifsta, 2, NULL, 0, 0); | ||
1173 | } | ||
1174 | |||
1175 | if (auth_alg != ifsta->auth_alg || | 1216 | if (auth_alg != ifsta->auth_alg || |
1176 | auth_transaction != ifsta->auth_transaction) | 1217 | auth_transaction != ifsta->auth_transaction) |
1177 | return; | 1218 | return; |
@@ -1381,8 +1422,6 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1381 | /* Add STA entry for the AP */ | 1422 | /* Add STA entry for the AP */ |
1382 | sta = sta_info_get(local, ifsta->bssid); | 1423 | sta = sta_info_get(local, ifsta->bssid); |
1383 | if (!sta) { | 1424 | if (!sta) { |
1384 | struct ieee80211_bss *bss; | ||
1385 | |||
1386 | newsta = true; | 1425 | newsta = true; |
1387 | 1426 | ||
1388 | sta = sta_info_alloc(sdata, ifsta->bssid, GFP_ATOMIC); | 1427 | sta = sta_info_alloc(sdata, ifsta->bssid, GFP_ATOMIC); |
@@ -1392,15 +1431,6 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1392 | rcu_read_unlock(); | 1431 | rcu_read_unlock(); |
1393 | return; | 1432 | return; |
1394 | } | 1433 | } |
1395 | bss = ieee80211_rx_bss_get(local, ifsta->bssid, | ||
1396 | local->hw.conf.channel->center_freq, | ||
1397 | ifsta->ssid, ifsta->ssid_len); | ||
1398 | if (bss) { | ||
1399 | sta->last_signal = bss->signal; | ||
1400 | sta->last_qual = bss->qual; | ||
1401 | sta->last_noise = bss->noise; | ||
1402 | ieee80211_rx_bss_put(local, bss); | ||
1403 | } | ||
1404 | 1434 | ||
1405 | /* update new sta with its last rx activity */ | 1435 | /* update new sta with its last rx activity */ |
1406 | sta->last_rx = jiffies; | 1436 | sta->last_rx = jiffies; |
@@ -1512,9 +1542,13 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1512 | } | 1542 | } |
1513 | 1543 | ||
1514 | 1544 | ||
1515 | static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | 1545 | static int __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, |
1516 | struct ieee80211_if_sta *ifsta, | 1546 | struct ieee80211_if_sta *ifsta, |
1517 | struct ieee80211_bss *bss) | 1547 | const u8 *bssid, const int beacon_int, |
1548 | const int freq, | ||
1549 | const size_t supp_rates_len, | ||
1550 | const u8 *supp_rates, | ||
1551 | const u16 capability) | ||
1518 | { | 1552 | { |
1519 | struct ieee80211_local *local = sdata->local; | 1553 | struct ieee80211_local *local = sdata->local; |
1520 | int res = 0, rates, i, j; | 1554 | int res = 0, rates, i, j; |
@@ -1530,7 +1564,7 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
1530 | } | 1564 | } |
1531 | 1565 | ||
1532 | if ((ifsta->flags & IEEE80211_STA_PREV_BSSID_SET) && | 1566 | if ((ifsta->flags & IEEE80211_STA_PREV_BSSID_SET) && |
1533 | memcmp(ifsta->bssid, bss->bssid, ETH_ALEN) == 0) | 1567 | memcmp(ifsta->bssid, bssid, ETH_ALEN) == 0) |
1534 | return res; | 1568 | return res; |
1535 | 1569 | ||
1536 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400 + | 1570 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400 + |
@@ -1541,28 +1575,28 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
1541 | return -ENOMEM; | 1575 | return -ENOMEM; |
1542 | } | 1576 | } |
1543 | 1577 | ||
1544 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
1545 | |||
1546 | if (!(ifsta->flags & IEEE80211_STA_PREV_BSSID_SET)) { | 1578 | if (!(ifsta->flags & IEEE80211_STA_PREV_BSSID_SET)) { |
1547 | /* Remove possible STA entries from other IBSS networks. */ | 1579 | /* Remove possible STA entries from other IBSS networks. */ |
1548 | sta_info_flush_delayed(sdata); | 1580 | sta_info_flush_delayed(sdata); |
1549 | } | 1581 | } |
1550 | 1582 | ||
1551 | memcpy(ifsta->bssid, bss->bssid, ETH_ALEN); | 1583 | memcpy(ifsta->bssid, bssid, ETH_ALEN); |
1552 | res = ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID); | 1584 | res = ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID); |
1553 | if (res) | 1585 | if (res) |
1554 | return res; | 1586 | return res; |
1555 | 1587 | ||
1556 | local->hw.conf.beacon_int = bss->beacon_int >= 10 ? bss->beacon_int : 10; | 1588 | local->hw.conf.beacon_int = beacon_int >= 10 ? beacon_int : 10; |
1557 | 1589 | ||
1558 | sdata->drop_unencrypted = bss->capability & | 1590 | sdata->drop_unencrypted = capability & |
1559 | WLAN_CAPABILITY_PRIVACY ? 1 : 0; | 1591 | WLAN_CAPABILITY_PRIVACY ? 1 : 0; |
1560 | 1592 | ||
1561 | res = ieee80211_set_freq(sdata, bss->freq); | 1593 | res = ieee80211_set_freq(sdata, freq); |
1562 | 1594 | ||
1563 | if (res) | 1595 | if (res) |
1564 | return res; | 1596 | return res; |
1565 | 1597 | ||
1598 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
1599 | |||
1566 | /* Build IBSS probe response */ | 1600 | /* Build IBSS probe response */ |
1567 | 1601 | ||
1568 | skb_reserve(skb, local->hw.extra_tx_headroom); | 1602 | skb_reserve(skb, local->hw.extra_tx_headroom); |
@@ -1571,33 +1605,32 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
1571 | skb_put(skb, 24 + sizeof(mgmt->u.beacon)); | 1605 | skb_put(skb, 24 + sizeof(mgmt->u.beacon)); |
1572 | memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); | 1606 | memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); |
1573 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | 1607 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
1574 | IEEE80211_STYPE_PROBE_RESP); | 1608 | IEEE80211_STYPE_PROBE_RESP); |
1575 | memset(mgmt->da, 0xff, ETH_ALEN); | 1609 | memset(mgmt->da, 0xff, ETH_ALEN); |
1576 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 1610 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); |
1577 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); | 1611 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); |
1578 | mgmt->u.beacon.beacon_int = | 1612 | mgmt->u.beacon.beacon_int = |
1579 | cpu_to_le16(local->hw.conf.beacon_int); | 1613 | cpu_to_le16(local->hw.conf.beacon_int); |
1580 | mgmt->u.beacon.timestamp = cpu_to_le64(bss->timestamp); | 1614 | mgmt->u.beacon.capab_info = cpu_to_le16(capability); |
1581 | mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability); | ||
1582 | 1615 | ||
1583 | pos = skb_put(skb, 2 + ifsta->ssid_len); | 1616 | pos = skb_put(skb, 2 + ifsta->ssid_len); |
1584 | *pos++ = WLAN_EID_SSID; | 1617 | *pos++ = WLAN_EID_SSID; |
1585 | *pos++ = ifsta->ssid_len; | 1618 | *pos++ = ifsta->ssid_len; |
1586 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); | 1619 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); |
1587 | 1620 | ||
1588 | rates = bss->supp_rates_len; | 1621 | rates = supp_rates_len; |
1589 | if (rates > 8) | 1622 | if (rates > 8) |
1590 | rates = 8; | 1623 | rates = 8; |
1591 | pos = skb_put(skb, 2 + rates); | 1624 | pos = skb_put(skb, 2 + rates); |
1592 | *pos++ = WLAN_EID_SUPP_RATES; | 1625 | *pos++ = WLAN_EID_SUPP_RATES; |
1593 | *pos++ = rates; | 1626 | *pos++ = rates; |
1594 | memcpy(pos, bss->supp_rates, rates); | 1627 | memcpy(pos, supp_rates, rates); |
1595 | 1628 | ||
1596 | if (bss->band == IEEE80211_BAND_2GHZ) { | 1629 | if (sband->band == IEEE80211_BAND_2GHZ) { |
1597 | pos = skb_put(skb, 2 + 1); | 1630 | pos = skb_put(skb, 2 + 1); |
1598 | *pos++ = WLAN_EID_DS_PARAMS; | 1631 | *pos++ = WLAN_EID_DS_PARAMS; |
1599 | *pos++ = 1; | 1632 | *pos++ = 1; |
1600 | *pos++ = ieee80211_frequency_to_channel(bss->freq); | 1633 | *pos++ = ieee80211_frequency_to_channel(freq); |
1601 | } | 1634 | } |
1602 | 1635 | ||
1603 | pos = skb_put(skb, 2 + 2); | 1636 | pos = skb_put(skb, 2 + 2); |
@@ -1607,12 +1640,12 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
1607 | *pos++ = 0; | 1640 | *pos++ = 0; |
1608 | *pos++ = 0; | 1641 | *pos++ = 0; |
1609 | 1642 | ||
1610 | if (bss->supp_rates_len > 8) { | 1643 | if (supp_rates_len > 8) { |
1611 | rates = bss->supp_rates_len - 8; | 1644 | rates = supp_rates_len - 8; |
1612 | pos = skb_put(skb, 2 + rates); | 1645 | pos = skb_put(skb, 2 + rates); |
1613 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | 1646 | *pos++ = WLAN_EID_EXT_SUPP_RATES; |
1614 | *pos++ = rates; | 1647 | *pos++ = rates; |
1615 | memcpy(pos, &bss->supp_rates[8], rates); | 1648 | memcpy(pos, &supp_rates[8], rates); |
1616 | } | 1649 | } |
1617 | 1650 | ||
1618 | add_extra_ies(skb, sdata->u.sta.ie_proberesp, | 1651 | add_extra_ies(skb, sdata->u.sta.ie_proberesp, |
@@ -1625,16 +1658,15 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
1625 | 1658 | ||
1626 | 1659 | ||
1627 | rates = 0; | 1660 | rates = 0; |
1628 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | 1661 | for (i = 0; i < supp_rates_len; i++) { |
1629 | for (i = 0; i < bss->supp_rates_len; i++) { | 1662 | int bitrate = (supp_rates[i] & 0x7f) * 5; |
1630 | int bitrate = (bss->supp_rates[i] & 0x7f) * 5; | ||
1631 | for (j = 0; j < sband->n_bitrates; j++) | 1663 | for (j = 0; j < sband->n_bitrates; j++) |
1632 | if (sband->bitrates[j].bitrate == bitrate) | 1664 | if (sband->bitrates[j].bitrate == bitrate) |
1633 | rates |= BIT(j); | 1665 | rates |= BIT(j); |
1634 | } | 1666 | } |
1635 | ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates; | 1667 | ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates; |
1636 | 1668 | ||
1637 | ieee80211_sta_def_wmm_params(sdata, bss); | 1669 | ieee80211_sta_def_wmm_params(sdata, supp_rates_len, supp_rates); |
1638 | 1670 | ||
1639 | ifsta->flags |= IEEE80211_STA_PREV_BSSID_SET; | 1671 | ifsta->flags |= IEEE80211_STA_PREV_BSSID_SET; |
1640 | ifsta->state = IEEE80211_STA_MLME_IBSS_JOINED; | 1672 | ifsta->state = IEEE80211_STA_MLME_IBSS_JOINED; |
@@ -1643,12 +1675,24 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
1643 | ieee80211_led_assoc(local, true); | 1675 | ieee80211_led_assoc(local, true); |
1644 | 1676 | ||
1645 | memset(&wrqu, 0, sizeof(wrqu)); | 1677 | memset(&wrqu, 0, sizeof(wrqu)); |
1646 | memcpy(wrqu.ap_addr.sa_data, bss->bssid, ETH_ALEN); | 1678 | memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN); |
1647 | wireless_send_event(sdata->dev, SIOCGIWAP, &wrqu, NULL); | 1679 | wireless_send_event(sdata->dev, SIOCGIWAP, &wrqu, NULL); |
1648 | 1680 | ||
1649 | return res; | 1681 | return res; |
1650 | } | 1682 | } |
1651 | 1683 | ||
1684 | static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | ||
1685 | struct ieee80211_if_sta *ifsta, | ||
1686 | struct ieee80211_bss *bss) | ||
1687 | { | ||
1688 | return __ieee80211_sta_join_ibss(sdata, ifsta, | ||
1689 | bss->cbss.bssid, | ||
1690 | bss->cbss.beacon_interval, | ||
1691 | bss->cbss.channel->center_freq, | ||
1692 | bss->supp_rates_len, bss->supp_rates, | ||
1693 | bss->cbss.capability); | ||
1694 | } | ||
1695 | |||
1652 | static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | 1696 | static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, |
1653 | struct ieee80211_mgmt *mgmt, | 1697 | struct ieee80211_mgmt *mgmt, |
1654 | size_t len, | 1698 | size_t len, |
@@ -1709,7 +1753,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
1709 | } | 1753 | } |
1710 | 1754 | ||
1711 | bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems, | 1755 | bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems, |
1712 | freq, beacon); | 1756 | channel, beacon); |
1713 | if (!bss) | 1757 | if (!bss) |
1714 | return; | 1758 | return; |
1715 | 1759 | ||
@@ -1721,76 +1765,87 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
1721 | } | 1765 | } |
1722 | 1766 | ||
1723 | /* was just updated in ieee80211_bss_info_update */ | 1767 | /* was just updated in ieee80211_bss_info_update */ |
1724 | beacon_timestamp = bss->timestamp; | 1768 | beacon_timestamp = bss->cbss.tsf; |
1725 | 1769 | ||
1726 | /* | 1770 | if (sdata->vif.type != NL80211_IFTYPE_ADHOC) |
1727 | * In STA mode, the remaining parameters should not be overridden | 1771 | goto put_bss; |
1728 | * by beacons because they're not necessarily accurate there. | ||
1729 | */ | ||
1730 | if (sdata->vif.type != NL80211_IFTYPE_ADHOC && | ||
1731 | bss->last_probe_resp && beacon) { | ||
1732 | ieee80211_rx_bss_put(local, bss); | ||
1733 | return; | ||
1734 | } | ||
1735 | 1772 | ||
1736 | /* check if we need to merge IBSS */ | 1773 | /* check if we need to merge IBSS */ |
1737 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC && beacon && | 1774 | |
1738 | (!(sdata->u.sta.flags & IEEE80211_STA_BSSID_SET)) && | 1775 | /* merge only on beacons (???) */ |
1739 | bss->capability & WLAN_CAPABILITY_IBSS && | 1776 | if (!beacon) |
1740 | bss->freq == local->oper_channel->center_freq && | 1777 | goto put_bss; |
1741 | elems->ssid_len == sdata->u.sta.ssid_len && | 1778 | |
1779 | /* we use a fixed BSSID */ | ||
1780 | if (sdata->u.sta.flags & IEEE80211_STA_BSSID_SET) | ||
1781 | goto put_bss; | ||
1782 | |||
1783 | /* not an IBSS */ | ||
1784 | if (!(bss->cbss.capability & WLAN_CAPABILITY_IBSS)) | ||
1785 | goto put_bss; | ||
1786 | |||
1787 | /* different channel */ | ||
1788 | if (bss->cbss.channel != local->oper_channel) | ||
1789 | goto put_bss; | ||
1790 | |||
1791 | /* different SSID */ | ||
1792 | if (elems->ssid_len != sdata->u.sta.ssid_len || | ||
1742 | memcmp(elems->ssid, sdata->u.sta.ssid, | 1793 | memcmp(elems->ssid, sdata->u.sta.ssid, |
1743 | sdata->u.sta.ssid_len) == 0) { | 1794 | sdata->u.sta.ssid_len)) |
1744 | if (rx_status->flag & RX_FLAG_TSFT) { | 1795 | goto put_bss; |
1745 | /* in order for correct IBSS merging we need mactime | 1796 | |
1746 | * | 1797 | if (rx_status->flag & RX_FLAG_TSFT) { |
1747 | * since mactime is defined as the time the first data | 1798 | /* |
1748 | * symbol of the frame hits the PHY, and the timestamp | 1799 | * For correct IBSS merging we need mactime; since mactime is |
1749 | * of the beacon is defined as "the time that the data | 1800 | * defined as the time the first data symbol of the frame hits |
1750 | * symbol containing the first bit of the timestamp is | 1801 | * the PHY, and the timestamp of the beacon is defined as "the |
1751 | * transmitted to the PHY plus the transmitting STA’s | 1802 | * time that the data symbol containing the first bit of the |
1752 | * delays through its local PHY from the MAC-PHY | 1803 | * timestamp is transmitted to the PHY plus the transmitting |
1753 | * interface to its interface with the WM" | 1804 | * STA's delays through its local PHY from the MAC-PHY |
1754 | * (802.11 11.1.2) - equals the time this bit arrives at | 1805 | * interface to its interface with the WM" (802.11 11.1.2) |
1755 | * the receiver - we have to take into account the | 1806 | * - equals the time this bit arrives at the receiver - we have |
1756 | * offset between the two. | 1807 | * to take into account the offset between the two. |
1757 | * e.g: at 1 MBit that means mactime is 192 usec earlier | 1808 | * |
1758 | * (=24 bytes * 8 usecs/byte) than the beacon timestamp. | 1809 | * E.g. at 1 MBit that means mactime is 192 usec earlier |
1759 | */ | 1810 | * (=24 bytes * 8 usecs/byte) than the beacon timestamp. |
1760 | int rate; | 1811 | */ |
1761 | if (rx_status->flag & RX_FLAG_HT) { | 1812 | int rate; |
1762 | rate = 65; /* TODO: HT rates */ | 1813 | |
1763 | } else { | 1814 | if (rx_status->flag & RX_FLAG_HT) |
1764 | rate = local->hw.wiphy->bands[band]-> | 1815 | rate = 65; /* TODO: HT rates */ |
1765 | bitrates[rx_status->rate_idx].bitrate; | ||
1766 | } | ||
1767 | rx_timestamp = rx_status->mactime + (24 * 8 * 10 / rate); | ||
1768 | } else if (local && local->ops && local->ops->get_tsf) | ||
1769 | /* second best option: get current TSF */ | ||
1770 | rx_timestamp = local->ops->get_tsf(local_to_hw(local)); | ||
1771 | else | 1816 | else |
1772 | /* can't merge without knowing the TSF */ | 1817 | rate = local->hw.wiphy->bands[band]-> |
1773 | rx_timestamp = -1LLU; | 1818 | bitrates[rx_status->rate_idx].bitrate; |
1819 | |||
1820 | rx_timestamp = rx_status->mactime + (24 * 8 * 10 / rate); | ||
1821 | } else if (local && local->ops && local->ops->get_tsf) | ||
1822 | /* second best option: get current TSF */ | ||
1823 | rx_timestamp = local->ops->get_tsf(local_to_hw(local)); | ||
1824 | else | ||
1825 | /* can't merge without knowing the TSF */ | ||
1826 | rx_timestamp = -1LLU; | ||
1827 | |||
1774 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 1828 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
1775 | printk(KERN_DEBUG "RX beacon SA=%pM BSSID=" | 1829 | printk(KERN_DEBUG "RX beacon SA=%pM BSSID=" |
1776 | "%pM TSF=0x%llx BCN=0x%llx diff=%lld @%lu\n", | 1830 | "%pM TSF=0x%llx BCN=0x%llx diff=%lld @%lu\n", |
1777 | mgmt->sa, mgmt->bssid, | 1831 | mgmt->sa, mgmt->bssid, |
1778 | (unsigned long long)rx_timestamp, | 1832 | (unsigned long long)rx_timestamp, |
1779 | (unsigned long long)beacon_timestamp, | 1833 | (unsigned long long)beacon_timestamp, |
1780 | (unsigned long long)(rx_timestamp - beacon_timestamp), | 1834 | (unsigned long long)(rx_timestamp - beacon_timestamp), |
1781 | jiffies); | 1835 | jiffies); |
1782 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 1836 | #endif |
1783 | if (beacon_timestamp > rx_timestamp) { | 1837 | |
1838 | if (beacon_timestamp > rx_timestamp) { | ||
1784 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 1839 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
1785 | printk(KERN_DEBUG "%s: beacon TSF higher than " | 1840 | printk(KERN_DEBUG "%s: beacon TSF higher than " |
1786 | "local TSF - IBSS merge with BSSID %pM\n", | 1841 | "local TSF - IBSS merge with BSSID %pM\n", |
1787 | sdata->dev->name, mgmt->bssid); | 1842 | sdata->dev->name, mgmt->bssid); |
1788 | #endif | 1843 | #endif |
1789 | ieee80211_sta_join_ibss(sdata, &sdata->u.sta, bss); | 1844 | ieee80211_sta_join_ibss(sdata, &sdata->u.sta, bss); |
1790 | ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates); | 1845 | ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates); |
1791 | } | ||
1792 | } | 1846 | } |
1793 | 1847 | ||
1848 | put_bss: | ||
1794 | ieee80211_rx_bss_put(local, bss); | 1849 | ieee80211_rx_bss_put(local, bss); |
1795 | } | 1850 | } |
1796 | 1851 | ||
@@ -1836,7 +1891,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
1836 | struct ieee802_11_elems elems; | 1891 | struct ieee802_11_elems elems; |
1837 | struct ieee80211_local *local = sdata->local; | 1892 | struct ieee80211_local *local = sdata->local; |
1838 | u32 changed = 0; | 1893 | u32 changed = 0; |
1839 | bool erp_valid, directed_tim, is_mc = false; | 1894 | bool erp_valid, directed_tim; |
1840 | u8 erp_value = 0; | 1895 | u8 erp_value = 0; |
1841 | 1896 | ||
1842 | /* Process beacon from the current BSS */ | 1897 | /* Process beacon from the current BSS */ |
@@ -1864,12 +1919,27 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
1864 | 1919 | ||
1865 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK && | 1920 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK && |
1866 | local->hw.conf.flags & IEEE80211_CONF_PS) { | 1921 | local->hw.conf.flags & IEEE80211_CONF_PS) { |
1867 | directed_tim = check_tim(&elems, ifsta->aid, &is_mc); | 1922 | directed_tim = ieee80211_check_tim(&elems, ifsta->aid); |
1868 | 1923 | ||
1869 | if (directed_tim || is_mc) { | 1924 | if (directed_tim) { |
1870 | local->hw.conf.flags &= ~IEEE80211_CONF_PS; | 1925 | if (local->hw.conf.dynamic_ps_timeout > 0) { |
1871 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); | 1926 | local->hw.conf.flags &= ~IEEE80211_CONF_PS; |
1872 | ieee80211_send_nullfunc(local, sdata, 0); | 1927 | ieee80211_hw_config(local, |
1928 | IEEE80211_CONF_CHANGE_PS); | ||
1929 | ieee80211_send_nullfunc(local, sdata, 0); | ||
1930 | } else { | ||
1931 | local->pspolling = true; | ||
1932 | |||
1933 | /* | ||
1934 | * Here is assumed that the driver will be | ||
1935 | * able to send ps-poll frame and receive a | ||
1936 | * response even though power save mode is | ||
1937 | * enabled, but some drivers might require | ||
1938 | * to disable power save here. This needs | ||
1939 | * to be investigated. | ||
1940 | */ | ||
1941 | ieee80211_send_pspoll(local, sdata); | ||
1942 | } | ||
1873 | } | 1943 | } |
1874 | } | 1944 | } |
1875 | 1945 | ||
@@ -1939,8 +2009,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, | |||
1939 | struct ieee80211_mgmt *resp; | 2009 | struct ieee80211_mgmt *resp; |
1940 | u8 *pos, *end; | 2010 | u8 *pos, *end; |
1941 | 2011 | ||
1942 | if (sdata->vif.type != NL80211_IFTYPE_ADHOC || | 2012 | if (ifsta->state != IEEE80211_STA_MLME_IBSS_JOINED || |
1943 | ifsta->state != IEEE80211_STA_MLME_IBSS_JOINED || | ||
1944 | len < 24 + 2 || !ifsta->probe_resp) | 2013 | len < 24 + 2 || !ifsta->probe_resp) |
1945 | return; | 2014 | return; |
1946 | 2015 | ||
@@ -2044,31 +2113,54 @@ static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, | |||
2044 | mgmt = (struct ieee80211_mgmt *) skb->data; | 2113 | mgmt = (struct ieee80211_mgmt *) skb->data; |
2045 | fc = le16_to_cpu(mgmt->frame_control); | 2114 | fc = le16_to_cpu(mgmt->frame_control); |
2046 | 2115 | ||
2047 | switch (fc & IEEE80211_FCTL_STYPE) { | 2116 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { |
2048 | case IEEE80211_STYPE_PROBE_REQ: | 2117 | switch (fc & IEEE80211_FCTL_STYPE) { |
2049 | ieee80211_rx_mgmt_probe_req(sdata, ifsta, mgmt, skb->len); | 2118 | case IEEE80211_STYPE_PROBE_REQ: |
2050 | break; | 2119 | ieee80211_rx_mgmt_probe_req(sdata, ifsta, mgmt, |
2051 | case IEEE80211_STYPE_PROBE_RESP: | 2120 | skb->len); |
2052 | ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len, rx_status); | 2121 | break; |
2053 | break; | 2122 | case IEEE80211_STYPE_PROBE_RESP: |
2054 | case IEEE80211_STYPE_BEACON: | 2123 | ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len, |
2055 | ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, rx_status); | 2124 | rx_status); |
2056 | break; | 2125 | break; |
2057 | case IEEE80211_STYPE_AUTH: | 2126 | case IEEE80211_STYPE_BEACON: |
2058 | ieee80211_rx_mgmt_auth(sdata, ifsta, mgmt, skb->len); | 2127 | ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, |
2059 | break; | 2128 | rx_status); |
2060 | case IEEE80211_STYPE_ASSOC_RESP: | 2129 | break; |
2061 | ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt, skb->len, 0); | 2130 | case IEEE80211_STYPE_AUTH: |
2062 | break; | 2131 | ieee80211_rx_mgmt_auth_ibss(sdata, ifsta, mgmt, |
2063 | case IEEE80211_STYPE_REASSOC_RESP: | 2132 | skb->len); |
2064 | ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt, skb->len, 1); | 2133 | break; |
2065 | break; | 2134 | } |
2066 | case IEEE80211_STYPE_DEAUTH: | 2135 | } else { /* NL80211_IFTYPE_STATION */ |
2067 | ieee80211_rx_mgmt_deauth(sdata, ifsta, mgmt, skb->len); | 2136 | switch (fc & IEEE80211_FCTL_STYPE) { |
2068 | break; | 2137 | case IEEE80211_STYPE_PROBE_RESP: |
2069 | case IEEE80211_STYPE_DISASSOC: | 2138 | ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len, |
2070 | ieee80211_rx_mgmt_disassoc(sdata, ifsta, mgmt, skb->len); | 2139 | rx_status); |
2071 | break; | 2140 | break; |
2141 | case IEEE80211_STYPE_BEACON: | ||
2142 | ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, | ||
2143 | rx_status); | ||
2144 | break; | ||
2145 | case IEEE80211_STYPE_AUTH: | ||
2146 | ieee80211_rx_mgmt_auth(sdata, ifsta, mgmt, skb->len); | ||
2147 | break; | ||
2148 | case IEEE80211_STYPE_ASSOC_RESP: | ||
2149 | ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt, | ||
2150 | skb->len, 0); | ||
2151 | break; | ||
2152 | case IEEE80211_STYPE_REASSOC_RESP: | ||
2153 | ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt, | ||
2154 | skb->len, 1); | ||
2155 | break; | ||
2156 | case IEEE80211_STYPE_DEAUTH: | ||
2157 | ieee80211_rx_mgmt_deauth(sdata, ifsta, mgmt, skb->len); | ||
2158 | break; | ||
2159 | case IEEE80211_STYPE_DISASSOC: | ||
2160 | ieee80211_rx_mgmt_disassoc(sdata, ifsta, mgmt, | ||
2161 | skb->len); | ||
2162 | break; | ||
2163 | } | ||
2072 | } | 2164 | } |
2073 | 2165 | ||
2074 | kfree_skb(skb); | 2166 | kfree_skb(skb); |
@@ -2113,7 +2205,15 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata, | |||
2113 | 2205 | ||
2114 | printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " | 2206 | printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " |
2115 | "IBSS networks with same SSID (merge)\n", sdata->dev->name); | 2207 | "IBSS networks with same SSID (merge)\n", sdata->dev->name); |
2116 | ieee80211_request_scan(sdata, ifsta->ssid, ifsta->ssid_len); | 2208 | |
2209 | /* XXX maybe racy? */ | ||
2210 | if (sdata->local->scan_req) | ||
2211 | return; | ||
2212 | |||
2213 | memcpy(sdata->local->int_scan_req.ssids[0].ssid, | ||
2214 | ifsta->ssid, IEEE80211_MAX_SSID_LEN); | ||
2215 | sdata->local->int_scan_req.ssids[0].ssid_len = ifsta->ssid_len; | ||
2216 | ieee80211_request_scan(sdata, &sdata->local->int_scan_req); | ||
2117 | } | 2217 | } |
2118 | 2218 | ||
2119 | 2219 | ||
@@ -2159,46 +2259,16 @@ static void ieee80211_sta_reset_auth(struct ieee80211_sub_if_data *sdata, | |||
2159 | netif_carrier_off(sdata->dev); | 2259 | netif_carrier_off(sdata->dev); |
2160 | } | 2260 | } |
2161 | 2261 | ||
2162 | |||
2163 | static int ieee80211_sta_match_ssid(struct ieee80211_if_sta *ifsta, | ||
2164 | const char *ssid, int ssid_len) | ||
2165 | { | ||
2166 | int tmp, hidden_ssid; | ||
2167 | |||
2168 | if (ssid_len == ifsta->ssid_len && | ||
2169 | !memcmp(ifsta->ssid, ssid, ssid_len)) | ||
2170 | return 1; | ||
2171 | |||
2172 | if (ifsta->flags & IEEE80211_STA_AUTO_BSSID_SEL) | ||
2173 | return 0; | ||
2174 | |||
2175 | hidden_ssid = 1; | ||
2176 | tmp = ssid_len; | ||
2177 | while (tmp--) { | ||
2178 | if (ssid[tmp] != '\0') { | ||
2179 | hidden_ssid = 0; | ||
2180 | break; | ||
2181 | } | ||
2182 | } | ||
2183 | |||
2184 | if (hidden_ssid && (ifsta->ssid_len == ssid_len || ssid_len == 0)) | ||
2185 | return 1; | ||
2186 | |||
2187 | if (ssid_len == 1 && ssid[0] == ' ') | ||
2188 | return 1; | ||
2189 | |||
2190 | return 0; | ||
2191 | } | ||
2192 | |||
2193 | static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata, | 2262 | static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata, |
2194 | struct ieee80211_if_sta *ifsta) | 2263 | struct ieee80211_if_sta *ifsta) |
2195 | { | 2264 | { |
2196 | struct ieee80211_local *local = sdata->local; | 2265 | struct ieee80211_local *local = sdata->local; |
2197 | struct ieee80211_bss *bss; | ||
2198 | struct ieee80211_supported_band *sband; | 2266 | struct ieee80211_supported_band *sband; |
2199 | u8 bssid[ETH_ALEN], *pos; | 2267 | u8 *pos; |
2268 | u8 bssid[ETH_ALEN]; | ||
2269 | u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; | ||
2270 | u16 capability; | ||
2200 | int i; | 2271 | int i; |
2201 | int ret; | ||
2202 | 2272 | ||
2203 | if (sdata->u.sta.flags & IEEE80211_STA_BSSID_SET) { | 2273 | if (sdata->u.sta.flags & IEEE80211_STA_BSSID_SET) { |
2204 | memcpy(bssid, ifsta->bssid, ETH_ALEN); | 2274 | memcpy(bssid, ifsta->bssid, ETH_ALEN); |
@@ -2216,36 +2286,29 @@ static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata, | |||
2216 | printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %pM\n", | 2286 | printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %pM\n", |
2217 | sdata->dev->name, bssid); | 2287 | sdata->dev->name, bssid); |
2218 | 2288 | ||
2219 | bss = ieee80211_rx_bss_add(local, bssid, | 2289 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
2220 | local->hw.conf.channel->center_freq, | ||
2221 | sdata->u.sta.ssid, sdata->u.sta.ssid_len); | ||
2222 | if (!bss) | ||
2223 | return -ENOMEM; | ||
2224 | |||
2225 | bss->band = local->hw.conf.channel->band; | ||
2226 | sband = local->hw.wiphy->bands[bss->band]; | ||
2227 | 2290 | ||
2228 | if (local->hw.conf.beacon_int == 0) | 2291 | if (local->hw.conf.beacon_int == 0) |
2229 | local->hw.conf.beacon_int = 100; | 2292 | local->hw.conf.beacon_int = 100; |
2230 | bss->beacon_int = local->hw.conf.beacon_int; | 2293 | |
2231 | bss->last_update = jiffies; | 2294 | capability = WLAN_CAPABILITY_IBSS; |
2232 | bss->capability = WLAN_CAPABILITY_IBSS; | ||
2233 | 2295 | ||
2234 | if (sdata->default_key) | 2296 | if (sdata->default_key) |
2235 | bss->capability |= WLAN_CAPABILITY_PRIVACY; | 2297 | capability |= WLAN_CAPABILITY_PRIVACY; |
2236 | else | 2298 | else |
2237 | sdata->drop_unencrypted = 0; | 2299 | sdata->drop_unencrypted = 0; |
2238 | 2300 | ||
2239 | bss->supp_rates_len = sband->n_bitrates; | 2301 | pos = supp_rates; |
2240 | pos = bss->supp_rates; | ||
2241 | for (i = 0; i < sband->n_bitrates; i++) { | 2302 | for (i = 0; i < sband->n_bitrates; i++) { |
2242 | int rate = sband->bitrates[i].bitrate; | 2303 | int rate = sband->bitrates[i].bitrate; |
2243 | *pos++ = (u8) (rate / 5); | 2304 | *pos++ = (u8) (rate / 5); |
2244 | } | 2305 | } |
2245 | 2306 | ||
2246 | ret = ieee80211_sta_join_ibss(sdata, ifsta, bss); | 2307 | return __ieee80211_sta_join_ibss(sdata, ifsta, |
2247 | ieee80211_rx_bss_put(local, bss); | 2308 | bssid, local->hw.conf.beacon_int, |
2248 | return ret; | 2309 | local->hw.conf.channel->center_freq, |
2310 | sband->n_bitrates, supp_rates, | ||
2311 | capability); | ||
2249 | } | 2312 | } |
2250 | 2313 | ||
2251 | 2314 | ||
@@ -2254,8 +2317,6 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata, | |||
2254 | { | 2317 | { |
2255 | struct ieee80211_local *local = sdata->local; | 2318 | struct ieee80211_local *local = sdata->local; |
2256 | struct ieee80211_bss *bss; | 2319 | struct ieee80211_bss *bss; |
2257 | int found = 0; | ||
2258 | u8 bssid[ETH_ALEN]; | ||
2259 | int active_ibss; | 2320 | int active_ibss; |
2260 | 2321 | ||
2261 | if (ifsta->ssid_len == 0) | 2322 | if (ifsta->ssid_len == 0) |
@@ -2266,56 +2327,39 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata, | |||
2266 | printk(KERN_DEBUG "%s: sta_find_ibss (active_ibss=%d)\n", | 2327 | printk(KERN_DEBUG "%s: sta_find_ibss (active_ibss=%d)\n", |
2267 | sdata->dev->name, active_ibss); | 2328 | sdata->dev->name, active_ibss); |
2268 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 2329 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
2269 | spin_lock_bh(&local->bss_lock); | 2330 | |
2270 | list_for_each_entry(bss, &local->bss_list, list) { | 2331 | if (active_ibss) |
2271 | if (ifsta->ssid_len != bss->ssid_len || | 2332 | return 0; |
2272 | memcmp(ifsta->ssid, bss->ssid, bss->ssid_len) != 0 | 2333 | |
2273 | || !(bss->capability & WLAN_CAPABILITY_IBSS)) | 2334 | if (ifsta->flags & IEEE80211_STA_BSSID_SET) |
2274 | continue; | 2335 | bss = ieee80211_rx_bss_get(local, ifsta->bssid, 0, |
2275 | if ((ifsta->flags & IEEE80211_STA_BSSID_SET) && | 2336 | ifsta->ssid, ifsta->ssid_len); |
2276 | memcmp(ifsta->bssid, bss->bssid, ETH_ALEN) != 0) | 2337 | else |
2277 | continue; | 2338 | bss = (void *)cfg80211_get_ibss(local->hw.wiphy, |
2278 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 2339 | NULL, |
2279 | printk(KERN_DEBUG " bssid=%pM found\n", bss->bssid); | 2340 | ifsta->ssid, ifsta->ssid_len); |
2280 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | ||
2281 | memcpy(bssid, bss->bssid, ETH_ALEN); | ||
2282 | found = 1; | ||
2283 | if (active_ibss || memcmp(bssid, ifsta->bssid, ETH_ALEN) != 0) | ||
2284 | break; | ||
2285 | } | ||
2286 | spin_unlock_bh(&local->bss_lock); | ||
2287 | 2341 | ||
2288 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 2342 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
2289 | if (found) | 2343 | if (bss) |
2290 | printk(KERN_DEBUG " sta_find_ibss: selected %pM current " | 2344 | printk(KERN_DEBUG " sta_find_ibss: selected %pM current " |
2291 | "%pM\n", bssid, ifsta->bssid); | 2345 | "%pM\n", bss->cbss.bssid, ifsta->bssid); |
2292 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 2346 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
2293 | 2347 | ||
2294 | if (found && | 2348 | if (bss && |
2295 | ((!(ifsta->flags & IEEE80211_STA_PREV_BSSID_SET)) || | 2349 | (!(ifsta->flags & IEEE80211_STA_PREV_BSSID_SET) || |
2296 | memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0)) { | 2350 | memcmp(ifsta->bssid, bss->cbss.bssid, ETH_ALEN))) { |
2297 | int ret; | 2351 | int ret; |
2298 | int search_freq; | ||
2299 | |||
2300 | if (ifsta->flags & IEEE80211_STA_AUTO_CHANNEL_SEL) | ||
2301 | search_freq = bss->freq; | ||
2302 | else | ||
2303 | search_freq = local->hw.conf.channel->center_freq; | ||
2304 | |||
2305 | bss = ieee80211_rx_bss_get(local, bssid, search_freq, | ||
2306 | ifsta->ssid, ifsta->ssid_len); | ||
2307 | if (!bss) | ||
2308 | goto dont_join; | ||
2309 | 2352 | ||
2310 | printk(KERN_DEBUG "%s: Selected IBSS BSSID %pM" | 2353 | printk(KERN_DEBUG "%s: Selected IBSS BSSID %pM" |
2311 | " based on configured SSID\n", | 2354 | " based on configured SSID\n", |
2312 | sdata->dev->name, bssid); | 2355 | sdata->dev->name, bss->cbss.bssid); |
2356 | |||
2313 | ret = ieee80211_sta_join_ibss(sdata, ifsta, bss); | 2357 | ret = ieee80211_sta_join_ibss(sdata, ifsta, bss); |
2314 | ieee80211_rx_bss_put(local, bss); | 2358 | ieee80211_rx_bss_put(local, bss); |
2315 | return ret; | 2359 | return ret; |
2316 | } | 2360 | } else if (bss) |
2361 | ieee80211_rx_bss_put(local, bss); | ||
2317 | 2362 | ||
2318 | dont_join: | ||
2319 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 2363 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
2320 | printk(KERN_DEBUG " did not try to join ibss\n"); | 2364 | printk(KERN_DEBUG " did not try to join ibss\n"); |
2321 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 2365 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
@@ -2329,8 +2373,15 @@ dont_join: | |||
2329 | IEEE80211_SCAN_INTERVAL)) { | 2373 | IEEE80211_SCAN_INTERVAL)) { |
2330 | printk(KERN_DEBUG "%s: Trigger new scan to find an IBSS to " | 2374 | printk(KERN_DEBUG "%s: Trigger new scan to find an IBSS to " |
2331 | "join\n", sdata->dev->name); | 2375 | "join\n", sdata->dev->name); |
2332 | return ieee80211_request_scan(sdata, ifsta->ssid, | 2376 | |
2333 | ifsta->ssid_len); | 2377 | /* XXX maybe racy? */ |
2378 | if (local->scan_req) | ||
2379 | return -EBUSY; | ||
2380 | |||
2381 | memcpy(local->int_scan_req.ssids[0].ssid, | ||
2382 | ifsta->ssid, IEEE80211_MAX_SSID_LEN); | ||
2383 | local->int_scan_req.ssids[0].ssid_len = ifsta->ssid_len; | ||
2384 | return ieee80211_request_scan(sdata, &local->int_scan_req); | ||
2334 | } else if (ifsta->state != IEEE80211_STA_MLME_IBSS_JOINED) { | 2385 | } else if (ifsta->state != IEEE80211_STA_MLME_IBSS_JOINED) { |
2335 | int interval = IEEE80211_SCAN_INTERVAL; | 2386 | int interval = IEEE80211_SCAN_INTERVAL; |
2336 | 2387 | ||
@@ -2364,50 +2415,44 @@ static int ieee80211_sta_config_auth(struct ieee80211_sub_if_data *sdata, | |||
2364 | struct ieee80211_if_sta *ifsta) | 2415 | struct ieee80211_if_sta *ifsta) |
2365 | { | 2416 | { |
2366 | struct ieee80211_local *local = sdata->local; | 2417 | struct ieee80211_local *local = sdata->local; |
2367 | struct ieee80211_bss *bss, *selected = NULL; | 2418 | struct ieee80211_bss *bss; |
2368 | int top_rssi = 0, freq; | 2419 | u8 *bssid = ifsta->bssid, *ssid = ifsta->ssid; |
2369 | 2420 | u8 ssid_len = ifsta->ssid_len; | |
2370 | spin_lock_bh(&local->bss_lock); | 2421 | u16 capa_mask = WLAN_CAPABILITY_ESS; |
2371 | freq = local->oper_channel->center_freq; | 2422 | u16 capa_val = WLAN_CAPABILITY_ESS; |
2372 | list_for_each_entry(bss, &local->bss_list, list) { | 2423 | struct ieee80211_channel *chan = local->oper_channel; |
2373 | if (!(bss->capability & WLAN_CAPABILITY_ESS)) | 2424 | |
2374 | continue; | 2425 | if (ifsta->flags & (IEEE80211_STA_AUTO_SSID_SEL | |
2375 | 2426 | IEEE80211_STA_AUTO_BSSID_SEL | | |
2376 | if ((ifsta->flags & (IEEE80211_STA_AUTO_SSID_SEL | | 2427 | IEEE80211_STA_AUTO_CHANNEL_SEL)) { |
2377 | IEEE80211_STA_AUTO_BSSID_SEL | | 2428 | capa_mask |= WLAN_CAPABILITY_PRIVACY; |
2378 | IEEE80211_STA_AUTO_CHANNEL_SEL)) && | 2429 | if (sdata->default_key) |
2379 | (!!(bss->capability & WLAN_CAPABILITY_PRIVACY) ^ | 2430 | capa_val |= WLAN_CAPABILITY_PRIVACY; |
2380 | !!sdata->default_key)) | 2431 | } |
2381 | continue; | 2432 | |
2382 | 2433 | if (ifsta->flags & IEEE80211_STA_AUTO_CHANNEL_SEL) | |
2383 | if (!(ifsta->flags & IEEE80211_STA_AUTO_CHANNEL_SEL) && | 2434 | chan = NULL; |
2384 | bss->freq != freq) | 2435 | |
2385 | continue; | 2436 | if (ifsta->flags & IEEE80211_STA_AUTO_BSSID_SEL) |
2386 | 2437 | bssid = NULL; | |
2387 | if (!(ifsta->flags & IEEE80211_STA_AUTO_BSSID_SEL) && | 2438 | |
2388 | memcmp(bss->bssid, ifsta->bssid, ETH_ALEN)) | 2439 | if (ifsta->flags & IEEE80211_STA_AUTO_SSID_SEL) { |
2389 | continue; | 2440 | ssid = NULL; |
2390 | 2441 | ssid_len = 0; | |
2391 | if (!(ifsta->flags & IEEE80211_STA_AUTO_SSID_SEL) && | ||
2392 | !ieee80211_sta_match_ssid(ifsta, bss->ssid, bss->ssid_len)) | ||
2393 | continue; | ||
2394 | |||
2395 | if (!selected || top_rssi < bss->signal) { | ||
2396 | selected = bss; | ||
2397 | top_rssi = bss->signal; | ||
2398 | } | ||
2399 | } | 2442 | } |
2400 | if (selected) | ||
2401 | atomic_inc(&selected->users); | ||
2402 | spin_unlock_bh(&local->bss_lock); | ||
2403 | 2443 | ||
2404 | if (selected) { | 2444 | bss = (void *)cfg80211_get_bss(local->hw.wiphy, chan, |
2405 | ieee80211_set_freq(sdata, selected->freq); | 2445 | bssid, ssid, ssid_len, |
2446 | capa_mask, capa_val); | ||
2447 | |||
2448 | if (bss) { | ||
2449 | ieee80211_set_freq(sdata, bss->cbss.channel->center_freq); | ||
2406 | if (!(ifsta->flags & IEEE80211_STA_SSID_SET)) | 2450 | if (!(ifsta->flags & IEEE80211_STA_SSID_SET)) |
2407 | ieee80211_sta_set_ssid(sdata, selected->ssid, | 2451 | ieee80211_sta_set_ssid(sdata, bss->ssid, |
2408 | selected->ssid_len); | 2452 | bss->ssid_len); |
2409 | ieee80211_sta_set_bssid(sdata, selected->bssid); | 2453 | ieee80211_sta_set_bssid(sdata, bss->cbss.bssid); |
2410 | ieee80211_sta_def_wmm_params(sdata, selected); | 2454 | ieee80211_sta_def_wmm_params(sdata, bss->supp_rates_len, |
2455 | bss->supp_rates); | ||
2411 | if (sdata->u.sta.mfp == IEEE80211_MFP_REQUIRED) | 2456 | if (sdata->u.sta.mfp == IEEE80211_MFP_REQUIRED) |
2412 | sdata->u.sta.flags |= IEEE80211_STA_MFP_ENABLED; | 2457 | sdata->u.sta.flags |= IEEE80211_STA_MFP_ENABLED; |
2413 | else | 2458 | else |
@@ -2416,24 +2461,29 @@ static int ieee80211_sta_config_auth(struct ieee80211_sub_if_data *sdata, | |||
2416 | /* Send out direct probe if no probe resp was received or | 2461 | /* Send out direct probe if no probe resp was received or |
2417 | * the one we have is outdated | 2462 | * the one we have is outdated |
2418 | */ | 2463 | */ |
2419 | if (!selected->last_probe_resp || | 2464 | if (!bss->last_probe_resp || |
2420 | time_after(jiffies, selected->last_probe_resp | 2465 | time_after(jiffies, bss->last_probe_resp |
2421 | + IEEE80211_SCAN_RESULT_EXPIRE)) | 2466 | + IEEE80211_SCAN_RESULT_EXPIRE)) |
2422 | ifsta->state = IEEE80211_STA_MLME_DIRECT_PROBE; | 2467 | ifsta->state = IEEE80211_STA_MLME_DIRECT_PROBE; |
2423 | else | 2468 | else |
2424 | ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE; | 2469 | ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE; |
2425 | 2470 | ||
2426 | ieee80211_rx_bss_put(local, selected); | 2471 | ieee80211_rx_bss_put(local, bss); |
2427 | ieee80211_sta_reset_auth(sdata, ifsta); | 2472 | ieee80211_sta_reset_auth(sdata, ifsta); |
2428 | return 0; | 2473 | return 0; |
2429 | } else { | 2474 | } else { |
2430 | if (ifsta->assoc_scan_tries < IEEE80211_ASSOC_SCANS_MAX_TRIES) { | 2475 | if (ifsta->assoc_scan_tries < IEEE80211_ASSOC_SCANS_MAX_TRIES) { |
2431 | ifsta->assoc_scan_tries++; | 2476 | ifsta->assoc_scan_tries++; |
2477 | /* XXX maybe racy? */ | ||
2478 | if (local->scan_req) | ||
2479 | return -1; | ||
2480 | memcpy(local->int_scan_req.ssids[0].ssid, | ||
2481 | ifsta->ssid, IEEE80211_MAX_SSID_LEN); | ||
2432 | if (ifsta->flags & IEEE80211_STA_AUTO_SSID_SEL) | 2482 | if (ifsta->flags & IEEE80211_STA_AUTO_SSID_SEL) |
2433 | ieee80211_start_scan(sdata, NULL, 0); | 2483 | local->int_scan_req.ssids[0].ssid_len = 0; |
2434 | else | 2484 | else |
2435 | ieee80211_start_scan(sdata, ifsta->ssid, | 2485 | local->int_scan_req.ssids[0].ssid_len = ifsta->ssid_len; |
2436 | ifsta->ssid_len); | 2486 | ieee80211_start_scan(sdata, &local->int_scan_req); |
2437 | ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE; | 2487 | ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE; |
2438 | set_bit(IEEE80211_STA_REQ_AUTH, &ifsta->request); | 2488 | set_bit(IEEE80211_STA_REQ_AUTH, &ifsta->request); |
2439 | } else { | 2489 | } else { |
@@ -2471,8 +2521,7 @@ static void ieee80211_sta_work(struct work_struct *work) | |||
2471 | ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE && | 2521 | ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE && |
2472 | ifsta->state != IEEE80211_STA_MLME_ASSOCIATE && | 2522 | ifsta->state != IEEE80211_STA_MLME_ASSOCIATE && |
2473 | test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request)) { | 2523 | test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request)) { |
2474 | ieee80211_start_scan(sdata, ifsta->scan_ssid, | 2524 | ieee80211_start_scan(sdata, local->scan_req); |
2475 | ifsta->scan_ssid_len); | ||
2476 | return; | 2525 | return; |
2477 | } | 2526 | } |
2478 | 2527 | ||