[sr-dev] git:master:b44b2452: topos: more flexible contact_mode 1/2 param parsing by using existing parse functions

Henning Westerholt hw at skalatan.de
Thu Jul 30 18:00:38 CEST 2020


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

Author: Henning Westerholt <hw at skalatan.de>
Committer: Henning Westerholt <hw at skalatan.de>
Date: 2020-07-30T15:53:37Z

topos: more flexible contact_mode 1/2 param parsing by using existing parse functions

---

Modified: src/modules/topos/tps_msg.c

---

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

---

diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c
index e3d4ab41cb..c296cd5b30 100644
--- a/src/modules/topos/tps_msg.c
+++ b/src/modules/topos/tps_msg.c
@@ -303,6 +303,7 @@ int tps_dlg_detect_direction(sip_msg_t *msg, tps_data_t *ptsd,
 int tps_dlg_message_update(sip_msg_t *msg, tps_data_t *ptsd, int ctmode)
 {
 	str tmp;
+	int ret;
 
 	if(parse_sip_msg_uri(msg)<0) {
 		LM_ERR("failed to parse r-uri\n");
@@ -314,12 +315,17 @@ int tps_dlg_message_update(sip_msg_t *msg, tps_data_t *ptsd, int ctmode)
 			LM_DBG("not an expected param format\n");
 			return 1;
 		}
-
-		tmp.s = msg->parsed_uri.sip_params.s;
-		// skip param and '=' sign
-		tmp.s += _tps_cparam_name.len + 1;
-		tmp.len = msg->parsed_uri.sip_params.len - _tps_cparam_name.len - 1;
-
+		// find parameter, there might be others
+		ret = tps_get_param_value(&msg->parsed_uri.params,
+			&_tps_cparam_name, &tmp);
+		if (ret < 0) {
+			LM_ERR("failed to parse param\n");
+			return -1;
+		}
+		if (ret == 1) {
+			LM_DBG("prefix para not found\n");
+			return 1;
+		}
 		if(memcmp(tmp.s, "atpsh-", 6)==0) {
 			ptsd->a_uuid = tmp;
 			return 0;




More information about the sr-dev mailing list