[tdls]: Block TDLS "PeerFound" event after timer expired 42/131442/2
authorManeesh Jain <maneesh.jain@samsung.com>
Mon, 29 May 2017 08:35:48 +0000 (14:05 +0530)
committerManeesh Jain <maneesh.jain@samsung.com>
Mon, 29 May 2017 08:38:38 +0000 (08:38 +0000)
Change-Id: Ia6d49f1b370f4c130149405d96d2faca29732a9a
Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
src/wifi-tdls.c

index 87def91..8c00068 100755 (executable)
@@ -40,6 +40,7 @@ char *peer_mac = NULL;
 int is_connected = 0;
 static gint tdls_timer_id = 0;
 int is_discover_broadcast = 0;
+int is_timer_expired = 0;
 
 #define TDLS_DISCOVER_TIMOUT 4 /*TDLS Unicast Discovery Timeout*/
 #define TDLS_DISCOVER_BROADCAST_TIMOUT 8 /*TDLS Broadcast Discovery Timeout*/
@@ -101,6 +102,8 @@ static gboolean _tdls_timer_discover_event(gpointer user_data)
        __netconfig_wifi_notify_tdls_discover_event("00:00:00:00:00:00", is_discover_broadcast);
        is_discover_broadcast = 0;
        stop_tdls_timer();
+       is_timer_expired = 1;
+
        return FALSE;
 }
 
@@ -199,6 +202,7 @@ gboolean handle_tdls_discover(Wifi *wifi, GDBusMethodInvocation *context,
        int discover_timeout = 0;
 
        GVariant *message = NULL;
+
        message = __netconfig_wifi_tdls_send_dbus_str("TDLSDiscover", (const char*)peer_mac_Addr);
 
        if (message == NULL) {
@@ -220,6 +224,7 @@ gboolean handle_tdls_discover(Wifi *wifi, GDBusMethodInvocation *context,
                discover_timeout = TDLS_DISCOVER_TIMOUT;
        }
 
+       is_timer_expired = 0;
        tdls_timer_id = g_timeout_add_seconds(discover_timeout,
                                        _tdls_timer_discover_event, NULL);
 
@@ -408,16 +413,19 @@ void netconfig_wifi_tdls_disconnected_event(GVariant *message)
 
 void netconfig_wifi_tdls_peer_found_event(GVariant *message)
 {
-       DBG("WiFi TDLS Discovery EVENT");
+       DBG("WiFi TDLS Discovery EVENT Received !!");
        const gchar *peer_mac_addr = NULL;
 
-       g_variant_get(message, "(s)", &peer_mac_addr);
-       INFO("Discover Peer Mac Address: [%s]", peer_mac_addr);
+       if (!is_timer_expired) {
 
+               g_variant_get(message, "(s)", &peer_mac_addr);
+               INFO("Discover Peer Mac Address: [%s]", peer_mac_addr);
 
-       if (is_discover_broadcast == 0)
-               stop_tdls_timer();
+               if (is_discover_broadcast == 0)
+                       stop_tdls_timer();
 
-       __netconfig_wifi_notify_tdls_discover_event(peer_mac_addr, is_discover_broadcast);
+               __netconfig_wifi_notify_tdls_discover_event(peer_mac_addr, is_discover_broadcast);
+       } else
+               DBG("Timer expired: Do not process the TDLS Discovery Event");
 }