[PATCH] bgscan_learn: Load BSS entries from current SSID only

Piotr.Nakraszewicz at tieto.com Piotr.Nakraszewicz
Thu Apr 19 07:32:31 PDT 2012


Hi,


Signed-hostap: Piotr Nakraszewicz <piotr.nakraszewicz at tieto.com>
---
 wpa_supplicant/bgscan_learn.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

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)
 		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





More information about the Hostap mailing list