Patchwork bgscan_learn: Load BSS entries from current SSID only

login
register
mail settings
Submitter Piotr.Nakraszewicz@tieto.com
Date April 23, 2012, 7:14 a.m.
Message ID <E50901D4F2CF69428D43141B7C85867929CCA19DE3@EXMB03.eu.tieto.com>
Download mbox | patch
Permalink /patch/154331/
State Superseded
Headers show

Comments

Piotr.Nakraszewicz@tieto.com - April 23, 2012, 7:14 a.m.
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 <piotr.nakraszewicz@tieto.com>
---
 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
Piotr.Nakraszewicz@tieto.com - July 5, 2012, 12:58 p.m.
On 30/06/12 15:58, Jouni Malinen wrote:
> On Thu, Jun 28, 2012 at 11:01:24AM +0300, Piotr.Nakraszewicz@tieto.com wrote:
>> Did you find the time to take a look at this patch?
> Not at details until now..
>
>> Do you have any comments?
> It would be better to store the SSID as a hexdump or some other way 
> that allows arbitrary binary data to be stored and parsed. Even '\0' 
> is a valid character in the middle of the SSID, i.e., it can be any 
> binary data..
>

Ok. I'll send v2.

Pozdrawiam / Best regards,
Piotr

Patch

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)