]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Fix p2p_long_listen
authorJohannes Berg <johannes.berg@intel.com>
Tue, 1 Feb 2011 16:09:38 +0000 (18:09 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 1 Feb 2011 16:09:38 +0000 (18:09 +0200)
There are two issues with p2p_long_listen:
 1) max_remain_on_channel is assumed to be 5 seconds,
 2) if max_remain_on_channel is not a full multiple of
    seconds, accounting breaks.

Fix these by converting p2p_long_listen to ms and
tracking it according to max_remain_on_channel.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index ca5f013915c1af310f5bff4745ed68e17f8ef4b4..cedd999a80d881ca1de31cb7ebd0c0e5314e6e72 100644 (file)
@@ -2986,7 +2986,7 @@ void wpas_p2p_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
                                          unsigned int freq)
 {
        wpa_printf(MSG_DEBUG, "P2P: Cancel remain-on-channel callback "
-                  "(p2p_long_listen=%d pending_action_tx=%p)",
+                  "(p2p_long_listen=%d ms pending_action_tx=%p)",
                   wpa_s->p2p_long_listen, wpa_s->pending_action_tx);
        wpa_s->off_channel_freq = 0;
        if (p2p_listen_end(wpa_s->global->p2p, freq) > 0)
@@ -2994,10 +2994,10 @@ void wpas_p2p_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
        if (wpa_s->pending_action_tx)
                return;
        if (wpa_s->p2p_long_listen > 0)
-               wpa_s->p2p_long_listen -= 5;
+               wpa_s->p2p_long_listen -= wpa_s->max_remain_on_chan;
        if (wpa_s->p2p_long_listen > 0) {
                wpa_printf(MSG_DEBUG, "P2P: Continuing long Listen state");
-               wpas_p2p_listen_start(wpa_s, wpa_s->p2p_long_listen * 1000);
+               wpas_p2p_listen_start(wpa_s, wpa_s->p2p_long_listen);
        }
 }
 
@@ -3497,7 +3497,7 @@ int wpas_p2p_listen(struct wpa_supplicant *wpa_s, unsigned int timeout)
 
        res = wpas_p2p_listen_start(wpa_s, timeout * 1000);
        if (res == 0 && timeout * 1000 > wpa_s->max_remain_on_chan) {
-               wpa_s->p2p_long_listen = timeout;
+               wpa_s->p2p_long_listen = timeout * 1000;
                eloop_register_timeout(timeout, 0,
                                       wpas_p2p_long_listen_timeout,
                                       wpa_s, NULL);
index 9fdd799101c57fe426d8b8dbdda4f867cbfaacb3..42020cd011cb90b61a28ed4b0a6e8061f1db2147 100644 (file)
@@ -488,7 +488,7 @@ struct wpa_supplicant {
                P2P_GROUP_INTERFACE_CLIENT
        } p2p_group_interface;
        struct p2p_group *p2p_group;
-       int p2p_long_listen;
+       int p2p_long_listen; /* remaining time in long Listen state in ms */
        char p2p_pin[10];
        int p2p_wps_method;
        u8 p2p_auth_invite[ETH_ALEN];