OSDN Git Service

am 89ca702e: Do not inform other virtual interfaces of scan results in all cases
[android-x86/external-wpa_supplicant_8.git] / wpa_supplicant / p2p_supplicant.c
index 6dbfcdf..f8db14e 100644 (file)
 #endif /* P2P_MAX_INITIAL_CONN_WAIT */
 
 #ifndef P2P_CONCURRENT_SEARCH_DELAY
-#ifdef ANDROID_P2P
-#define P2P_CONCURRENT_SEARCH_DELAY 0
-#else
 #define P2P_CONCURRENT_SEARCH_DELAY 500
-#endif
 #endif /* P2P_CONCURRENT_SEARCH_DELAY */
 
 enum p2p_group_removal_reason {
@@ -82,9 +78,7 @@ enum p2p_group_removal_reason {
 #endif
 };
 
-#ifdef ANDROID_P2P
-static int wpas_global_scan_in_progress(struct wpa_supplicant *wpa_s);
-#endif
+
 static void wpas_p2p_long_listen_timeout(void *eloop_ctx, void *timeout_ctx);
 static struct wpa_supplicant *
 wpas_p2p_get_group_iface(struct wpa_supplicant *wpa_s, int addr_allocated,
@@ -104,22 +98,6 @@ static void wpas_p2p_set_group_idle_timeout(struct wpa_supplicant *wpa_s);
 static void wpas_p2p_fallback_to_go_neg(struct wpa_supplicant *wpa_s,
                                        int group_added);
 
-#ifdef ANDROID_P2P
-static int wpas_global_scan_in_progress(struct wpa_supplicant *wpa_s)
-{
-       struct wpa_supplicant *iface = NULL;
-
-       for (iface = wpa_s->global->ifaces; iface; iface = iface->next) {
-               if(iface->scanning  || iface->wpa_state == WPA_SCANNING) {
-                       wpa_printf(MSG_DEBUG, "P2P: Scan in progress on %s,"
-                       "defer P2P SEARCH", iface->ifname);
-                       return 1;
-               }
-       }
-
-       return 0;
-}
-#endif
 
 static void wpas_p2p_scan_res_handler(struct wpa_supplicant *wpa_s,
                                      struct wpa_scan_results *scan_res)
@@ -166,7 +144,7 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq,
                        wpa_printf(MSG_DEBUG, "Delaying P2P scan to allow "
                                   "pending station mode scan to be "
                                   "completed on interface %s", ifs->ifname);
-                       wpa_s->p2p_cb_on_scan_complete = 1;
+                       wpa_s->global->p2p_cb_on_scan_complete = 1;
                        wpa_supplicant_req_scan(ifs, 0, 0);
                        return 1;
                }
@@ -223,10 +201,13 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq,
        wpabuf_free(ies);
 
        if (ret) {
-               if (wpa_s->scanning ||
-                   wpa_s->scan_res_handler == wpas_p2p_scan_res_handler) {
-                       wpa_s->p2p_cb_on_scan_complete = 1;
-                       ret = 1;
+               for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) {
+                       if (ifs->scanning ||
+                           ifs->scan_res_handler == wpas_p2p_scan_res_handler) {
+                               wpa_s->global->p2p_cb_on_scan_complete = 1;
+                               ret = 1;
+                               break;
+                       }
                }
        } else
                wpa_s->scan_res_handler = wpas_p2p_scan_res_handler;
@@ -283,11 +264,7 @@ static int wpas_p2p_group_delete(struct wpa_supplicant *wpa_s,
        const char *reason;
 
        ssid = wpa_s->current_ssid;
-#ifdef ANDROID_P2P
-       if ((ssid == NULL) && (wpa_s->p2p_group_interface == NOT_P2P_GROUP_INTERFACE)) {
-#else
        if (ssid == NULL) {
-#endif
                /*
                 * The current SSID was not known, but there may still be a
                 * pending P2P group interface waiting for provisioning.
@@ -700,6 +677,7 @@ static void wpas_group_formation_completed(struct wpa_supplicant *wpa_s,
 #ifdef ANDROID_P2P
                /* For client Second phase of Group formation (4-way handshake) can be still pending
                 * So we need to restore wpa_s->global->p2p_group_formation */
+               wpa_printf(MSG_INFO, "Restoring back wpa_s->global->p2p_group_formation to wpa_s %p\n", wpa_s);
                wpa_s->global->p2p_group_formation = wpa_s;
 #endif
 
@@ -1189,7 +1167,7 @@ void wpas_dev_found(void *ctx, const u8 *addr,
        char devtype[WPS_DEV_TYPE_BUFSIZE];
 #define WFD_DEV_INFO_SIZE 9
        char wfd_dev_info_hex[2 * WFD_DEV_INFO_SIZE + 1];
-
+       os_memset(wfd_dev_info_hex, 0, sizeof(wfd_dev_info_hex));
 #ifdef CONFIG_WIFI_DISPLAY
        if (info->wfd_subelems) {
                wpa_snprintf_hex(wfd_dev_info_hex, sizeof(wfd_dev_info_hex),
@@ -1197,7 +1175,6 @@ void wpas_dev_found(void *ctx, const u8 *addr,
                                        WFD_DEV_INFO_SIZE);
        }
 #endif /* CONFIG_WIFI_DISPLAY */
-
        wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_DEVICE_FOUND MACSTR
                " p2p_dev_addr=" MACSTR
                " pri_dev_type=%s name='%s' config_methods=0x%x "
@@ -2193,6 +2170,18 @@ static void wpas_prov_disc_fail(void *ctx, const u8 *peer,
                return;
        }
 
+#ifdef ANDROID_P2P
+       /* If provision discovery failed it is safe to cancel the timer here and
+        * also do not start the join */
+       if (wpa_s->pending_pd_before_join &&
+           (os_memcmp(peer, wpa_s->pending_join_dev_addr, ETH_ALEN) == 0 ||
+            os_memcmp(peer, wpa_s->pending_join_iface_addr, ETH_ALEN) == 0)) {
+               wpa_s->pending_pd_before_join = 0;
+               wpa_printf(MSG_DEBUG, "P2P: Do not Start pending "
+                          "join-existing-group operation");
+               eloop_cancel_timeout(wpas_p2p_pd_before_join_timeout, wpa_s, NULL);
+       }
+#endif /* ANDROID_P2P */
        wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_PROV_DISC_FAILURE
                " p2p_dev_addr=" MACSTR " status=%d",
                MAC2STR(peer), status);
@@ -4270,7 +4259,7 @@ void wpas_p2p_stop_find(struct wpa_supplicant *wpa_s)
        wpa_s->p2p_long_listen = 0;
        eloop_cancel_timeout(wpas_p2p_long_listen_timeout, wpa_s, NULL);
        eloop_cancel_timeout(wpas_p2p_join_scan, wpa_s, NULL);
-       wpa_s->p2p_cb_on_scan_complete = 0;
+       wpa_s->global->p2p_cb_on_scan_complete = 0;
 
        if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) {
                wpa_drv_p2p_stop_find(wpa_s);
@@ -4603,9 +4592,9 @@ void wpas_p2p_completed(struct wpa_supplicant *wpa_s)
        wpas_notify_p2p_group_started(wpa_s, ssid, network_id, 1);
 
 done:
-       if (wpa_s->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled &&
+       if (wpa_s->global->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled &&
            wpa_s->global->p2p != NULL) {
-               wpa_s->p2p_cb_on_scan_complete = 0;
+               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");
@@ -5198,28 +5187,9 @@ int wpas_p2p_disconnect(struct wpa_supplicant *wpa_s)
 
 int wpas_p2p_in_progress(struct wpa_supplicant *wpa_s)
 {
-#ifdef ANDROID_P2P
-       struct wpa_supplicant *group = wpa_s;
-#endif
-
        if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
                return 0;
 
-#ifdef ANDROID_P2P
-       while (group && (group->p2p_group_interface != NOT_P2P_GROUP_INTERFACE)) {
-               if(group->wpa_state == WPA_ASSOCIATED) {
-                       /* WPA_ASSOCIATED hasn't moved to WPA_COMPLETED. So it could be in WPS
-                        * or 4Way Hanshake phase. Avoid allowing scan during this time critical
-                        * phase
-                        */
-                       wpa_printf(MSG_ERROR, "P2P: WPS/4way handshake in Progress."
-                       " Defer SCAN ");
-                       return 1;
-               }
-               group = group->next;
-       }
-#endif
-
        return p2p_in_progress(wpa_s->global->p2p);
 }
 
@@ -5385,7 +5355,7 @@ int wpas_p2p_handle_frequency_conflicts(struct wpa_supplicant *wpa_s, int freq)
                         * P2P Client, remove the interface depending up on the connection
                         * priority */
                        if(!wpas_is_p2p_prioritized(wpa_s)) {
-                               /* STA connection has priority over existing 
+                               /* STA connection has priority over existing
                                 * P2P connection. So remove the interface */
                                wpa_printf(MSG_DEBUG, "P2P: Removing P2P connection due to Single channel"
                                                "concurrent mode frequency conflict");