wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions
bss.c File Reference

BSS table. More...

#include "utils/includes.h"
#include "utils/common.h"
#include "utils/eloop.h"
#include "common/ieee802_11_defs.h"
#include "drivers/driver.h"
#include "wpa_supplicant_i.h"
#include "config.h"
#include "notify.h"
#include "scan.h"
#include "bss.h"

Macros

#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)
 
#define ANQP_DUP(f)   if (anqp->f) n->f = wpabuf_dup(anqp->f)
 

Functions

struct wpa_bss_anqpwpa_bss_anqp_alloc (void)
 Allocate ANQP data structure for a BSS entry. More...
 
int wpa_bss_anqp_unshare_alloc (struct wpa_bss *bss)
 Unshare ANQP data (if shared) in a BSS entry. More...
 
struct wpa_bsswpa_bss_get (struct wpa_supplicant *wpa_s, const u8 *bssid, const u8 *ssid, size_t ssid_len)
 Fetch a BSS table entry based on BSSID and SSID. More...
 
void wpa_bss_update_start (struct wpa_supplicant *wpa_s)
 Start a BSS table update from scan results. More...
 
void wpa_bss_update_scan_res (struct wpa_supplicant *wpa_s, struct wpa_scan_res *res, struct os_reltime *fetch_time)
 Update a BSS table entry based on a scan result. More...
 
void wpa_bss_update_end (struct wpa_supplicant *wpa_s, struct scan_info *info, int new_scan)
 End a BSS table update from scan results. More...
 
void wpa_bss_flush_by_age (struct wpa_supplicant *wpa_s, int age)
 Flush old BSS entries. More...
 
int wpa_bss_init (struct wpa_supplicant *wpa_s)
 Initialize BSS table. More...
 
void wpa_bss_flush (struct wpa_supplicant *wpa_s)
 Flush all unused BSS entries. More...
 
void wpa_bss_deinit (struct wpa_supplicant *wpa_s)
 Deinitialize BSS table. More...
 
struct wpa_bsswpa_bss_get_bssid (struct wpa_supplicant *wpa_s, const u8 *bssid)
 Fetch a BSS table entry based on BSSID. More...
 
struct wpa_bsswpa_bss_get_bssid_latest (struct wpa_supplicant *wpa_s, const u8 *bssid)
 Fetch the latest BSS table entry based on BSSID. More...
 
struct wpa_bsswpa_bss_get_p2p_dev_addr (struct wpa_supplicant *wpa_s, const u8 *dev_addr)
 Fetch a BSS table entry based on P2P Device Addr. More...
 
struct wpa_bsswpa_bss_get_id (struct wpa_supplicant *wpa_s, unsigned int id)
 Fetch a BSS table entry based on identifier. More...
 
struct wpa_bsswpa_bss_get_id_range (struct wpa_supplicant *wpa_s, unsigned int idf, unsigned int idl)
 Fetch a BSS table entry based on identifier range. More...
 
const u8 * wpa_bss_get_ie (const struct wpa_bss *bss, u8 ie)
 Fetch a specified information element from a BSS entry. More...
 
const u8 * wpa_bss_get_vendor_ie (const struct wpa_bss *bss, u32 vendor_type)
 Fetch a vendor information element from a BSS entry. More...
 
const u8 * wpa_bss_get_vendor_ie_beacon (const struct wpa_bss *bss, u32 vendor_type)
 Fetch a vendor information from a BSS entry. More...
 
struct wpabufwpa_bss_get_vendor_ie_multi (const struct wpa_bss *bss, u32 vendor_type)
 Fetch vendor IE data from a BSS entry. More...
 
struct wpabufwpa_bss_get_vendor_ie_multi_beacon (const struct wpa_bss *bss, u32 vendor_type)
 Fetch vendor IE data from a BSS entry. More...
 
int wpa_bss_get_max_rate (const struct wpa_bss *bss)
 Get maximum legacy TX rate supported in a BSS. More...
 
int wpa_bss_get_bit_rates (const struct wpa_bss *bss, u8 **rates)
 Get legacy TX rates supported in a BSS. More...
 

Detailed Description

BSS table.

Function Documentation

struct wpa_bss_anqp* wpa_bss_anqp_alloc ( void  )

Allocate ANQP data structure for a BSS entry.

Returns
Allocated ANQP data structure or NULL on failure

The allocated ANQP data structure has its users count set to 1. It may be shared by multiple BSS entries and each shared entry is freed with wpa_bss_anqp_free().

int wpa_bss_anqp_unshare_alloc ( struct wpa_bss bss)

Unshare ANQP data (if shared) in a BSS entry.

Parameters
bssBSS entry
Returns
0 on success, -1 on failure

This function ensures the specific BSS entry has an ANQP data structure that is not shared with any other BSS entry.

void wpa_bss_deinit ( struct wpa_supplicant wpa_s)

Deinitialize BSS table.

Parameters
wpa_sPointer to wpa_supplicant data
void wpa_bss_flush ( struct wpa_supplicant wpa_s)

Flush all unused BSS entries.

Parameters
wpa_sPointer to wpa_supplicant data
void wpa_bss_flush_by_age ( struct wpa_supplicant wpa_s,
int  age 
)

Flush old BSS entries.

Parameters
wpa_sPointer to wpa_supplicant data
ageMaximum entry age in seconds

Remove BSS entries that have not been updated during the last age seconds.

struct wpa_bss* wpa_bss_get ( struct wpa_supplicant wpa_s,
const u8 *  bssid,
const u8 *  ssid,
size_t  ssid_len 
)

Fetch a BSS table entry based on BSSID and SSID.

Parameters
wpa_sPointer to wpa_supplicant data
bssidBSSID
ssidSSID
ssid_lenLength of ssid
Returns
Pointer to the BSS entry or NULL if not found
int wpa_bss_get_bit_rates ( const struct wpa_bss bss,
u8 **  rates 
)

Get legacy TX rates supported in a BSS.

Parameters
bssBSS table entry
ratesBuffer for returning a pointer to the rates list (units of 500 kbps)
Returns
number of legacy TX rates or -1 on failure

The caller is responsible for freeing the returned buffer with os_free() in case of success.

struct wpa_bss* wpa_bss_get_bssid ( struct wpa_supplicant wpa_s,
const u8 *  bssid 
)

Fetch a BSS table entry based on BSSID.

Parameters
wpa_sPointer to wpa_supplicant data
bssidBSSID
Returns
Pointer to the BSS entry or NULL if not found
struct wpa_bss* wpa_bss_get_bssid_latest ( struct wpa_supplicant wpa_s,
const u8 *  bssid 
)

Fetch the latest BSS table entry based on BSSID.

Parameters
wpa_sPointer to wpa_supplicant data
bssidBSSID
Returns
Pointer to the BSS entry or NULL if not found

This function is like wpa_bss_get_bssid(), but full BSS table is iterated to find the entry that has the most recent update. This can help in finding the correct entry in cases where the SSID of the AP may have changed recently (e.g., in WPS reconfiguration cases).

struct wpa_bss* wpa_bss_get_id ( struct wpa_supplicant wpa_s,
unsigned int  id 
)

Fetch a BSS table entry based on identifier.

Parameters
wpa_sPointer to wpa_supplicant data
idUnique identifier (struct wpa_bss::id) assigned for the entry
Returns
Pointer to the BSS entry or NULL if not found
struct wpa_bss* wpa_bss_get_id_range ( struct wpa_supplicant wpa_s,
unsigned int  idf,
unsigned int  idl 
)

Fetch a BSS table entry based on identifier range.

Parameters
wpa_sPointer to wpa_supplicant data
idfSmallest allowed identifier assigned for the entry
idfLargest allowed identifier assigned for the entry
Returns
Pointer to the BSS entry or NULL if not found

This function is similar to wpa_bss_get_id() but allows a BSS entry with the smallest id value to be fetched within the specified range without the caller having to know the exact id.

const u8* wpa_bss_get_ie ( const struct wpa_bss bss,
u8  ie 
)

Fetch a specified information element from a BSS entry.

Parameters
bssBSS table entry
ieInformation element identitifier (WLAN_EID_*)
Returns
Pointer to the information element (id field) or NULL if not found

This function returns the first matching information element in the BSS entry.

int wpa_bss_get_max_rate ( const struct wpa_bss bss)

Get maximum legacy TX rate supported in a BSS.

Parameters
bssBSS table entry
Returns
Maximum legacy rate in units of 500 kbps
struct wpa_bss* wpa_bss_get_p2p_dev_addr ( struct wpa_supplicant wpa_s,
const u8 *  dev_addr 
)

Fetch a BSS table entry based on P2P Device Addr.

Parameters
wpa_sPointer to wpa_supplicant data
dev_addrP2P Device Address of the GO
Returns
Pointer to the BSS entry or NULL if not found
const u8* wpa_bss_get_vendor_ie ( const struct wpa_bss bss,
u32  vendor_type 
)

Fetch a vendor information element from a BSS entry.

Parameters
bssBSS table entry
vendor_typeVendor type (four octets starting the IE payload)
Returns
Pointer to the information element (id field) or NULL if not found

This function returns the first matching information element in the BSS entry.

const u8* wpa_bss_get_vendor_ie_beacon ( const struct wpa_bss bss,
u32  vendor_type 
)

Fetch a vendor information from a BSS entry.

Parameters
bssBSS table entry
vendor_typeVendor type (four octets starting the IE payload)
Returns
Pointer to the information element (id field) or NULL if not found

This function returns the first matching information element in the BSS entry.

This function is like wpa_bss_get_vendor_ie(), but uses IE buffer only from Beacon frames instead of either Beacon or Probe Response frames.

struct wpabuf* wpa_bss_get_vendor_ie_multi ( const struct wpa_bss bss,
u32  vendor_type 
)

Fetch vendor IE data from a BSS entry.

Parameters
bssBSS table entry
vendor_typeVendor type (four octets starting the IE payload)
Returns
Pointer to the information element payload or NULL if not found

This function returns concatenated payload of possibly fragmented vendor specific information elements in the BSS entry. The caller is responsible for freeing the returned buffer.

struct wpabuf* wpa_bss_get_vendor_ie_multi_beacon ( const struct wpa_bss bss,
u32  vendor_type 
)

Fetch vendor IE data from a BSS entry.

Parameters
bssBSS table entry
vendor_typeVendor type (four octets starting the IE payload)
Returns
Pointer to the information element payload or NULL if not found

This function returns concatenated payload of possibly fragmented vendor specific information elements in the BSS entry. The caller is responsible for freeing the returned buffer.

This function is like wpa_bss_get_vendor_ie_multi(), but uses IE buffer only from Beacon frames instead of either Beacon or Probe Response frames.

int wpa_bss_init ( struct wpa_supplicant wpa_s)

Initialize BSS table.

Parameters
wpa_sPointer to wpa_supplicant data
Returns
0 on success, -1 on failure

This prepares BSS table lists and timer for periodic updates. The BSS table is deinitialized with wpa_bss_deinit() once not needed anymore.

void wpa_bss_update_end ( struct wpa_supplicant wpa_s,
struct scan_info *  info,
int  new_scan 
)

End a BSS table update from scan results.

Parameters
wpa_sPointer to wpa_supplicant data
infoInformation about scan parameters
new_scanWhether this update round was based on a new scan

This function is called at the end of each BSS table update round for new scan results. The start of the update was indicated with a call to wpa_bss_update_start().

void wpa_bss_update_scan_res ( struct wpa_supplicant wpa_s,
struct wpa_scan_res res,
struct os_reltime fetch_time 
)

Update a BSS table entry based on a scan result.

Parameters
wpa_sPointer to wpa_supplicant data
resScan result
fetch_timeTime when the result was fetched from the driver

This function updates a BSS table entry (or adds one) based on a scan result. This is called separately for each scan result between the calls to wpa_bss_update_start() and wpa_bss_update_end().

void wpa_bss_update_start ( struct wpa_supplicant wpa_s)

Start a BSS table update from scan results.

Parameters
wpa_sPointer to wpa_supplicant data

This function is called at the start of each BSS table update round for new scan results. The actual scan result entries are indicated with calls to wpa_bss_update_scan_res() and the update round is finished with a call to wpa_bss_update_end().