tm: default port checking in via_matching()
authorDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 23 Nov 2017 08:50:30 +0000 (09:50 +0100)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 23 Nov 2017 08:51:10 +0000 (09:51 +0100)
src/modules/tm/t_lookup.c

index 1fff011..98a7bf9 100644 (file)
@@ -259,17 +259,35 @@ static inline int via_matching( struct via_body *inv_via,
         * different senders generating the same tid
         */
        if (inv_via->host.len!=ack_via->host.len)
-               return 0;;
+               return 0;
        if (memcmp(inv_via->host.s, ack_via->host.s,
                                ack_via->host.len)!=0)
                return 0;
-       if (inv_via->port!=ack_via->port)
-               return 0;
+       if (inv_via->port!=ack_via->port) {
+               if(!(inv_via->port==0
+                               && (ack_via->port==SIP_PORT || ack_via->port==SIPS_PORT)))
+                       return 0;
+               if(!(ack_via->port==0
+                               && (inv_via->port==SIP_PORT || inv_via->port==SIPS_PORT)))
+                       return 0;
+       }
        if (inv_via->transport.len!=ack_via->transport.len)
                return 0;
        if (memcmp(inv_via->transport.s, ack_via->transport.s,
                                ack_via->transport.len)!=0)
                return 0;
+
+       if (inv_via->port!=ack_via->port
+                       && (inv_via->port==0 || ack_via->port==0)) {
+               /* test SIPS_PORT (5061) is used with TLS transport*/
+               if(inv_via->port==SIPS_PORT || ack_via->port==SIPS_PORT) {
+                       if(ack_via->transport.len!=3
+                                       || memcmp(inv_via->transport.s, "TLS", 3)!=0) {
+                               return 0;
+                       }
+               }
+       }
+
        /* everything matched -- we found it */
        return 1;
 }