소스 검색

tm: default port checking in via_matching()

(cherry picked from commit 5fabdea4d86c527a2e38caaae7a54884367d6a7c)
(cherry picked from commit be53e5d24707d8248a904124a6c88913b6eb0174)
Daniel-Constantin Mierla 7 년 전
부모
커밋
5736d90efa
1개의 변경된 파일21개의 추가작업 그리고 3개의 파일을 삭제
  1. 21 3
      src/modules/tm/t_lookup.c

+ 21 - 3
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;
 }