From patchwork Thu May 3 13:16:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7/7] Adding a simple periodic autoscan module Date: Thu, 03 May 2012 03:16:56 -0000 From: Tomasz Bursztyka X-Patchwork-Id: 156698 Message-Id: <1336051016-15005-8-git-send-email-tomasz.bursztyka@linux.intel.com> To: hostap@lists.shmoo.com This module will sets a fixed scanning interval. Thus, the parameter to this module is following this format: Signed-hostap: Tomasz Bursztyka --- wpa_supplicant/Makefile | 6 +++ wpa_supplicant/autoscan.c | 7 +++ wpa_supplicant/autoscan_periodic.c | 74 ++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 0 deletions(-) create mode 100644 wpa_supplicant/autoscan_periodic.c diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile index 859db6b..3ebf111 100644 --- a/wpa_supplicant/Makefile +++ b/wpa_supplicant/Makefile @@ -1317,6 +1317,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 diff --git a/wpa_supplicant/autoscan.c b/wpa_supplicant/autoscan.c index d2645bc..98e032c 100644 --- a/wpa_supplicant/autoscan.c +++ b/wpa_supplicant/autoscan.c @@ -24,10 +24,17 @@ 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 index 0000000..15fb855 --- /dev/null +++ b/wpa_supplicant/autoscan_periodic.c @@ -0,0 +1,74 @@ +/* + * WPA Supplicant - auto scan periodic module + * + * 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 "autoscan.h" + + +static int periodic_interval = 0; + +static int autoscan_periodic_get_params(const char *params) +{ + int interval; + + if (params == NULL) + return -1; + + interval = atoi(params); + + if (interval < 0) + return -1; + + periodic_interval = interval; + + return 0; +} + + +static void * autoscan_periodic_init(struct wpa_supplicant *wpa_s, + const char *params) +{ + if (autoscan_periodic_get_params(params) < 0) + return NULL; + + wpa_printf(MSG_DEBUG, "autoscan periodic: interval is %d", + periodic_interval); + + return &periodic_interval; +} + + +static void autoscan_periodic_deinit(void *priv) +{ + periodic_interval = 0; +} + + +static int autoscan_periodic_notify_scan(void *priv, + struct wpa_scan_results *scan_res) +{ + wpa_printf(MSG_DEBUG, "autoscan periodic: scan result notification"); + + return 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, +};