]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
patch for FSCORE-219
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 27 Nov 2008 02:30:11 +0000 (02:30 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 27 Nov 2008 02:30:11 +0000 (02:30 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10554 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_stun.h
src/mod/endpoints/mod_sofia/sofia_glue.c
src/switch_stun.c

index 1542873fff1277cd10e9f29b65d75303aa1bc7c4..5a0a78a27c096beba878ab52464b58bc61ffdafb 100644 (file)
@@ -147,6 +147,7 @@ SWITCH_DECLARE(switch_stun_packet_t *) switch_stun_packet_parse(uint8_t *buf, ui
 */
 SWITCH_DECLARE(const char *) switch_stun_value_to_name(int32_t type, uint32_t value);
 
+SWITCH_DECLARE(char *) switch_stun_host_lookup(const char *host, switch_memory_pool_t *pool);
 
 /*!
   \brief Extract a mapped address (IP:PORT) from a packet attribute
index 5d2ee72ab42f46c1848d7bbb0bf09fa318a87e8b..b63be91b2fab9fe60242b92916e41dd3eb84a674 100644 (file)
@@ -448,7 +448,9 @@ switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_
                return status;
        }
 
-       if (!strncasecmp(sourceip, "stun:", 5)) {
+       if (!strncasecmp(sourceip, "host:", 5)) {
+               status = (*ip = switch_stun_host_lookup(sourceip + 5, pool)) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
+       } else if (!strncasecmp(sourceip, "stun:", 5)) {
                char *p;
 
                if (!(profile->pflags & PFLAG_STUN_ENABLED)) {
index c68da753ee4d71ec88da97cf2858ff56e849566c..bc8e540d049b2b622983e2ba899f0152ed300960 100644 (file)
@@ -428,6 +428,16 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_username(switch_stun_pa
        return 1;
 }
 
+SWITCH_DECLARE(char *) switch_stun_host_lookup(const char *host, switch_memory_pool_t *pool)
+{
+       switch_sockaddr_t *addr = NULL;
+       char buf[30];
+       
+       switch_sockaddr_info_get(&addr, host, SWITCH_UNSPEC, 0, 0, pool);
+       return switch_core_strdup(pool, switch_str_nil(switch_get_addr(buf, sizeof(buf), addr)));
+       
+}
+
 SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
                                                                                                   switch_port_t *port, char *stunip, switch_port_t stunport, char **err, switch_memory_pool_t *pool)
 {