Added support of WPA3-SAE security mode.
[platform/upstream/connman.git] / src / timeserver.c
old mode 100644 (file)
new mode 100755 (executable)
index d41fa40..6325ece
@@ -88,6 +88,15 @@ static void resolv_result(GResolvResultStatus status, char **results,
 {
        int i;
 
+#if defined TIZEN_EXT
+       gchar *server = NULL;
+
+       server = g_strdup((gchar *)user_data);
+       ts_list = g_slist_append(ts_list, server);
+
+       DBG("added server %s", server);
+#endif
+
        DBG("status %d", status);
 
        if (status == G_RESOLV_RESULT_STATUS_SUCCESS) {
@@ -117,7 +126,7 @@ static void resolv_result(GResolvResultStatus status, char **results,
  * Once the timeserver list (ts_list) is created, we start querying the
  * servers one by one. If resolving fails on one of them, we move to the
  * next one. The user can enter either an IP address or a URL for the
- * timeserver. We only resolve the urls. Once we have a IP for the NTP
+ * timeserver. We only resolve the URLs. Once we have an IP for the NTP
  * server, we start querying it for time corrections.
  */
 void __connman_timeserver_sync_next()
@@ -137,7 +146,7 @@ void __connman_timeserver_sync_next()
 
        ts_list = g_slist_delete_link(ts_list, ts_list);
 
-       /* if its a IP , directly query it. */
+       /* if it's an IP, directly query it. */
        if (connman_inet_check_ipaddress(ts_current) > 0) {
                DBG("Using timeserver %s", ts_current);
 
@@ -146,10 +155,15 @@ void __connman_timeserver_sync_next()
                return;
        }
 
-       DBG("Resolving server %s", ts_current);
+       DBG("Resolving timeserver %s", ts_current);
 
+#if defined TIZEN_EXT
+       resolv_id = g_resolv_lookup_hostname(resolv, ts_current,
+                                               resolv_result, ts_current);
+#else
        resolv_id = g_resolv_lookup_hostname(resolv, ts_current,
                                                resolv_result, NULL);
+#endif
 
        return;
 }
@@ -200,7 +214,7 @@ GSList *__connman_timeserver_get_all(struct connman_service *service)
 
        service_ts = connman_service_get_timeservers(service);
 
-       /* First add Service Timeservers via DHCP to the list */
+       /* Then add Service Timeservers via DHCP to the list */
        for (i = 0; service_ts && service_ts[i]; i++)
                list = __connman_timeserver_add_list(list, service_ts[i]);
 
@@ -286,11 +300,13 @@ static void ts_recheck_enable(void)
 
 /*
  * This function must be called everytime the default service changes, the
- * service timeserver(s) or gatway changes or the global timeserver(s) changes.
+ * service timeserver(s) or gateway changes or the global timeserver(s) changes.
  */
 int __connman_timeserver_sync(struct connman_service *default_service)
 {
        struct connman_service *service;
+       char **nameservers;
+       int i;
 
        if (default_service)
                service = default_service;
@@ -314,6 +330,17 @@ int __connman_timeserver_sync(struct connman_service *default_service)
        if (resolv_id > 0)
                g_resolv_cancel_lookup(resolv, resolv_id);
 
+       g_resolv_flush_nameservers(resolv);
+
+       nameservers = connman_service_get_nameservers(service);
+       if (!nameservers)
+               return -EINVAL;
+
+       for (i = 0; nameservers[i]; i++)
+               g_resolv_add_nameserver(resolv, nameservers[i], 53, 0);
+
+       g_strfreev(nameservers);
+
        g_slist_free_full(ts_list, g_free);
 
        ts_list = __connman_timeserver_get_all(service);