Browse Source

relaxed CANCEL matching (no to-tags included) introduced

Jiri Kuthan 23 years ago
parent
commit
15b681f5eb
2 changed files with 29 additions and 5 deletions
  1. 9 3
      modules/tm/README
  2. 20 2
      modules/tm/t_lookup.c

+ 9 - 3
modules/tm/README

@@ -285,8 +285,8 @@ or cat test/transaction.fifo > /tmp/ser_fifo
 
 
 Defines
 Defines
 -------
 -------
-- TOTAG enables matching of acknowledgemnts including to-tags;
-  it is disabled by default for two reasons:
+- ACK_TAG enables stricter matching of acknowledgemnts including to-tags;
+  without it, to-tags are ignored; it is disabled by default for two reasons:
   a) it eliminates an unlikely race condition in which
   a) it eliminates an unlikely race condition in which
      transaction's to-tag is being rewritten by a 200 OK
      transaction's to-tag is being rewritten by a 200 OK
      whereas an ACK is being looked up by to-tag
      whereas an ACK is being looked up by to-tag
@@ -296,7 +296,13 @@ Defines
   negative reply sent upstream and 200/ACKs are not matched
   negative reply sent upstream and 200/ACKs are not matched
   as they consititute another transaction. It will make no
   as they consititute another transaction. It will make no
   difference at all when the new magic cookie matching is
   difference at all when the new magic cookie matching is
-  enabled.
+  enabled anyway.
+- CANCEL_TAG similarly enables strict matching of CANCELs 
+  including to-tags -- act of mercy to UACs, who screw up
+  the to-tags (however, it still depends on how forgiving
+  the downstream UAS is); like with ACK_TAG, all this
+  complex transactions matching goes with RFC3261's
+  magic cookie away anyway
 
 
 
 
 
 

+ 20 - 2
modules/tm/t_lookup.c

@@ -191,7 +191,10 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
 			/* To only the uri and ... */
 			/* To only the uri and ... */
 			if (get_to(t_msg)->uri.len!=get_to(p_msg)->uri.len)
 			if (get_to(t_msg)->uri.len!=get_to(p_msg)->uri.len)
 				continue;
 				continue;
-#ifdef TOTAG
+			/* don't care about to-tags -- many UAC screw them
+			 * up anyway, and it doesn't hurt if we ignore 
+			 * them */
+#ifdef ACKTAG
 			/* ... its to-tag compared to reply's tag */
 			/* ... its to-tag compared to reply's tag */
 			if (p_cell->uas.to_tag.len!=get_to(p_msg)->tag_value.len)
 			if (p_cell->uas.to_tag.len!=get_to(p_msg)->tag_value.len)
 				continue;
 				continue;
@@ -207,7 +210,7 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
 			if (!EQ_STR(from)) continue;
 			if (!EQ_STR(from)) continue;
 			if (memcmp(get_to(t_msg)->uri.s, get_to(p_msg)->uri.s,
 			if (memcmp(get_to(t_msg)->uri.s, get_to(p_msg)->uri.s,
 				get_to(t_msg)->uri.len)!=0) continue;
 				get_to(t_msg)->uri.len)!=0) continue;
-#ifdef TOTAG
+#ifdef ACKTAG
 			if (
 			if (
 #ifdef _BUG
 #ifdef _BUG
 				p_cell->uas.to_tag.len!=0 /* to-tags empty */ || 
 				p_cell->uas.to_tag.len!=0 /* to-tags empty */ || 
@@ -299,8 +302,17 @@ struct cell* t_lookupOriginalT(  struct sip_msg* p_msg )
 			continue;
 			continue;
 		if (!EQ_LEN(from))
 		if (!EQ_LEN(from))
 			continue;
 			continue;
+#ifdef CANCEL_TAG
 		if (!EQ_LEN(to))
 		if (!EQ_LEN(to))
 			continue;
 			continue;
+#else
+		/* relaxed matching -- we don't care about to-tags anymore,
+		 * many broken UACs screw them up and ignoring them does not
+		 * actually hurt
+		 */
+		if (get_to(t_msg)->uri.len!=get_to(p_msg)->uri.len)
+			continue;
+#endif
 		if (!EQ_REQ_URI_LEN)
 		if (!EQ_REQ_URI_LEN)
 			continue;
 			continue;
 		if (!EQ_VIA_LEN(via1))
 		if (!EQ_VIA_LEN(via1))
@@ -314,8 +326,14 @@ struct cell* t_lookupOriginalT(  struct sip_msg* p_msg )
 			continue;
 			continue;
 		if (!EQ_STR(from))
 		if (!EQ_STR(from))
 			continue;
 			continue;
+#ifdef CANCEL_TAG
 		if (!EQ_STR(to))
 		if (!EQ_STR(to))
 			continue;
 			continue;
+#else
+		if (memcmp(get_to(t_msg)->uri.s, get_to(p_msg)->uri.s,
+					get_to(t_msg)->uri.len)!=0)
+			continue;
+#endif
 		if (!EQ_REQ_URI_STR)
 		if (!EQ_REQ_URI_STR)
 			continue;
 			continue;
 		if (!EQ_VIA_STR(via1))
 		if (!EQ_VIA_STR(via1))