Lines Matching refs:bss

33 static void wpa_bss_set_hessid(struct wpa_bss *bss)  in wpa_bss_set_hessid()  argument
36 const u8 *ie = wpa_bss_get_ie(bss, WLAN_EID_INTERWORKING); in wpa_bss_set_hessid()
38 os_memset(bss->hessid, 0, ETH_ALEN); in wpa_bss_set_hessid()
42 os_memcpy(bss->hessid, ie + 3, ETH_ALEN); in wpa_bss_set_hessid()
44 os_memcpy(bss->hessid, ie + 5, ETH_ALEN); in wpa_bss_set_hessid()
118 int wpa_bss_anqp_unshare_alloc(struct wpa_bss *bss) in wpa_bss_anqp_unshare_alloc() argument
122 if (bss->anqp && bss->anqp->users > 1) { in wpa_bss_anqp_unshare_alloc()
124 anqp = wpa_bss_anqp_clone(bss->anqp); in wpa_bss_anqp_unshare_alloc()
128 bss->anqp->users--; in wpa_bss_anqp_unshare_alloc()
129 bss->anqp = anqp; in wpa_bss_anqp_unshare_alloc()
133 if (bss->anqp) in wpa_bss_anqp_unshare_alloc()
137 bss->anqp = wpa_bss_anqp_alloc(); in wpa_bss_anqp_unshare_alloc()
138 return bss->anqp ? 0 : -1; in wpa_bss_anqp_unshare_alloc()
205 if (cwork->bss != old_bss) in wpa_bss_update_pending_connect()
210 cwork->bss = new_bss; in wpa_bss_update_pending_connect()
216 static void wpa_bss_remove(struct wpa_supplicant *wpa_s, struct wpa_bss *bss, in wpa_bss_remove() argument
222 if (wpa_s->last_scan_res[i] == bss) { in wpa_bss_remove()
232 wpa_bss_update_pending_connect(wpa_s, bss, NULL); in wpa_bss_remove()
233 dl_list_del(&bss->list); in wpa_bss_remove()
234 dl_list_del(&bss->list_id); in wpa_bss_remove()
237 " SSID '%s' due to %s", bss->id, MAC2STR(bss->bssid), in wpa_bss_remove()
238 wpa_ssid_txt(bss->ssid, bss->ssid_len), reason); in wpa_bss_remove()
239 wpas_notify_bss_removed(wpa_s, bss->bssid, bss->id); in wpa_bss_remove()
240 wpa_bss_anqp_free(bss->anqp); in wpa_bss_remove()
241 os_free(bss); in wpa_bss_remove()
256 struct wpa_bss *bss; in wpa_bss_get() local
259 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_get()
260 if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0 && in wpa_bss_get()
261 bss->ssid_len == ssid_len && in wpa_bss_get()
262 os_memcmp(bss->ssid, ssid, ssid_len) == 0) in wpa_bss_get()
263 return bss; in wpa_bss_get()
306 static int wpa_bss_known(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) in wpa_bss_known() argument
313 if (ssid->ssid_len == bss->ssid_len && in wpa_bss_known()
314 os_memcmp(ssid->ssid, bss->ssid, ssid->ssid_len) == 0) in wpa_bss_known()
322 static int wpa_bss_in_use(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) in wpa_bss_in_use() argument
324 if (bss == wpa_s->current_bss) in wpa_bss_in_use()
328 (bss->ssid_len != wpa_s->current_bss->ssid_len || in wpa_bss_in_use()
329 os_memcmp(bss->ssid, wpa_s->current_bss->ssid, in wpa_bss_in_use()
330 bss->ssid_len) != 0)) in wpa_bss_in_use()
333 return !is_zero_ether_addr(bss->bssid) && in wpa_bss_in_use()
334 (os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) == 0 || in wpa_bss_in_use()
335 os_memcmp(bss->bssid, wpa_s->pending_bssid, ETH_ALEN) == 0); in wpa_bss_in_use()
341 struct wpa_bss *bss; in wpa_bss_remove_oldest_unknown() local
343 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_remove_oldest_unknown()
344 if (!wpa_bss_known(wpa_s, bss)) { in wpa_bss_remove_oldest_unknown()
345 wpa_bss_remove(wpa_s, bss, __func__); in wpa_bss_remove_oldest_unknown()
356 struct wpa_bss *bss; in wpa_bss_remove_oldest() local
368 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_remove_oldest()
369 if (!wpa_bss_in_use(wpa_s, bss)) { in wpa_bss_remove_oldest()
370 wpa_bss_remove(wpa_s, bss, __func__); in wpa_bss_remove_oldest()
384 struct wpa_bss *bss; in wpa_bss_add() local
386 bss = os_zalloc(sizeof(*bss) + res->ie_len + res->beacon_ie_len); in wpa_bss_add()
387 if (bss == NULL) in wpa_bss_add()
389 bss->id = wpa_s->bss_next_id++; in wpa_bss_add()
390 bss->last_update_idx = wpa_s->bss_update_idx; in wpa_bss_add()
391 wpa_bss_copy_res(bss, res, fetch_time); in wpa_bss_add()
392 os_memcpy(bss->ssid, ssid, ssid_len); in wpa_bss_add()
393 bss->ssid_len = ssid_len; in wpa_bss_add()
394 bss->ie_len = res->ie_len; in wpa_bss_add()
395 bss->beacon_ie_len = res->beacon_ie_len; in wpa_bss_add()
396 os_memcpy(bss + 1, res + 1, res->ie_len + res->beacon_ie_len); in wpa_bss_add()
397 wpa_bss_set_hessid(bss); in wpa_bss_add()
407 dl_list_add_tail(&wpa_s->bss, &bss->list); in wpa_bss_add()
408 dl_list_add_tail(&wpa_s->bss_id, &bss->list_id); in wpa_bss_add()
412 bss->id, MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len), in wpa_bss_add()
413 bss->freq); in wpa_bss_add()
414 wpas_notify_bss_added(wpa_s, bss->bssid, bss->id); in wpa_bss_add()
415 return bss; in wpa_bss_add()
516 const struct wpa_bss *bss) in notify_bss_changes() argument
519 wpas_notify_bss_freq_changed(wpa_s, bss->id); in notify_bss_changes()
522 wpas_notify_bss_signal_changed(wpa_s, bss->id); in notify_bss_changes()
525 wpas_notify_bss_privacy_changed(wpa_s, bss->id); in notify_bss_changes()
528 wpas_notify_bss_mode_changed(wpa_s, bss->id); in notify_bss_changes()
531 wpas_notify_bss_wpaie_changed(wpa_s, bss->id); in notify_bss_changes()
534 wpas_notify_bss_rsnie_changed(wpa_s, bss->id); in notify_bss_changes()
537 wpas_notify_bss_wps_changed(wpa_s, bss->id); in notify_bss_changes()
540 wpas_notify_bss_ies_changed(wpa_s, bss->id); in notify_bss_changes()
543 wpas_notify_bss_rates_changed(wpa_s, bss->id); in notify_bss_changes()
545 wpas_notify_bss_seen(wpa_s, bss->id); in notify_bss_changes()
550 wpa_bss_update(struct wpa_supplicant *wpa_s, struct wpa_bss *bss, in wpa_bss_update() argument
555 changes = wpa_bss_compare_res(bss, res); in wpa_bss_update()
558 MAC2STR(bss->bssid), bss->freq, res->freq); in wpa_bss_update()
559 bss->scan_miss_count = 0; in wpa_bss_update()
560 bss->last_update_idx = wpa_s->bss_update_idx; in wpa_bss_update()
561 wpa_bss_copy_res(bss, res, fetch_time); in wpa_bss_update()
563 dl_list_del(&bss->list); in wpa_bss_update()
565 if (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) && in wpa_bss_update()
577 MAC2STR(bss->bssid)); in wpa_bss_update()
580 if (bss->ie_len + bss->beacon_ie_len >= in wpa_bss_update()
582 os_memcpy(bss + 1, res + 1, res->ie_len + res->beacon_ie_len); in wpa_bss_update()
583 bss->ie_len = res->ie_len; in wpa_bss_update()
584 bss->beacon_ie_len = res->beacon_ie_len; in wpa_bss_update()
587 struct dl_list *prev = bss->list_id.prev; in wpa_bss_update()
588 dl_list_del(&bss->list_id); in wpa_bss_update()
589 nbss = os_realloc(bss, sizeof(*bss) + res->ie_len + in wpa_bss_update()
594 if (wpa_s->last_scan_res[i] == bss) { in wpa_bss_update()
599 if (wpa_s->current_bss == bss) in wpa_bss_update()
601 wpa_bss_update_pending_connect(wpa_s, bss, nbss); in wpa_bss_update()
602 bss = nbss; in wpa_bss_update()
603 os_memcpy(bss + 1, res + 1, in wpa_bss_update()
605 bss->ie_len = res->ie_len; in wpa_bss_update()
606 bss->beacon_ie_len = res->beacon_ie_len; in wpa_bss_update()
608 dl_list_add(prev, &bss->list_id); in wpa_bss_update()
611 wpa_bss_set_hessid(bss); in wpa_bss_update()
612 dl_list_add_tail(&wpa_s->bss, &bss->list); in wpa_bss_update()
614 notify_bss_changes(wpa_s, changes, bss); in wpa_bss_update()
616 return bss; in wpa_bss_update()
653 struct wpa_bss *bss; in wpa_bss_update_scan_res() local
707 bss = wpa_bss_get(wpa_s, res->bssid, ssid + 2, ssid[1]); in wpa_bss_update_scan_res()
708 if (bss == NULL) in wpa_bss_update_scan_res()
709 bss = wpa_bss_add(wpa_s, ssid + 2, ssid[1], res, fetch_time); in wpa_bss_update_scan_res()
711 bss = wpa_bss_update(wpa_s, bss, res, fetch_time); in wpa_bss_update_scan_res()
715 if (bss == wpa_s->last_scan_res[i]) { in wpa_bss_update_scan_res()
723 if (bss == NULL) in wpa_bss_update_scan_res()
741 wpa_s->last_scan_res[wpa_s->last_scan_res_used++] = bss; in wpa_bss_update_scan_res()
745 static int wpa_bss_included_in_scan(const struct wpa_bss *bss, in wpa_bss_included_in_scan() argument
757 if (bss->freq == info->freqs[i]) { in wpa_bss_included_in_scan()
771 (s->ssid_len == bss->ssid_len && in wpa_bss_included_in_scan()
772 os_memcmp(s->ssid, bss->ssid, bss->ssid_len) == in wpa_bss_included_in_scan()
799 struct wpa_bss *bss, *n; in wpa_bss_update_end() local
805 dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_update_end()
806 if (wpa_bss_in_use(wpa_s, bss)) in wpa_bss_update_end()
808 if (!wpa_bss_included_in_scan(bss, info)) in wpa_bss_update_end()
810 if (bss->last_update_idx < wpa_s->bss_update_idx) in wpa_bss_update_end()
811 bss->scan_miss_count++; in wpa_bss_update_end()
812 if (bss->scan_miss_count >= in wpa_bss_update_end()
814 wpa_bss_remove(wpa_s, bss, "no match in scan"); in wpa_bss_update_end()
832 struct wpa_bss *bss, *n; in wpa_bss_flush_by_age() local
835 if (dl_list_empty(&wpa_s->bss)) in wpa_bss_flush_by_age()
841 dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_flush_by_age()
842 if (wpa_bss_in_use(wpa_s, bss)) in wpa_bss_flush_by_age()
845 if (os_reltime_before(&bss->last_update, &t)) { in wpa_bss_flush_by_age()
846 wpa_bss_remove(wpa_s, bss, __func__); in wpa_bss_flush_by_age()
863 dl_list_init(&wpa_s->bss); in wpa_bss_init()
875 struct wpa_bss *bss, *n; in wpa_bss_flush() local
879 if (wpa_s->bss.next == NULL) in wpa_bss_flush()
882 dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_flush()
883 if (wpa_bss_in_use(wpa_s, bss)) in wpa_bss_flush()
885 wpa_bss_remove(wpa_s, bss, __func__); in wpa_bss_flush()
909 struct wpa_bss *bss; in wpa_bss_get_bssid() local
912 dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_get_bssid()
913 if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0) in wpa_bss_get_bssid()
914 return bss; in wpa_bss_get_bssid()
934 struct wpa_bss *bss, *found = NULL; in wpa_bss_get_bssid_latest() local
937 dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_get_bssid_latest()
938 if (os_memcmp(bss->bssid, bssid, ETH_ALEN) != 0) in wpa_bss_get_bssid_latest()
941 os_reltime_before(&found->last_update, &bss->last_update)) in wpa_bss_get_bssid_latest()
942 found = bss; in wpa_bss_get_bssid_latest()
958 struct wpa_bss *bss; in wpa_bss_get_p2p_dev_addr() local
959 dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_get_p2p_dev_addr()
961 if (p2p_parse_dev_addr((const u8 *) (bss + 1), bss->ie_len, in wpa_bss_get_p2p_dev_addr()
964 return bss; in wpa_bss_get_p2p_dev_addr()
979 struct wpa_bss *bss; in wpa_bss_get_id() local
980 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_bss_get_id()
981 if (bss->id == id) in wpa_bss_get_id()
982 return bss; in wpa_bss_get_id()
1002 struct wpa_bss *bss; in wpa_bss_get_id_range() local
1003 dl_list_for_each(bss, &wpa_s->bss_id, struct wpa_bss, list_id) { in wpa_bss_get_id_range()
1004 if (bss->id >= idf && bss->id <= idl) in wpa_bss_get_id_range()
1005 return bss; in wpa_bss_get_id_range()
1020 const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie) in wpa_bss_get_ie() argument
1022 return get_ie((const u8 *) (bss + 1), bss->ie_len, ie); in wpa_bss_get_ie()
1035 const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type) in wpa_bss_get_vendor_ie() argument
1039 pos = (const u8 *) (bss + 1); in wpa_bss_get_vendor_ie()
1040 end = pos + bss->ie_len; in wpa_bss_get_vendor_ie()
1067 const u8 * wpa_bss_get_vendor_ie_beacon(const struct wpa_bss *bss, in wpa_bss_get_vendor_ie_beacon() argument
1072 if (bss->beacon_ie_len == 0) in wpa_bss_get_vendor_ie_beacon()
1075 pos = (const u8 *) (bss + 1); in wpa_bss_get_vendor_ie_beacon()
1076 pos += bss->ie_len; in wpa_bss_get_vendor_ie_beacon()
1077 end = pos + bss->beacon_ie_len; in wpa_bss_get_vendor_ie_beacon()
1102 struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss, in wpa_bss_get_vendor_ie_multi() argument
1108 buf = wpabuf_alloc(bss->ie_len); in wpa_bss_get_vendor_ie_multi()
1112 pos = (const u8 *) (bss + 1); in wpa_bss_get_vendor_ie_multi()
1113 end = pos + bss->ie_len; in wpa_bss_get_vendor_ie_multi()
1146 struct wpabuf * wpa_bss_get_vendor_ie_multi_beacon(const struct wpa_bss *bss, in wpa_bss_get_vendor_ie_multi_beacon() argument
1152 buf = wpabuf_alloc(bss->beacon_ie_len); in wpa_bss_get_vendor_ie_multi_beacon()
1156 pos = (const u8 *) (bss + 1); in wpa_bss_get_vendor_ie_multi_beacon()
1157 pos += bss->ie_len; in wpa_bss_get_vendor_ie_multi_beacon()
1158 end = pos + bss->beacon_ie_len; in wpa_bss_get_vendor_ie_multi_beacon()
1183 int wpa_bss_get_max_rate(const struct wpa_bss *bss) in wpa_bss_get_max_rate() argument
1189 ie = wpa_bss_get_ie(bss, WLAN_EID_SUPP_RATES); in wpa_bss_get_max_rate()
1195 ie = wpa_bss_get_ie(bss, WLAN_EID_EXT_SUPP_RATES); in wpa_bss_get_max_rate()
1214 int wpa_bss_get_bit_rates(const struct wpa_bss *bss, u8 **rates) in wpa_bss_get_bit_rates() argument
1221 ie = wpa_bss_get_ie(bss, WLAN_EID_SUPP_RATES); in wpa_bss_get_bit_rates()
1222 ie2 = wpa_bss_get_ie(bss, WLAN_EID_EXT_SUPP_RATES); in wpa_bss_get_bit_rates()