]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 230145 via svnmerge from
authorJoshua Colp <jcolp@digium.com>
Fri, 13 Nov 2009 22:01:06 +0000 (22:01 +0000)
committerJoshua Colp <jcolp@digium.com>
Fri, 13 Nov 2009 22:01:06 +0000 (22:01 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

................
  r230145 | file | 2009-11-13 16:00:44 -0600 (Fri, 13 Nov 2009) | 15 lines

  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/branches/1.6.0@230146 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index c9dd6b71dcc2c68bb14fe27f4d5e0e201b2bdeb4..13817e34eb03587c3838e7b977ac2b7f03d04005 100644 (file)
@@ -12120,7 +12120,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;
        struct hostent *hp;
        struct ast_hostent ahp;
 
@@ -12136,8 +12136,16 @@ 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) 
+       if (c)
                *c = '\0';
 
        c = strchr(via, ' ');
@@ -12151,6 +12159,9 @@ static void check_via(struct sip_pvt *p, struct sip_request *req)
                pt = strchr(c, ':');
                if (pt)
                        *pt++ = '\0';   /* remember port pointer */
+               /* Use maddr if found */
+               if (maddr)
+                       c = maddr;
                hp = ast_gethostbyname(c, &ahp);
                if (!hp) {
                        ast_log(LOG_WARNING, "'%s' is not a valid host\n", c);