[PATCH] Send CTRL-EVENT-NETWORK-NOT-FOUND if no suitable network was found

Dmitry Shmidt dimitrysh
Sat Jun 27 11:27:44 PDT 2015


On Sat, Jun 27, 2015 at 2:12 AM, Jouni Malinen <j at w1.fi> wrote:
> On Fri, Jun 26, 2015 at 02:31:17PM -0700, Dmitry Shmidt wrote:
>> The issue our wifi manager developers are trying to resolve is next:
>> We select network to connect but let's say it is not in real scan results.
>> wpa_supplicant will "do nothing". It will print debug log, but wifi manager
>> will not know that it is not planning to do anything else.
>
> The place here in wpas_select_network_from_last_scan() is far from an
> indication of not planning on doing anything else.. Once asked to
> connect, wpa_supplicant will continue trying to do so until told
> otherwise.
>
>> If there is other way to catch this situation, rather then explicitly
>> send the event above, it will be great.
>
> Assuming the goal is to know that the first scan results (or any
> scan trying to connect after this) did not result in an action other
> than rescheduling the connection scan, a small change to the patch can
> be used to cover this. The wpa_msg_ctrl() call just needs to be moved
> down a bit in the function to avoid the cases where there are other
> actions taken. The patch below shows this and I think I'll apply this.
>
> That said, even the existing control interface events would allow most
> of this to be figured out:
>
> SELECT_NETWORK 0
> --->
> <3>CTRL-EVENT-SCAN-STARTED
> <3>CTRL-EVENT-BSS-ADDED 0 02:00:00:00:03:00
> <3>CTRL-EVENT-SCAN-RESULTS
> <3>CTRL-EVENT-NETWORK-NOT-FOUND
> (5 seconds)
> <3>CTRL-EVENT-SCAN-STARTED
> <3>CTRL-EVENT-SCAN-RESULTS
> <3>CTRL-EVENT-NETWORK-NOT-FOUND
>
> In this case, the matching network was not there and there was no
> connection attempt after the scan results event. A bit more complex to
> notice this case since this would depend on waiting a bit to see if
> anything follows CTRL-EVENT-SCAN-RESULTS, so adding the new event here
> is justifiable.
>
> SELECT_NETWORK any
> <3>CTRL-EVENT-SCAN-STARTED
> <3>CTRL-EVENT-SCAN-RESULTS
> <3>SME: Trying to authenticate with 02:00:00:00:03:00 (SSID='open' freq=2412 MHz)
> <3>Trying to associate with 02:00:00:00:03:00 (SSID='open' freq=2412 MHz)
> <3>Associated with 02:00:00:00:03:00
> <3>CTRL-EVENT-CONNECTED - Connection to 02:00:00:00:03:00 completed [id=1 id_str=]
>
> Here the "Trying to associate" event message would show up more or less
> immediately after CTRL-EVENT-SCAN-RESULTS.
>

Thank you, this is what will help us!

>
> The updated patch:
>
> This provides more information to upper layer programs on what happens
> with connection attempts in cases where the enabled networks are not
> found in scan results.
>
> Signed-off-by: Dmitry Shmidt <dimitrysh at google.com>
> ---
>  src/common/wpa_ctrl.h   | 2 ++
>  wpa_supplicant/events.c | 3 +++
>  2 files changed, 5 insertions(+)
>
> diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h
> index e3a816f..e700523 100644
> --- a/src/common/wpa_ctrl.h
> +++ b/src/common/wpa_ctrl.h
> @@ -68,6 +68,8 @@ extern "C" {
>  #define WPA_EVENT_BSS_ADDED "CTRL-EVENT-BSS-ADDED "
>  /** A BSS entry was removed (followed by BSS entry id and BSSID) */
>  #define WPA_EVENT_BSS_REMOVED "CTRL-EVENT-BSS-REMOVED "
> +/** No suitable network was found */
> +#define WPA_EVENT_NETWORK_NOT_FOUND "CTRL-EVENT-NETWORK-NOT-FOUND "
>  /** Change in the signal level was reported by the driver */
>  #define WPA_EVENT_SIGNAL_CHANGE "CTRL-EVENT-SIGNAL-CHANGE "
>  /** Regulatory domain channel */
> diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
> index 601ddb3..aa171ef 100644
> --- a/wpa_supplicant/events.c
> +++ b/wpa_supplicant/events.c
> @@ -1628,6 +1628,9 @@ static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
>                         if (wpa_supplicant_req_sched_scan(wpa_s))
>                                 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
>                                                             timeout_usec);
> +
> +                       wpa_msg_ctrl(wpa_s, MSG_INFO,
> +                                    WPA_EVENT_NETWORK_NOT_FOUND);
>                 }
>         }
>         return 0;
> --
> 1.9.1
>
>
>
> --
> Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list