From patchwork Mon Apr 23 07:14:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr.Nakraszewicz@tieto.com X-Patchwork-Id: 154331 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 D5F2FB70C3 for ; Mon, 23 Apr 2012 17:14:59 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 9DB889D1F3; Mon, 23 Apr 2012 03:14:55 -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 H1KzZ6DcZ8Vo; Mon, 23 Apr 2012 03:14:55 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 28FD99C234; Mon, 23 Apr 2012 03:14:51 -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 8E87E9C234 for ; Mon, 23 Apr 2012 03:14: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 XRgcEiT7LxfN for ; Mon, 23 Apr 2012 03:14:45 -0400 (EDT) Received: from ebb05.tieto.com (ebb05.tieto.com [131.207.168.36]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "ebb05.tieto.com", Issuer "VeriSign Class 3 Secure Server CA - G3" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 0175E9C1F8 for ; Mon, 23 Apr 2012 03:14:44 -0400 (EDT) X-AuditID: 83cfa824-b7c6bae000005775-e0-4f950162da53 Received: from FIHGA-EXHUB01.eu.tieto.com ( [131.207.136.34]) by ebb05.tieto.com (SMTP Mailer) with SMTP id B3.75.22389.261059F4; Mon, 23 Apr 2012 10:14:43 +0300 (EEST) Received: from EXMB03.eu.tieto.com ([169.254.1.51]) by FIHGA-EXHUB01.eu.tieto.com ([131.207.136.34]) with mapi; Mon, 23 Apr 2012 10:14:42 +0300 From: To: Date: Mon, 23 Apr 2012 10:14:41 +0300 Subject: RE: [PATCH] bgscan_learn: Load BSS entries from current SSID only Thread-Topic: [PATCH] bgscan_learn: Load BSS entries from current SSID only Thread-Index: Ac0eOUEh1MdzYSOITESB5CWzpcRIVwC4b9Iw Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 X-Brightmail-Tracker: AAAAARqSVuA= 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 Hi, Adding description: bgscan_learn wrongly loads BSS entries from data file even if we changed ESS we are connected to. To prevent that add SSID parameter to data file and compare it with current SSID before loading the entries. Pozdrawiam / Best regards, Piotr -----Original Message----- From: hostap-bounces@lists.shmoo.com [mailto:hostap-bounces@lists.shmoo.com] On Behalf Of Piotr.Nakraszewicz@tieto.com Sent: 19 kwietnia 2012 16:33 To: hostap@lists.shmoo.com Subject: [PATCH] bgscan_learn: Load BSS entries from current SSID only Hi, Signed-hostap: Piotr Nakraszewicz --- wpa_supplicant/bgscan_learn.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) return; fprintf(f, "wpa_supplicant-bgscan-learn\n"); + pos = buf; + os_memcpy(pos, "SSID ", 5); + pos += 5; + os_memcpy(pos, data->ssid->ssid, data->ssid->ssid_len); + pos += data->ssid->ssid_len; + os_memcpy(pos, "\n", 1); + pos += 1; + fwrite(buf, 1, pos-buf, f); + dl_list_for_each(bss, &data->bss, struct bgscan_learn_bss, list) { fprintf(f, "BSS " MACSTR " %d\n", MAC2STR(bss->bssid), bss->freq); -- 1.7.0.4 Pozdrawiam / Best regards, Piotr diff --git a/wpa_supplicant/bgscan_learn.c b/wpa_supplicant/bgscan_learn.c index ed4d879..6de1b24 100644 --- a/wpa_supplicant/bgscan_learn.c +++ b/wpa_supplicant/bgscan_learn.c @@ -151,6 +151,17 @@ static int bgscan_learn_load(struct bgscan_learn_data *data) bgscan_learn_add_neighbor(bss, addr); } + + if (os_strncmp(buf, "SSID ", 5) == 0) { + if (os_strncmp(buf + 5, (char *)data->ssid->ssid, + data->ssid->ssid_len)) { + wpa_printf(MSG_INFO, "bgscan learn: " + "Different ssid in data file, " + "omitting BSS entries"); + fclose(f); + return 0; + } + } } fclose(f); @@ -162,6 +173,8 @@ static void bgscan_learn_save(struct bgscan_learn_data *data) { FILE *f; struct bgscan_learn_bss *bss; + char buf[MAX_SSID_LEN + 6]; + char *pos; if (data->fname == NULL) return; @@ -174,6 +187,15 @@ static void bgscan_learn_save(struct bgscan_learn_data *data)