Hi Alok,

On 03/21/2012 01:08 PM, Alok Barsode wrote:
From: Alok Barsode<[email protected]>

Add default service Gateway to the timeserver query list.
Now the list is service timeservers(via DHCP), gateway and global
timeservers, in that order.
---
  src/timeserver.c |   25 ++++++++++++++++++++++---
  1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/timeserver.c b/src/timeserver.c
index 0ec87a5..c16716a 100644
--- a/src/timeserver.c
+++ b/src/timeserver.c
@@ -34,6 +34,7 @@
  static GList *ts_list = NULL;

  static char **service_ts = NULL;
+static const char *service_gw;

  static GResolv *resolv = NULL;
  static int resolv_id = 0;
@@ -153,11 +154,12 @@ void __connman_timeserver_sync_next()
   * __connman_timeserver_sync function recreates the timeserver
   * list which will be used to determine NTP server for time corrections.
   * It must be called everytime the default service changes, the service
- * timeserver(s) changes or the global timeserver(s) changes.The service
- * settings take priority over the global timeservers.
+ * timeserver(s) or gatway changes or the global timeserver(s) changes.
+ * The service settings take priority over the global timeservers.
   */
  int __connman_timeserver_sync(struct connman_service *service)
  {
+       struct connman_ipconfig *ipconfig;
        char **timeservers = NULL;
        int i;

@@ -178,12 +180,23 @@ int __connman_timeserver_sync(struct connman_service 
*service)
                ts_list = NULL;
        }

-       if(service)
+       if(service) {

Style issue, space missing

                service_ts = connman_service_get_timeservers(service);

+               ipconfig = __connman_service_get_ip4config(service);

What about IPv6, it has a gateway also?

+
+               service_gw = __connman_ipconfig_get_gateway(ipconfig);
+       }
+
+       /* First add Service Timeservers via DHCP to the list */
        for(i=0; service_ts != NULL&&  service_ts[i] != NULL; i++)
                ts_list = g_list_append(ts_list, g_strdup(service_ts[i]));

+       /* Then add Service Gateway to the list */
+       if(service_gw)

Style issue, space missing here

+               ts_list = g_list_append(ts_list, g_strdup(service_gw));
+
+       /* Then add Global Timeservers to the list */
        timeservers = load_timeservers();

        for(i=0; timeservers != NULL&&  timeservers[i] != NULL; i++)
@@ -201,6 +214,7 @@ int __connman_timeserver_sync(struct connman_service 
*service)

  static int timeserver_start(struct connman_service *service)
  {
+       struct connman_ipconfig *ipconfig;
        char **nameservers = NULL;
        int i;

@@ -237,6 +251,11 @@ static int timeserver_start(struct connman_service 
*service)
        /* Cache service timeservers */
        service_ts = connman_service_get_timeservers(service);

+       ipconfig = __connman_service_get_ip4config(service);

IPv6 needs to be remembered also

+
+       /* Cache service Gateway */
+       service_gw = __connman_ipconfig_get_gateway(ipconfig);
+
        return __connman_timeserver_sync(NULL);
  }



Cheers,
Jukka

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to