Browse code

topos: uniform processing for requests during early dialog

- requests that are handled during 1xx state, like PRACK, UPDATE, BYE

Daniel-Constantin Mierla authored on 26/04/2021 07:28:35
Showing 1 changed files
... ...
@@ -834,35 +834,31 @@ int tps_request_received(sip_msg_t *msg, int dialog)
834 834
 
835 835
 	tps_storage_lock_get(&lkey);
836 836
 
837
-	if((get_cseq(msg)->method_id)&(METHOD_PRACK)) {
838
-		if(tps_storage_link_msg(msg, &mtsd, TPS_DIR_DOWNSTREAM)<0) {
837
+	if(tps_storage_load_dialog(msg, &mtsd, &stsd) < 0) {
838
+		goto error;
839
+	}
840
+	if(((get_cseq(msg)->method_id) & (METHOD_BYE|METHOD_PRACK|METHOD_UPDATE))
841
+			&& stsd.b_contact.len <= 0) {
842
+		/* no B-side contact, look for INVITE transaction record */
843
+		memset(&stsd, 0, sizeof(tps_data_t));
844
+		if((get_cseq(msg)->method_id) & (METHOD_UPDATE)) {
845
+			/* detect direction - via from-tag */
846
+			if(tps_dlg_detect_direction(msg, &stsd, &direction) < 0) {
847
+				goto error;
848
+			}
849
+		}
850
+		if(tps_storage_link_msg(msg, &mtsd, direction) < 0) {
839 851
 			goto error;
840 852
 		}
841
-		if(tps_storage_load_branch(msg, &mtsd, &stsd, 1)<0) {
853
+		if(tps_storage_load_branch(msg, &mtsd, &stsd, 1) < 0) {
842 854
 			goto error;
843 855
 		}
844 856
 		use_branch = 1;
845 857
 	} else {
846
-		if(tps_storage_load_dialog(msg, &mtsd, &stsd) < 0) {
858
+		/* detect direction - via from-tag */
859
+		if(tps_dlg_detect_direction(msg, &stsd, &direction) < 0) {
847 860
 			goto error;
848 861
 		}
849
-		if(((get_cseq(msg)->method_id) & (METHOD_BYE))
850
-				&& stsd.b_contact.len <= 0) {
851
-			/* BYE but not B-side contact, look for INVITE transaction record */
852
-			memset(&stsd, 0, sizeof(tps_data_t));
853
-			if(tps_storage_link_msg(msg, &mtsd, TPS_DIR_DOWNSTREAM) < 0) {
854
-				goto error;
855
-			}
856
-			if(tps_storage_load_branch(msg, &mtsd, &stsd, 1) < 0) {
857
-				goto error;
858
-			}
859
-			use_branch = 1;
860
-		} else {
861
-			/* detect direction - via from-tag */
862
-			if(tps_dlg_detect_direction(msg, &stsd, &direction) < 0) {
863
-				goto error;
864
-			}
865
-		}
866 862
 	}
867 863
 
868 864
 	mtsd.direction = direction;