Browse code

topos: use direction for loading invite record for other early dialog requests

- GH #3090

Daniel-Constantin Mierla authored on 21/04/2022 07:00:09
Showing 2 changed files
... ...
@@ -803,6 +803,7 @@ int tps_request_received(sip_msg_t *msg, int dialog)
803 803
 	uint32_t direction = TPS_DIR_DOWNSTREAM;
804 804
 	int ret;
805 805
 	int use_branch = 0;
806
+	unsigned int metid = 0;
806 807
 
807 808
 	LM_DBG("handling incoming request\n");
808 809
 
... ...
@@ -835,11 +836,11 @@ int tps_request_received(sip_msg_t *msg, int dialog)
835 836
 	if(tps_storage_load_dialog(msg, &mtsd, &stsd) < 0) {
836 837
 		goto error;
837 838
 	}
838
-        if(((((get_cseq(msg)->method_id) & (METHOD_PRACK|METHOD_UPDATE))
839
-			&& stsd.b_contact.len <= 0)) || (((get_cseq(msg)->method_id) 
840
-                        & (METHOD_BYE) && stsd.b_contact.len <= 0) && (0 == dialog))) {
839
+	metid = get_cseq(msg)->method_id;
840
+	if((metid & (METHOD_BYE|METHOD_PRACK|METHOD_UPDATE))
841
+			&& stsd.b_contact.len <= 0) {
841 842
 		/* no B-side contact, look for INVITE transaction record */
842
-		if((get_cseq(msg)->method_id) & (METHOD_UPDATE)) {
843
+		if(metid & (METHOD_BYE|METHOD_UPDATE)) {
843 844
 			/* detect direction - via from-tag */
844 845
 			if(tps_dlg_detect_direction(msg, &stsd, &direction) < 0) {
845 846
 				goto error;
... ...
@@ -917,7 +918,7 @@ int tps_request_received(sip_msg_t *msg, int dialog)
917 918
 				goto error;
918 919
 			}
919 920
 		}
920
-		if((get_cseq(msg)->method_id)&(METHOD_SUBSCRIBE)) {
921
+		if(metid & METHOD_SUBSCRIBE) {
921 922
 			if(tps_storage_update_dialog(msg, &mtsd, &stsd, TPS_DBU_CONTACT|TPS_DBU_TIME)<0) {
922 923
 				goto error;
923 924
 			}
... ...
@@ -1146,7 +1146,11 @@ int tps_db_load_branch(sip_msg_t *msg, tps_data_t *md, tps_data_t *sd,
1146 1146
 		db_ops[nr_keys]=OP_EQ;
1147 1147
 		db_vals[nr_keys].type = DB1_STR;
1148 1148
 		db_vals[nr_keys].nul = 0;
1149
-		db_vals[nr_keys].val.str_val = TPS_STRZ(md->b_tag);
1149
+		if(md->direction==TPS_DIR_DOWNSTREAM) {
1150
+			db_vals[nr_keys].val.str_val = TPS_STRZ(md->b_tag);
1151
+		} else {
1152
+			db_vals[nr_keys].val.str_val = TPS_STRZ(md->a_tag);
1153
+		}
1150 1154
 		nr_keys++;
1151 1155
 
1152 1156
 		db_keys[nr_keys]=&tt_col_s_method;