From 5fabdea4d86c527a2e38caaae7a54884367d6a7c Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Thu, 23 Nov 2017 09:50:30 +0100 Subject: [PATCH] tm: default port checking in via_matching() --- src/modules/tm/t_lookup.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/modules/tm/t_lookup.c b/src/modules/tm/t_lookup.c index 1fff011dee0..98a7bf97b9d 100644 --- a/src/modules/tm/t_lookup.c +++ b/src/modules/tm/t_lookup.c @@ -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; }