Revision
14653
Author
anthm
Date
2009-08-27 17:58:55 -0500 (Thu, 27 Aug 2009)

Log Message

add a host lookup func

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/switch_utils.h (14652 => 14653)


--- freeswitch/trunk/src/include/switch_utils.h	2009-08-27 21:41:47 UTC (rev 14652)
+++ freeswitch/trunk/src/include/switch_utils.h	2009-08-27 22:58:55 UTC (rev 14653)
@@ -165,6 +165,9 @@
 (switch_is_number(expr) && !atoi(expr)))) ? SWITCH_TRUE : SWITCH_FALSE)
 
 
+SWITCH_DECLARE(switch_status_t) switch_resolve_host(char *host, char *buf, size_t buflen);
+
+
 /*!
   \brief find local ip of the box
   \param buf the buffer to write the ip adress found into

Modified: freeswitch/trunk/src/switch_utils.c (14652 => 14653)


--- freeswitch/trunk/src/switch_utils.c	2009-08-27 21:41:47 UTC (rev 14652)
+++ freeswitch/trunk/src/switch_utils.c	2009-08-27 22:58:55 UTC (rev 14653)
@@ -866,6 +866,25 @@
 
 #endif
 
+
+SWITCH_DECLARE(switch_status_t) switch_resolve_host(char *host, char *buf, size_t buflen)
+{
+
+    struct addrinfo *ai;
+    int err;
+	
+    if ((err = getaddrinfo(host, 0, 0, &ai))) {
+        return SWITCH_STATUS_FALSE;
+    }
+
+	get_addr(buf, buflen, ai->ai_addr, sizeof(*ai->ai_addr));
+
+    freeaddrinfo(ai);
+
+    return SWITCH_STATUS_SUCCESS;
+}
+
+
 SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int *mask, int family)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;