[PATCH] Treat '' in SSIDs param of DBus Interface.Scan as a request for braodcast scan.

Dan Williams dcbw at redhat.com
Thu Oct 7 02:06:31 EDT 2010


On Wed, 2010-10-06 at 15:46 -0700, Daniel Kurtz wrote:
> This patch changes wpa_supplicant policy for handling '' in SSIDs field of Interface.SSID DBus message.
> It treats '' (zero-length) SSID as a request for a broadcast scan, instead of ignoring it.

Does not sending any SSIDs somehow not work?  This seems like a pretty
big kludge.  The behavior should be that if no SSID property is sent,
then no specific scan is performed.  A zero-length SSID should actually
be rejected with an error.

Dan

> This patch updates DBus API .Scan() logic per the test cases listed below:
> 
> 1) Interface.Scan({'Type':'active', 'Channel':(2412, 20)})
>    Request:     Active scan with only '' SSID (1 channel)
>    Should be:   1 broadcast ProbeRequest on specified channel
>    Previous:    1 broadcast ProbeRequest on specified channel
>    This Patch:  1 broadcast ProbeRequest on specified channel
> 
> 2) Interface.Scan({'Type':'active', 'Channel':(2412, 20), 'SSIDs':['']})
>    Request:     Active scan with only '' SSID (1 channel)
>    Should be:   1 broadcast ProbeRequest on specified channel
>    Previous:    No ProbeRequests; passive scan results for specified channel
>    This Patch:  FIXED: 1 broadcast ProbeRequest on specified channel
> 
> 3) Interface.Scan({'Type':'active', 'Channel':(2412, 20), 'SSIDs':['MySSID']})
>    Request:     Active scan with only non-'' SSIDs (1 channel)
>    Should be:   1 directed ProbeRequest for each SSID on specified channel, no broadcast ProbeRequest
>    Previous:    1 directed ProbeRequest for each SSID on specified channel, no broadcast ProbeRequest
>    This Patch:  1 directed ProbeRequest for each SSID on specified channel, no broadcast ProbeRequest
> 
> 4) Interface.Scan({'Type':'active', 'Channel':(2412, 20), 'SSIDs':['', 'MySSID']})
>    Request:     Active scan with SSIDs, including 1 '' SSID (1 channel)
>    Should be:   1 broadcast ProbeRequest, 1 directed ProbeRequest for each non-'' SSID on specified channel
>    Previous:    1 directed ProbeRequest for each non-'' SSID on specified channel
>    This Patch:  FIXED: 1 broadcast ProbeRequest, 1 directed ProbeRequest for each non-'' SSID on specified channel
> ---
>  wpa_supplicant/dbus/dbus_new_handlers.c |   30 +++++++++++++++++-------------
>  1 files changed, 17 insertions(+), 13 deletions(-)
> 
> diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
> index e2b5e50..36eb917 100644
> --- a/wpa_supplicant/dbus/dbus_new_handlers.c
> +++ b/wpa_supplicant/dbus/dbus_new_handlers.c
> @@ -987,21 +987,25 @@ static int wpas_dbus_get_scan_ssids(DBusMessage *message, DBusMessageIter *var,
>  		dbus_message_iter_recurse(&array_iter, &sub_array_iter);
>  
>  		dbus_message_iter_get_fixed_array(&sub_array_iter, &val, &len);
> -		if (len == 0) {
> -			dbus_message_iter_next(&array_iter);
> -			continue;
> -		}
>  
> -		ssid = os_malloc(len);
> -		if (ssid == NULL) {
> -			wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: "
> -				   "out of memory. Cannot allocate memory for "
> -				   "SSID");
> -			*reply = dbus_message_new_error(
> -				message, DBUS_ERROR_NO_MEMORY, NULL);
> -			return -1;
> +		if (len != 0) {
> +			ssid = os_malloc(len);
> +			if (ssid == NULL) {
> +				wpa_printf(MSG_DEBUG,
> +					   "wpas_dbus_handler_scan[dbus]: "
> +					   "out of memory. Cannot allocate "
> +					   "memory for SSID");
> +				*reply = dbus_message_new_error(
> +						message, DBUS_ERROR_NO_MEMORY,
> +						NULL);
> +				return -1;
> +			}
> +			os_memcpy(ssid, val, len);
> +		} else {
> +			/* Allow zero-length SSIDs */
> +			ssid = NULL;
>  		}
> -		os_memcpy(ssid, val, len);
> +
>  		ssids[ssids_num].ssid = ssid;
>  		ssids[ssids_num].ssid_len = len;
>  




More information about the HostAP mailing list