[sr-dev] git:master:ceb688b3: topos: use direction for loading invite record for other early dialog requests

Daniel-Constantin Mierla miconda at gmail.com
Thu Apr 21 09:02:33 CEST 2022


Module: kamailio
Branch: master
Commit: ceb688b3d364bb7b8d9f52b7238d560cb4e30b3d
URL: https://github.com/kamailio/kamailio/commit/ceb688b3d364bb7b8d9f52b7238d560cb4e30b3d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-04-21T09:02:01+02:00

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

- GH #3090

---

Modified: src/modules/topos/tps_msg.c
Modified: src/modules/topos/tps_storage.c

---

Diff:  https://github.com/kamailio/kamailio/commit/ceb688b3d364bb7b8d9f52b7238d560cb4e30b3d.diff
Patch: https://github.com/kamailio/kamailio/commit/ceb688b3d364bb7b8d9f52b7238d560cb4e30b3d.patch

---

diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c
index c7de5e514f..c16a0adacb 100644
--- a/src/modules/topos/tps_msg.c
+++ b/src/modules/topos/tps_msg.c
@@ -803,6 +803,7 @@ int tps_request_received(sip_msg_t *msg, int dialog)
 	uint32_t direction = TPS_DIR_DOWNSTREAM;
 	int ret;
 	int use_branch = 0;
+	unsigned int metid = 0;
 
 	LM_DBG("handling incoming request\n");
 
@@ -835,11 +836,11 @@ int tps_request_received(sip_msg_t *msg, int dialog)
 	if(tps_storage_load_dialog(msg, &mtsd, &stsd) < 0) {
 		goto error;
 	}
-        if(((((get_cseq(msg)->method_id) & (METHOD_PRACK|METHOD_UPDATE))
-			&& stsd.b_contact.len <= 0)) || (((get_cseq(msg)->method_id) 
-                        & (METHOD_BYE) && stsd.b_contact.len <= 0) && (0 == dialog))) {
+	metid = get_cseq(msg)->method_id;
+	if((metid & (METHOD_BYE|METHOD_PRACK|METHOD_UPDATE))
+			&& stsd.b_contact.len <= 0) {
 		/* no B-side contact, look for INVITE transaction record */
-		if((get_cseq(msg)->method_id) & (METHOD_UPDATE)) {
+		if(metid & (METHOD_BYE|METHOD_UPDATE)) {
 			/* detect direction - via from-tag */
 			if(tps_dlg_detect_direction(msg, &stsd, &direction) < 0) {
 				goto error;
@@ -917,7 +918,7 @@ int tps_request_received(sip_msg_t *msg, int dialog)
 				goto error;
 			}
 		}
-		if((get_cseq(msg)->method_id)&(METHOD_SUBSCRIBE)) {
+		if(metid & METHOD_SUBSCRIBE) {
 			if(tps_storage_update_dialog(msg, &mtsd, &stsd, TPS_DBU_CONTACT|TPS_DBU_TIME)<0) {
 				goto error;
 			}
diff --git a/src/modules/topos/tps_storage.c b/src/modules/topos/tps_storage.c
index 1a67c0252c..56d56776a4 100644
--- a/src/modules/topos/tps_storage.c
+++ b/src/modules/topos/tps_storage.c
@@ -1146,7 +1146,11 @@ int tps_db_load_branch(sip_msg_t *msg, tps_data_t *md, tps_data_t *sd,
 		db_ops[nr_keys]=OP_EQ;
 		db_vals[nr_keys].type = DB1_STR;
 		db_vals[nr_keys].nul = 0;
-		db_vals[nr_keys].val.str_val = TPS_STRZ(md->b_tag);
+		if(md->direction==TPS_DIR_DOWNSTREAM) {
+			db_vals[nr_keys].val.str_val = TPS_STRZ(md->b_tag);
+		} else {
+			db_vals[nr_keys].val.str_val = TPS_STRZ(md->a_tag);
+		}
 		nr_keys++;
 
 		db_keys[nr_keys]=&tt_col_s_method;




More information about the sr-dev mailing list