Module: kamailio
Branch: master
Commit: a61425ed4b398bc40fb3f82b778b4d1150ca02dc
URL:
https://github.com/kamailio/kamailio/commit/a61425ed4b398bc40fb3f82b778b4d1…
Author: Alex Hermann <alex(a)hexla.nl>
Committer: Alex Hermann <alex(a)hexla.nl>
Date: 2021-02-23T17:45:42+01:00
uac_redirect: Make default q-value configurable
The old, quite arbitrary, default of 0.01 is preserved.
---
Modified: src/modules/uac_redirect/doc/uac_redirect_admin.xml
Modified: src/modules/uac_redirect/rd_funcs.c
Modified: src/modules/uac_redirect/uac_redirect.c
---
Diff:
https://github.com/kamailio/kamailio/commit/a61425ed4b398bc40fb3f82b778b4d1…
Patch:
https://github.com/kamailio/kamailio/commit/a61425ed4b398bc40fb3f82b778b4d1…
---
diff --git a/src/modules/uac_redirect/doc/uac_redirect_admin.xml
b/src/modules/uac_redirect/doc/uac_redirect_admin.xml
index b044d38c25..97cb6414ad 100644
--- a/src/modules/uac_redirect/doc/uac_redirect_admin.xml
+++ b/src/modules/uac_redirect/doc/uac_redirect_admin.xml
@@ -337,6 +337,28 @@ branch_route[1] {
<programlisting format="linespecific">
...
modparam("uac_redirect","flags_hdr_mode",2)
+...
+ </programlisting>
+ </example>
+ </section>
+ <section>
+ <title><varname>default_q_value</varname> (int)</title>
+ <para>
+ Specifies the q-value to asign to contacts without one. Because
+ Kamailio doesn't support float parameter types, the value in the
+ parameter is divided by 1000 and stored as float. For example, if
+ you want default_q_value to be 0.38, use value 380 here.
+ </para>
+ <para>
+ <emphasis>
+ The default value is 10 (0.01).
+ </emphasis>
+ </para>
+ <example>
+ <title>Set <varname>default_q_value</varname>
parameter</title>
+ <programlisting format="linespecific">
+...
+modparam("uac_redirect","default_q_value",0)
...
</programlisting>
</example>
diff --git a/src/modules/uac_redirect/rd_funcs.c b/src/modules/uac_redirect/rd_funcs.c
index 5b105d1011..5ce2644ec2 100644
--- a/src/modules/uac_redirect/rd_funcs.c
+++ b/src/modules/uac_redirect/rd_funcs.c
@@ -33,9 +33,9 @@
extern sruid_t _redirect_sruid;
+extern int default_q_value;
#define MAX_CONTACTS_PER_REPLY 16
-#define DEFAULT_Q_VALUE 10
static int shmcontact2dset(struct sip_msg *req, struct sip_msg *shrpl,
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,
/* does the contact has a q val? */
q_para = ct_list->q;
if (q_para==0 || q_para->body.len==0) {
- q = DEFAULT_Q_VALUE;
+ q = default_q_value;
} else {
if (str2q( &q, q_para->body.s, q_para->body.len)!=0) {
LM_ERR("invalid q param\n");
diff --git a/src/modules/uac_redirect/uac_redirect.c
b/src/modules/uac_redirect/uac_redirect.c
index 57ec038b39..6968f0b7ec 100644
--- a/src/modules/uac_redirect/uac_redirect.c
+++ b/src/modules/uac_redirect/uac_redirect.c
@@ -52,6 +52,9 @@ int flags_hdr_mode = 0;
#define ACCEPT_RULE_STR "accept"
#define DENY_RULE_STR "deny"
+#define DEFAULT_Q_VALUE 10
+
+int default_q_value = DEFAULT_Q_VALUE;
/* sruid to get internal uid */
sruid_t _redirect_sruid;
@@ -88,6 +91,7 @@ static param_export_t params[] = {
{"acc_db_table", PARAM_STRING, &acc_db_table },
{"bflags", INT_PARAM, &bflags },
{"flags_hdr_mode", INT_PARAM, &flags_hdr_mode },
+ {"default_q_value", INT_PARAM, &default_q_value },
{0, 0, 0}
};