diff options
author | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-04-14 13:16:05 +0000 |
---|---|---|
committer | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-04-14 13:16:05 +0000 |
commit | cd899dc5128223afae19dd8d69b5a6c0e81fd71e (patch) | |
tree | f3434ff7344296dcb4f7e9759a2ae07a011848b7 /channels | |
parent | 8d2ad48d0b5364200d833e32c2af4925ae8d0bca (diff) |
Merged revisions 188247 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r188247 | file | 2009-04-14 10:14:21 -0300 (Tue, 14 Apr 2009) | 7 lines
Fix a bug with the change I made yesterday to outbound proxy support.
Per discussion with oej on IRC we need the actual IP address, not the
outbound proxy IP address, in the sa field. This change matches the already
existing code for all other uses of the outbound proxy setting.
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@188248 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_sip.c | 68 |
1 files changed, 30 insertions, 38 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index ea303f159..f5e975309 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -4200,48 +4200,40 @@ static int create_addr(struct sip_pvt *dialog, const char *opeer, int newdialog) /* Get the outbound proxy information */ dialog->outboundproxy = obproxy_get(dialog, NULL); - /* If we have an outbound proxy, don't bother with DNS resolution at all */ - if (dialog->outboundproxy) { - /* If we have an outbound proxy, don't bother with DNS resolution at all, but set the port */ - portno = port ? atoi(port) : (dialog->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT; - memcpy(&dialog->sa.sin_addr, &dialog->outboundproxy->ip.sin_addr, sizeof(dialog->sa.sin_addr)); - } else { + /* Let's see if we can find the host in DNS. First try DNS SRV records, + then hostname lookup */ + /*! \todo Fix this function. When we ask SRC, we should check all transports + In the future, we should first check NAPTR to find out transport preference + */ - /* Let's see if we can find the host in DNS. First try DNS SRV records, - then hostname lookup */ - /*! \todo Fix this function. When we ask SRC, we should check all transports - In the future, we should first check NAPTR to find out transport preference - */ + hostn = peername; + /* Section 4.2 of RFC 3263 specifies that if a port number is specified, then + * an A record lookup should be used instead of SRV. + */ + if (!port && global_srvlookup) { + char service[MAXHOSTNAMELEN]; + int tportno; + int ret; - hostn = peername; - /* Section 4.2 of RFC 3263 specifies that if a port number is specified, then - * an A record lookup should be used instead of SRV. - */ - if (!port && global_srvlookup) { - char service[MAXHOSTNAMELEN]; - int tportno; - int ret; - - snprintf(service, sizeof(service), "_sip._%s.%s", get_transport(dialog->socket.type), peername); - ret = ast_get_srv(NULL, host, sizeof(host), &tportno, service); - if (ret > 0) { - hostn = host; - portno = tportno; - } - } - if (!portno) - portno = port ? atoi(port) : (dialog->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT; - hp = ast_gethostbyname(hostn, &ahp); - if (!hp) { - ast_log(LOG_WARNING, "No such host: %s\n", peername); - return -1; - } - memcpy(&dialog->sa.sin_addr, hp->h_addr, sizeof(dialog->sa.sin_addr)); - if (ast_strlen_zero(port) || sscanf(port, "%u", &portno) != 1) { - portno = (dialog->socket.type & SIP_TRANSPORT_TLS) ? - STANDARD_TLS_PORT : STANDARD_SIP_PORT; + snprintf(service, sizeof(service), "_sip._%s.%s", get_transport(dialog->socket.type), peername); + ret = ast_get_srv(NULL, host, sizeof(host), &tportno, service); + if (ret > 0) { + hostn = host; + portno = tportno; } } + if (!portno) + portno = port ? atoi(port) : (dialog->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT; + hp = ast_gethostbyname(hostn, &ahp); + if (!hp) { + ast_log(LOG_WARNING, "No such host: %s\n", peername); + return -1; + } + memcpy(&dialog->sa.sin_addr, hp->h_addr, sizeof(dialog->sa.sin_addr)); + if (ast_strlen_zero(port) || sscanf(port, "%u", &portno) != 1) { + portno = (dialog->socket.type & SIP_TRANSPORT_TLS) ? + STANDARD_TLS_PORT : STANDARD_SIP_PORT; + } if (!dialog->socket.type) dialog->socket.type = SIP_TRANSPORT_UDP; |