[PATCH 2/3] Added notifications about chenges in BBSIDs list
Witold Sowa
witold.sowa
Tue Nov 10 09:04:13 PST 2009
Dan Williams pisze:
> emit the added/chagned stuff. I'll poke around and resubmit the patch
> if wsowa doesn't get around to it first.
>
I do :-) Fixed. We allocate an array for previous scan's bssids
and free previous scan results, next we send notiffications and
then we free bssids array.
If scan results introduces new BSSs or discards some previously known,
new wpas_notify_bss_added or wpas_notify_bss_removed notifications are
called
---
wpa_supplicant/notify.c | 12 +++++++++
wpa_supplicant/notify.h | 2 +
wpa_supplicant/wpa_supplicant.c | 52
++++++++++++++++++++++++++++++++++++++-
3 files changed, 65 insertions(+), 1 deletions(-)
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 066f5a9..733d251 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -152,6 +152,18 @@ void wpas_notify_network_removed(struct
wpa_supplicant *wpa_s,
}
+void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
+ u8 bssid[])
+{
+}
+
+
+void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
+ u8 bssid[])
+{
+}
+
+
void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
{
}
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index b8231aa..ca212b3 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -46,6 +46,8 @@ void wpas_notify_network_added(struct wpa_supplicant
*wpa_s,
struct wpa_ssid *ssid);
void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid);
+void wpas_notify_bss_added(struct wpa_supplicant *wpa_s, u8 bssid[]);
+void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, u8 bssid[]);
void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char
*name);
void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char
*name);
diff --git a/wpa_supplicant/wpa_supplicant.c
b/wpa_supplicant/wpa_supplicant.c
index 681a9d9..e3a6ea2 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -1549,6 +1549,35 @@ int wpa_supplicant_set_debug_params(struct
wpa_global *global, int debug_level,
}
+static void notify_about_bssid_chenges(struct wpa_supplicant *wpa_s,
+ u8 (*prev_bssids)[ETH_ALEN], int prev_num,
+ struct wpa_scan_results *new)
+{
+ int new_num, i, j;
+
+ new_num = (new != NULL ? new->num : 0);
+ if (prev_bssids == NULL)
+ prev_num = 0;
+
+ for (i = 0; i < prev_num; i++) {
+ for (j = 0; j < new_num; j++) {
+ if (!os_memcmp(prev_bssids[i], new->res[j]->bssid, ETH_ALEN))
+ break;
+ }
+ if (j == new_num)
+ wpas_notify_bss_removed(wpa_s, prev_bssids[i]);
+ }
+ for (i = 0; i < new_num; i++) {
+ for (j = 0; j < prev_num; j++) {
+ if (!os_memcmp(new->res[i]->bssid, prev_bssids[j], ETH_ALEN))
+ break;
+ }
+ if (j == prev_num)
+ wpas_notify_bss_added(wpa_s, new->res[i]->bssid);
+ }
+}
+
+
static struct wpa_scan_results * wpa_supplicant_get_scan_results_old(
struct wpa_supplicant *wpa_s)
{
@@ -1664,7 +1693,24 @@ static struct wpa_scan_results *
wpa_supplicant_get_scan_results_old(
*/
int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s)
{
- int ret;
+ int ret, i, prev_scan_res_num;
+ u8 (*prev_scan_bssids)[ETH_ALEN];
+
+ prev_scan_res_num = (wpa_s->scan_res ? wpa_s->scan_res->num : 0);
+ prev_scan_bssids = (u8 (*)[ETH_ALEN])
+ os_malloc(prev_scan_res_num * sizeof(*prev_scan_bssids));
+
+ if (prev_scan_bssids) {
+ for (i = 0; i < prev_scan_res_num; i++) {
+ os_memcpy(prev_scan_bssids[i], wpa_s->scan_res->res[i]->bssid,
ETH_ALEN);
+ }
+ }
+ else {
+ wpa_printf(MSG_WARNING, "Not enough memory to allocate "
+ "old scan results list.\n"
+ "No 'BSSID removed' notification will be performed");
+ prev_scan_res_num = 0;
+ }
wpa_scan_results_free(wpa_s->scan_res);
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
@@ -1681,6 +1727,10 @@ int wpa_supplicant_get_scan_results(struct
wpa_supplicant *wpa_s)
wpa_scan_sort_results(wpa_s->scan_res);
}
+ notify_about_bssid_chenges(wpa_s,
+ prev_scan_bssids, prev_scan_res_num, wpa_s->scan_res);
+
+ os_free(prev_scan_bssids);
return ret;
}
--
1.6.0.2
More information about the Hostap
mailing list