diff options
author | Niraj Kumar Goit <niraj.g@samsung.com> | 2022-02-15 10:23:07 +0530 |
---|---|---|
committer | Niraj Kumar Goit <niraj.g@samsung.com> | 2022-02-15 10:25:05 +0530 |
commit | f89b473dfd8e916314b534b3397442f8c869c783 (patch) | |
tree | b6f15a191886ac5b78e98b1b2b210adefae69cf2 /src/main.c | |
parent | dd3cccc5e67548dcc2dd6c6254ed6c97859085d5 (diff) | |
download | connman-f89b473dfd8e916314b534b3397442f8c869c783.tar.gz connman-f89b473dfd8e916314b534b3397442f8c869c783.tar.bz2 connman-f89b473dfd8e916314b534b3397442f8c869c783.zip |
Imported Upstream version 1.40upstream/1.40
Change-Id: Id3e405d088ee3fb19fd0ca049e1cb7f812b40fca
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 92 |
1 files changed, 81 insertions, 11 deletions
@@ -44,6 +44,14 @@ #define DEFAULT_INPUT_REQUEST_TIMEOUT (120 * 1000) #define DEFAULT_BROWSER_LAUNCH_TIMEOUT (300 * 1000) +/* + * We set the integer to 1 sec so that we have a chance to get + * necessary IPv6 router advertisement messages that might have + * DNS data etc. + */ +#define DEFAULT_ONLINE_CHECK_INITIAL_INTERVAL 1 +#define DEFAULT_ONLINE_CHECK_MAX_INTERVAL 12 + #define MAINFILE "main.conf" #define CONFIGMAINFILE CONFIGDIR "/" MAINFILE @@ -88,6 +96,9 @@ static struct { bool enable_6to4; char *vendor_class_id; bool enable_online_check; + bool enable_online_to_ready_transition; + unsigned int online_check_initial_interval; + unsigned int online_check_max_interval; bool auto_connect_roaming_services; bool acd; bool use_gateways_as_timeservers; @@ -110,6 +121,9 @@ static struct { .enable_6to4 = false, .vendor_class_id = NULL, .enable_online_check = true, + .enable_online_to_ready_transition = false, + .online_check_initial_interval = DEFAULT_ONLINE_CHECK_INITIAL_INTERVAL, + .online_check_max_interval = DEFAULT_ONLINE_CHECK_MAX_INTERVAL, .auto_connect_roaming_services = false, .acd = false, .use_gateways_as_timeservers = false, @@ -133,6 +147,9 @@ static struct { #define CONF_ENABLE_6TO4 "Enable6to4" #define CONF_VENDOR_CLASS_ID "VendorClassID" #define CONF_ENABLE_ONLINE_CHECK "EnableOnlineCheck" +#define CONF_ENABLE_ONLINE_TO_READY_TRANSITION "EnableOnlineToReadyTransition" +#define CONF_ONLINE_CHECK_INITIAL_INTERVAL "OnlineCheckInitialInterval" +#define CONF_ONLINE_CHECK_MAX_INTERVAL "OnlineCheckMaxInterval" #define CONF_AUTO_CONNECT_ROAMING_SERVICES "AutoConnectRoamingServices" #define CONF_ACD "AddressConflictDetection" #define CONF_USE_GATEWAYS_AS_TIMESERVERS "UseGatewaysAsTimeservers" @@ -141,6 +158,7 @@ static const char *supported_options[] = { CONF_BG_SCAN, CONF_PREF_TIMESERVERS, CONF_AUTO_CONNECT_TECHS, + CONF_FAVORITE_TECHS, CONF_ALWAYS_CONNECTED_TECHS, CONF_PREFERRED_TECHS, CONF_FALLBACK_NAMESERVERS, @@ -155,6 +173,9 @@ static const char *supported_options[] = { CONF_ENABLE_6TO4, CONF_VENDOR_CLASS_ID, CONF_ENABLE_ONLINE_CHECK, + CONF_ENABLE_ONLINE_TO_READY_TRANSITION, + CONF_ONLINE_CHECK_INITIAL_INTERVAL, + CONF_ONLINE_CHECK_MAX_INTERVAL, CONF_AUTO_CONNECT_ROAMING_SERVICES, CONF_ACD, CONF_USE_GATEWAYS_AS_TIMESERVERS, @@ -280,9 +301,9 @@ static void parse_config(GKeyFile *config) char **interfaces; char **str_list; char **tethering; - char *vendor_class_id; + char *string; gsize len; - int timeout; + int integer; if (!config) { connman_settings.auto_connect = @@ -369,17 +390,17 @@ static void parse_config(GKeyFile *config) g_clear_error(&error); - timeout = g_key_file_get_integer(config, "General", + integer = g_key_file_get_integer(config, "General", CONF_TIMEOUT_INPUTREQ, &error); - if (!error && timeout >= 0) - connman_settings.timeout_inputreq = timeout * 1000; + if (!error && integer >= 0) + connman_settings.timeout_inputreq = integer * 1000; g_clear_error(&error); - timeout = g_key_file_get_integer(config, "General", + integer = g_key_file_get_integer(config, "General", CONF_TIMEOUT_BROWSERLAUNCH, &error); - if (!error && timeout >= 0) - connman_settings.timeout_browserlaunch = timeout * 1000; + if (!error && integer >= 0) + connman_settings.timeout_browserlaunch = integer * 1000; g_clear_error(&error); @@ -440,10 +461,10 @@ static void parse_config(GKeyFile *config) g_clear_error(&error); - vendor_class_id = __connman_config_get_string(config, "General", + string = __connman_config_get_string(config, "General", CONF_VENDOR_CLASS_ID, &error); if (!error) - connman_settings.vendor_class_id = vendor_class_id; + connman_settings.vendor_class_id = string; g_clear_error(&error); @@ -458,6 +479,40 @@ static void parse_config(GKeyFile *config) g_clear_error(&error); boolean = __connman_config_get_bool(config, "General", + CONF_ENABLE_ONLINE_TO_READY_TRANSITION, &error); + if (!error) { + connman_settings.enable_online_to_ready_transition = boolean; + } + + g_clear_error(&error); + + integer = g_key_file_get_integer(config, "General", + CONF_ONLINE_CHECK_INITIAL_INTERVAL, &error); + if (!error && integer >= 0) + connman_settings.online_check_initial_interval = integer; + + g_clear_error(&error); + + integer = g_key_file_get_integer(config, "General", + CONF_ONLINE_CHECK_MAX_INTERVAL, &error); + if (!error && integer >= 0) + connman_settings.online_check_max_interval = integer; + + g_clear_error(&error); + + if (connman_settings.online_check_initial_interval < 1 || + connman_settings.online_check_initial_interval > + connman_settings.online_check_max_interval) { + connman_warn("Incorrect online check intervals [%u, %u]", + connman_settings.online_check_initial_interval, + connman_settings.online_check_max_interval); + connman_settings.online_check_initial_interval = + DEFAULT_ONLINE_CHECK_INITIAL_INTERVAL; + connman_settings.online_check_max_interval = + DEFAULT_ONLINE_CHECK_MAX_INTERVAL; + } + + boolean = __connman_config_get_bool(config, "General", CONF_AUTO_CONNECT_ROAMING_SERVICES, &error); if (!error) connman_settings.auto_connect_roaming_services = boolean; @@ -648,7 +703,7 @@ static GOptionEntry options[] = { { NULL }, }; -const char *connman_option_get_string(const char *key) +char *connman_setting_get_string(const char *key) { if (g_str_equal(key, CONF_VENDOR_CLASS_ID)) return connman_settings.vendor_class_id; @@ -686,6 +741,9 @@ bool connman_setting_get_bool(const char *key) if (g_str_equal(key, CONF_ENABLE_ONLINE_CHECK)) return connman_settings.enable_online_check; + if (g_str_equal(key, CONF_ENABLE_ONLINE_TO_READY_TRANSITION)) + return connman_settings.enable_online_to_ready_transition; + if (g_str_equal(key, CONF_AUTO_CONNECT_ROAMING_SERVICES)) return connman_settings.auto_connect_roaming_services; @@ -698,6 +756,17 @@ bool connman_setting_get_bool(const char *key) return false; } +unsigned int connman_setting_get_uint(const char *key) +{ + if (g_str_equal(key, CONF_ONLINE_CHECK_INITIAL_INTERVAL)) + return connman_settings.online_check_initial_interval; + + if (g_str_equal(key, CONF_ONLINE_CHECK_MAX_INTERVAL)) + return connman_settings.online_check_max_interval; + + return 0; +} + char **connman_setting_get_string_list(const char *key) { if (g_str_equal(key, CONF_PREF_TIMESERVERS)) @@ -919,6 +988,7 @@ int main(int argc, char *argv[]) g_strfreev(connman_settings.fallback_nameservers); g_strfreev(connman_settings.blacklisted_interfaces); g_strfreev(connman_settings.tethering_technologies); + g_free(connman_settings.vendor_class_id); g_free(option_debug); g_free(option_wifi); |