]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add a host lookup func
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 27 Aug 2009 22:58:55 +0000 (22:58 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 27 Aug 2009 22:58:55 +0000 (22:58 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14653 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_utils.h
src/switch_utils.c

index 3bb578e98fc93142df80d4383eccbaf6f5f83c92..daa2f615acf85d4c3cc39f460e21cd15dbd474fa 100644 (file)
@@ -165,6 +165,9 @@ SWITCH_DECLARE(switch_status_t) switch_frame_free(switch_frame_t **frame);
 (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
index 079ee7bc302b1682c164369df034bf634cee6a59..2e1d6be3212a57d300563247c1c210996b3c1b7b 100644 (file)
@@ -866,6 +866,25 @@ static int get_netmask(struct sockaddr_in *me, int *mask)
 
 #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;