[PATCH 2/3] Added notifications about chenges in BBSIDs list

Dan Williams dcbw at redhat.com
Wed Oct 21 13:55:48 EDT 2009


On Sun, 2009-10-18 at 03:56 +0200, Witold Sowa wrote:
> If scan results introduces new BSSs or discards some previously known,
> new wpas_notify_bss_added or wpas_notify_bss_removed notifications are
> called

I assume instead of "chenges" you mean "changes"?  English sucks :(

Dan

> ---
>  wpa_supplicant/notify.c         |   12 ++++++++++++
>  wpa_supplicant/notify.h         |    2 ++
>  wpa_supplicant/wpa_supplicant.c |   34 +++++++++++++++++++++++++++++++++-
>  3 files changed, 47 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..0a2b131 100644
> --- a/wpa_supplicant/wpa_supplicant.c
> +++ b/wpa_supplicant/wpa_supplicant.c
> @@ -1549,6 +1549,36 @@ int wpa_supplicant_set_debug_params(struct wpa_global *global, int debug_level,
>  }
>  
> 
> +static void notify_about_bssid_chenges(struct wpa_supplicant *wpa_s,
> +				    struct wpa_scan_results *prev,
> +				    struct wpa_scan_results *new)
> +{
> +	int prev_num, new_num, i, j;
> +
> +	prev_num = (prev != NULL ? prev->num : 0);
> +	new_num = (new != NULL ? new->num : 0);
> +
> +	for (i = 0; i < prev_num; i++) {
> +		for (j = 0; j < new_num; j++) {
> +			if (!os_memcmp(prev->res[i]->bssid, new->res[j]->bssid,
> +				       ETH_ALEN))
> +				break;
> +		}
> +		if (j == new_num)
> +			wpas_notify_bss_removed(wpa_s, prev->res[i]->bssid);
> +	}
> +	for (i = 0; i < new_num; i++) {
> +		for (j = 0; j < prev_num; j++) {
> +			if (!os_memcmp(new->res[i]->bssid, prev->res[j]->bssid,
> +				       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)
>  {
> @@ -1665,8 +1695,8 @@ static struct wpa_scan_results * wpa_supplicant_get_scan_results_old(
>  int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s)
>  {
>  	int ret;
> +	struct wpa_scan_results *prev_scan_res = wpa_s->scan_res;
>  
> -	wpa_scan_results_free(wpa_s->scan_res);
>  	if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
>  		wpa_s->scan_res = ieee80211_sta_get_scan_results(wpa_s);
>  	else if (wpa_s->driver->get_scan_results2 == NULL)
> @@ -1681,6 +1711,8 @@ 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_res, wpa_s->scan_res);
> +	wpa_scan_results_free(prev_scan_res);
>  	return ret;
>  }
>  



More information about the HostAP mailing list