From: Alok Barsode <[email protected]>

Use getaddrinfo instead of g_hostname_is_ip_address to
determine if the timeserver is a Domain name or a IP
address.
---
 src/timeserver.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/src/timeserver.c b/src/timeserver.c
index 641ac06..d716940 100644
--- a/src/timeserver.c
+++ b/src/timeserver.c
@@ -28,6 +28,7 @@
 #include <glib.h>
 #include <stdlib.h>
 #include <gweb/gresolv.h>
+#include <netdb.h>
 
 #include "connman.h"
 
@@ -142,6 +143,9 @@ void __connman_timeserver_sync_next()
 {
        char *server;
        GSList *list;
+       int ret;
+       struct addrinfo hints;
+       struct addrinfo *addr;
 
        __connman_ntp_stop();
 
@@ -154,8 +158,15 @@ void __connman_timeserver_sync_next()
 
        ts_list = g_slist_delete_link(ts_list, list);
 
+       memset(&hints, 0, sizeof(struct addrinfo));
+       hints.ai_flags = AI_NUMERICHOST;
+       addr = NULL;
+
+       ret = getaddrinfo(server, NULL, &hints, &addr);
+       freeaddrinfo(addr);
+
        /* if its a IP , directly query it. */
-       if (g_hostname_is_ip_address(server) == TRUE) {
+       if (ret == 0) {
                DBG("Using timeservers %s", server);
 
                __connman_ntp_start(server);
-- 
1.7.5.4

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

Reply via email to