From patchwork Tue Jun 26 08:05:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomasz Bursztyka X-Patchwork-Id: 167333 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id 160421007DB for ; Tue, 26 Jun 2012 18:07:56 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C9BB59D2B5; Tue, 26 Jun 2012 04:07:40 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iJu0mPMFoVMU; Tue, 26 Jun 2012 04:07:40 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id B08109D247; Tue, 26 Jun 2012 04:06:33 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 1AAAB9D28D for ; Tue, 26 Jun 2012 04:06:32 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id B3sJKS425tCj for ; Tue, 26 Jun 2012 04:06:27 -0400 (EDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id D79159D236 for ; Tue, 26 Jun 2012 04:06:15 -0400 (EDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 26 Jun 2012 01:06:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.67,351,1309762800"; d="scan'208";a="162733327" Received: from mriya.fi.intel.com ([10.237.68.149]) by orsmga002.jf.intel.com with ESMTP; 26 Jun 2012 01:06:10 -0700 From: Tomasz Bursztyka To: hostap@lists.shmoo.com Subject: =?UTF-8?q?=5BPATCH=206/7=5D=20Adding=20autoscan=20module=20named=20exponential?= Date: Tue, 26 Jun 2012 11:05:51 +0300 Message-Id: <1340697952-4209-7-git-send-email-tomasz.bursztyka@linux.intel.com> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1340697952-4209-1-git-send-email-tomasz.bursztyka@linux.intel.com> References: <1340697952-4209-1-git-send-email-tomasz.bursztyka@linux.intel.com> MIME-Version: 1.0 X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com This module will compute the interval on a base exponential. Thus, params to this module are following this format: : Signed-hostap: Tomasz Bursztyka --- wpa_supplicant/Makefile | 6 ++ wpa_supplicant/autoscan.c | 7 ++ wpa_supplicant/autoscan_exponential.c | 100 +++++++++++++++++++++++++++++++++ wpa_supplicant/defconfig | 3 + wpa_supplicant/wpa_supplicant.conf | 4 + 5 files changed, 120 insertions(+), 0 deletions(-) create mode 100644 wpa_supplicant/autoscan_exponential.c diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile index d06a15b..e088685 100644 --- a/wpa_supplicant/Makefile +++ b/wpa_supplicant/Makefile @@ -1321,6 +1321,12 @@ CFLAGS += -DCONFIG_BGSCAN OBJS += bgscan.o endif +ifdef CONFIG_AUTOSCAN_EXPONENTIAL +CFLAGS += -DCONFIG_AUTOSCAN_EXPONENTIAL +OBJS += autoscan_exponential.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 ba0f699..4abf62a 100644 --- a/wpa_supplicant/autoscan.c +++ b/wpa_supplicant/autoscan.c @@ -15,7 +15,14 @@ #include "scan.h" #include "autoscan.h" +#ifdef CONFIG_AUTOSCAN_EXPONENTIAL +extern const struct autoscan_ops autoscan_exponential_ops; +#endif /* CONFIG_AUTOSCAN_EXPONENTIAL */ + static const struct autoscan_ops * autoscan_modules[] = { +#ifdef CONFIG_AUTOSCAN_EXPONENTIAL + &autoscan_exponential_ops, +#endif /* CONFIG_AUTOSCAN_EXPONENTIAL */ NULL }; diff --git a/wpa_supplicant/autoscan_exponential.c b/wpa_supplicant/autoscan_exponential.c new file mode 100644 index 0000000..e96de4e --- /dev/null +++ b/wpa_supplicant/autoscan_exponential.c @@ -0,0 +1,100 @@ +/* + * WPA Supplicant - auto scan exponential module + * Copyright (c) 2012, Intel Corporation. All rights reserved. + * + * This software may be distributed under the terms of the BSD license. + * See README and COPYING for more details. + */ + +#include "includes.h" + +#include "common.h" +#include "wpa_supplicant_i.h" +#include "autoscan.h" + +struct autoscan_exponential_data { + struct wpa_supplicant *wpa_s; + int base; + int limit; + int interval; +}; + + +static int autoscan_exponential_get_params(struct autoscan_exponential_data *data, + const char *params) +{ + const char *pos; + + if (params == NULL) + return -1; + + data->base = atoi(params); + + pos = os_strchr(params, ':'); + if (pos == NULL) + return -1; + + pos++; + data->limit = atoi(pos); + + return 0; +} + + +static void * autoscan_exponential_init(struct wpa_supplicant *wpa_s, + const char *params) +{ + struct autoscan_exponential_data *data; + + data = os_zalloc(sizeof(struct autoscan_exponential_data)); + if (data == NULL) + return NULL; + + if (autoscan_exponential_get_params(data, params) < 0) { + os_free(data); + return NULL; + } + + wpa_printf(MSG_DEBUG, "autoscan exponential: base exponential is %d " + "and limit is %d", data->base, data->limit); + + data->wpa_s = wpa_s; + + return data; +} + + +static void autoscan_exponential_deinit(void *priv) +{ + struct autoscan_exponential_data *data = priv; + + os_free(data); +} + + +static int autoscan_exponential_notify_scan(void *priv, + struct wpa_scan_results *scan_res) +{ + struct autoscan_exponential_data *data = priv; + + wpa_printf(MSG_DEBUG, "autoscan exponential: scan result notification"); + + if (data->interval >= data->limit) + return data->limit; + + if (data->interval <= 0) + data->interval = data->base; + + data->interval = data->interval * data->base; + + return data->interval; + +} + + +const struct autoscan_ops autoscan_exponential_ops = { + .name = "exponential", + .init = autoscan_exponential_init, + .deinit = autoscan_exponential_deinit, + .notify_scan = autoscan_exponential_notify_scan, +}; diff --git a/wpa_supplicant/defconfig b/wpa_supplicant/defconfig index 026ebee..c007909 100644 --- a/wpa_supplicant/defconfig +++ b/wpa_supplicant/defconfig @@ -505,3 +505,6 @@ CONFIG_PEERKEY=y # This can be used to enable automatic scan support in wpa_supplicant. # See wpa_supplicant.conf for more information on autoscan usage. #CONFIG_AUTOSCAN=y +# Enabling directly a module will enable autoscan support. +# For exponential module: +#CONFIG_AUTOSCAN_EXPONENTIAL=y diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index 52e6581..4557467 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -230,6 +230,10 @@ fast_reauth=1 # within an interface in following format: #autoscan=: # autoscan is like bgscan but on disconnected or inactive state. +# For instance, on exponential module parameters would be : +#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) # filter_ssids - SSID-based scan result filtering # 0 = do not filter scan results (default)