From a0c29c7da07fa8bf3e8839a4a64a183a02296a32 Mon Sep 17 00:00:00 2001 From: Niraj Kumar Goit Date: Mon, 23 Sep 2019 15:45:33 +0530 Subject: [PATCH] Added support to enable/disable Auto-IP option. Added support to enable/disable Auto-IP option using main.conf Change-Id: Iea1cae5a28681a90a5f79735c7374791a227feb7 Signed-off-by: Niraj Kumar Goit --- src/dhcp.c | 8 ++++++++ src/main.c | 15 +++++++++++++++ src/main.conf | 9 +++++++++ 3 files changed, 32 insertions(+) diff --git a/src/dhcp.c b/src/dhcp.c index 16f59b7..951836f 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -284,6 +284,14 @@ static void no_lease_cb(GDHCPClient *dhcp_client, gpointer user_data) DBG("No lease available ipv4ll %d client %p", dhcp->ipv4ll_running, dhcp->ipv4ll_client); +#if defined TIZEN_EXT + if (connman_setting_get_bool("EnableAutoIp") == false) { + DBG("link-local address autoconfiguration is disabled."); + if (dhcp->network) + __connman_network_disconnect(dhcp->network); + return; + } +#endif if (dhcp->timeout > 0) g_source_remove(dhcp->timeout); diff --git a/src/main.c b/src/main.c index 8221c35..0e603b8 100644 --- a/src/main.c +++ b/src/main.c @@ -96,6 +96,7 @@ static struct { #if defined TIZEN_EXT char **cellular_interfaces; bool tizen_tv_extension; + bool auto_ip; #endif } connman_settings = { .bg_scan = true, @@ -122,6 +123,7 @@ static struct { #if defined TIZEN_EXT .cellular_interfaces = NULL, .tizen_tv_extension = false, + .auto_ip = true, #endif }; @@ -149,6 +151,7 @@ static struct { #if defined TIZEN_EXT #define CONF_CELLULAR_INTERFACE "NetworkCellularInterfaceList" #define CONF_TIZEN_TV_EXT "TizenTVExtension" +#define CONF_ENABLE_AUTO_IP "EnableAutoIp" #endif static const char *supported_options[] = { @@ -312,6 +315,13 @@ static void check_Tizen_configuration(GKeyFile *config) connman_settings.tizen_tv_extension = boolean; g_clear_error(&error); + + boolean = __connman_config_get_bool(config, "General", + CONF_ENABLE_AUTO_IP, &error); + if (!error) + connman_settings.auto_ip = boolean; + + g_clear_error(&error); } static void set_nofile_inc(void) @@ -760,6 +770,11 @@ bool connman_setting_get_bool(const char *key) if (g_str_equal(key, CONF_USE_GATEWAYS_AS_TIMESERVERS)) return connman_settings.use_gateways_as_timeservers; +#if defined TIZEN_EXT + if (g_str_equal(key, CONF_ENABLE_AUTO_IP)) + return connman_settings.auto_ip; +#endif + return false; } diff --git a/src/main.conf b/src/main.conf index c3190ca..f40ac13 100755 --- a/src/main.conf +++ b/src/main.conf @@ -154,3 +154,12 @@ SingleConnectedTechnology = true # AddressConflictDetection = false NetworkCellularInterfaceList = pdp,rmnet,seth_td,seth_w + +# Enable use of link-local address for auto-configuration. +# When a device fails to get IP address from DHCP server, +# ConnMan will start link-local address autoconfiguration and +# assign a link-local IP address to device. +# If this setting is false and device fails to get IP address +# from DHCP server then device state will be set to disconnected. +# Default value is true. +# EnableAutoIp = false -- 2.7.4