aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/bgscan.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-09-14 21:08:24 (GMT)
committerJouni Malinen <j@w1.fi>2009-09-14 21:08:24 (GMT)
commit60b94c9819199c0427e623080ebae27fe44be6b5 (patch)
tree6f8ccef606126a46a2097fdd42b2a9b81601c1cf /wpa_supplicant/bgscan.c
parent3180d7a2088fdd429c2eb9ae74abfa96e6a9b9b0 (diff)
downloadhostap-60b94c9819199c0427e623080ebae27fe44be6b5.zip
hostap-60b94c9819199c0427e623080ebae27fe44be6b5.tar.gz
hostap-60b94c9819199c0427e623080ebae27fe44be6b5.tar.bz2
Add preliminary background scan and roaming module design
This allows background scanning and roaming decisions to be contained in a single place based on a defined set of notification events which will hopefully make it easier to experiment with roaming improvements. In addition, this allows multiple intra-ESS roaming policies to be used (each network configuration block can configure its own bgscan module). The beacon loss and signal strength notifications are implemented for the bgscan API, but the actual events are not yet available from the driver. The included sample bgscan module ("simple") is an example of what can be done with the new bgscan mechanism. It requests periodic background scans when the device remains associated with an ESS and has couple of notes on what a more advanced bgscan module could do to optimize background scanning and roaming. The periodic scans will cause the scan result handler to pick a better AP if one becomes available. This bgscan module can be taken into use by adding bgscan="simple" (or bgscan="simple:<bgscan interval in seconds>") into the network configuration block.
Diffstat (limited to 'wpa_supplicant/bgscan.c')
-rw-r--r--wpa_supplicant/bgscan.c110
1 files changed, 110 insertions, 0 deletions
diff --git a/wpa_supplicant/bgscan.c b/wpa_supplicant/bgscan.c
new file mode 100644
index 0000000..60dcd0d
--- /dev/null
+++ b/wpa_supplicant/bgscan.c
@@ -0,0 +1,110 @@
+/*
+ * WPA Supplicant - background scan and roaming interface
+ * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+#include "includes.h"
+
+#include "common.h"
+#include "wpa_supplicant_i.h"
+#include "config_ssid.h"
+#include "bgscan.h"
+
+#ifdef CONFIG_BGSCAN_SIMPLE
+extern const struct bgscan_ops bgscan_simple_ops;
+#endif /* CONFIG_BGSCAN_SIMPLE */
+
+static const struct bgscan_ops * bgscan_modules[] = {
+#ifdef CONFIG_BGSCAN_SIMPLE
+ &bgscan_simple_ops,
+#endif /* CONFIG_BGSCAN_SIMPLE */
+ NULL
+};
+
+
+int bgscan_init(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
+{
+ const char *name = ssid->bgscan;
+ const char *params;
+ size_t nlen;
+ int i;
+ const struct bgscan_ops *ops = NULL;
+
+ bgscan_deinit(wpa_s);
+ if (name == NULL)
+ return 0;
+
+ params = os_strchr(name, ':');
+ if (params == NULL) {
+ params = "";
+ nlen = os_strlen(name);
+ } else {
+ nlen = params - name;
+ params++;
+ }
+
+ for (i = 0; bgscan_modules[i]; i++) {
+ if (os_strncmp(name, bgscan_modules[i]->name, nlen) == 0) {
+ ops = bgscan_modules[i];
+ break;
+ }
+ }
+
+ if (ops == NULL) {
+ wpa_printf(MSG_ERROR, "bgscan: Could not find module "
+ "matching the parameter '%s'", name);
+ return -1;
+ }
+
+ wpa_s->bgscan_priv = ops->init(wpa_s, params, ssid);
+ if (wpa_s->bgscan_priv == NULL)
+ return -1;
+ wpa_s->bgscan = ops;
+ wpa_printf(MSG_DEBUG, "bgscan: Initialized module '%s' with "
+ "parameters '%s'", ops->name, params);
+
+ return 0;
+}
+
+
+void bgscan_deinit(struct wpa_supplicant *wpa_s)
+{
+ if (wpa_s->bgscan && wpa_s->bgscan_priv) {
+ wpa_printf(MSG_DEBUG, "bgscan: Deinitializing module '%s'",
+ wpa_s->bgscan->name);
+ wpa_s->bgscan->deinit(wpa_s->bgscan_priv);
+ wpa_s->bgscan = NULL;
+ wpa_s->bgscan_priv = NULL;
+ }
+}
+
+
+int bgscan_notify_scan(struct wpa_supplicant *wpa_s)
+{
+ if (wpa_s->bgscan && wpa_s->bgscan_priv)
+ return wpa_s->bgscan->notify_scan(wpa_s->bgscan_priv);
+ return 0;
+}
+
+
+void bgscan_notify_beacon_loss(struct wpa_supplicant *wpa_s)
+{
+ if (wpa_s->bgscan && wpa_s->bgscan_priv)
+ wpa_s->bgscan->notify_beacon_loss(wpa_s->bgscan_priv);
+}
+
+
+void bgscan_notify_signal_change(struct wpa_supplicant *wpa_s)
+{
+ if (wpa_s->bgscan && wpa_s->bgscan_priv)
+ wpa_s->bgscan->notify_signal_change(wpa_s->bgscan_priv);
+}