Loading...

connman@connman.net

[Prev] Thread [Next]  |  [Prev] Date [Next]

[PATCH v6 13/14] timeservers: Add Fallback Timerservers Alok Barsode Thu Apr 05 04:00:40 2012

From: Alok Barsode <[EMAIL PROTECTED]>

Add Fallback timeservers via main.conf.
These timeservers are used for time corrections when
there are no valid timeservers provided by the user or by the
network. The list of timeservers which are queried for
timing correction are Timeservers.Configuration (set by the
user), service timeservers(via service), gateway, global
timeservers (via clock API) and fallback timeservers, in that order.
---
 src/main.conf    |    7 +++++++
 src/timeserver.c |    7 +++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/main.conf b/src/main.conf
index b4144dd..92ec841 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -5,3 +5,10 @@
 # the scan list is empty. In that case, a simple backoff
 # mechanism starting from 10s up to 5 minutes will run.
 BackgroundScanning = true
+
+# List of Fallback timeservers separated by ",".
+# These timeservers are used for NTP sync when there are
+# no timeserver set by the user or by the service.
+# These can contain mixed combination of fully qualified
+# domain names, IPv4 and IPv6 addresses.
+# FallbackTimeservers =
diff --git a/src/timeserver.c b/src/timeserver.c
index 2558d99..65b7ad0 100644
--- a/src/timeserver.c
+++ b/src/timeserver.c
@@ -172,6 +172,7 @@ int __connman_timeserver_sync(struct connman_service 
*default_service)
        char **service_ts;
        char **service_ts_config;
        const char *service_gw;
+       char **fallback_ts;
        int index, i;
 
        if (default_service != NULL)
@@ -227,6 +228,12 @@ int __connman_timeserver_sync(struct connman_service 
*default_service)
        for (i=0; timeservers != NULL && timeservers[i] != NULL; i++)
                ts_list = g_slist_prepend(ts_list, g_strdup(timeservers[i]));
 
+       fallback_ts = connman_setting_get_string_list("FallbackTimeservers");
+
+       /* Lastly add the fallback servers */
+       for (i=0; fallback_ts != NULL && fallback_ts[i] != NULL; i++)
+               ts_list = g_slist_prepend(ts_list, g_strdup(fallback_ts[i]));
+
        if (ts_list == NULL) {
                DBG("No timeservers set.");
                return 0;
-- 
1.7.5.4

_______________________________________________
connman mailing list
[EMAIL PROTECTED]
http://lists.connman.net/listinfo/connman