@@ -151,6 +151,29 @@ static int bgscan_learn_load(struct bgscan_learn_data *data)
bgscan_learn_add_neighbor(bss, addr);
}
+
+ if (os_strncmp(buf, "SSID ", 5) == 0) {
+ /*
+ * Check if current SSID is the same as the one stored
+ * in the data file.
+ */
+ u8 ssid[MAX_SSID_LEN];
+ char *start = buf + 5;
+ char *end = os_strstr(start, "\n");
+
+ if (data->ssid->ssid &&
+ (!end ||
+ end - start != (int) data->ssid->ssid_len * 2 ||
+ hexstr2bin(start, ssid, data->ssid->ssid_len) ||
+ os_memcmp(ssid, data->ssid->ssid,
+ data->ssid->ssid_len) != 0)) {
+ wpa_printf(MSG_INFO, "bgscan learn: "
+ "Different SSID in data file, "
+ "omitting BSS entries");
+ fclose(f);
+ return 0;
+ }
+ }
}
fclose(f);
@@ -162,6 +185,8 @@ static void bgscan_learn_save(struct bgscan_learn_data *data)
{
FILE *f;
struct bgscan_learn_bss *bss;
+ char buf[2 * MAX_SSID_LEN + 5 + 2];
+ char *pos;
if (data->fname == NULL)
return;
@@ -174,6 +199,17 @@ static void bgscan_learn_save(struct bgscan_learn_data *data)
return;
fprintf(f, "wpa_supplicant-bgscan-learn\n");
+ if (data->ssid->ssid) {
+ /* Store SSID as a hexdump */
+ pos = buf;
+ os_memcpy(pos, "SSID ", 5);
+ pos += 5;
+ pos += wpa_snprintf_hex(pos, 2 * MAX_SSID_LEN + 1,
+ data->ssid->ssid, data->ssid->ssid_len);
+ os_memcpy(pos, "\n", 2);
+ fprintf(f, "%s", buf);
+ }
+
dl_list_for_each(bss, &data->bss, struct bgscan_learn_bss, list) {
fprintf(f, "BSS " MACSTR " %d\n",
MAC2STR(bss->bssid), bss->freq);