aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c68
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;