summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorMichael L. Young <elgueromexicano@gmail.com>2012-11-29 21:58:41 +0000
committerMichael L. Young <elgueromexicano@gmail.com>2012-11-29 21:58:41 +0000
commit587906cb6c6129cb04ab3e85ae1b33c9bf4e8de8 (patch)
tree93baee42ece00e2882e9222c76f8a3bcfe508e16 /channels
parent23c53c18c0db619efdc55f6c1669f458822f5327 (diff)
Improve Code Readability And Fix Setting natdetected Flag
For 1.8, 10, 11 and trunk we are are improving the code readability. For 11 and trunk, auto nat detection was added. The natdetected flag was being set to 1 when the host address in the VIA header did not specifiy a port. This patch fixes this by setting the port on the temporary sock address used to SIP_STANDARD_PORT in order for the sock address comparison to work properly. (closes issue ASTERISK-20724) Reported by: Michael L. Young Patches: asterisk-20724-set-port-v2.diff uploaded by Michael L. Young (license 5026) Review: https://reviewboard.asterisk.org/r/2206/ ........ Merged revisions 376834 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 376835 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 376836 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@376837 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 67c2a1c7c..0dc6069c8 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -17896,10 +17896,13 @@ static void check_via(struct sip_pvt *p, struct sip_request *req)
if (ast_sockaddr_resolve_first(&tmp, c, 0)) {
ast_log(LOG_WARNING, "Could not resolve socket address for '%s'\n", c);
+ port = STANDARD_SIP_PORT;
+ } else if (!(port = ast_sockaddr_port(&tmp)) {
+ port = STANDARD_SIP_PORT;
+ ast_sockaddr_set_port(&tmp, port);
}
- port = ast_sockaddr_port(&tmp);
- ast_sockaddr_set_port(&p->sa,
- port != 0 ? port : STANDARD_SIP_PORT);
+
+ ast_sockaddr_set_port(&p->sa, port);
/* Check and see if the requesting UA is likely to be behind a NAT. If they are, set the
* natdetected flag so that later, peers with nat=auto_* can use the value. Also