diff options
author | twilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-01-17 00:29:43 +0000 |
---|---|---|
committer | twilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-01-17 00:29:43 +0000 |
commit | 530398aeded0fa14353b08861cab768fd3147b29 (patch) | |
tree | f751edf4f54f607e8ae4d24d264feda6f18c5321 | |
parent | 31e7d73422f7967e3ddd2c3efed1b7c09e06cc5b (diff) |
Merged revisions 169044 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r169044 | twilson | 2009-01-16 18:03:39 -0600 (Fri, 16 Jan 2009) | 8 lines
Fix port :0 added to SIP INVITE URI when outboundproxy used
(closes issue #14233)
Reported by: chris-mac
Patches:
asterisk-bug14233.diff.txt uploaded by jamesgolovich (license 176)
Tested by: jamesgolovich, chris-mac, otherwiseguy
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@169078 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_sip.c | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 6522dd7c9..f493a0162 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -4163,42 +4163,47 @@ static int create_addr(struct sip_pvt *dialog, const char *opeer) dialog->outboundproxy = obproxy_get(dialog, NULL); /* If we have an outbound proxy, don't bother with DNS resolution at all */ - if (dialog->outboundproxy) - return 0; + 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; + } 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; + if (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; + } + } + 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; + } + } - hostn = peername; if (!dialog->socket.type) dialog->socket.type = SIP_TRANSPORT_UDP; if (!dialog->socket.port) dialog->socket.port = bindaddr.sin_port; - if (ast_strlen_zero(port) || sscanf(port, "%u", &portno) != 1) { - portno = (dialog->socket.type & SIP_TRANSPORT_TLS) ? - STANDARD_TLS_PORT : STANDARD_SIP_PORT; - } - if (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; - } - } - 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)); dialog->sa.sin_port = htons(portno); dialog->recv = dialog->sa; return 0; |