P2P: Use common function for re-starting P2P scan after station scan
authorJouni Malinen <jouni@qca.qualcomm.com>
Mon, 18 Mar 2013 14:31:09 +0000 (16:31 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 18 Mar 2013 15:32:31 +0000 (17:32 +0200)
Make the implementation more consistent and cleaner by using a single
function for addressing all the cases where completion of a station mode
scan operation allows a P2P operation (search) to be re-started.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

wpa_supplicant/events.c
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/p2p_supplicant.h
wpa_supplicant/wpa_supplicant.c

index d91dd31..1c48eba 100644 (file)
@@ -2505,18 +2505,9 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 #ifndef CONFIG_NO_SCAN_PROCESSING
        case EVENT_SCAN_RESULTS:
                wpa_supplicant_event_scan_results(wpa_s, data);
-#ifdef CONFIG_P2P
-       if (wpa_s->global->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled &&
-           wpa_s->global->p2p != NULL &&
-           wpa_s->wpa_state != WPA_AUTHENTICATING &&
-           wpa_s->wpa_state != WPA_ASSOCIATING) {
-               wpa_s->global->p2p_cb_on_scan_complete = 0;
-               if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) {
-                       wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation "
-                               "continued after scan result processing");
-               }
-       }
-#endif /* CONFIG_P2P */
+               if (wpa_s->wpa_state != WPA_AUTHENTICATING &&
+                   wpa_s->wpa_state != WPA_ASSOCIATING)
+                       wpas_p2p_continue_after_scan(wpa_s);
                break;
 #endif /* CONFIG_NO_SCAN_PROCESSING */
        case EVENT_ASSOCINFO:
index bbcde8f..76ddf0f 100644 (file)
@@ -4964,17 +4964,7 @@ void wpas_p2p_completed(struct wpa_supplicant *wpa_s)
        wpas_notify_p2p_group_started(wpa_s, ssid, network_id, 1);
 
 done:
-       if (wpa_s->global->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled &&
-           wpa_s->global->p2p != NULL) {
-               wpa_s->global->p2p_cb_on_scan_complete = 0;
-               if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) {
-                       wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation "
-                               "continued after successful connection");
-                       p2p_increase_search_delay(
-                               wpa_s->global->p2p,
-                               wpas_p2p_search_delay(wpa_s));
-               }
-       }
+       wpas_p2p_continue_after_scan(wpa_s);
 }
 
 
@@ -5748,3 +5738,27 @@ unsigned int wpas_p2p_search_delay(struct wpa_supplicant *wpa_s)
 
        return 0;
 }
+
+
+void wpas_p2p_continue_after_scan(struct wpa_supplicant *wpa_s)
+{
+       wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Station mode scan operation not "
+               "pending anymore (sta_scan_pending=%d "
+               "p2p_cb_on_scan_complete=%d)", wpa_s->sta_scan_pending,
+               wpa_s->global->p2p_cb_on_scan_complete);
+       wpa_s->sta_scan_pending = 0;
+
+       if (!wpa_s->global->p2p_cb_on_scan_complete)
+               return;
+       wpa_s->global->p2p_cb_on_scan_complete = 0;
+
+       if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
+               return;
+
+       if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) {
+               wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation "
+                       "continued after successful connection");
+               p2p_increase_search_delay(wpa_s->global->p2p,
+                                         wpas_p2p_search_delay(wpa_s));
+       }
+}
index 5f0bfd2..0a7212c 100644 (file)
@@ -150,4 +150,12 @@ int wpas_p2p_get_ht40_mode(struct wpa_supplicant *wpa_s,
                           struct hostapd_hw_modes *mode, u8 channel);
 unsigned int wpas_p2p_search_delay(struct wpa_supplicant *wpa_s);
 
+#ifdef CONFIG_P2P
+void wpas_p2p_continue_after_scan(struct wpa_supplicant *wpa_s);
+#else /* CONFIG_P2P */
+static inline void wpas_p2p_continue_after_scan(struct wpa_supplicant *wpa_s)
+{
+}
+#endif /* CONFIG_P2P */
+
 #endif /* P2P_SUPPLICANT_H */
index 23e2da2..24cc8b6 100644 (file)
@@ -199,16 +199,7 @@ static void wpa_supplicant_timeout(void *eloop_ctx, void *timeout_ctx)
         */
        wpa_supplicant_req_scan(wpa_s, 1, 0);
 
-#ifdef CONFIG_P2P
-       if (wpa_s->global->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled &&
-           wpa_s->global->p2p != NULL) {
-               wpa_s->global->p2p_cb_on_scan_complete = 0;
-               if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) {
-                       wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation "
-                               "continued after timed out authentication");
-               }
-       }
-#endif /* CONFIG_P2P */
+       wpas_p2p_continue_after_scan(wpa_s);
 }
 
 
@@ -3554,16 +3545,7 @@ void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid)
        wpa_supplicant_req_scan(wpa_s, timeout / 1000,
                                1000 * (timeout % 1000));
 
-#ifdef CONFIG_P2P
-       if (wpa_s->global->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled &&
-           wpa_s->global->p2p != NULL) {
-               wpa_s->global->p2p_cb_on_scan_complete = 0;
-               if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) {
-                       wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation "
-                               "continued after failed association");
-               }
-       }
-#endif /* CONFIG_P2P */
+       wpas_p2p_continue_after_scan(wpa_s);
 }