bgscan: Add global bgscan configuration

This option can be used to globally configure bgscan parameters
for all the network blocks.

Note that this configuration will not override a network block
specific bgscan settings, but will only be used in case that
the network block does not have a valid bgscan configuration.

Signed-hostap: Haim Dreyfuss <haim.dreyfuss@intel.com>
This commit is contained in:
Haim Dreyfuss 2013-11-03 15:19:59 +02:00 committed by Jouni Malinen
parent 5061a301e5
commit 3139270903
6 changed files with 51 additions and 7 deletions

View file

@ -31,9 +31,9 @@ static const struct bgscan_ops * bgscan_modules[] = {
}; };
int bgscan_init(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) int bgscan_init(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
const char *name)
{ {
const char *name = ssid->bgscan;
const char *params; const char *params;
size_t nlen; size_t nlen;
int i; int i;
@ -41,7 +41,7 @@ int bgscan_init(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
bgscan_deinit(wpa_s); bgscan_deinit(wpa_s);
if (name == NULL) if (name == NULL)
return 0; return -1;
params = os_strchr(name, ':'); params = os_strchr(name, ':');
if (params == NULL) { if (params == NULL) {

View file

@ -29,7 +29,8 @@ struct bgscan_ops {
#ifdef CONFIG_BGSCAN #ifdef CONFIG_BGSCAN
int bgscan_init(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); int bgscan_init(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
const char *name);
void bgscan_deinit(struct wpa_supplicant *wpa_s); void bgscan_deinit(struct wpa_supplicant *wpa_s);
int bgscan_notify_scan(struct wpa_supplicant *wpa_s, int bgscan_notify_scan(struct wpa_supplicant *wpa_s,
struct wpa_scan_results *scan_res); struct wpa_scan_results *scan_res);
@ -41,7 +42,7 @@ void bgscan_notify_signal_change(struct wpa_supplicant *wpa_s, int above,
#else /* CONFIG_BGSCAN */ #else /* CONFIG_BGSCAN */
static inline int bgscan_init(struct wpa_supplicant *wpa_s, static inline int bgscan_init(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid) struct wpa_ssid *ssid, const char name)
{ {
return 0; return 0;
} }

View file

@ -2848,6 +2848,24 @@ static int wpa_global_config_parse_str(const struct global_parse_data *data,
} }
static int wpa_config_process_bgscan(const struct global_parse_data *data,
struct wpa_config *config, int line,
const char *pos)
{
size_t len;
char *tmp;
tmp = wpa_config_parse_string(pos, &len);
if (tmp == NULL) {
wpa_printf(MSG_ERROR, "Line %d: failed to parse %s",
line, data->name);
return -1;
}
return wpa_global_config_parse_str(data, config, line, tmp);
}
static int wpa_global_config_parse_bin(const struct global_parse_data *data, static int wpa_global_config_parse_bin(const struct global_parse_data *data,
struct wpa_config *config, int line, struct wpa_config *config, int line,
const char *pos) const char *pos)
@ -3209,6 +3227,7 @@ static const struct global_parse_data global_fields[] = {
#endif /* CONFIG_CTRL_IFACE */ #endif /* CONFIG_CTRL_IFACE */
{ INT_RANGE(eapol_version, 1, 2), 0 }, { INT_RANGE(eapol_version, 1, 2), 0 },
{ INT(ap_scan), 0 }, { INT(ap_scan), 0 },
{ FUNC(bgscan), 0 },
{ INT(disable_scan_offload), 0 }, { INT(disable_scan_offload), 0 },
{ INT(fast_reauth), 0 }, { INT(fast_reauth), 0 },
{ STR(opensc_engine_path), 0 }, { STR(opensc_engine_path), 0 },

View file

@ -328,6 +328,18 @@ struct wpa_config {
*/ */
int ap_scan; int ap_scan;
/**
* bgscan - Background scan and roaming parameters or %NULL if none
*
* This is an optional set of parameters for background scanning and
* roaming within a network (ESS). For more detailed information see
* ssid block documentation.
*
* The variable defines default bgscan behavior for all BSS station
* networks except for those which have their own bgscan configuration.
*/
char *bgscan;
/** /**
* disable_scan_offload - Disable automatic offloading of scan requests * disable_scan_offload - Disable automatic offloading of scan requests
* *

View file

@ -570,14 +570,22 @@ const char * wpa_supplicant_state_txt(enum wpa_states state)
static void wpa_supplicant_start_bgscan(struct wpa_supplicant *wpa_s) static void wpa_supplicant_start_bgscan(struct wpa_supplicant *wpa_s)
{ {
const char *name;
if (wpa_s->current_ssid && wpa_s->current_ssid->bgscan)
name = wpa_s->current_ssid->bgscan;
else
name = wpa_s->conf->bgscan;
if (name == NULL)
return;
if (wpas_driver_bss_selection(wpa_s)) if (wpas_driver_bss_selection(wpa_s))
return; return;
if (wpa_s->current_ssid == wpa_s->bgscan_ssid) if (wpa_s->current_ssid == wpa_s->bgscan_ssid)
return; return;
bgscan_deinit(wpa_s); bgscan_deinit(wpa_s);
if (wpa_s->current_ssid && wpa_s->current_ssid->bgscan) { if (wpa_s->current_ssid) {
if (bgscan_init(wpa_s, wpa_s->current_ssid)) { if (bgscan_init(wpa_s, wpa_s->current_ssid, name)) {
wpa_dbg(wpa_s, MSG_DEBUG, "Failed to initialize " wpa_dbg(wpa_s, MSG_DEBUG, "Failed to initialize "
"bgscan"); "bgscan");
/* /*

View file

@ -550,6 +550,10 @@ fast_reauth=1
# <long interval>[:<database file name>]" # <long interval>[:<database file name>]"
# bgscan="learn:30:-45:300:/etc/wpa_supplicant/network1.bgscan" # bgscan="learn:30:-45:300:/etc/wpa_supplicant/network1.bgscan"
# #
# This option can also be set outside of all network blocks for the bgscan
# parameter to apply for all the networks that have no specific bgscan
# parameter.
#
# proto: list of accepted protocols # proto: list of accepted protocols
# WPA = WPA/IEEE 802.11i/D3.0 # WPA = WPA/IEEE 802.11i/D3.0
# RSN = WPA2/IEEE 802.11i (also WPA2 can be used as an alias for RSN) # RSN = WPA2/IEEE 802.11i (also WPA2 can be used as an alias for RSN)