]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add a simple periodic autoscan module
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Tue, 26 Jun 2012 16:28:21 +0000 (19:28 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 26 Jun 2012 16:28:21 +0000 (19:28 +0300)
This module will sets a fixed scanning interval. Thus, the parameter to
this module is following this format: <fixed interval>

Signed-hostap: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>

wpa_supplicant/Android.mk
wpa_supplicant/Makefile
wpa_supplicant/autoscan.c
wpa_supplicant/autoscan_periodic.c [new file with mode: 0644]
wpa_supplicant/defconfig
wpa_supplicant/wpa_supplicant.conf

index 97affc18e0f021eb55230d64b5448e77e8d2f19b..0666f4d1e8cedc67a0453ef42dc26bfc1eae27c2 100644 (file)
@@ -1310,6 +1310,12 @@ OBJS += autoscan_exponential.c
 NEED_AUTOSCAN=y
 endif
 
+ifdef CONFIG_AUTOSCAN_PERIODIC
+CFLAGS += -DCONFIG_AUTOSCAN_PERIODIC
+OBJS += autoscan_periodic.c
+NEED_AUTOSCAN=y
+endif
+
 ifdef NEED_AUTOSCAN
 L_CFLAGS += -DCONFIG_AUTOSCAN
 OBJS += autoscan.c
index e08868582709f82dfb132e96e35b7763b02fc41f..dc6af350680ddf737cc241d5523328fa587a8bd0 100644 (file)
@@ -1327,6 +1327,12 @@ OBJS += autoscan_exponential.o
 NEED_AUTOSCAN=y
 endif
 
+ifdef CONFIG_AUTOSCAN_PERIODIC
+CFLAGS += -DCONFIG_AUTOSCAN_PERIODIC
+OBJS += autoscan_periodic.o
+NEED_AUTOSCAN=y
+endif
+
 ifdef NEED_AUTOSCAN
 CFLAGS += -DCONFIG_AUTOSCAN
 OBJS += autoscan.o
index c537291467eddf1f24f8605b0a32936fdf442c8e..bac8df67f33685a8dc0f2188d33032ad2339f646 100644 (file)
 extern const struct autoscan_ops autoscan_exponential_ops;
 #endif /* CONFIG_AUTOSCAN_EXPONENTIAL */
 
+#ifdef CONFIG_AUTOSCAN_PERIODIC
+extern const struct autoscan_ops autoscan_periodic_ops;
+#endif /* CONFIG_AUTOSCAN_PERIODIC */
+
 static const struct autoscan_ops * autoscan_modules[] = {
 #ifdef CONFIG_AUTOSCAN_EXPONENTIAL
        &autoscan_exponential_ops,
 #endif /* CONFIG_AUTOSCAN_EXPONENTIAL */
+#ifdef CONFIG_AUTOSCAN_PERIODIC
+       &autoscan_periodic_ops,
+#endif /* CONFIG_AUTOSCAN_PERIODIC */
        NULL
 };
 
diff --git a/wpa_supplicant/autoscan_periodic.c b/wpa_supplicant/autoscan_periodic.c
new file mode 100644 (file)
index 0000000..102d723
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * WPA Supplicant - auto scan periodic module
+ * Copyright (c) 2012, Intel Corporation. All rights reserved.
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+#include "includes.h"
+
+#include "common.h"
+#include "wpa_supplicant_i.h"
+#include "autoscan.h"
+
+
+struct autoscan_periodic_data {
+       int periodic_interval;
+};
+
+
+static int autoscan_periodic_get_params(struct autoscan_periodic_data *data,
+                                       const char *params)
+{
+       int interval;
+
+       if (params == NULL)
+               return -1;
+
+       interval = atoi(params);
+
+       if (interval < 0)
+               return -1;
+
+       data->periodic_interval = interval;
+
+       return 0;
+}
+
+
+static void * autoscan_periodic_init(struct wpa_supplicant *wpa_s,
+                                    const char *params)
+{
+       struct autoscan_periodic_data *data;
+
+       data = os_zalloc(sizeof(struct autoscan_periodic_data));
+       if (data == NULL)
+               return NULL;
+
+       if (autoscan_periodic_get_params(data, params) < 0) {
+               os_free(data);
+               return NULL;
+       }
+
+       wpa_printf(MSG_DEBUG, "autoscan periodic: interval is %d",
+                  data->periodic_interval);
+
+       return data;
+}
+
+
+static void autoscan_periodic_deinit(void *priv)
+{
+       struct autoscan_periodic_data *data = priv;
+
+       os_free(data);
+}
+
+
+static int autoscan_periodic_notify_scan(void *priv,
+                                        struct wpa_scan_results *scan_res)
+{
+       struct autoscan_periodic_data *data = priv;
+
+       wpa_printf(MSG_DEBUG, "autoscan periodic: scan result notification");
+
+       return data->periodic_interval;
+}
+
+
+const struct autoscan_ops autoscan_periodic_ops = {
+       .name = "periodic",
+       .init = autoscan_periodic_init,
+       .deinit = autoscan_periodic_deinit,
+       .notify_scan = autoscan_periodic_notify_scan,
+};
index e705173345ef8a0328d6759af9648d04550fe9c1..392d8a814902f7bfc5f63a8af569509abd120451 100644 (file)
@@ -508,3 +508,5 @@ CONFIG_PEERKEY=y
 # Enabling directly a module will enable autoscan support.
 # For exponential module:
 #CONFIG_AUTOSCAN_EXPONENTIAL=y
+# For periodic module:
+#CONFIG_AUTOSCAN_PERIODIC=y
index 4557467236a8729bb4a7df1d8cd0f106405e1117..ccde8445acfc414141691e85c600292014319f55 100644 (file)
@@ -234,6 +234,9 @@ fast_reauth=1
 #autoscan=exponential:3:300
 # Which means a delay between scans on a base exponential of 3,
 # up to the limit of 300 seconds (3, 9, 27 ... 300)
+# For periodic module, parameters would be <fixed interval>
+#autoscan=periodic:30
+# So a delay of 30 seconds will be applied between each scan
 
 # filter_ssids - SSID-based scan result filtering
 # 0 = do not filter scan results (default)