[SPIN] network: enable DHCP failure. 12/74412/1
authorNiraj Kumar Goit <niraj.g@samsung.com>
Tue, 14 Jun 2016 12:42:33 +0000 (18:12 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Tue, 14 Jun 2016 12:42:33 +0000 (18:12 +0530)
When DHCP is failed, most of normal users cannot understand
auto-generated IP (IPV4 link local). So set error CONNMAN_NETWORK_ERROR_DHCP_FAIL.

Change-Id: Ic80eb0436e41cff3a4bfb11dfef722b3029b0399
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
include/network.h
src/dhcp.c
src/network.c

index db25ae0..a095b52 100755 (executable)
@@ -55,6 +55,9 @@ enum connman_network_error {
        CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL  = 2,
        CONNMAN_NETWORK_ERROR_INVALID_KEY     = 3,
        CONNMAN_NETWORK_ERROR_CONNECT_FAIL    = 4,
+#if defined TIZEN_EXT
+       CONNMAN_NETWORK_ERROR_DHCP_FAIL       = 5,
+#endif
 };
 
 #define CONNMAN_NETWORK_PRIORITY_LOW      -100
index e4497fc..bc7deb2 100755 (executable)
@@ -476,11 +476,24 @@ done:
 static void ipv4ll_available_cb(GDHCPClient *ipv4ll_client, gpointer user_data)
 {
        struct connman_dhcp *dhcp = user_data;
-       char *address, *netmask;
-       unsigned char prefixlen;
+#if !defined TIZEN_EXT
+               char *address, *netmask;
+               unsigned char prefixlen;
+#endif
 
        DBG("IPV4LL available");
 
+#if defined TIZEN_EXT
+               /*
+                * Description: When DHCP is failed,
+                *               most of normal users cannot understand auto-generated IP
+                *              (IPV4 link local) and serious troubles to make Internet connection.
+                */
+               dhcp_invalidate(dhcp, true);
+
+               connman_network_set_error(dhcp->network,
+                                       CONNMAN_NETWORK_ERROR_DHCP_FAIL);
+#else
        address = g_dhcp_client_get_address(ipv4ll_client);
        netmask = g_dhcp_client_get_netmask(ipv4ll_client);
 
@@ -496,6 +509,7 @@ static void ipv4ll_available_cb(GDHCPClient *ipv4ll_client, gpointer user_data)
 
        g_free(address);
        g_free(netmask);
+#endif
 }
 
 static int dhcp_initialize(struct connman_dhcp *dhcp)
index 0d6b442..cf74682 100755 (executable)
@@ -1399,6 +1399,21 @@ static void set_connect_error(struct connman_network *network)
                                        CONNMAN_SERVICE_ERROR_CONNECT_FAILED);
 }
 
+#if defined TIZEN_EXT
+static void set_dhcp_error(struct connman_network *network)
+{
+       struct connman_service *service;
+
+       if (network->associating != FALSE)
+               network->associating = FALSE;
+
+       service = connman_service_lookup_from_network(network);
+
+       __connman_service_indicate_error(service,
+                                       CONNMAN_SERVICE_ERROR_DHCP_FAILED);
+}
+#endif
+
 void connman_network_set_ipv4_method(struct connman_network *network,
                                        enum connman_ipconfig_method method)
 {
@@ -1456,6 +1471,11 @@ void connman_network_set_error(struct connman_network *network,
        case CONNMAN_NETWORK_ERROR_CONNECT_FAIL:
                set_connect_error(network);
                break;
+#if defined TIZEN_EXT
+       case CONNMAN_NETWORK_ERROR_DHCP_FAIL:
+               set_dhcp_error(network);
+               break;
+#endif
        }
 
        network_change(network);