Module: sip-router
Branch: alexh/master
Commit: 54e95bd7a9411f89a52774de0e457c0baa4556ef
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=54e95bd…
Author: Alex Hermann <alex(a)speakup.nl>
Committer: Alex Hermann <alex(a)speakup.nl>
Date: Tue Aug 2 10:25:20 2011 +0200
modules_k/uac_redirect: Make using the flags Contact-header-parameter configurable
---
modules_k/uac_redirect/README | 42 ++++++++++++++++----
modules_k/uac_redirect/doc/uac_redirect_admin.xml | 36 +++++++++++++++++-
modules_k/uac_redirect/rd_funcs.c | 8 +++-
modules_k/uac_redirect/rd_funcs.h | 2 +
modules_k/uac_redirect/redirect.c | 2 +
5 files changed, 78 insertions(+), 12 deletions(-)
diff --git a/modules_k/uac_redirect/README b/modules_k/uac_redirect/README
index ca88e4c..9bc562d 100644
--- a/modules_k/uac_redirect/README
+++ b/modules_k/uac_redirect/README
@@ -30,6 +30,7 @@ Bogdan-Andrei Iancu
4.4. acc_function (string)
4.5. acc_db_table (string)
4.6. bflags (int)
+ 4.7. flags_hdr_mode (int)
5. Exported Functions
@@ -48,11 +49,12 @@ Bogdan-Andrei Iancu
1.4. Set acc_function parameter
1.5. Set acc_db_table parameter
1.6. Set bflags module parameter
- 1.7. set_deny_filter usage
- 1.8. set_accept_filter usage
- 1.9. get_redirects usage
+ 1.7. Set flags_hdr_mode parameter
+ 1.8. set_deny_filter usage
+ 1.9. set_accept_filter usage
1.10. get_redirects usage
- 1.11. Redirection script example
+ 1.11. get_redirects usage
+ 1.12. Redirection script example
Chapter 1. Admin Guide
@@ -73,6 +75,7 @@ Chapter 1. Admin Guide
4.4. acc_function (string)
4.5. acc_db_table (string)
4.6. bflags (int)
+ 4.7. flags_hdr_mode (int)
5. Exported Functions
@@ -145,6 +148,7 @@ Chapter 1. Admin Guide
4.4. acc_function (string)
4.5. acc_db_table (string)
4.6. bflags (int)
+ 4.7. flags_hdr_mode (int)
4.1. default_filter (string)
@@ -249,6 +253,26 @@ branch_route[1] {
}
}
+4.7. flags_hdr_mode (int)
+
+ 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.
+
+ Its values may be:
+ * 0 - ignore flags header parameter, just use bflags module parameter
+ * 1 - use flags header parameter if present, ignore bflags module
+ parameter
+ * 2 - use flags header parameter if present and merg (binary or) it
+ with the bflags module parameter
+
+ The default value is “0”.
+
+ Example 1.7. Set flags_hdr_mode parameter
+...
+modparam("uac_redirect","flags_hdr_mode",2)
+...
+
5. Exported Functions
5.1. set_deny_filter(filter,flags)
@@ -271,7 +295,7 @@ branch_route[1] {
This function can be used from FAILURE_ROUTE.
- Example 1.7. set_deny_filter usage
+ Example 1.8. set_deny_filter usage
...
set_deny_filter(".*(a)domain2.net","reset_all")uot;reset_all");
set_deny_filter(".*(a)domain1.net","")","");
@@ -292,7 +316,7 @@ set_deny_filter(".*(a)domain1.net","")","");
This function can be used from FAILURE_ROUTE.
- Example 1.8. set_accept_filter usage
+ Example 1.9. set_accept_filter usage
...
set_accept_filter(".*(a)domain2.net","reset_added")t;reset_added");
set_accept_filter(".*(a)domain1.net","")","");
@@ -321,7 +345,7 @@ set_accept_filter(".*(a)domain1.net","")","");
This function can be used from FAILURE_ROUTE.
- Example 1.9. get_redirects usage
+ Example 1.10. get_redirects usage
...
# max 2 contacts per branch, but no overall limit
get_redirects("*:2");
@@ -345,14 +369,14 @@ get_redirects("*");
This function can be used from FAILURE_ROUTE.
- Example 1.10. get_redirects usage
+ Example 1.11. get_redirects usage
...
get_redirects("4:1","Redirected");
...
6. Script Example
- Example 1.11. Redirection script example
+ Example 1.12. Redirection script example
loadmodule "modules/sl/sl.so"
loadmodule "modules/usrloc/usrloc.so"
loadmodule "modules/registrar/registrar.so"
diff --git a/modules_k/uac_redirect/doc/uac_redirect_admin.xml
b/modules_k/uac_redirect/doc/uac_redirect_admin.xml
index de9a7e6..2ffc444 100644
--- a/modules_k/uac_redirect/doc/uac_redirect_admin.xml
+++ b/modules_k/uac_redirect/doc/uac_redirect_admin.xml
@@ -302,8 +302,42 @@ 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 merg (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>Exported Functions</title>
<section>
diff --git a/modules_k/uac_redirect/rd_funcs.c b/modules_k/uac_redirect/rd_funcs.c
index 173f398..9c4c296 100644
--- a/modules_k/uac_redirect/rd_funcs.c
+++ b/modules_k/uac_redirect/rd_funcs.c
@@ -273,9 +273,13 @@ static int shmcontact2dset(struct sip_msg *req, struct sip_msg
*sh_rpl,
/* add the sortet contacts as branches in dset and log this! */
for ( i=0 ; i<n ; i++ ) {
LM_DBG("adding contact <%.*s>\n", scontacts[i]->uri.len,
- scontacts[i]->uri.s);
- if (!scontacts[i]->flags || str2int(&(scontacts[i]->flags->body),
&flags) < 0)
+ scontacts[i]->uri.s, flags_hdr_mode);
+ 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 (km_append_branch( 0, &scontacts[i]->uri, 0, 0, sqvalues[i],
flags, 0)<0) {
LM_ERR("failed to add contact to dset\n");
diff --git a/modules_k/uac_redirect/rd_funcs.h b/modules_k/uac_redirect/rd_funcs.h
index 0b21eeb..9168427 100644
--- a/modules_k/uac_redirect/rd_funcs.h
+++ b/modules_k/uac_redirect/rd_funcs.h
@@ -42,6 +42,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/modules_k/uac_redirect/redirect.c b/modules_k/uac_redirect/redirect.c
index febd373..eeaa4b8 100644
--- a/modules_k/uac_redirect/redirect.c
+++ b/modules_k/uac_redirect/redirect.c
@@ -52,6 +52,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"
@@ -87,6 +88,7 @@ static param_export_t params[] = {
{"acc_function", STR_PARAM, &acc_fct_s },
{"acc_db_table", STR_PARAM, &acc_db_table },
{"bflags", INT_PARAM, &bflags },
+ {"flags_hdr_mode", INT_PARAM, &flags_hdr_mode },
{0, 0, 0}
};