[PATCH] bgscan: Add global bgscan configuration
Ilan Peer
ilan.peer
Sun Nov 3 05:19:59 PST 2013
From: Haim Dreyfuss <haim.dreyfuss at intel.com>
This option can be used to globally configure bgscan paramerters
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 at intel.com>
---
wpa_supplicant/bgscan.c | 6 +++---
wpa_supplicant/bgscan.h | 5 +++--
wpa_supplicant/config.c | 16 ++++++++++++++++
wpa_supplicant/config.h | 11 +++++++++++
wpa_supplicant/wpa_supplicant.c | 8 ++++++--
wpa_supplicant/wpa_supplicant.conf | 5 +++++
6 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/wpa_supplicant/bgscan.c b/wpa_supplicant/bgscan.c
index 9a9bd52..f74cdbf 100644
--- a/wpa_supplicant/bgscan.c
+++ b/wpa_supplicant/bgscan.c
@@ -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;
size_t nlen;
int i;
@@ -41,7 +41,7 @@ int bgscan_init(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
bgscan_deinit(wpa_s);
if (name == NULL)
- return 0;
+ return -1;
params = os_strchr(name, ':');
if (params == NULL) {
diff --git a/wpa_supplicant/bgscan.h b/wpa_supplicant/bgscan.h
index e9d15fc..9131e4e 100644
--- a/wpa_supplicant/bgscan.h
+++ b/wpa_supplicant/bgscan.h
@@ -29,7 +29,8 @@ struct bgscan_ops {
#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);
int bgscan_notify_scan(struct wpa_supplicant *wpa_s,
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 */
static inline int bgscan_init(struct wpa_supplicant *wpa_s,
- struct wpa_ssid *ssid)
+ struct wpa_ssid *ssid, const char name)
{
return 0;
}
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 08d2ecd..3494297 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -2846,7 +2846,22 @@ static int wpa_global_config_parse_str(const struct global_parse_data *data,
return 0;
}
+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,
struct wpa_config *config, int line,
@@ -3209,6 +3224,7 @@ static const struct global_parse_data global_fields[] = {
#endif /* CONFIG_CTRL_IFACE */
{ INT_RANGE(eapol_version, 1, 2), 0 },
{ INT(ap_scan), 0 },
+ { FUNC(bgscan), 0 },
{ INT(disable_scan_offload), 0 },
{ INT(fast_reauth), 0 },
{ STR(opensc_engine_path), 0 },
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index 8cbeb62..4dfc9be 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -329,6 +329,17 @@ struct wpa_config {
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
*
* By default, %wpa_supplicant tries to offload scanning if the driver
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 255c712..3301b14 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -570,14 +570,18 @@ const char * wpa_supplicant_state_txt(enum wpa_states state)
static void wpa_supplicant_start_bgscan(struct wpa_supplicant *wpa_s)
{
+ const char *name = wpa_s->current_ssid->bgscan ?
+ wpa_s->current_ssid->bgscan : wpa_s->conf->bgscan;
+ if (name == NULL)
+ return;
if (wpas_driver_bss_selection(wpa_s))
return;
if (wpa_s->current_ssid == wpa_s->bgscan_ssid)
return;
bgscan_deinit(wpa_s);
- if (wpa_s->current_ssid && wpa_s->current_ssid->bgscan) {
- if (bgscan_init(wpa_s, wpa_s->current_ssid)) {
+ if (wpa_s->current_ssid) {
+ if (bgscan_init(wpa_s, wpa_s->current_ssid, name)) {
wpa_dbg(wpa_s, MSG_DEBUG, "Failed to initialize "
"bgscan");
/*
diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf
index 6414f44..9ca6908 100644
--- a/wpa_supplicant/wpa_supplicant.conf
+++ b/wpa_supplicant/wpa_supplicant.conf
@@ -549,6 +549,11 @@ fast_reauth=1
# bgscan="learn:<short bgscan interval in seconds>:<signal strength threshold>:
# <long interval>[:<database file name>]"
# bgscan="learn:30:-45:300:/etc/wpa_supplicant/network1.bgscan"
+# note this option can also be set outside of all network blocks, in this case
+# the bgscan parameters will apply for all the natwork who have no valid
+# bgscan parameters.
+#
+#
#
# proto: list of accepted protocols
# WPA = WPA/IEEE 802.11i/D3.0
--
1.7.10.4
More information about the Hostap
mailing list