Lines Matching refs:bss
34 static void wpa_bss_set_hessid(struct wpa_bss *bss) in wpa_bss_set_hessid() argument
37 const u8 *ie = wpa_bss_get_ie(bss, WLAN_EID_INTERWORKING); in wpa_bss_set_hessid()
39 os_memset(bss->hessid, 0, ETH_ALEN); in wpa_bss_set_hessid()
43 os_memcpy(bss->hessid, ie + 3, ETH_ALEN); in wpa_bss_set_hessid()
45 os_memcpy(bss->hessid, ie + 5, ETH_ALEN); in wpa_bss_set_hessid()
122 int wpa_bss_anqp_unshare_alloc(struct wpa_bss *bss) in wpa_bss_anqp_unshare_alloc() argument
126 if (bss->anqp && bss->anqp->users > 1) { in wpa_bss_anqp_unshare_alloc()
128 anqp = wpa_bss_anqp_clone(bss->anqp); in wpa_bss_anqp_unshare_alloc()
132 bss->anqp->users--; in wpa_bss_anqp_unshare_alloc()
133 bss->anqp = anqp; in wpa_bss_anqp_unshare_alloc()
137 if (bss->anqp) in wpa_bss_anqp_unshare_alloc()
141 bss->anqp = wpa_bss_anqp_alloc(); in wpa_bss_anqp_unshare_alloc()
142 return bss->anqp ? 0 : -1; in wpa_bss_anqp_unshare_alloc()
212 if (cwork->bss != old_bss) in wpa_bss_update_pending_connect()
217 cwork->bss = new_bss; in wpa_bss_update_pending_connect()
223 void wpa_bss_remove(struct wpa_supplicant *wpa_s, struct wpa_bss *bss, in wpa_bss_remove() argument
229 if (wpa_s->last_scan_res[i] == bss) { in wpa_bss_remove()
239 wpa_bss_update_pending_connect(wpa_s, bss, NULL); in wpa_bss_remove()
240 dl_list_del(&bss->list); in wpa_bss_remove()
241 dl_list_del(&bss->list_id); in wpa_bss_remove()
244 " SSID '%s' due to %s", bss->id, MAC2STR(bss->bssid), in wpa_bss_remove()
245 wpa_ssid_txt(bss->ssid, bss->ssid_len), reason); in wpa_bss_remove()
246 wpas_notify_bss_removed(wpa_s, bss->bssid, bss->id); in wpa_bss_remove()
247 wpa_bss_anqp_free(bss->anqp); in wpa_bss_remove()
248 os_free(bss); in wpa_bss_remove()
263 struct wpa_bss *bss; in wpa_bss_get() local
266 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_get()
267 if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0 && in wpa_bss_get()
268 bss->ssid_len == ssid_len && in wpa_bss_get()
269 os_memcmp(bss->ssid, ssid, ssid_len) == 0) in wpa_bss_get()
270 return bss; in wpa_bss_get()
314 struct wpa_bss *bss) in wpa_bss_is_wps_candidate() argument
321 wps_ie = wpa_bss_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE); in wpa_bss_is_wps_candidate()
336 (ssid->ssid_len != bss->ssid_len || in wpa_bss_is_wps_candidate()
337 os_memcmp(ssid->ssid, bss->ssid, ssid->ssid_len) != 0)) in wpa_bss_is_wps_candidate()
354 static int wpa_bss_known(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) in wpa_bss_known() argument
361 if (ssid->ssid_len == bss->ssid_len && in wpa_bss_known()
362 os_memcmp(ssid->ssid, bss->ssid, ssid->ssid_len) == 0) in wpa_bss_known()
370 static int wpa_bss_in_use(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) in wpa_bss_in_use() argument
372 if (bss == wpa_s->current_bss) in wpa_bss_in_use()
376 (bss->ssid_len != wpa_s->current_bss->ssid_len || in wpa_bss_in_use()
377 os_memcmp(bss->ssid, wpa_s->current_bss->ssid, in wpa_bss_in_use()
378 bss->ssid_len) != 0)) in wpa_bss_in_use()
381 return !is_zero_ether_addr(bss->bssid) && in wpa_bss_in_use()
382 (os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) == 0 || in wpa_bss_in_use()
383 os_memcmp(bss->bssid, wpa_s->pending_bssid, ETH_ALEN) == 0); in wpa_bss_in_use()
389 struct wpa_bss *bss; in wpa_bss_remove_oldest_unknown() local
391 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_remove_oldest_unknown()
392 if (!wpa_bss_known(wpa_s, bss) && in wpa_bss_remove_oldest_unknown()
393 !wpa_bss_is_wps_candidate(wpa_s, bss)) { in wpa_bss_remove_oldest_unknown()
394 wpa_bss_remove(wpa_s, bss, __func__); in wpa_bss_remove_oldest_unknown()
405 struct wpa_bss *bss; in wpa_bss_remove_oldest() local
417 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_remove_oldest()
418 if (!wpa_bss_in_use(wpa_s, bss)) { in wpa_bss_remove_oldest()
419 wpa_bss_remove(wpa_s, bss, __func__); in wpa_bss_remove_oldest()
433 struct wpa_bss *bss; in wpa_bss_add() local
436 bss = os_zalloc(sizeof(*bss) + res->ie_len + res->beacon_ie_len); in wpa_bss_add()
437 if (bss == NULL) in wpa_bss_add()
439 bss->id = wpa_s->bss_next_id++; in wpa_bss_add()
440 bss->last_update_idx = wpa_s->bss_update_idx; in wpa_bss_add()
441 wpa_bss_copy_res(bss, res, fetch_time); in wpa_bss_add()
442 os_memcpy(bss->ssid, ssid, ssid_len); in wpa_bss_add()
443 bss->ssid_len = ssid_len; in wpa_bss_add()
444 bss->ie_len = res->ie_len; in wpa_bss_add()
445 bss->beacon_ie_len = res->beacon_ie_len; in wpa_bss_add()
446 os_memcpy(bss + 1, res + 1, res->ie_len + res->beacon_ie_len); in wpa_bss_add()
447 wpa_bss_set_hessid(bss); in wpa_bss_add()
457 dl_list_add_tail(&wpa_s->bss, &bss->list); in wpa_bss_add()
458 dl_list_add_tail(&wpa_s->bss_id, &bss->list_id); in wpa_bss_add()
460 if (!is_zero_ether_addr(bss->hessid)) in wpa_bss_add()
462 MAC2STR(bss->hessid)); in wpa_bss_add()
467 bss->id, MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len), in wpa_bss_add()
468 bss->freq, extra); in wpa_bss_add()
469 wpas_notify_bss_added(wpa_s, bss->bssid, bss->id); in wpa_bss_add()
470 return bss; in wpa_bss_add()
571 const struct wpa_bss *bss) in notify_bss_changes() argument
574 wpas_notify_bss_freq_changed(wpa_s, bss->id); in notify_bss_changes()
577 wpas_notify_bss_signal_changed(wpa_s, bss->id); in notify_bss_changes()
580 wpas_notify_bss_privacy_changed(wpa_s, bss->id); in notify_bss_changes()
583 wpas_notify_bss_mode_changed(wpa_s, bss->id); in notify_bss_changes()
586 wpas_notify_bss_wpaie_changed(wpa_s, bss->id); in notify_bss_changes()
589 wpas_notify_bss_rsnie_changed(wpa_s, bss->id); in notify_bss_changes()
592 wpas_notify_bss_wps_changed(wpa_s, bss->id); in notify_bss_changes()
595 wpas_notify_bss_ies_changed(wpa_s, bss->id); in notify_bss_changes()
598 wpas_notify_bss_rates_changed(wpa_s, bss->id); in notify_bss_changes()
600 wpas_notify_bss_seen(wpa_s, bss->id); in notify_bss_changes()
605 wpa_bss_update(struct wpa_supplicant *wpa_s, struct wpa_bss *bss, in wpa_bss_update() argument
610 if (bss->last_update_idx == wpa_s->bss_update_idx) { in wpa_bss_update()
622 MAC2STR(bss->bssid)); in wpa_bss_update()
626 (unsigned int) bss->last_update.sec, in wpa_bss_update()
627 (unsigned int) bss->last_update.usec, in wpa_bss_update()
628 bss->freq, in wpa_bss_update()
629 (bss->flags & WPA_BSS_ASSOCIATED) ? " assoc" : ""); in wpa_bss_update()
635 if ((bss->flags & WPA_BSS_ASSOCIATED) || in wpa_bss_update()
637 !os_reltime_before(&bss->last_update, &update_time))) { in wpa_bss_update()
640 return bss; in wpa_bss_update()
646 changes = wpa_bss_compare_res(bss, res); in wpa_bss_update()
649 MAC2STR(bss->bssid), bss->freq, res->freq); in wpa_bss_update()
650 bss->scan_miss_count = 0; in wpa_bss_update()
651 bss->last_update_idx = wpa_s->bss_update_idx; in wpa_bss_update()
652 wpa_bss_copy_res(bss, res, fetch_time); in wpa_bss_update()
654 dl_list_del(&bss->list); in wpa_bss_update()
656 if (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) && in wpa_bss_update()
668 MAC2STR(bss->bssid)); in wpa_bss_update()
671 if (bss->ie_len + bss->beacon_ie_len >= in wpa_bss_update()
673 os_memcpy(bss + 1, res + 1, res->ie_len + res->beacon_ie_len); in wpa_bss_update()
674 bss->ie_len = res->ie_len; in wpa_bss_update()
675 bss->beacon_ie_len = res->beacon_ie_len; in wpa_bss_update()
678 struct dl_list *prev = bss->list_id.prev; in wpa_bss_update()
679 dl_list_del(&bss->list_id); in wpa_bss_update()
680 nbss = os_realloc(bss, sizeof(*bss) + res->ie_len + in wpa_bss_update()
685 if (wpa_s->last_scan_res[i] == bss) { in wpa_bss_update()
690 if (wpa_s->current_bss == bss) in wpa_bss_update()
692 wpa_bss_update_pending_connect(wpa_s, bss, nbss); in wpa_bss_update()
693 bss = nbss; in wpa_bss_update()
694 os_memcpy(bss + 1, res + 1, in wpa_bss_update()
696 bss->ie_len = res->ie_len; in wpa_bss_update()
697 bss->beacon_ie_len = res->beacon_ie_len; in wpa_bss_update()
699 dl_list_add(prev, &bss->list_id); in wpa_bss_update()
702 wpa_bss_set_hessid(bss); in wpa_bss_update()
703 dl_list_add_tail(&wpa_s->bss, &bss->list); in wpa_bss_update()
705 notify_bss_changes(wpa_s, changes, bss); in wpa_bss_update()
707 return bss; in wpa_bss_update()
744 struct wpa_bss *bss; in wpa_bss_update_scan_res() local
798 bss = wpa_bss_get(wpa_s, res->bssid, ssid + 2, ssid[1]); in wpa_bss_update_scan_res()
799 if (bss == NULL) in wpa_bss_update_scan_res()
800 bss = wpa_bss_add(wpa_s, ssid + 2, ssid[1], res, fetch_time); in wpa_bss_update_scan_res()
802 bss = wpa_bss_update(wpa_s, bss, res, fetch_time); in wpa_bss_update_scan_res()
806 if (bss == wpa_s->last_scan_res[i]) { in wpa_bss_update_scan_res()
814 if (bss == NULL) in wpa_bss_update_scan_res()
832 wpa_s->last_scan_res[wpa_s->last_scan_res_used++] = bss; in wpa_bss_update_scan_res()
836 static int wpa_bss_included_in_scan(const struct wpa_bss *bss, in wpa_bss_included_in_scan() argument
848 if (bss->freq == info->freqs[i]) { in wpa_bss_included_in_scan()
862 (s->ssid_len == bss->ssid_len && in wpa_bss_included_in_scan()
863 os_memcmp(s->ssid, bss->ssid, bss->ssid_len) == in wpa_bss_included_in_scan()
890 struct wpa_bss *bss, *n; in wpa_bss_update_end() local
896 dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_update_end()
897 if (wpa_bss_in_use(wpa_s, bss)) in wpa_bss_update_end()
899 if (!wpa_bss_included_in_scan(bss, info)) in wpa_bss_update_end()
901 if (bss->last_update_idx < wpa_s->bss_update_idx) in wpa_bss_update_end()
902 bss->scan_miss_count++; in wpa_bss_update_end()
903 if (bss->scan_miss_count >= in wpa_bss_update_end()
905 wpa_bss_remove(wpa_s, bss, "no match in scan"); in wpa_bss_update_end()
923 struct wpa_bss *bss, *n; in wpa_bss_flush_by_age() local
926 if (dl_list_empty(&wpa_s->bss)) in wpa_bss_flush_by_age()
932 dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_flush_by_age()
933 if (wpa_bss_in_use(wpa_s, bss)) in wpa_bss_flush_by_age()
936 if (os_reltime_before(&bss->last_update, &t)) { in wpa_bss_flush_by_age()
937 wpa_bss_remove(wpa_s, bss, __func__); in wpa_bss_flush_by_age()
954 dl_list_init(&wpa_s->bss); in wpa_bss_init()
966 struct wpa_bss *bss, *n; in wpa_bss_flush() local
970 if (wpa_s->bss.next == NULL) in wpa_bss_flush()
973 dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_flush()
974 if (wpa_bss_in_use(wpa_s, bss)) in wpa_bss_flush()
976 wpa_bss_remove(wpa_s, bss, __func__); in wpa_bss_flush()
1000 struct wpa_bss *bss; in wpa_bss_get_bssid() local
1003 dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_get_bssid()
1004 if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0) in wpa_bss_get_bssid()
1005 return bss; in wpa_bss_get_bssid()
1025 struct wpa_bss *bss, *found = NULL; in wpa_bss_get_bssid_latest() local
1028 dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_get_bssid_latest()
1029 if (os_memcmp(bss->bssid, bssid, ETH_ALEN) != 0) in wpa_bss_get_bssid_latest()
1032 os_reltime_before(&found->last_update, &bss->last_update)) in wpa_bss_get_bssid_latest()
1033 found = bss; in wpa_bss_get_bssid_latest()
1053 struct wpa_bss *bss, *found = NULL; in wpa_bss_get_p2p_dev_addr() local
1054 dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_get_p2p_dev_addr()
1056 if (p2p_parse_dev_addr((const u8 *) (bss + 1), bss->ie_len, in wpa_bss_get_p2p_dev_addr()
1061 os_reltime_before(&found->last_update, &bss->last_update)) in wpa_bss_get_p2p_dev_addr()
1062 found = bss; in wpa_bss_get_p2p_dev_addr()
1077 struct wpa_bss *bss; in wpa_bss_get_id() local
1078 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_get_id()
1079 if (bss->id == id) in wpa_bss_get_id()
1080 return bss; in wpa_bss_get_id()
1100 struct wpa_bss *bss; in wpa_bss_get_id_range() local
1101 dl_list_for_each(bss, &wpa_s->bss_id, struct wpa_bss, list_id) { in wpa_bss_get_id_range()
1102 if (bss->id >= idf && bss->id <= idl) in wpa_bss_get_id_range()
1103 return bss; in wpa_bss_get_id_range()
1118 const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie) in wpa_bss_get_ie() argument
1120 return get_ie((const u8 *) (bss + 1), bss->ie_len, ie); in wpa_bss_get_ie()
1133 const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type) in wpa_bss_get_vendor_ie() argument
1137 pos = (const u8 *) (bss + 1); in wpa_bss_get_vendor_ie()
1138 end = pos + bss->ie_len; in wpa_bss_get_vendor_ie()
1165 const u8 * wpa_bss_get_vendor_ie_beacon(const struct wpa_bss *bss, in wpa_bss_get_vendor_ie_beacon() argument
1170 if (bss->beacon_ie_len == 0) in wpa_bss_get_vendor_ie_beacon()
1173 pos = (const u8 *) (bss + 1); in wpa_bss_get_vendor_ie_beacon()
1174 pos += bss->ie_len; in wpa_bss_get_vendor_ie_beacon()
1175 end = pos + bss->beacon_ie_len; in wpa_bss_get_vendor_ie_beacon()
1200 struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss, in wpa_bss_get_vendor_ie_multi() argument
1206 buf = wpabuf_alloc(bss->ie_len); in wpa_bss_get_vendor_ie_multi()
1210 pos = (const u8 *) (bss + 1); in wpa_bss_get_vendor_ie_multi()
1211 end = pos + bss->ie_len; in wpa_bss_get_vendor_ie_multi()
1244 struct wpabuf * wpa_bss_get_vendor_ie_multi_beacon(const struct wpa_bss *bss, in wpa_bss_get_vendor_ie_multi_beacon() argument
1250 buf = wpabuf_alloc(bss->beacon_ie_len); in wpa_bss_get_vendor_ie_multi_beacon()
1254 pos = (const u8 *) (bss + 1); in wpa_bss_get_vendor_ie_multi_beacon()
1255 pos += bss->ie_len; in wpa_bss_get_vendor_ie_multi_beacon()
1256 end = pos + bss->beacon_ie_len; in wpa_bss_get_vendor_ie_multi_beacon()
1281 int wpa_bss_get_max_rate(const struct wpa_bss *bss) in wpa_bss_get_max_rate() argument
1287 ie = wpa_bss_get_ie(bss, WLAN_EID_SUPP_RATES); in wpa_bss_get_max_rate()
1293 ie = wpa_bss_get_ie(bss, WLAN_EID_EXT_SUPP_RATES); in wpa_bss_get_max_rate()
1312 int wpa_bss_get_bit_rates(const struct wpa_bss *bss, u8 **rates) in wpa_bss_get_bit_rates() argument
1319 ie = wpa_bss_get_ie(bss, WLAN_EID_SUPP_RATES); in wpa_bss_get_bit_rates()
1320 ie2 = wpa_bss_get_ie(bss, WLAN_EID_EXT_SUPP_RATES); in wpa_bss_get_bit_rates()
1340 const u8 * wpa_bss_get_fils_cache_id(struct wpa_bss *bss) in wpa_bss_get_fils_cache_id() argument
1344 if (bss) { in wpa_bss_get_fils_cache_id()
1345 ie = wpa_bss_get_ie(bss, WLAN_EID_FILS_INDICATION); in wpa_bss_get_fils_cache_id()
1355 int wpa_bss_ext_capab(const struct wpa_bss *bss, unsigned int capab) in wpa_bss_ext_capab() argument
1357 return ieee802_11_ext_capab(wpa_bss_get_ie(bss, WLAN_EID_EXT_CAPAB), in wpa_bss_ext_capab()