From patchwork Fri Aug 24 18:14:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Shmidt X-Patchwork-Id: 179878 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 3824E2C00FD for ; Sat, 25 Aug 2012 04:36:04 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 0743717C018; Fri, 24 Aug 2012 14:36:01 -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 AHGWqjpewpQ9; Fri, 24 Aug 2012 14:36:00 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id E30439D285; Fri, 24 Aug 2012 14:35:55 -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 A91439D284 for ; Fri, 24 Aug 2012 14:35:54 -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 psHV9li0QshW for ; Fri, 24 Aug 2012 14:35:49 -0400 (EDT) Received: from mail-ey0-f202.google.com (mail-ey0-f202.google.com [209.85.215.202]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 919049D285 for ; Fri, 24 Aug 2012 14:35:49 -0400 (EDT) Received: by eaac1 with SMTP id c1so107490eaa.5 for ; Fri, 24 Aug 2012 11:35:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:date:subject:to:message-id:x-gm-message-state; bh=mX1B/kvN4PrzEM+w90zqC1b7xxo5kkmVOprpJgFinUg=; b=ChN6EyDeooYb67QMUD/2g9DMVx79o/sqXO89vy9W4mYXNxEXF2Nlr+AtwJplKCEzwB B1XtAFIkp0km5uEl4+k6whDNVnQ6qoqMnMeZmF6D+qpns4i0+6cmYPJE10HOC0Jr0OAn bB/Gm/kcyHc58P0kgQUuFub/VzJlO7yYYHrWJQ4Ws/mMqHMGf0CZIuM5U9RVWX3cQkZa flGURyEFQiV+Pv3kEDtRyC/rqoFGhZ1werlMXZw6BxGOoAjJbcnds9az59Jm9708BHbt JHYG5yK0zyrl66LanNkQPUj81q3YcOhSd/SDW/aNVT10LFYLdLP4hT3BKrhaVIsbdvZ1 DCLw== Received: by 10.180.88.195 with SMTP id bi3mr525065wib.3.1345833348550; Fri, 24 Aug 2012 11:35:48 -0700 (PDT) Received: by 10.180.88.195 with SMTP id bi3mr525062wib.3.1345833348495; Fri, 24 Aug 2012 11:35:48 -0700 (PDT) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id cd1si22632wib.1.2012.08.24.11.35.48 (version=TLSv1/SSLv3 cipher=AES128-SHA); Fri, 24 Aug 2012 11:35:48 -0700 (PDT) Received: from ushik.mtv.corp.google.com (ushik.mtv.corp.google.com [172.18.104.41]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id 1C44020004E for ; Fri, 24 Aug 2012 11:35:48 -0700 (PDT) Received: by ushik.mtv.corp.google.com (Postfix, from userid 57417) id 5D58838371; Fri, 24 Aug 2012 11:35:47 -0700 (PDT) From: Dmitry Shmidt Date: Fri, 24 Aug 2012 11:14:44 -0700 Subject: [PATCH] wpa_supplicant: Add bss_flush command to invalidate scan results To: hostap@lists.shmoo.com Message-Id: <20120824183547.5D58838371@ushik.mtv.corp.google.com> X-Gm-Message-State: ALoCoQnFzabmLUSIEd4CulZQcOqFLYehlIXDIBKNwdJTqvwcMmKjs5dkT5QuEjRObtLMSXTh69vvW/YaEwZFOREtow2nGyHWF2p0/8x/9ZmzOoEnJJtSMFrXyTJbL8kgkWlVEFm9Lxhp8gXWAdcemQ9P/vsgm6blSOQ+HJ7UBh1nv/9a1wRAYF7/z6fSWLUaT6Iq2akzty34osnoGiMXrzbqoQlEaVyBK9py5CFBKFaSkIlkZw2wKKM= 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: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com Change-Id: I1a6ebc4fe53e16909ac44e2d04a6b651993dae91 Signed-off-by: Dmitry Shmidt --- wpa_supplicant/ctrl_iface.c | 16 ++++++++++++++++ wpa_supplicant/wpa_cli.c | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 0 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 5de4f7b..ec61b84 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2884,6 +2884,19 @@ static int wpa_supplicant_ctrl_iface_bss_expire_count( } +static int wpa_supplicant_ctrl_iface_bss_flush( + struct wpa_supplicant *wpa_s, char *cmd) +{ + int flush_age = atoi(cmd); + + if (flush_age == 0) + wpa_bss_flush(wpa_s); + else + wpa_bss_flush_by_age(wpa_s, flush_age); + return 0; +} + + static void wpa_supplicant_ctrl_iface_drop_sa(struct wpa_supplicant *wpa_s) { wpa_printf(MSG_DEBUG, "Dropping SA without deauthentication"); @@ -4578,6 +4591,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, if (wpa_supplicant_ctrl_iface_bss_expire_count(wpa_s, buf + 17)) reply_len = -1; + } else if (os_strncmp(buf, "BSS_FLUSH ", 10) == 0) { + if (wpa_supplicant_ctrl_iface_bss_flush(wpa_s, buf + 10)) + reply_len = -1; #ifdef CONFIG_TDLS } else if (os_strncmp(buf, "TDLS_DISCOVER ", 14) == 0) { if (wpa_supplicant_ctrl_iface_tdls_discover(wpa_s, buf + 14)) diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 8e89281..53ed05d 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -656,6 +656,23 @@ static int wpa_cli_cmd_bss_expire_count(struct wpa_ctrl *ctrl, int argc, } +static int wpa_cli_cmd_bss_flush(struct wpa_ctrl *ctrl, int argc, char *argv[]) +{ + char cmd[256]; + int res; + + if (argc < 1) + res = os_snprintf(cmd, sizeof(cmd), "BSS_FLUSH 0"); + else + res = os_snprintf(cmd, sizeof(cmd), "BSS_FLUSH %s", argv[0]); + if (res < 0 || (size_t) res >= sizeof(cmd) - 1) { + printf("Too long BSS_FLUSH command.\n"); + return -1; + } + return wpa_ctrl_command(ctrl, cmd); +} + + static int wpa_cli_cmd_stkstart(struct wpa_ctrl *ctrl, int argc, char *argv[]) { @@ -2264,6 +2281,9 @@ static struct wpa_cli_cmd wpa_cli_commands[] = { { "bss_expire_count", wpa_cli_cmd_bss_expire_count, cli_cmd_flag_none, " = set BSS expiration scan count parameter" }, + { "bss_flush", wpa_cli_cmd_bss_flush, + cli_cmd_flag_none, + " = set BSS flush age (0 by default)" }, { "stkstart", wpa_cli_cmd_stkstart, cli_cmd_flag_none, " = request STK negotiation with " },