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

WPA Supplicant - Scanning. More...

#include "utils/includes.h"
#include "utils/common.h"
#include "utils/eloop.h"
#include "common/ieee802_11_defs.h"
#include "common/wpa_ctrl.h"
#include "config.h"
#include "wpa_supplicant_i.h"
#include "driver_i.h"
#include "wps_supplicant.h"
#include "p2p_supplicant.h"
#include "p2p/p2p.h"
#include "hs20_supplicant.h"
#include "notify.h"
#include "bss.h"
#include "scan.h"
#include "mesh.h"

Macros

#define GREAT_SNR   30
 
#define IS_5GHZ(n)   (n > 4000)
 
#define MIN(a, b)   a < b ? a : b
 
#define DEFAULT_NOISE_FLOOR_2GHZ   (-89)
 
#define DEFAULT_NOISE_FLOOR_5GHZ   (-92)
 

Functions

int wpa_supplicant_enabled_networks (struct wpa_supplicant *wpa_s)
 Check whether there are enabled networks. More...
 
int wpa_supplicant_trigger_scan (struct wpa_supplicant *wpa_s, struct wpa_driver_scan_params *params)
 Request driver to start a scan. More...
 
int wpa_supplicant_start_sched_scan (struct wpa_supplicant *wpa_s, struct wpa_driver_scan_params *params, int interval)
 
int wpa_supplicant_stop_sched_scan (struct wpa_supplicant *wpa_s)
 
void wpa_supplicant_update_scan_int (struct wpa_supplicant *wpa_s, int sec)
 
void wpa_supplicant_req_scan (struct wpa_supplicant *wpa_s, int sec, int usec)
 Schedule a scan for neighboring access points. More...
 
int wpa_supplicant_delayed_sched_scan (struct wpa_supplicant *wpa_s, int sec, int usec)
 Request a delayed scheduled scan. More...
 
int wpa_supplicant_req_sched_scan (struct wpa_supplicant *wpa_s)
 Start a periodic scheduled scan. More...
 
void wpa_supplicant_cancel_scan (struct wpa_supplicant *wpa_s)
 Cancel a scheduled scan request. More...
 
void wpa_supplicant_cancel_delayed_sched_scan (struct wpa_supplicant *wpa_s)
 Stop a delayed scheduled scan. More...
 
void wpa_supplicant_cancel_sched_scan (struct wpa_supplicant *wpa_s)
 Stop running scheduled scans. More...
 
void wpa_supplicant_notify_scanning (struct wpa_supplicant *wpa_s, int scanning)
 Indicate possible scan state change. More...
 
const u8 * wpa_scan_get_ie (const struct wpa_scan_res *res, u8 ie)
 Fetch a specified information element from a scan result. More...
 
const u8 * wpa_scan_get_vendor_ie (const struct wpa_scan_res *res, u32 vendor_type)
 Fetch vendor information element from a scan result. More...
 
const u8 * wpa_scan_get_vendor_ie_beacon (const struct wpa_scan_res *res, u32 vendor_type)
 Fetch vendor information from a scan result. More...
 
struct wpabufwpa_scan_get_vendor_ie_multi (const struct wpa_scan_res *res, u32 vendor_type)
 Fetch vendor IE data from a scan result. More...
 
int wpa_supplicant_filter_bssid_match (struct wpa_supplicant *wpa_s, const u8 *bssid)
 Is the specified BSSID allowed. More...
 
struct wpa_scan_resultswpa_supplicant_get_scan_results (struct wpa_supplicant *wpa_s, struct scan_info *info, int new_scan)
 Get scan results. More...
 
int wpa_supplicant_update_scan_results (struct wpa_supplicant *wpa_s)
 Update scan results from the driver. More...
 
void scan_only_handler (struct wpa_supplicant *wpa_s, struct wpa_scan_results *scan_res)
 Reports scan results.
 
int wpas_scan_scheduled (struct wpa_supplicant *wpa_s)
 
struct wpa_driver_scan_paramswpa_scan_clone_params (const struct wpa_driver_scan_params *src)
 
void wpa_scan_free_params (struct wpa_driver_scan_params *params)
 
int wpas_start_pno (struct wpa_supplicant *wpa_s)
 
int wpas_stop_pno (struct wpa_supplicant *wpa_s)
 
void wpas_mac_addr_rand_scan_clear (struct wpa_supplicant *wpa_s, unsigned int type)
 
int wpas_mac_addr_rand_scan_set (struct wpa_supplicant *wpa_s, unsigned int type, const u8 *addr, const u8 *mask)
 

Detailed Description

WPA Supplicant - Scanning.

Function Documentation

const u8* wpa_scan_get_ie ( const struct wpa_scan_res res,
u8  ie 
)

Fetch a specified information element from a scan result.

Parameters
resScan result 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 scan result.

const u8* wpa_scan_get_vendor_ie ( const struct wpa_scan_res res,
u32  vendor_type 
)

Fetch vendor information element from a scan result.

Parameters
resScan result 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 scan result.

const u8* wpa_scan_get_vendor_ie_beacon ( const struct wpa_scan_res res,
u32  vendor_type 
)

Fetch vendor information from a scan result.

Parameters
resScan result 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 scan result.

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

struct wpabuf* wpa_scan_get_vendor_ie_multi ( const struct wpa_scan_res res,
u32  vendor_type 
)

Fetch vendor IE data from a scan result.

Parameters
resScan result 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 scan result. The caller is responsible for freeing the returned buffer.

void wpa_supplicant_cancel_delayed_sched_scan ( struct wpa_supplicant wpa_s)

Stop a delayed scheduled scan.

Parameters
wpa_sPointer to wpa_supplicant data

This function is used to stop a delayed scheduled scan.

void wpa_supplicant_cancel_scan ( struct wpa_supplicant wpa_s)

Cancel a scheduled scan request.

Parameters
wpa_sPointer to wpa_supplicant data

This function is used to cancel a scan request scheduled with wpa_supplicant_req_scan().

void wpa_supplicant_cancel_sched_scan ( struct wpa_supplicant wpa_s)

Stop running scheduled scans.

Parameters
wpa_sPointer to wpa_supplicant data

This function is used to stop a periodic scheduled scan.

int wpa_supplicant_delayed_sched_scan ( struct wpa_supplicant wpa_s,
int  sec,
int  usec 
)

Request a delayed scheduled scan.

Parameters
wpa_sPointer to wpa_supplicant data
secNumber of seconds after which to scan
usecNumber of microseconds after which to scan
Returns
0 on success or -1 otherwise

This function is used to schedule periodic scans for neighboring access points after the specified time.

int wpa_supplicant_enabled_networks ( struct wpa_supplicant wpa_s)

Check whether there are enabled networks.

Parameters
wpa_sPointer to wpa_supplicant data
Returns
0 if no networks are enabled, >0 if networks are enabled

This function is used to figure out whether any networks (or Interworking with enabled credentials and auto_interworking) are present in the current configuration.

int wpa_supplicant_filter_bssid_match ( struct wpa_supplicant wpa_s,
const u8 *  bssid 
)

Is the specified BSSID allowed.

Parameters
wpa_sPointer to wpa_supplicant data
bssidBSSID to check
Returns
0 if the BSSID is filtered or 1 if not

This function is used to filter out specific BSSIDs from scan reslts mainly for testing purposes (SET bssid_filter ctrl_iface command).

struct wpa_scan_results* wpa_supplicant_get_scan_results ( struct wpa_supplicant wpa_s,
struct scan_info *  info,
int  new_scan 
)

Get scan results.

Parameters
wpa_sPointer to wpa_supplicant data
infoInformation about what was scanned or NULL if not available
new_scanWhether a new scan was performed
Returns
Scan results, NULL on failure

This function request the current scan results from the driver and updates the local BSS list wpa_s->bss. The caller is responsible for freeing the results with wpa_scan_results_free().

void wpa_supplicant_notify_scanning ( struct wpa_supplicant wpa_s,
int  scanning 
)

Indicate possible scan state change.

Parameters
wpa_sPointer to wpa_supplicant data
scanningWhether scanning is currently in progress

This function is to generate scanning notifycations. It is called whenever there may have been a change in scanning (scan started, completed, stopped). wpas_notify_scanning() is called whenever the scanning state changed from the previously notified state.

void wpa_supplicant_req_scan ( struct wpa_supplicant wpa_s,
int  sec,
int  usec 
)

Schedule a scan for neighboring access points.

Parameters
wpa_sPointer to wpa_supplicant data
secNumber of seconds after which to scan
usecNumber of microseconds after which to scan

This function is used to schedule a scan for neighboring access points after the specified time.

int wpa_supplicant_req_sched_scan ( struct wpa_supplicant wpa_s)

Start a periodic scheduled scan.

Parameters
wpa_sPointer to wpa_supplicant data
Returns
0 is sched_scan was started or -1 otherwise

This function is used to schedule periodic scans for neighboring access points repeating the scan continuously.

int wpa_supplicant_trigger_scan ( struct wpa_supplicant wpa_s,
struct wpa_driver_scan_params params 
)

Request driver to start a scan.

Parameters
wpa_sPointer to wpa_supplicant data
paramsScan parameters
Returns
0 on success, -1 on failure
int wpa_supplicant_update_scan_results ( struct wpa_supplicant wpa_s)

Update scan results from the driver.

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

This function updates the BSS table within wpa_supplicant based on the currently available scan results from the driver without requesting a new scan. This is used in cases where the driver indicates an association (including roaming within ESS) and wpa_supplicant does not yet have the needed information to complete the connection (e.g., to perform validation steps in 4-way handshake).