]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5396 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 12 Jul 2013 18:35:59 +0000 (13:35 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 12 Jul 2013 18:36:04 +0000 (13:36 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.c

index 98d2228e967db335b90dba73838eb3b678e29368..b8b00ac758a818a49a699cf78b21d756c1495fe7 100644 (file)
@@ -4275,6 +4275,24 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
                        }
                } else {
                        host++;
+                       
+                       if (!strchr(host, '.')) {
+                               struct sockaddr_in sa;
+                               struct hostent *he = gethostbyname(host);
+                               char *ip, *tmp;
+
+                               if (he) {
+                                       memcpy(&sa.sin_addr, he->h_addr, sizeof(struct in_addr));
+                                       ip = inet_ntoa(sa.sin_addr);
+                                       
+                                       tmp = switch_string_replace(dest, host, ip);
+                                       //host = switch_core_session_strdup(nsession, ip);
+                                       //dest = switch_core_session_strdup(nsession, tmp);
+                                       switch_channel_set_variable_printf(nchannel, "sip_route_uri", "sip:%s", tmp);
+                                       free(tmp);
+                               }
+                       }
+
                        tech_pvt->dest = switch_core_session_alloc(nsession, strlen(dest) + 5);
                        tech_pvt->e_dest = switch_core_session_strdup(nsession, dest);
                        switch_snprintf(tech_pvt->dest, strlen(dest) + 5, "sip:%s", dest);