[sr-dev] git:master:da4e4a7a: topos: new parameter to allow specifying initial request methods to skip topos

Daniel-Constantin Mierla miconda at gmail.com
Tue Jul 5 20:42:00 CEST 2022


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-07-05T20:36:24+02:00

topos: new parameter to allow specifying initial request methods to skip topos

---

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

---

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

---

diff --git a/src/modules/topos/topos_mod.c b/src/modules/topos/topos_mod.c
index 0c78f3ee38..4c096cf298 100644
--- a/src/modules/topos/topos_mod.c
+++ b/src/modules/topos/topos_mod.c
@@ -87,6 +87,8 @@ extern int _tps_branch_expire;
 extern int _tps_dialog_expire;
 extern unsigned int _tps_methods_nocontact;
 str _tps_methods_nocontact_list = str_init("");
+extern unsigned int _tps_methods_noinitial;
+str _tps_methods_noinitial_list = str_init("");
 
 int _tps_clean_interval = 60;
 
@@ -169,6 +171,7 @@ static param_export_t params[]={
 	{"rr_update",		PARAM_INT, &_tps_rr_update},
 	{"context",			PARAM_STR, &_tps_context_param},
 	{"methods_nocontact",		PARAM_STR, &_tps_methods_nocontact_list},
+	{"methods_noinitial",		PARAM_STR, &_tps_methods_noinitial_list},
 
 	{0,0,0}
 };
@@ -225,6 +228,12 @@ static int mod_init(void)
 			return -1;
 		}
 	}
+	if(_tps_methods_noinitial_list.len>0) {
+		if(parse_methods(&_tps_methods_nocontact_list, &_tps_methods_noinitial)<0) {
+			LM_ERR("failed to parse methods_noinitial parameter\n");
+			return -1;
+		}
+	}
 	if(_tps_storage.len==2 && strncmp(_tps_storage.s, "db", 2)==0) {
 		/* Find a database module */
 		if (db_bind_mod(&_tps_db_url, &_tpsdbf)) {
diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c
index 798885df56..5e1b1be032 100644
--- a/src/modules/topos/tps_msg.c
+++ b/src/modules/topos/tps_msg.c
@@ -58,6 +58,7 @@ str _sr_hname_xbranch = str_init("P-SR-XBranch");
 str _sr_hname_xuuid = str_init("P-SR-XUID");
 
 unsigned int _tps_methods_nocontact = METHOD_CANCEL|METHOD_BYE|METHOD_PRACK;
+unsigned int _tps_methods_noinitial = 0;
 
 /**
  *
@@ -271,6 +272,13 @@ int tps_skip_msg(sip_msg_t *msg)
 	if((get_cseq(msg)->method_id)&(METHOD_REGISTER|METHOD_PUBLISH))
 		return 1;
 
+	if(_tps_methods_noinitial!=0 && msg->first_line.type==SIP_REQUEST
+			&& get_to(msg)->tag_value.len<=0) {
+		if((get_cseq(msg)->method_id) & _tps_methods_noinitial) {
+			return 1;
+		}
+	}
+
 	return 0;
 }
 




More information about the sr-dev mailing list