Home | History | Annotate | Download | only in wpa_supplicant

Lines Matching refs:bss

2  * BSS table
20 #include "bss.h"
34 static void wpa_bss_set_hessid(struct wpa_bss *bss)
37 const u8 *ie = wpa_bss_get_ie(bss, WLAN_EID_INTERWORKING);
39 os_memset(bss->hessid, 0, ETH_ALEN);
43 os_memcpy(bss->hessid, ie + 3, ETH_ALEN);
45 os_memcpy(bss->hessid, ie + 5, ETH_ALEN);
51 * wpa_bss_anqp_alloc - Allocate ANQP data structure for a BSS entry
55 * shared by multiple BSS entries and each shared entry is freed with
113 * wpa_bss_anqp_unshare_alloc - Unshare ANQP data (if shared) in a BSS entry
114 * @bss: BSS entry
117 * This function ensures the specific BSS entry has an ANQP data structure that
118 * is not shared with any other BSS entry.
120 int wpa_bss_anqp_unshare_alloc(struct wpa_bss *bss)
124 if (bss->anqp && bss->anqp->users > 1) {
126 anqp = wpa_bss_anqp_clone(bss->anqp);
130 bss->anqp->users--;
131 bss->anqp = anqp;
135 if (bss->anqp)
139 bss->anqp = wpa_bss_anqp_alloc();
140 return bss->anqp ? 0 : -1;
159 /* Another BSS entry holds a pointer to this ANQP info */
208 if (cwork->bss != old_bss)
212 "Update BSS pointer for the pending connect radio work");
213 cwork->bss = new_bss;
219 void wpa_bss_remove(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
225 if (wpa_s->last_scan_res[i] == bss) {
235 wpa_bss_update_pending_connect(wpa_s, bss, NULL);
236 dl_list_del(&bss->list);
237 dl_list_del(&bss->list_id);
239 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Remove id %u BSSID " MACSTR
240 " SSID '%s' due to %s", bss->id, MAC2STR(bss->bssid),
241 wpa_ssid_txt(bss->ssid, bss->ssid_len), reason);
242 wpas_notify_bss_removed(wpa_s, bss->bssid, bss->id);
243 wpa_bss_anqp_free(bss->anqp);
244 os_free(bss);
249 * wpa_bss_get - Fetch a BSS table entry based on BSSID and SSID
254 * Returns: Pointer to the BSS entry or %NULL if not found
259 struct wpa_bss *bss;
262 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
263 if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0 &&
264 bss->ssid_len == ssid_len &&
265 os_memcmp(bss->ssid, ssid, ssid_len) == 0)
266 return bss;
310 struct wpa_bss *bss)
317 wps_ie = wpa_bss_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
332 (ssid->ssid_len != bss->ssid_len ||
333 os_memcmp(ssid->ssid, bss->ssid, ssid->ssid_len) != 0))
350 static int wpa_bss_known(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
357 if (ssid->ssid_len == bss->ssid_len &&
358 os_memcmp(ssid->ssid, bss->ssid, ssid->ssid_len) == 0)
366 static int wpa_bss_in_use(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
368 if (bss == wpa_s->current_bss)
372 (bss->ssid_len != wpa_s->current_bss->ssid_len ||
373 os_memcmp(bss->ssid, wpa_s->current_bss->ssid,
374 bss->ssid_len) != 0))
377 return !is_zero_ether_addr(bss->bssid) &&
378 (os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) == 0 ||
379 os_memcmp(bss->bssid, wpa_s->pending_bssid, ETH_ALEN) == 0);
385 struct wpa_bss *bss;
387 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
388 if (!wpa_bss_known(wpa_s, bss) &&
389 !wpa_bss_is_wps_candidate(wpa_s, bss)) {
390 wpa_bss_remove(wpa_s, bss, __func__);
401 struct wpa_bss *bss;
413 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
414 if (!wpa_bss_in_use(wpa_s, bss)) {
415 wpa_bss_remove(wpa_s, bss, __func__);
429 struct wpa_bss *bss;
431 bss = os_zalloc(sizeof(*bss) + res->ie_len + res->beacon_ie_len);
432 if (bss == NULL)
434 bss->id = wpa_s->bss_next_id++;
435 bss->last_update_idx = wpa_s->bss_update_idx;
436 wpa_bss_copy_res(bss, res, fetch_time);
437 os_memcpy(bss->ssid, ssid, ssid_len);
438 bss->ssid_len = ssid_len;
439 bss->ie_len = res->ie_len;
440 bss->beacon_ie_len = res->beacon_ie_len;
441 os_memcpy(bss + 1, res + 1, res->ie_len + res->beacon_ie_len);
442 wpa_bss_set_hessid(bss);
446 wpa_printf(MSG_ERROR, "Increasing the MAX BSS count to %d "
452 dl_list_add_tail(&wpa_s->bss, &bss->list);
453 dl_list_add_tail(&wpa_s->bss_id, &bss->list_id);
455 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Add new id %u BSSID " MACSTR
457 bss->id, MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len),
458 bss->freq);
459 wpas_notify_bss_added(wpa_s, bss->bssid, bss->id);
460 return bss;
491 wpa_printf(MSG_DEBUG, "bss: %s: cannot compare IEs", __func__);
561 const struct wpa_bss *bss)
564 wpas_notify_bss_freq_changed(wpa_s, bss->id);
567 wpas_notify_bss_signal_changed(wpa_s, bss->id);
570 wpas_notify_bss_privacy_changed(wpa_s, bss->id);
573 wpas_notify_bss_mode_changed(wpa_s, bss->id);
576 wpas_notify_bss_wpaie_changed(wpa_s, bss->id);
579 wpas_notify_bss_rsnie_changed(wpa_s, bss->id);
582 wpas_notify_bss_wps_changed(wpa_s, bss->id);
585 wpas_notify_bss_ies_changed(wpa_s, bss->id);
588 wpas_notify_bss_rates_changed(wpa_s, bss->id);
590 wpas_notify_bss_seen(wpa_s, bss->id);
595 wpa_bss_update(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
600 if (bss->last_update_idx == wpa_s->bss_update_idx) {
604 * Some drivers (e.g., cfg80211) include multiple BSS entries
605 * for the same BSS if that BSS's channel changes. The BSS list
608 * most current BSS information remains in the table.
610 wpa_printf(MSG_DEBUG, "BSS: " MACSTR
612 MAC2STR(bss->bssid));
616 (unsigned int) bss->last_update.sec,
617 (unsigned int) bss->last_update.usec,
618 bss
619 (bss->flags & WPA_BSS_ASSOCIATED) ? " assoc" : "");
625 if ((bss->flags & WPA_BSS_ASSOCIATED) ||
627 !os_reltime_before(&bss->last_update, &update_time))) {
629 "Ignore this BSS entry since the previous update looks more current");
630 return bss;
633 "Accept this BSS entry since it looks more current than the previous update");
636 changes = wpa_bss_compare_res(bss, res);
638 wpa_printf(MSG_DEBUG, "BSS: " MACSTR " changed freq %d --> %d",
639 MAC2STR(bss->bssid), bss->freq, res->freq);
640 bss->scan_miss_count = 0;
641 bss->last_update_idx = wpa_s->bss_update_idx;
642 wpa_bss_copy_res(bss, res, fetch_time);
644 dl_list_del(&bss->list);
646 if (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) &&
652 * Do not update the IEs in this BSS entry to avoid such loss of
656 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Do not update scan IEs for "
658 MAC2STR(bss->bssid));
661 if (bss->ie_len + bss->beacon_ie_len >=
663 os_memcpy(bss + 1, res + 1, res->ie_len + res->beacon_ie_len);
664 bss->ie_len = res->ie_len;
665 bss->beacon_ie_len = res->beacon_ie_len;
668 struct dl_list *prev = bss->list_id.prev;
669 dl_list_del(&bss->list_id);
670 nbss = os_realloc(bss, sizeof(*bss) + res->ie_len +
675 if (wpa_s->last_scan_res[i] == bss) {
680 if (wpa_s->current_bss == bss)
682 wpa_bss_update_pending_connect(wpa_s, bss, nbss);
683 bss = nbss;
684 os_memcpy(bss + 1, res + 1,
686 bss->ie_len = res->ie_len;
687 bss->beacon_ie_len = res->beacon_ie_len;
689 dl_list_add(prev, &bss->list_id);
692 wpa_bss_set_hessid(bss);
693 dl_list_add_tail(&wpa_s->bss, &bss->list);
695 notify_bss_changes(wpa_s, changes, bss);
697 return bss;
702 * wpa_bss_update_start - Start a BSS table update from scan results
705 * This function is called at the start of each BSS table update round for new
713 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Start scan result update %u",
720 * wpa_bss_update_scan_res - Update a BSS table entry based on a scan result
725 * This function updates a BSS table entry (or adds one) based on a scan result.
734 struct wpa_bss *bss;
743 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Ignore driver BSS "
754 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: No SSID IE included for "
759 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Too long SSID IE included for "
772 wpa_printf(MSG_DEBUG, "BSS: No P2P IE - skipping BSS " MACSTR
788 bss = wpa_bss_get(wpa_s, res->bssid, ssid + 2, ssid[1]);
789 if (bss == NULL)
790 bss = wpa_bss_add(wpa_s, ssid + 2, ssid[1], res, fetch_time);
792 bss = wpa_bss_update(wpa_s, bss, res, fetch_time);
796 if (bss == wpa_s->last_scan_res[i]) {
804 if (bss == NULL)
822 wpa_s->last_scan_res[wpa_s->last_scan_res_used++] = bss;
826 static int wpa_bss_included_in_scan(const struct wpa_bss *bss,
838 if (bss->freq == info->freqs[i]) {
852 (s->ssid_len == bss->ssid_len &&
853 os_memcmp(s->ssid, bss->ssid, bss->ssid_len) ==
868 * wpa_bss_update_end - End a BSS table update from scan results
873 * This function is called at the end of each BSS table update round for new
880 struct wpa_bss *bss, *n;
886 dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {
887 if (wpa_bss_in_use(wpa_s, bss))
889 if (!wpa_bss_included_in_scan(bss, info))
891 if (bss->last_update_idx < wpa_s->bss_update_idx)
892 bss->scan_miss_count++;
893 if (bss->scan_miss_count >=
895 wpa_bss_remove(wpa_s, bss, "no match in scan");
899 wpa_printf(MSG_DEBUG, "BSS: last_scan_res_used=%u/%u",
905 * wpa_bss_flush_by_age - Flush old BSS entries
909 * Remove BSS entries that have not been updated during the last @age seconds.
913 struct wpa_bss *bss, *n;
916 if (dl_list_empty(&wpa_s->bss))
922 dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {
923 if (wpa_bss_in_use(wpa_s, bss))
926 if (os_reltime_before(&bss->last_update, &t)) {
927 wpa_bss_remove(wpa_s, bss, __func__);
935 * wpa_bss_init - Initialize BSS table
939 * This prepares BSS table lists and timer for periodic updates. The BSS table
944 dl_list_init(&wpa_s->bss);
951 * wpa_bss_flush - Flush all unused BSS entries
956 struct wpa_bss *bss, *n;
960 if (wpa_s->bss.next == NULL)
961 return; /* BSS table not yet initialized */
963 dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {
964 if (wpa_bss_in_use(wpa_s, bss))
966 wpa_bss_remove(wpa_s, bss, __func__);
972 * wpa_bss_deinit - Deinitialize BSS table
982 * wpa_bss_get_bssid - Fetch a BSS table entry based on BSSID
985 * Returns: Pointer to the BSS entry or %NULL if not found
990 struct wpa_bss *bss;
993 dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) {
994 if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0)
995 return bss;
1002 * wpa_bss_get_bssid_latest - Fetch the latest BSS table entry based on BSSID
1005 * Returns: Pointer to the BSS entry or %NULL if not found
1007 * This function is like wpa_bss_get_bssid(), but full BSS table is iterated to
1015 struct wpa_bss *bss, *found = NULL;
1018 dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) {
1019 if (os_memcmp(bss->bssid, bssid, ETH_ALEN) != 0)
1022 os_reltime_before(&found->last_update, &bss->last_update))
1023 found = bss;
1031 * wpa_bss_get_p2p_dev_addr - Fetch a BSS table entry based on P2P Device Addr
1034 * Returns: Pointer to the BSS entry or %NULL if not found
1039 struct wpa_bss *bss;
1040 dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) {
1042 if (p2p_parse_dev_addr((const u8 *) (bss + 1), bss->ie_len,
1045 return bss;
1053 * wpa_bss_get_id - Fetch a BSS table entry based on identifier
1056 * Returns: Pointer to the BSS entry or %NULL if not found
1060 struct wpa_bss *bss;
1061 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
1062 if (bss->id == id)
1063 return bss;
1070 * wpa_bss_get_id_range - Fetch a BSS table entry based on identifier range
1074 * Returns: Pointer to the BSS entry or %NULL if not found
1076 * This function is similar to wpa_bss_get_id() but allows a BSS entry with the
1083 struct wpa_bss *bss;
1084 dl_list_for_each(bss, &wpa_s->bss_id, struct wpa_bss, list_id) {
1085 if (bss->id >= idf && bss->id <= idl)
1086 return bss;
1093 * wpa_bss_get_ie - Fetch a specified information element from a BSS entry
1094 * @bss: BSS table entry
1098 * This function returns the first matching information element in the BSS
1101 const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie)
1103 return get_ie((const u8 *) (bss + 1), bss->ie_len, ie);
1108 * wpa_bss_get_vendor_ie - Fetch a vendor information element from a BSS entry
1109 * @bss: BSS table entry
1113 * This function returns the first matching information element in the BSS
1116 const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type)
1120 pos = (const u8 *) (bss + 1);
1121 end = pos + bss->ie_len;
1137 * wpa_bss_get_vendor_ie_beacon - Fetch a vendor information from a BSS entry
1138 * @bss: BSS table entry
1142 * This function returns the first matching information element in the BSS
1148 const u8 * wpa_bss_get_vendor_ie_beacon(const struct wpa_bss *bss,
1153 if (bss->beacon_ie_len == 0)
1156 pos = (const u8 *) (bss + 1);
1157 pos += bss->ie_len;
1158 end = pos + bss->beacon_ie_len;
1174 * wpa_bss_get_vendor_ie_multi - Fetch vendor IE data from a BSS entry
1175 * @bss: BSS table entry
1180 * specific information elements in the BSS entry. The caller is responsible for
1183 struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss,
1189 buf = wpabuf_alloc(bss->ie_len);
1193 pos = (const u8 *) (bss + 1);
1194 end = pos + bss->ie_len;
1215 * wpa_bss_get_vendor_ie_multi_beacon - Fetch vendor IE data from a BSS entry
1216 * @bss: BSS table entry
1221 * specific information elements in the BSS entry. The caller is responsible for
1227 struct wpabuf * wpa_bss_get_vendor_ie_multi_beacon(const struct wpa_bss *bss,
1233 buf = wpabuf_alloc(bss->beacon_ie_len);
1237 pos = (const u8 *) (bss + 1);
1238 pos += bss->ie_len;
1239 end = pos + bss->beacon_ie_len;
1260 * wpa_bss_get_max_rate - Get maximum legacy TX rate supported in a BSS
1261 * @bss: BSS table entry
1264 int wpa_bss_get_max_rate(const struct wpa_bss *bss)
1270 ie = wpa_bss_get_ie(bss, WLAN_EID_SUPP_RATES);
1276 ie = wpa_bss_get_ie(bss, WLAN_EID_EXT_SUPP_RATES);
1287 * wpa_bss_get_bit_rates - Get legacy TX rates supported in a BSS
1288 * @bss: BSS table entry
1295 int wpa_bss_get_bit_rates(const struct wpa_bss *bss, u8 **rates)
1302 ie = wpa_bss_get_ie(bss, WLAN_EID_SUPP_RATES);
1303 ie2 = wpa_bss_get_ie(bss, WLAN_EID_EXT_SUPP_RATES);
1323 const u8 * wpa_bss_get_fils_cache_id(struct wpa_bss *bss)
1327 if (bss) {
1328 ie = wpa_bss_get_ie(bss, WLAN_EID_FILS_INDICATION);