Browse code

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

Daniel-Constantin Mierla authored on 05/07/2022 18:36:24
Showing 2 changed files
... ...
@@ -87,6 +87,8 @@ extern int _tps_branch_expire;
87 87
 extern int _tps_dialog_expire;
88 88
 extern unsigned int _tps_methods_nocontact;
89 89
 str _tps_methods_nocontact_list = str_init("");
90
+extern unsigned int _tps_methods_noinitial;
91
+str _tps_methods_noinitial_list = str_init("");
90 92
 
91 93
 int _tps_clean_interval = 60;
92 94
 
... ...
@@ -169,6 +171,7 @@ static param_export_t params[]={
169 171
 	{"rr_update",		PARAM_INT, &_tps_rr_update},
170 172
 	{"context",			PARAM_STR, &_tps_context_param},
171 173
 	{"methods_nocontact",		PARAM_STR, &_tps_methods_nocontact_list},
174
+	{"methods_noinitial",		PARAM_STR, &_tps_methods_noinitial_list},
172 175
 
173 176
 	{0,0,0}
174 177
 };
... ...
@@ -225,6 +228,12 @@ static int mod_init(void)
225 228
 			return -1;
226 229
 		}
227 230
 	}
231
+	if(_tps_methods_noinitial_list.len>0) {
232
+		if(parse_methods(&_tps_methods_nocontact_list, &_tps_methods_noinitial)<0) {
233
+			LM_ERR("failed to parse methods_noinitial parameter\n");
234
+			return -1;
235
+		}
236
+	}
228 237
 	if(_tps_storage.len==2 && strncmp(_tps_storage.s, "db", 2)==0) {
229 238
 		/* Find a database module */
230 239
 		if (db_bind_mod(&_tps_db_url, &_tpsdbf)) {
... ...
@@ -58,6 +58,7 @@ str _sr_hname_xbranch = str_init("P-SR-XBranch");
58 58
 str _sr_hname_xuuid = str_init("P-SR-XUID");
59 59
 
60 60
 unsigned int _tps_methods_nocontact = METHOD_CANCEL|METHOD_BYE|METHOD_PRACK;
61
+unsigned int _tps_methods_noinitial = 0;
61 62
 
62 63
 /**
63 64
  *
... ...
@@ -271,6 +272,13 @@ int tps_skip_msg(sip_msg_t *msg)
271 272
 	if((get_cseq(msg)->method_id)&(METHOD_REGISTER|METHOD_PUBLISH))
272 273
 		return 1;
273 274
 
275
+	if(_tps_methods_noinitial!=0 && msg->first_line.type==SIP_REQUEST
276
+			&& get_to(msg)->tag_value.len<=0) {
277
+		if((get_cseq(msg)->method_id) & _tps_methods_noinitial) {
278
+			return 1;
279
+		}
280
+	}
281
+
274 282
 	return 0;
275 283
 }
276 284