Browse code

topos: added methods_nocontact parameter

- specify the list of methods to skip adding contact header for

Daniel-Constantin Mierla authored on 21/06/2022 06:52:41
Showing 2 changed files
... ...
@@ -50,6 +50,7 @@
50 50
 #include "../../core/parser/parse_uri.h"
51 51
 #include "../../core/parser/parse_to.h"
52 52
 #include "../../core/parser/parse_from.h"
53
+#include "../../core/parser/parse_methods.h"
53 54
 #include "../../core/timer_proc.h"
54 55
 #include "../../core/fmsg.h"
55 56
 #include "../../core/onsend.h"
... ...
@@ -84,6 +85,8 @@ str _tps_storage = str_init("db");
84 85
 
85 86
 extern int _tps_branch_expire;
86 87
 extern int _tps_dialog_expire;
88
+extern unsigned int _tps_methods_nocontact;
89
+str _tps_methods_nocontact_list = str_init("");
87 90
 
88 91
 int _tps_clean_interval = 60;
89 92
 
... ...
@@ -165,6 +168,8 @@ static param_export_t params[]={
165 168
 	{"xavu_field_contact_host", PARAM_STR, &_tps_xavu_field_contact_host},
166 169
 	{"rr_update",		PARAM_INT, &_tps_rr_update},
167 170
 	{"context",			PARAM_STR, &_tps_context_param},
171
+	{"methods_nocontact",		PARAM_STR, &_tps_methods_nocontact_list},
172
+
168 173
 	{0,0,0}
169 174
 };
170 175
 
... ...
@@ -214,6 +219,12 @@ static int mod_init(void)
214 219
 		return -1;
215 220
 	}
216 221
 
222
+	if(_tps_methods_nocontact_list.len>0) {
223
+		if(parse_methods(&_tps_methods_nocontact_list, &_tps_methods_nocontact)<0) {
224
+			LM_ERR("failed to parse methods_nocontact parameter\n");
225
+			return -1;
226
+		}
227
+	}
217 228
 	if(_tps_storage.len==2 && strncmp(_tps_storage.s, "db", 2)==0) {
218 229
 		/* Find a database module */
219 230
 		if (db_bind_mod(&_tps_db_url, &_tpsdbf)) {
... ...
@@ -46,8 +46,6 @@
46 46
 #include "tps_msg.h"
47 47
 #include "tps_storage.h"
48 48
 
49
-#define TPS_METHODS_NOCONTACT (METHOD_CANCEL|METHOD_BYE|METHOD_PRACK)
50
-
51 49
 extern int _tps_param_mask_callid;
52 50
 extern int _tps_contact_mode;
53 51
 extern str _tps_cparam_name;
... ...
@@ -59,6 +57,8 @@ extern str _tps_context_value;
59 57
 str _sr_hname_xbranch = str_init("P-SR-XBranch");
60 58
 str _sr_hname_xuuid = str_init("P-SR-XUID");
61 59
 
60
+unsigned int _tps_methods_nocontact = METHOD_CANCEL|METHOD_BYE|METHOD_PRACK;
61
+
62 62
 /**
63 63
  *
64 64
  */
... ...
@@ -584,7 +584,7 @@ int tps_reinsert_contact(sip_msg_t *msg, tps_data_t *ptsd, str *hbody)
584 584
 {
585 585
 	str hname = str_init("Contact");
586 586
 
587
-	if (get_cseq(msg)->method_id & TPS_METHODS_NOCONTACT) {
587
+	if (get_cseq(msg)->method_id & _tps_methods_nocontact) {
588 588
 		return 0;
589 589
 	}
590 590