Home | History | Annotate | Download | only in wpa_supplicant

Lines Matching refs:bss

2  * BSS table
19 #include "bss.h"
33 static void wpa_bss_set_hessid(struct wpa_bss *bss)
36 const u8 *ie = wpa_bss_get_ie(bss, WLAN_EID_INTERWORKING);
38 os_memset(bss->hessid, 0, ETH_ALEN);
42 os_memcpy(bss->hessid, ie + 3, ETH_ALEN);
44 os_memcpy(bss->hessid, ie + 5, ETH_ALEN);
50 * wpa_bss_anqp_alloc - Allocate ANQP data structure for a BSS entry
54 * shared by multiple BSS entries and each shared entry is freed with
111 * wpa_bss_anqp_unshare_alloc - Unshare ANQP data (if shared) in a BSS entry
112 * @bss: BSS entry
115 * This function ensures the specific BSS entry has an ANQP data structure that
116 * is not shared with any other BSS entry.
118 int wpa_bss_anqp_unshare_alloc(struct wpa_bss *bss)
122 if (bss->anqp && bss->anqp->users > 1) {
124 anqp = wpa_bss_anqp_clone(bss->anqp);
128 bss->anqp->users--;
129 bss->anqp = anqp;
133 if (bss->anqp)
137 bss->anqp = wpa_bss_anqp_alloc();
138 return bss->anqp ? 0 : -1;
157 /* Another BSS entry holds a pointer to this ANQP info */
205 if (cwork->bss != old_bss)
209 "Update BSS pointer for the pending connect radio work");
210 cwork->bss = new_bss;
216 static void wpa_bss_remove(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
222 if (wpa_s->last_scan_res[i] == bss) {
232 wpa_bss_update_pending_connect(wpa_s, bss, NULL);
233 dl_list_del(&bss->list);
234 dl_list_del(&bss->list_id);
236 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Remove id %u BSSID " MACSTR
237 " SSID '%s' due to %s", bss->id, MAC2STR(bss->bssid),
238 wpa_ssid_txt(bss->ssid, bss->ssid_len), reason);
239 wpas_notify_bss_removed(wpa_s, bss->bssid, bss->id);
240 wpa_bss_anqp_free(bss->anqp);
241 os_free(bss);
246 * wpa_bss_get - Fetch a BSS table entry based on BSSID and SSID
251 * Returns: Pointer to the BSS entry or %NULL if not found
256 struct wpa_bss *bss;
259 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
260 if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0 &&
261 bss->ssid_len == ssid_len &&
262 os_memcmp(bss->ssid, ssid, ssid_len) == 0)
263 return bss;
306 static int wpa_bss_known(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
313 if (ssid->ssid_len == bss->ssid_len &&
314 os_memcmp(ssid->ssid, bss->ssid, ssid->ssid_len) == 0)
322 static int wpa_bss_in_use(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
324 if (bss == wpa_s->current_bss)
328 (bss->ssid_len != wpa_s->current_bss->ssid_len ||
329 os_memcmp(bss->ssid, wpa_s->current_bss->ssid,
330 bss->ssid_len) != 0))
333 return !is_zero_ether_addr(bss->bssid) &&
334 (os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) == 0 ||
335 os_memcmp(bss->bssid, wpa_s->pending_bssid, ETH_ALEN) == 0);
341 struct wpa_bss *bss;
343 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
344 if (!wpa_bss_known(wpa_s, bss)) {
345 wpa_bss_remove(wpa_s, bss, __func__);
356 struct wpa_bss *bss;
368 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
369 if (!wpa_bss_in_use(wpa_s, bss)) {
370 wpa_bss_remove(wpa_s, bss, __func__);
384 struct wpa_bss *bss;
386 bss = os_zalloc(sizeof(*bss) + res->ie_len + res->beacon_ie_len);
387 if (bss == NULL)
389 bss->id = wpa_s->bss_next_id++;
390 bss->last_update_idx = wpa_s->bss_update_idx;
391 wpa_bss_copy_res(bss, res, fetch_time);
392 os_memcpy(bss->ssid, ssid, ssid_len);
393 bss->ssid_len = ssid_len;
394 bss->ie_len = res->ie_len;
395 bss->beacon_ie_len = res->beacon_ie_len;
396 os_memcpy(bss + 1, res + 1, res->ie_len + res->beacon_ie_len);
397 wpa_bss_set_hessid(bss);
401 wpa_printf(MSG_ERROR, "Increasing the MAX BSS count to %d "
407 dl_list_add_tail(&wpa_s->bss, &bss->list);
408 dl_list_add_tail(&wpa_s->bss_id, &bss->list_id);
410 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Add new id %u BSSID " MACSTR
412 bss->id, MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len),
413 bss->freq);
414 wpas_notify_bss_added(wpa_s, bss->bssid, bss->id);
415 return bss;
446 wpa_printf(MSG_DEBUG, "bss: %s: cannot compare IEs", __func__);
516 const struct wpa_bss *bss)
519 wpas_notify_bss_freq_changed(wpa_s, bss->id);
522 wpas_notify_bss_signal_changed(wpa_s, bss->id);
525 wpas_notify_bss_privacy_changed(wpa_s, bss->id);
528 wpas_notify_bss_mode_changed(wpa_s, bss->id);
531 wpas_notify_bss_wpaie_changed(wpa_s, bss->id);
534 wpas_notify_bss_rsnie_changed(wpa_s, bss->id);
537 wpas_notify_bss_wps_changed(wpa_s, bss->id);
540 wpas_notify_bss_ies_changed(wpa_s, bss->id);
543 wpas_notify_bss_rates_changed(wpa_s, bss->id);
545 wpas_notify_bss_seen(wpa_s, bss->id);
550 wpa_bss_update(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
555 changes = wpa_bss_compare_res(bss, res);
557 wpa_printf(MSG_DEBUG, "BSS: " MACSTR " changed freq %d --> %d",
558 MAC2STR(bss->bssid), bss->freq, res->freq);
559 bss->scan_miss_count = 0;
560 bss->last_update_idx = wpa_s->bss_update_idx;
561 wpa_bss_copy_res(bss, res, fetch_time);
563 dl_list_del(&bss->list);
565 if (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) &&
571 * Do not update the IEs in this BSS entry to avoid such loss of
575 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Do not update scan IEs for "
577 MAC2STR(bss->bssid));
580 if (bss->ie_len + bss->beacon_ie_len >=
582 os_memcpy(bss + 1, res + 1, res->ie_len + res->beacon_ie_len);
583 bss->ie_len = res->ie_len;
584 bss->beacon_ie_len = res->beacon_ie_len;
587 struct dl_list *prev = bss->list_id.prev;
588 dl_list_del(&bss->list_id);
589 nbss = os_realloc(bss, sizeof(*bss) + res->ie_len +
594 if (wpa_s->last_scan_res[i] == bss) {
599 if (wpa_s->current_bss == bss)
601 wpa_bss_update_pending_connect(wpa_s, bss, nbss);
602 bss = nbss;
603 os_memcpy(bss + 1, res + 1,
605 bss->ie_len = res->ie_len;
606 bss->beacon_ie_len = res->beacon_ie_len;
608 dl_list_add(prev, &bss->list_id);
611 wpa_bss_set_hessid(bss);
612 dl_list_add_tail(&wpa_s->bss, &bss->list);
614 notify_bss_changes(wpa_s, changes, bss);
616 return bss;
621 * wpa_bss_update_start - Start a BSS table update from scan results
624 * This function is called at the start of each BSS table update round for new
632 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Start scan result update %u",
639 * wpa_bss_update_scan_res - Update a BSS table entry based on a scan result
644 * This function updates a BSS table entry (or adds one) based on a scan result.
653 struct wpa_bss *bss;
662 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Ignore driver BSS "
673 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: No SSID IE included for "
678 wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Too long SSID IE included for "
691 wpa_printf(MSG_DEBUG, "BSS: No P2P IE - skipping BSS " MACSTR
707 bss = wpa_bss_get(wpa_s, res->bssid, ssid + 2, ssid[1]);
708 if (bss == NULL)
709 bss = wpa_bss_add(wpa_s, ssid + 2, ssid[1], res, fetch_time);
711 bss = wpa_bss_update(wpa_s, bss, res, fetch_time);
715 if (bss == wpa_s->last_scan_res[i]) {
723 if (bss == NULL)
741 wpa_s->last_scan_res[wpa_s->last_scan_res_used++] = bss;
745 static int wpa_bss_included_in_scan(const struct wpa_bss *bss,
757 if (bss->freq == info->freqs[i]) {
771 (s->ssid_len == bss->ssid_len &&
772 os_memcmp(s->ssid, bss->ssid, bss->ssid_len) ==
787 * wpa_bss_update_end - End a BSS table update from scan results
792 * This function is called at the end of each BSS table update round for new
799 struct wpa_bss *bss, *n;
805 dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {
806 if (wpa_bss_in_use(wpa_s, bss))
808 if (!wpa_bss_included_in_scan(bss, info))
810 if (bss->last_update_idx < wpa_s->bss_update_idx)
811 bss->scan_miss_count++;
812 if (bss->scan_miss_count >=
814 wpa_bss_remove(wpa_s, bss, "no match in scan");
818 wpa_printf(MSG_DEBUG, "BSS: last_scan_res_used=%u/%u",
824 * wpa_bss_flush_by_age - Flush old BSS entries
828 * Remove BSS entries that have not been updated during the last @age seconds.
832 struct wpa_bss *bss, *n;
835 if (dl_list_empty(&wpa_s->bss))
841 dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {
842 if (wpa_bss_in_use(wpa_s, bss))
845 if (os_reltime_before(&bss->last_update, &t)) {
846 wpa_bss_remove(wpa_s, bss, __func__);
854 * wpa_bss_init - Initialize BSS table
858 * This prepares BSS table lists and timer for periodic updates. The BSS table
863 dl_list_init(&wpa_s->bss);
870 * wpa_bss_flush - Flush all unused BSS entries
875 struct wpa_bss *bss, *n;
879 if (wpa_s->bss.next == NULL)
880 return; /* BSS table not yet initialized */
882 dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {
883 if (wpa_bss_in_use(wpa_s, bss))
885 wpa_bss_remove(wpa_s, bss, __func__);
891 * wpa_bss_deinit - Deinitialize BSS table
901 * wpa_bss_get_bssid - Fetch a BSS table entry based on BSSID
904 * Returns: Pointer to the BSS entry or %NULL if not found
909 struct wpa_bss *bss;
912 dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) {
913 if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0)
914 return bss;
921 * wpa_bss_get_bssid_latest - Fetch the latest BSS table entry based on BSSID
924 * Returns: Pointer to the BSS entry or %NULL if not found
926 * This function is like wpa_bss_get_bssid(), but full BSS table is iterated to
934 struct wpa_bss *bss, *found = NULL;
937 dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) {
938 if (os_memcmp(bss->bssid, bssid, ETH_ALEN) != 0)
941 os_reltime_before(&found->last_update, &bss->last_update))
942 found = bss;
950 * wpa_bss_get_p2p_dev_addr - Fetch a BSS table entry based on P2P Device Addr
953 * Returns: Pointer to the BSS entry or %NULL if not found
958 struct wpa_bss *bss;
959 dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) {
961 if (p2p_parse_dev_addr((const u8 *) (bss + 1), bss->ie_len,
964 return bss;
972 * wpa_bss_get_id - Fetch a BSS table entry based on identifier
975 * Returns: Pointer to the BSS entry or %NULL if not found
979 struct wpa_bss *bss;
980 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
981 if (bss->id == id)
982 return bss;
989 * wpa_bss_get_id_range - Fetch a BSS table entry based on identifier range
993 * Returns: Pointer to the BSS entry or %NULL if not found
995 * This function is similar to wpa_bss_get_id() but allows a BSS entry with the
1002 struct wpa_bss *bss;
1003 dl_list_for_each(bss, &wpa_s->bss_id, struct wpa_bss, list_id) {
1004 if (bss->id >= idf && bss->id <= idl)
1005 return bss;
1012 * wpa_bss_get_ie - Fetch a specified information element from a BSS entry
1013 * @bss: BSS table entry
1017 * This function returns the first matching information element in the BSS
1020 const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie)
1022 return get_ie((const u8 *) (bss + 1), bss->ie_len, ie);
1027 * wpa_bss_get_vendor_ie - Fetch a vendor information element from a BSS entry
1028 * @bss: BSS table entry
1032 * This function returns the first matching information element in the BSS
1035 const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type)
1039 pos = (const u8 *) (bss + 1);
1040 end = pos + bss->ie_len;
1056 * wpa_bss_get_vendor_ie_beacon - Fetch a vendor information from a BSS entry
1057 * @bss: BSS table entry
1061 * This function returns the first matching information element in the BSS
1067 const u8 * wpa_bss_get_vendor_ie_beacon(const struct wpa_bss *bss,
1072 if (bss->beacon_ie_len == 0)
1075 pos = (const u8 *) (bss + 1);
1076 pos += bss->ie_len;
1077 end = pos + bss->beacon_ie_len;
1093 * wpa_bss_get_vendor_ie_multi - Fetch vendor IE data from a BSS entry
1094 * @bss: BSS table entry
1099 * specific information elements in the BSS entry. The caller is responsible for
1102 struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss,
1108 buf = wpabuf_alloc(bss->ie_len);
1112 pos = (const u8 *) (bss + 1);
1113 end = pos + bss->ie_len;
1134 * wpa_bss_get_vendor_ie_multi_beacon - Fetch vendor IE data from a BSS entry
1135 * @bss: BSS table entry
1140 * specific information elements in the BSS entry. The caller is responsible for
1146 struct wpabuf * wpa_bss_get_vendor_ie_multi_beacon(const struct wpa_bss *bss,
1152 buf = wpabuf_alloc(bss->beacon_ie_len);
1156 pos = (const u8 *) (bss + 1);
1157 pos += bss->ie_len;
1158 end = pos + bss->beacon_ie_len;
1179 * wpa_bss_get_max_rate - Get maximum legacy TX rate supported in a BSS
1180 * @bss: BSS table entry
1183 int wpa_bss_get_max_rate(const struct wpa_bss *bss)
1189 ie = wpa_bss_get_ie(bss, WLAN_EID_SUPP_RATES);
1195 ie = wpa_bss_get_ie(bss, WLAN_EID_EXT_SUPP_RATES);
1206 * wpa_bss_get_bit_rates - Get legacy TX rates supported in a BSS
1207 * @bss: BSS table entry
1214 bss, u8 **rates)
1221 ie = wpa_bss_get_ie(bss, WLAN_EID_SUPP_RATES);
1222 ie2 = wpa_bss_get_ie(bss, WLAN_EID_EXT_SUPP_RATES);