From patchwork Tue Jun 26 08:05:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomasz Bursztyka X-Patchwork-Id: 167334 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 9EC7F1007DA for ; Tue, 26 Jun 2012 18:08:05 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 24D969C0B4; Tue, 26 Jun 2012 04:07:49 -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 81EbJlPldnGD; Tue, 26 Jun 2012 04:07:48 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 7C3009D292; Tue, 26 Jun 2012 04:06:35 -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 504949D236 for ; Tue, 26 Jun 2012 04:06:33 -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 9TtCoPvpvqFC for ; Tue, 26 Jun 2012 04:06:28 -0400 (EDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 120119D247 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:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.67,351,1309762800"; d="scan'208";a="162733336" Received: from mriya.fi.intel.com ([10.237.68.149]) by orsmga002.jf.intel.com with ESMTP; 26 Jun 2012 01:06:11 -0700 From: Tomasz Bursztyka To: hostap@lists.shmoo.com Subject: =?UTF-8?q?=5BPATCH=207/7=5D=20Adding=20a=20simple=20periodic=20autoscan=20module?= Date: Tue, 26 Jun 2012 11:05:52 +0300 Message-Id: <1340697952-4209-8-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 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 | 69 ++++++++++++++++++++++++++++++++++++ wpa_supplicant/defconfig | 2 + wpa_supplicant/wpa_supplicant.conf | 3 ++ 5 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 e088685..dc6af35 100644 --- a/wpa_supplicant/Makefile +++ b/wpa_supplicant/Makefile @@ -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 diff --git a/wpa_supplicant/autoscan.c b/wpa_supplicant/autoscan.c index 4abf62a..8a65df3 100644 --- a/wpa_supplicant/autoscan.c +++ b/wpa_supplicant/autoscan.c @@ -19,10 +19,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..887120f --- /dev/null +++ b/wpa_supplicant/autoscan_periodic.c @@ -0,0 +1,69 @@ +/* + * 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 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, +}; diff --git a/wpa_supplicant/defconfig b/wpa_supplicant/defconfig index c007909..9addcbf 100644 --- a/wpa_supplicant/defconfig +++ b/wpa_supplicant/defconfig @@ -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 diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index 4557467..ccde844 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -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 +#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)