2009-12-27 20:07:47 +01:00
|
|
|
/*
|
|
|
|
* BSS table
|
2019-01-02 16:56:41 +01:00
|
|
|
* Copyright (c) 2009-2019, Jouni Malinen <j@w1.fi>
|
2009-12-27 20:07:47 +01:00
|
|
|
*
|
2012-02-11 15:46:35 +01:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2009-12-27 20:07:47 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BSS_H
|
|
|
|
#define BSS_H
|
|
|
|
|
2010-01-02 15:41:38 +01:00
|
|
|
struct wpa_scan_res;
|
|
|
|
|
2009-12-27 20:07:47 +01:00
|
|
|
#define WPA_BSS_QUAL_INVALID BIT(0)
|
|
|
|
#define WPA_BSS_NOISE_INVALID BIT(1)
|
|
|
|
#define WPA_BSS_LEVEL_INVALID BIT(2)
|
|
|
|
#define WPA_BSS_LEVEL_DBM BIT(3)
|
|
|
|
#define WPA_BSS_AUTHENTICATED BIT(4)
|
|
|
|
#define WPA_BSS_ASSOCIATED BIT(5)
|
2011-10-16 21:44:28 +02:00
|
|
|
#define WPA_BSS_ANQP_FETCH_TRIED BIT(6)
|
2020-03-07 17:03:32 +01:00
|
|
|
#define WPA_BSS_OWE_TRANSITION BIT(7)
|
2009-12-27 20:07:47 +01:00
|
|
|
|
2020-11-03 20:20:01 +01:00
|
|
|
#define WPA_BSS_FREQ_CHANGED_FLAG BIT(0)
|
|
|
|
#define WPA_BSS_SIGNAL_CHANGED_FLAG BIT(1)
|
|
|
|
#define WPA_BSS_PRIVACY_CHANGED_FLAG BIT(2)
|
|
|
|
#define WPA_BSS_MODE_CHANGED_FLAG BIT(3)
|
|
|
|
#define WPA_BSS_WPAIE_CHANGED_FLAG BIT(4)
|
|
|
|
#define WPA_BSS_RSNIE_CHANGED_FLAG BIT(5)
|
|
|
|
#define WPA_BSS_WPS_CHANGED_FLAG BIT(6)
|
|
|
|
#define WPA_BSS_RATES_CHANGED_FLAG BIT(7)
|
|
|
|
#define WPA_BSS_IES_CHANGED_FLAG BIT(8)
|
|
|
|
|
2015-10-07 15:10:38 +02:00
|
|
|
struct wpa_bss_anqp_elem {
|
|
|
|
struct dl_list list;
|
|
|
|
u16 infoid;
|
2021-02-21 11:48:13 +01:00
|
|
|
bool protected_response; /* received in a protected GAS response */
|
2015-10-07 15:10:38 +02:00
|
|
|
struct wpabuf *payload;
|
|
|
|
};
|
|
|
|
|
2012-12-27 11:29:05 +01:00
|
|
|
/**
|
|
|
|
* struct wpa_bss_anqp - ANQP data for a BSS entry (struct wpa_bss)
|
|
|
|
*/
|
2012-09-04 15:02:29 +02:00
|
|
|
struct wpa_bss_anqp {
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Number of BSS entries referring to this ANQP data instance */
|
2012-09-04 15:02:29 +02:00
|
|
|
unsigned int users;
|
|
|
|
#ifdef CONFIG_INTERWORKING
|
2015-02-18 03:35:10 +01:00
|
|
|
struct wpabuf *capability_list;
|
2012-09-04 15:02:29 +02:00
|
|
|
struct wpabuf *venue_name;
|
|
|
|
struct wpabuf *network_auth_type;
|
|
|
|
struct wpabuf *roaming_consortium;
|
|
|
|
struct wpabuf *ip_addr_type_availability;
|
|
|
|
struct wpabuf *nai_realm;
|
|
|
|
struct wpabuf *anqp_3gpp;
|
|
|
|
struct wpabuf *domain_name;
|
2016-12-17 21:01:02 +01:00
|
|
|
struct wpabuf *fils_realm_info;
|
2015-10-07 15:10:38 +02:00
|
|
|
struct dl_list anqp_elems; /* list of struct wpa_bss_anqp_elem */
|
2012-09-04 15:02:29 +02:00
|
|
|
#endif /* CONFIG_INTERWORKING */
|
|
|
|
#ifdef CONFIG_HS20
|
2015-02-18 03:35:09 +01:00
|
|
|
struct wpabuf *hs20_capability_list;
|
2012-09-04 15:02:29 +02:00
|
|
|
struct wpabuf *hs20_operator_friendly_name;
|
|
|
|
struct wpabuf *hs20_wan_metrics;
|
|
|
|
struct wpabuf *hs20_connection_capability;
|
|
|
|
struct wpabuf *hs20_operating_class;
|
2013-01-08 22:51:16 +01:00
|
|
|
struct wpabuf *hs20_osu_providers_list;
|
2018-04-16 12:16:39 +02:00
|
|
|
struct wpabuf *hs20_operator_icon_metadata;
|
2018-10-05 19:51:51 +02:00
|
|
|
struct wpabuf *hs20_osu_providers_nai_list;
|
2012-09-04 15:02:29 +02:00
|
|
|
#endif /* CONFIG_HS20 */
|
|
|
|
};
|
|
|
|
|
2009-12-27 20:07:47 +01:00
|
|
|
/**
|
|
|
|
* struct wpa_bss - BSS table
|
|
|
|
*
|
|
|
|
* This structure is used to store information about neighboring BSSes in
|
|
|
|
* generic format. It is mainly updated based on scan results from the driver.
|
|
|
|
*/
|
|
|
|
struct wpa_bss {
|
2012-12-27 11:29:05 +01:00
|
|
|
/** List entry for struct wpa_supplicant::bss */
|
2009-12-27 20:07:47 +01:00
|
|
|
struct dl_list list;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** List entry for struct wpa_supplicant::bss_id */
|
2009-12-27 23:30:38 +01:00
|
|
|
struct dl_list list_id;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Unique identifier for this BSS entry */
|
2009-12-27 20:07:47 +01:00
|
|
|
unsigned int id;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Number of counts without seeing this BSS */
|
2009-12-27 20:07:47 +01:00
|
|
|
unsigned int scan_miss_count;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Index of the last scan update */
|
2009-12-27 20:07:47 +01:00
|
|
|
unsigned int last_update_idx;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Information flags about the BSS/IBSS (WPA_BSS_*) */
|
2009-12-27 20:07:47 +01:00
|
|
|
unsigned int flags;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** BSSID */
|
2009-12-27 20:07:47 +01:00
|
|
|
u8 bssid[ETH_ALEN];
|
2012-12-27 11:29:05 +01:00
|
|
|
/** HESSID */
|
2012-09-04 16:08:58 +02:00
|
|
|
u8 hessid[ETH_ALEN];
|
2012-12-27 11:29:05 +01:00
|
|
|
/** SSID */
|
2015-04-07 11:00:13 +02:00
|
|
|
u8 ssid[SSID_MAX_LEN];
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Length of SSID */
|
2009-12-27 20:07:47 +01:00
|
|
|
size_t ssid_len;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Frequency of the channel in MHz (e.g., 2412 = channel 1) */
|
2009-12-27 20:07:47 +01:00
|
|
|
int freq;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Beacon interval in TUs (host byte order) */
|
2009-12-27 20:07:47 +01:00
|
|
|
u16 beacon_int;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Capability information field in host byte order */
|
2009-12-27 20:07:47 +01:00
|
|
|
u16 caps;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Signal quality */
|
2009-12-27 20:07:47 +01:00
|
|
|
int qual;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Noise level */
|
2009-12-27 20:07:47 +01:00
|
|
|
int noise;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Signal level */
|
2009-12-27 20:07:47 +01:00
|
|
|
int level;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Timestamp of last Beacon/Probe Response frame */
|
2009-12-27 20:07:47 +01:00
|
|
|
u64 tsf;
|
2022-04-24 11:06:56 +02:00
|
|
|
/** Whether the Beacon frame data is known to be newer */
|
|
|
|
bool beacon_newer;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Time of the last update (i.e., Beacon or Probe Response RX) */
|
2013-12-16 21:08:28 +01:00
|
|
|
struct os_reltime last_update;
|
2015-02-22 09:50:55 +01:00
|
|
|
/** Estimated throughput in kbps */
|
|
|
|
unsigned int est_throughput;
|
|
|
|
/** Signal-to-noise ratio in dB */
|
|
|
|
int snr;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** ANQP data */
|
2012-09-04 15:02:29 +02:00
|
|
|
struct wpa_bss_anqp *anqp;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Length of the following IE field in octets (from Probe Response) */
|
2009-12-27 20:07:47 +01:00
|
|
|
size_t ie_len;
|
2012-12-27 11:29:05 +01:00
|
|
|
/** Length of the following Beacon IE field in octets */
|
2010-01-16 15:11:05 +01:00
|
|
|
size_t beacon_ie_len;
|
2022-09-08 16:44:15 +02:00
|
|
|
/** MLD address of the AP */
|
|
|
|
u8 mld_addr[ETH_ALEN];
|
2023-06-12 21:59:49 +02:00
|
|
|
|
|
|
|
/** An array of MLD links */
|
|
|
|
u8 n_mld_links;
|
|
|
|
struct mld_link {
|
|
|
|
u8 link_id;
|
|
|
|
u8 bssid[ETH_ALEN];
|
|
|
|
int freq;
|
|
|
|
} mld_links[MAX_NUM_MLD_LINKS];
|
|
|
|
|
2009-12-27 20:07:47 +01:00
|
|
|
/* followed by ie_len octets of IEs */
|
2010-01-16 15:11:05 +01:00
|
|
|
/* followed by beacon_ie_len octets of IEs */
|
2020-11-16 15:25:17 +01:00
|
|
|
u8 ies[];
|
2009-12-27 20:07:47 +01:00
|
|
|
};
|
|
|
|
|
2020-11-16 15:21:56 +01:00
|
|
|
static inline const u8 * wpa_bss_ie_ptr(const struct wpa_bss *bss)
|
|
|
|
{
|
2020-11-16 15:25:17 +01:00
|
|
|
return bss->ies;
|
2020-11-16 15:21:56 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 20:20:01 +01:00
|
|
|
void notify_bss_changes(struct wpa_supplicant *wpa_s, u32 changes,
|
|
|
|
const struct wpa_bss *bss);
|
2009-12-27 20:07:47 +01:00
|
|
|
void wpa_bss_update_start(struct wpa_supplicant *wpa_s);
|
|
|
|
void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s,
|
2013-02-12 18:14:32 +01:00
|
|
|
struct wpa_scan_res *res,
|
2013-12-16 21:08:28 +01:00
|
|
|
struct os_reltime *fetch_time);
|
2016-09-05 16:33:07 +02:00
|
|
|
void wpa_bss_remove(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|
|
|
const char *reason);
|
2010-01-02 12:57:44 +01:00
|
|
|
void wpa_bss_update_end(struct wpa_supplicant *wpa_s, struct scan_info *info,
|
|
|
|
int new_scan);
|
2009-12-27 20:07:47 +01:00
|
|
|
int wpa_bss_init(struct wpa_supplicant *wpa_s);
|
|
|
|
void wpa_bss_deinit(struct wpa_supplicant *wpa_s);
|
2011-03-20 11:02:33 +01:00
|
|
|
void wpa_bss_flush(struct wpa_supplicant *wpa_s);
|
|
|
|
void wpa_bss_flush_by_age(struct wpa_supplicant *wpa_s, int age);
|
2010-01-02 12:36:12 +01:00
|
|
|
struct wpa_bss * wpa_bss_get(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
|
|
|
const u8 *ssid, size_t ssid_len);
|
2009-12-27 23:30:38 +01:00
|
|
|
struct wpa_bss * wpa_bss_get_bssid(struct wpa_supplicant *wpa_s,
|
|
|
|
const u8 *bssid);
|
2013-03-31 16:15:39 +02:00
|
|
|
struct wpa_bss * wpa_bss_get_bssid_latest(struct wpa_supplicant *wpa_s,
|
|
|
|
const u8 *bssid);
|
2012-02-07 15:23:21 +01:00
|
|
|
struct wpa_bss * wpa_bss_get_p2p_dev_addr(struct wpa_supplicant *wpa_s,
|
|
|
|
const u8 *dev_addr);
|
2009-12-27 23:30:38 +01:00
|
|
|
struct wpa_bss * wpa_bss_get_id(struct wpa_supplicant *wpa_s, unsigned int id);
|
2013-02-07 11:27:52 +01:00
|
|
|
struct wpa_bss * wpa_bss_get_id_range(struct wpa_supplicant *wpa_s,
|
|
|
|
unsigned int idf, unsigned int idl);
|
2009-12-27 23:30:38 +01:00
|
|
|
const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie);
|
2023-10-29 01:24:35 +02:00
|
|
|
const u8 * wpa_bss_get_ie_nth(const struct wpa_bss *bss, u8 ie, int nth);
|
2020-11-16 15:00:21 +01:00
|
|
|
const u8 * wpa_bss_get_ie_ext(const struct wpa_bss *bss, u8 ext);
|
2009-12-27 23:30:38 +01:00
|
|
|
const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type);
|
2013-10-14 18:22:09 +02:00
|
|
|
const u8 * wpa_bss_get_vendor_ie_beacon(const struct wpa_bss *bss,
|
|
|
|
u32 vendor_type);
|
2009-12-27 23:30:38 +01:00
|
|
|
struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss,
|
|
|
|
u32 vendor_type);
|
2012-09-02 18:54:42 +02:00
|
|
|
struct wpabuf * wpa_bss_get_vendor_ie_multi_beacon(const struct wpa_bss *bss,
|
|
|
|
u32 vendor_type);
|
2009-12-28 00:09:32 +01:00
|
|
|
int wpa_bss_get_max_rate(const struct wpa_bss *bss);
|
2010-01-04 15:52:30 +01:00
|
|
|
int wpa_bss_get_bit_rates(const struct wpa_bss *bss, u8 **rates);
|
2012-09-04 15:02:29 +02:00
|
|
|
struct wpa_bss_anqp * wpa_bss_anqp_alloc(void);
|
2012-10-03 13:17:41 +02:00
|
|
|
int wpa_bss_anqp_unshare_alloc(struct wpa_bss *bss);
|
2020-11-16 14:52:22 +01:00
|
|
|
const u8 * wpa_bss_get_fils_cache_id(const struct wpa_bss *bss);
|
2019-01-02 16:56:41 +01:00
|
|
|
int wpa_bss_ext_capab(const struct wpa_bss *bss, unsigned int capab);
|
2009-12-27 20:07:47 +01:00
|
|
|
|
2014-05-12 09:35:41 +02:00
|
|
|
static inline int bss_is_dmg(const struct wpa_bss *bss)
|
|
|
|
{
|
|
|
|
return bss->freq > 45000;
|
|
|
|
}
|
|
|
|
|
2016-02-08 11:30:04 +01:00
|
|
|
/**
|
|
|
|
* Test whether a BSS is a PBSS.
|
|
|
|
* This checks whether a BSS is a DMG-band PBSS. PBSS is used for P2P DMG
|
|
|
|
* network.
|
|
|
|
*/
|
|
|
|
static inline int bss_is_pbss(struct wpa_bss *bss)
|
|
|
|
{
|
|
|
|
return bss_is_dmg(bss) &&
|
|
|
|
(bss->caps & IEEE80211_CAP_DMG_MASK) == IEEE80211_CAP_DMG_PBSS;
|
|
|
|
}
|
|
|
|
|
2015-02-18 03:35:15 +01:00
|
|
|
static inline void wpa_bss_update_level(struct wpa_bss *bss, int new_level)
|
|
|
|
{
|
2020-11-03 08:54:16 +01:00
|
|
|
if (bss != NULL && new_level > -WPA_INVALID_NOISE && new_level < 0)
|
2015-02-18 03:35:15 +01:00
|
|
|
bss->level = new_level;
|
|
|
|
}
|
|
|
|
|
2017-01-02 22:04:02 +01:00
|
|
|
void calculate_update_time(const struct os_reltime *fetch_time,
|
|
|
|
unsigned int age_ms,
|
|
|
|
struct os_reltime *update_time);
|
|
|
|
|
2022-12-06 10:46:06 +01:00
|
|
|
struct wpabuf * wpa_bss_defrag_mle(const struct wpa_bss *bss, u8 type);
|
2023-06-12 21:59:49 +02:00
|
|
|
int wpa_bss_parse_basic_ml_element(struct wpa_supplicant *wpa_s,
|
|
|
|
struct wpa_bss *bss,
|
|
|
|
u8 *ap_mld_addr,
|
|
|
|
u16 *missing_links);
|
2023-06-12 21:59:50 +02:00
|
|
|
u16 wpa_bss_parse_reconf_ml_element(struct wpa_supplicant *wpa_s,
|
|
|
|
struct wpa_bss *bss);
|
2022-12-06 10:46:06 +01:00
|
|
|
|
2009-12-27 20:07:47 +01:00
|
|
|
#endif /* BSS_H */
|