Module: kamailio
Branch: master
Commit: 27e1e63a9b31f3d85b0cdcd916e9ab85f9264fde
URL:
https://github.com/kamailio/kamailio/commit/27e1e63a9b31f3d85b0cdcd916e9ab8…
Author: Alex Hermann <alex(a)hexla.nl>
Committer: Henning Westerholt <henningw(a)users.noreply.github.com>
Date: 2019-02-11T21:42:26+01:00
uac_redirect: Use Contact's "flags" header parameter into branch flags.
---
Modified: src/modules/uac_redirect/doc/uac_redirect_admin.xml
Modified: src/modules/uac_redirect/rd_funcs.c
Modified: src/modules/uac_redirect/rd_funcs.h
Modified: src/modules/uac_redirect/uac_redirect.c
---
Diff:
https://github.com/kamailio/kamailio/commit/27e1e63a9b31f3d85b0cdcd916e9ab8…
Patch:
https://github.com/kamailio/kamailio/commit/27e1e63a9b31f3d85b0cdcd916e9ab8…
---
diff --git a/src/modules/uac_redirect/doc/uac_redirect_admin.xml
b/src/modules/uac_redirect/doc/uac_redirect_admin.xml
index 2c7fc0e883..b044d38c25 100644
--- a/src/modules/uac_redirect/doc/uac_redirect_admin.xml
+++ b/src/modules/uac_redirect/doc/uac_redirect_admin.xml
@@ -302,8 +302,46 @@ branch_route[1] {
</programlisting>
</example>
</section>
+ <section>
+ <title><varname>flags_hdr_mode</varname> (int)</title>
+ <para>
+ Specifies if and how a Contact's flags header parameter
+ must be used. If set, and a flags header parameter is set,
+ its value will be set as branch flags for that contact.
+ </para>
+ <para>
+ Its values may be:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>0</emphasis> - ignore flags header parameter,
+ just use bflags module parameter</para>
+ </listitem>
+ <listitem>
+ <para><emphasis>1</emphasis> - use flags header parameter if
+ present, ignore bflags module parameter</para>
+ </listitem>
+ <listitem>
+ <para><emphasis>2</emphasis> - use flags header parameter if
+ present and merge (binary or) it with the bflags module
+ parameter</para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ <emphasis>
+ The default value is <quote>0</quote>.
+ </emphasis>
+ </para>
+ <example>
+ <title>Set <varname>flags_hdr_mode</varname>
parameter</title>
+ <programlisting format="linespecific">
+...
+modparam("uac_redirect","flags_hdr_mode",2)
+...
+ </programlisting>
+ </example>
+ </section>
</section>
-
<section>
<title>Functions</title>
<section id="uac_redirect.f.set_deny_filter">
diff --git a/src/modules/uac_redirect/rd_funcs.c b/src/modules/uac_redirect/rd_funcs.c
index fdd885b179..3dcf8077b6 100644
--- a/src/modules/uac_redirect/rd_funcs.c
+++ b/src/modules/uac_redirect/rd_funcs.c
@@ -199,6 +199,7 @@ static int shmcontact2dset(struct sip_msg *req, struct sip_msg
*sh_rpl,
int added;
int dup;
int ret;
+ unsigned int flags;
/* dup can be:
* 0 - sh reply but nothing duplicated
@@ -294,8 +295,14 @@ static int shmcontact2dset(struct sip_msg *req, struct sip_msg
*sh_rpl,
LM_DBG("adding contact <%.*s>\n", scontacts[i]->uri.len,
scontacts[i]->uri.s);
if(sruid_next(&_redirect_sruid)==0) {
+ if (flags_hdr_mode && scontacts[i]->flags &&
str2int(&(scontacts[i]->flags->body), &flags) == 0) {
+ if (flags_hdr_mode == 2)
+ flags |= bflags;
+ } else {
+ flags = bflags;
+ }
if(append_branch( 0, &scontacts[i]->uri, 0, 0, sqvalues[i],
- bflags, 0, &_redirect_sruid.uid, 0,
+ flags, 0, &_redirect_sruid.uid, 0,
&_redirect_sruid.uid, &_redirect_sruid.uid)<0) {
LM_ERR("failed to add contact to dset\n");
} else {
diff --git a/src/modules/uac_redirect/rd_funcs.h b/src/modules/uac_redirect/rd_funcs.h
index a5304c19dc..f686615969 100644
--- a/src/modules/uac_redirect/rd_funcs.h
+++ b/src/modules/uac_redirect/rd_funcs.h
@@ -36,6 +36,8 @@ extern cmd_function rd_acc_fct;
extern char *acc_db_table;
+extern int flags_hdr_mode;
+
int get_redirect( struct sip_msg *msg , int maxt, int maxb,
struct acc_param *reason, unsigned int bflags);
diff --git a/src/modules/uac_redirect/uac_redirect.c
b/src/modules/uac_redirect/uac_redirect.c
index e1f7d640db..6ade1719c6 100644
--- a/src/modules/uac_redirect/uac_redirect.c
+++ b/src/modules/uac_redirect/uac_redirect.c
@@ -48,6 +48,7 @@ char *accept_filter_s = 0;
char *def_filter_s = 0;
unsigned int bflags = 0;
+int flags_hdr_mode = 0;
#define ACCEPT_RULE_STR "accept"
#define DENY_RULE_STR "deny"
@@ -86,6 +87,7 @@ static param_export_t params[] = {
{"acc_function", PARAM_STRING, &acc_fct_s },
{"acc_db_table", PARAM_STRING, &acc_db_table },
{"bflags", INT_PARAM, &bflags },
+ {"flags_hdr_mode", INT_PARAM, &flags_hdr_mode },
{0, 0, 0}
};