Start IP conflict monitoring only after default profile has been updated 35/191735/1 submit/tizen/20181023.084114
authorAbhishek Sansanwal <abhishek.s94@samsung.com>
Tue, 23 Oct 2018 05:52:06 +0000 (11:22 +0530)
committerAbhishek Sansanwal <abhishek.s94@samsung.com>
Tue, 23 Oct 2018 05:55:24 +0000 (11:25 +0530)
Signed-off-by: Abhishek Sansanwal <abhishek.s94@samsung.com>
Change-Id: I113a4f033a5bb398a494195fb4de11957cd7e7ff

src/ip-conflict-detect.c
src/signal-handler.c

index 0490866..4f9fc98 100755 (executable)
@@ -226,6 +226,7 @@ static gboolean send_arp(gpointer data)
        int ifindex = 0;
        errno = 0;
        const char *default_ip = NULL;
+       const char *if_name = NULL;
        static int initial_send_arp_count = 0;
 
        if (initial_bursts && initial_send_arp_count >= INITIAL_BURST_ARP_COUNT) {
@@ -272,7 +273,14 @@ static gboolean send_arp(gpointer data)
 
        memset(&net_ifr, 0, sizeof(net_ifr));
        /* ifreq structure creation */
-       size_t if_name_len = strlen(netconfig_get_default_ifname());
+       if_name = netconfig_get_default_ifname();
+       size_t if_name_len = strlen(if_name);
+
+       if (if_name_len == 0) {
+               INFO("Error : Unable to get interface name ");
+               goto err;
+       }
+
        if (if_name_len < sizeof(net_ifr.ifr_name)) {
                memcpy(net_ifr.ifr_name, netconfig_get_default_ifname(), if_name_len);
                net_ifr.ifr_name[if_name_len] = 0;
index 0552b46..8d7b66b 100755 (executable)
@@ -326,19 +326,6 @@ static void _service_signal_cb(GDBusConnection *conn,
                g_variant_get(variant, "s", &property);
 
                DBG("[%s] %s", property, path);
-               if (netconfig_is_wifi_profile(path) || netconfig_is_ethernet_profile(path)) {
-                       if (g_strcmp0(property, "ready") == 0) {
-                               for (idx = 0; idx < MAX_SOCKET_OPEN_RETRY; idx++) {
-                                       sd = start_ip_conflict_mon();
-                                       if (sd != NULL)
-                                               break;
-                               }
-                       } else if (g_strcmp0(property, "online") == 0) {
-                               // do nothing
-                       } else {
-                               stop_ip_conflict_mon();
-                       }
-               }
 
                if (netconfig_is_wifi_profile(path) == TRUE) {
                        int wifi_state = 0;
@@ -453,6 +440,21 @@ static void _service_signal_cb(GDBusConnection *conn,
                                netconfig_update_default_profile(NULL);
                        }
                }
+
+               if (netconfig_is_wifi_profile(path) || netconfig_is_ethernet_profile(path)) {
+                       if (g_strcmp0(property, "ready") == 0) {
+                               for (idx = 0; idx < MAX_SOCKET_OPEN_RETRY; idx++) {
+                                       sd = start_ip_conflict_mon();
+                                       if (sd != NULL)
+                                               break;
+                               }
+                       } else if (g_strcmp0(property, "online") == 0) {
+                               // do nothing
+                       } else {
+                               stop_ip_conflict_mon();
+                       }
+               }
+
                g_free(property);
        } else if (g_strcmp0(sigvalue, "Proxy") == 0) {
                if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0)