2009-12-27 14:07:47 -05:00
|
|
|
/*
|
|
|
|
* BSS table
|
2019-01-02 10:56:41 -05:00
|
|
|
* Copyright (c) 2009-2019, Jouni Malinen <j@w1.fi>
|
2009-12-27 14:07:47 -05:00
|
|
|
*
|
2012-02-11 09:46:35 -05:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2009-12-27 14:07:47 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BSS_H
|
|
|
|
#define BSS_H
|
|
|
|
|
2010-01-02 09:41:38 -05:00
|
|
|
struct wpa_scan_res;
|
|
|
|
|
2009-12-27 14:07:47 -05: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 15:44:28 -04:00
|
|
|
#define WPA_BSS_ANQP_FETCH_TRIED BIT(6)
|
2020-03-07 11:03:32 -05:00
|
|
|
#define WPA_BSS_OWE_TRANSITION BIT(7)
|
2009-12-27 14:07:47 -05:00
|
|
|
|
2015-10-07 09:10:38 -04:00
|
|
|
struct wpa_bss_anqp_elem {
|
|
|
|
struct dl_list list;
|
|
|
|
u16 infoid;
|
2020-11-23 13:32:26 -05:00
|
|
|
bool protected; /* received in a protected GAS response */
|
2015-10-07 09:10:38 -04:00
|
|
|
struct wpabuf *payload;
|
|
|
|
};
|
|
|
|
|
2012-12-27 05:29:05 -05:00
|
|
|
/**
|
|
|
|
* struct wpa_bss_anqp - ANQP data for a BSS entry (struct wpa_bss)
|
|
|
|
*/
|
2012-09-04 09:02:29 -04:00
|
|
|
struct wpa_bss_anqp {
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Number of BSS entries referring to this ANQP data instance */
|
2012-09-04 09:02:29 -04:00
|
|
|
unsigned int users;
|
|
|
|
#ifdef CONFIG_INTERWORKING
|
2015-02-17 21:35:10 -05:00
|
|
|
struct wpabuf *capability_list;
|
2012-09-04 09:02:29 -04: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 15:01:02 -05:00
|
|
|
struct wpabuf *fils_realm_info;
|
2015-10-07 09:10:38 -04:00
|
|
|
struct dl_list anqp_elems; /* list of struct wpa_bss_anqp_elem */
|
2012-09-04 09:02:29 -04:00
|
|
|
#endif /* CONFIG_INTERWORKING */
|
|
|
|
#ifdef CONFIG_HS20
|
2015-02-17 21:35:09 -05:00
|
|
|
struct wpabuf *hs20_capability_list;
|
2012-09-04 09:02:29 -04: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 16:51:16 -05:00
|
|
|
struct wpabuf *hs20_osu_providers_list;
|
2018-04-16 06:16:39 -04:00
|
|
|
struct wpabuf *hs20_operator_icon_metadata;
|
2018-10-05 13:51:51 -04:00
|
|
|
struct wpabuf *hs20_osu_providers_nai_list;
|
2012-09-04 09:02:29 -04:00
|
|
|
#endif /* CONFIG_HS20 */
|
|
|
|
};
|
|
|
|
|
2009-12-27 14:07:47 -05: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 05:29:05 -05:00
|
|
|
/** List entry for struct wpa_supplicant::bss */
|
2009-12-27 14:07:47 -05:00
|
|
|
struct dl_list list;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** List entry for struct wpa_supplicant::bss_id */
|
2009-12-27 17:30:38 -05:00
|
|
|
struct dl_list list_id;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Unique identifier for this BSS entry */
|
2009-12-27 14:07:47 -05:00
|
|
|
unsigned int id;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Number of counts without seeing this BSS */
|
2009-12-27 14:07:47 -05:00
|
|
|
unsigned int scan_miss_count;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Index of the last scan update */
|
2009-12-27 14:07:47 -05:00
|
|
|
unsigned int last_update_idx;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Information flags about the BSS/IBSS (WPA_BSS_*) */
|
2009-12-27 14:07:47 -05:00
|
|
|
unsigned int flags;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** BSSID */
|
2009-12-27 14:07:47 -05:00
|
|
|
u8 bssid[ETH_ALEN];
|
2012-12-27 05:29:05 -05:00
|
|
|
/** HESSID */
|
2012-09-04 10:08:58 -04:00
|
|
|
u8 hessid[ETH_ALEN];
|
2012-12-27 05:29:05 -05:00
|
|
|
/** SSID */
|
2015-04-07 05:00:13 -04:00
|
|
|
u8 ssid[SSID_MAX_LEN];
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Length of SSID */
|
2009-12-27 14:07:47 -05:00
|
|
|
size_t ssid_len;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Frequency of the channel in MHz (e.g., 2412 = channel 1) */
|
2009-12-27 14:07:47 -05:00
|
|
|
int freq;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Beacon interval in TUs (host byte order) */
|
2009-12-27 14:07:47 -05:00
|
|
|
u16 beacon_int;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Capability information field in host byte order */
|
2009-12-27 14:07:47 -05:00
|
|
|
u16 caps;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Signal quality */
|
2009-12-27 14:07:47 -05:00
|
|
|
int qual;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Noise level */
|
2009-12-27 14:07:47 -05:00
|
|
|
int noise;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Signal level */
|
2009-12-27 14:07:47 -05:00
|
|
|
int level;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Timestamp of last Beacon/Probe Response frame */
|
2009-12-27 14:07:47 -05:00
|
|
|
u64 tsf;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Time of the last update (i.e., Beacon or Probe Response RX) */
|
2013-12-16 15:08:28 -05:00
|
|
|
struct os_reltime last_update;
|
2015-02-22 03:50:55 -05:00
|
|
|
/** Estimated throughput in kbps */
|
|
|
|
unsigned int est_throughput;
|
|
|
|
/** Signal-to-noise ratio in dB */
|
|
|
|
int snr;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** ANQP data */
|
2012-09-04 09:02:29 -04:00
|
|
|
struct wpa_bss_anqp *anqp;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Length of the following IE field in octets (from Probe Response) */
|
2009-12-27 14:07:47 -05:00
|
|
|
size_t ie_len;
|
2012-12-27 05:29:05 -05:00
|
|
|
/** Length of the following Beacon IE field in octets */
|
2010-01-16 09:11:05 -05:00
|
|
|
size_t beacon_ie_len;
|
2009-12-27 14:07:47 -05:00
|
|
|
/* followed by ie_len octets of IEs */
|
2010-01-16 09:11:05 -05:00
|
|
|
/* followed by beacon_ie_len octets of IEs */
|
2020-11-16 09:25:17 -05:00
|
|
|
u8 ies[];
|
2009-12-27 14:07:47 -05:00
|
|
|
};
|
|
|
|
|
2020-11-16 09:21:56 -05:00
|
|
|
static inline const u8 * wpa_bss_ie_ptr(const struct wpa_bss *bss)
|
|
|
|
{
|
2020-11-16 09:25:17 -05:00
|
|
|
return bss->ies;
|
2020-11-16 09:21:56 -05:00
|
|
|
}
|
|
|
|
|
2009-12-27 14:07:47 -05: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 12:14:32 -05:00
|
|
|
struct wpa_scan_res *res,
|
2013-12-16 15:08:28 -05:00
|
|
|
struct os_reltime *fetch_time);
|
2016-09-05 10:33:07 -04:00
|
|
|
void wpa_bss_remove(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|
|
|
const char *reason);
|
2010-01-02 06:57:44 -05:00
|
|
|
void wpa_bss_update_end(struct wpa_supplicant *wpa_s, struct scan_info *info,
|
|
|
|
int new_scan);
|
2009-12-27 14:07:47 -05:00
|
|
|
int wpa_bss_init(struct wpa_supplicant *wpa_s);
|
|
|
|
void wpa_bss_deinit(struct wpa_supplicant *wpa_s);
|
2011-03-20 06:02:33 -04: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 06:36:12 -05: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 17:30:38 -05:00
|
|
|
struct wpa_bss * wpa_bss_get_bssid(struct wpa_supplicant *wpa_s,
|
|
|
|
const u8 *bssid);
|
2013-03-31 10:15:39 -04:00
|
|
|
struct wpa_bss * wpa_bss_get_bssid_latest(struct wpa_supplicant *wpa_s,
|
|
|
|
const u8 *bssid);
|
2012-02-07 09:23:21 -05:00
|
|
|
struct wpa_bss * wpa_bss_get_p2p_dev_addr(struct wpa_supplicant *wpa_s,
|
|
|
|
const u8 *dev_addr);
|
2009-12-27 17:30:38 -05:00
|
|
|
struct wpa_bss * wpa_bss_get_id(struct wpa_supplicant *wpa_s, unsigned int id);
|
2013-02-07 05:27:52 -05:00
|
|
|
struct wpa_bss * wpa_bss_get_id_range(struct wpa_supplicant *wpa_s,
|
|
|
|
unsigned int idf, unsigned int idl);
|
2009-12-27 17:30:38 -05:00
|
|
|
const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie);
|
2020-11-16 09:00:21 -05:00
|
|
|
const u8 * wpa_bss_get_ie_ext(const struct wpa_bss *bss, u8 ext);
|
2009-12-27 17:30:38 -05:00
|
|
|
const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type);
|
2013-10-14 12:22:09 -04:00
|
|
|
const u8 * wpa_bss_get_vendor_ie_beacon(const struct wpa_bss *bss,
|
|
|
|
u32 vendor_type);
|
2009-12-27 17:30:38 -05:00
|
|
|
struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss,
|
|
|
|
u32 vendor_type);
|
2012-09-02 12:54:42 -04:00
|
|
|
struct wpabuf * wpa_bss_get_vendor_ie_multi_beacon(const struct wpa_bss *bss,
|
|
|
|
u32 vendor_type);
|
2009-12-27 18:09:32 -05:00
|
|
|
int wpa_bss_get_max_rate(const struct wpa_bss *bss);
|
2010-01-04 09:52:30 -05:00
|
|
|
int wpa_bss_get_bit_rates(const struct wpa_bss *bss, u8 **rates);
|
2012-09-04 09:02:29 -04:00
|
|
|
struct wpa_bss_anqp * wpa_bss_anqp_alloc(void);
|
2012-10-03 07:17:41 -04:00
|
|
|
int wpa_bss_anqp_unshare_alloc(struct wpa_bss *bss);
|
2020-11-16 08:52:22 -05:00
|
|
|
const u8 * wpa_bss_get_fils_cache_id(const struct wpa_bss *bss);
|
2019-01-02 10:56:41 -05:00
|
|
|
int wpa_bss_ext_capab(const struct wpa_bss *bss, unsigned int capab);
|
2009-12-27 14:07:47 -05:00
|
|
|
|
2014-05-12 03:35:41 -04:00
|
|
|
static inline int bss_is_dmg(const struct wpa_bss *bss)
|
|
|
|
{
|
|
|
|
return bss->freq > 45000;
|
|
|
|
}
|
|
|
|
|
2016-02-08 05:30:04 -05: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-17 21:35:15 -05:00
|
|
|
static inline void wpa_bss_update_level(struct wpa_bss *bss, int new_level)
|
|
|
|
{
|
|
|
|
if (bss != NULL && new_level < 0)
|
|
|
|
bss->level = new_level;
|
|
|
|
}
|
|
|
|
|
2017-01-02 16:04:02 -05:00
|
|
|
void calculate_update_time(const struct os_reltime *fetch_time,
|
|
|
|
unsigned int age_ms,
|
|
|
|
struct os_reltime *update_time);
|
|
|
|
|
2009-12-27 14:07:47 -05:00
|
|
|
#endif /* BSS_H */
|