Browse code

Merge pull request #2647 from hexla/features/uac_redirect/default_q

uac_redirect: Make default q-value configurable

Daniel-Constantin Mierla authored on 09/03/2021 12:37:53 • GitHub committed on 09/03/2021 12:37:53
Showing 3 changed files
... ...
@@ -337,6 +337,28 @@ branch_route[1] {
337 337
 				<programlisting format="linespecific">
338 338
 ...
339 339
 modparam("uac_redirect","flags_hdr_mode",2)
340
+...
341
+				</programlisting>
342
+			</example>
343
+		</section>
344
+		<section>
345
+			<title><varname>default_q_value</varname> (int)</title>
346
+			<para>
347
+			Specifies the q-value to asign to contacts without one. Because
348
+			Kamailio doesn't support float parameter types, the value in the
349
+			parameter is divided by 1000 and stored as float. For example, if
350
+			you want default_q_value to be 0.38, use value 380 here.
351
+			</para>
352
+			<para>
353
+				<emphasis>
354
+					The default value is 10 (0.01).
355
+				</emphasis>
356
+			</para>
357
+			<example>
358
+				<title>Set <varname>default_q_value</varname> parameter</title>
359
+				<programlisting format="linespecific">
360
+...
361
+modparam("uac_redirect","default_q_value",0)
340 362
 ...
341 363
 				</programlisting>
342 364
 			</example>
... ...
@@ -33,9 +33,9 @@
33 33
 
34 34
 
35 35
 extern sruid_t _redirect_sruid;
36
+extern int default_q_value;
36 37
 
37 38
 #define MAX_CONTACTS_PER_REPLY   16
38
-#define DEFAULT_Q_VALUE          10
39 39
 
40 40
 static int shmcontact2dset(struct sip_msg *req, struct sip_msg *shrpl,
41 41
 		long max, struct acc_param *reason, unsigned int bflags);
... ...
@@ -147,7 +147,7 @@ static int sort_contacts(hdr_field_t *chdr, contact_t **ct_array,
147 147
 			/* does the contact has a q val? */
148 148
 			q_para = ct_list->q;
149 149
 			if (q_para==0 || q_para->body.len==0) {
150
-				q = DEFAULT_Q_VALUE;
150
+				q = default_q_value;
151 151
 			} else {
152 152
 				if (str2q( &q, q_para->body.s, q_para->body.len)!=0) {
153 153
 					LM_ERR("invalid q param\n");
... ...
@@ -52,6 +52,9 @@ int flags_hdr_mode = 0;
52 52
 
53 53
 #define ACCEPT_RULE_STR "accept"
54 54
 #define DENY_RULE_STR   "deny"
55
+#define DEFAULT_Q_VALUE 10
56
+
57
+int default_q_value = DEFAULT_Q_VALUE;
55 58
 
56 59
 /* sruid to get internal uid */
57 60
 sruid_t _redirect_sruid;
... ...
@@ -88,6 +91,7 @@ static param_export_t params[] = {
88 91
 	{"acc_db_table",    PARAM_STRING,  &acc_db_table     },
89 92
 	{"bflags",    		INT_PARAM,  &bflags			  },
90 93
 	{"flags_hdr_mode",	INT_PARAM,  &flags_hdr_mode	  },
94
+	{"default_q_value", INT_PARAM,  &default_q_value     },
91 95
 	{0, 0, 0}
92 96
 };
93 97