Sfoglia il codice sorgente

topos: use INVITE transaction record to route BYE if dlg has no B-contact

Daniel-Constantin Mierla 8 anni fa
parent
commit
b3b95b5b70
1 ha cambiato i file con 17 aggiunte e 4 eliminazioni
  1. 17 4
      src/modules/topos/tps_msg.c

+ 17 - 4
src/modules/topos/tps_msg.c

@@ -773,12 +773,25 @@ int tps_request_received(sip_msg_t *msg, int dialog)
 		}
 		use_branch = 1;
 	} else {
-		if(tps_storage_load_dialog(msg, &mtsd, &stsd)<0) {
+		if(tps_storage_load_dialog(msg, &mtsd, &stsd) < 0) {
 			goto error;
 		}
-		/* detect direction - via from-tag */
-		if(tps_dlg_detect_direction(msg, &stsd, &direction) < 0) {
-			goto error;
+		if(((get_cseq(msg)->method_id) & (METHOD_BYE))
+				&& stsd.b_contact.len <= 0) {
+			/* BYE but not B-side contact, look for INVITE transaction record */
+			memset(&stsd, 0, sizeof(tps_data_t));
+			if(tps_storage_link_msg(msg, &mtsd, TPS_DIR_DOWNSTREAM) < 0) {
+				goto error;
+			}
+			if(tps_storage_load_branch(msg, &mtsd, &stsd, 1) < 0) {
+				goto error;
+			}
+			use_branch = 1;
+		} else {
+			/* detect direction - via from-tag */
+			if(tps_dlg_detect_direction(msg, &stsd, &direction) < 0) {
+				goto error;
+			}
 		}
 	}