Module: kamailio
Branch: master
Commit: 5fabdea4d86c527a2e38caaae7a54884367d6a7c
URL:
https://github.com/kamailio/kamailio/commit/5fabdea4d86c527a2e38caaae7a5488…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-11-23T09:51:10+01:00
tm: default port checking in via_matching()
---
Modified: src/modules/tm/t_lookup.c
---
Diff:
https://github.com/kamailio/kamailio/commit/5fabdea4d86c527a2e38caaae7a5488…
Patch:
https://github.com/kamailio/kamailio/commit/5fabdea4d86c527a2e38caaae7a5488…
---
diff --git a/src/modules/tm/t_lookup.c b/src/modules/tm/t_lookup.c
index 1fff011dee..98a7bf97b9 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;
}