summaryrefslogtreecommitdiff
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2009-11-13 22:00:44 +0000
committerJoshua Colp <jcolp@digium.com>2009-11-13 22:00:44 +0000
commit8ba56154bb2c891097b53eaa426c61b61d36f26e (patch)
tree71648d4dc8af93a8ca7f92225ce18351813f5828 /channels/chan_sip.c
parent5e2aa190fe2e4903bfc72701bb3c9ed1672b9c2f (diff)
Merged revisions 230144 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r230144 | file | 2009-11-13 16:00:19 -0600 (Fri, 13 Nov 2009) | 8 lines Respect the maddr parameter in the Via header. (closes issue #14446) Reported by: frawd Patches: via_maddr.patch uploaded by frawd (license 610) Tested by: frawd ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@230145 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 487b6e39a..66262e6e2 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -14490,7 +14490,7 @@ static attribute_unused void check_via_response(struct sip_pvt *p, struct sip_re
static void check_via(struct sip_pvt *p, struct sip_request *req)
{
char via[512];
- char *c, *pt;
+ char *c, *pt, *maddr;
ast_copy_string(via, get_header(req, "Via"), sizeof(via));
@@ -14504,12 +14504,23 @@ static void check_via(struct sip_pvt *p, struct sip_request *req)
if (c && (c[6] != '=')) /* rport query, not answer */
ast_set_flag(&p->flags[1], SIP_PAGE2_RPORT_PRESENT);
+ /* Check for maddr */
+ maddr = strstr(via, "maddr=");
+ if (maddr) {
+ maddr += 6;
+ c = maddr + strspn(maddr, "0123456789.");
+ *c = '\0';
+ }
+
c = strchr(via, ';');
if (c)
*c = '\0';
c = strchr(via, ' ');
if (c) {
+ struct hostent *hp;
+ struct ast_hostent ahp;
+
*c = '\0';
c = ast_skip_blanks(c+1);
if (strcasecmp(via, "SIP/2.0/UDP") && strcasecmp(via, "SIP/2.0/TCP") && strcasecmp(via, "SIP/2.0/TLS")) {
@@ -14519,7 +14530,12 @@ static void check_via(struct sip_pvt *p, struct sip_request *req)
pt = strchr(c, ':');
if (pt)
*pt++ = '\0'; /* remember port pointer */
- p->sa = p->recv;
+
+ if (maddr && (hp = ast_gethostbyname(maddr, &ahp))) {
+ memcpy(&p->sa.sin_addr, hp->h_addr, sizeof(p->sa.sin_addr));
+ } else {
+ p->sa = p->recv;
+ }
p->sa.sin_port = htons(port_str2int(pt, STANDARD_SIP_PORT));
if (sip_debug_test_pvt(p)) {