Module: sip-router
Branch: master
Commit: 121cb0f4feb2cc1a670d17432593ff7e025d65a5
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=121cb0f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Sep 8 17:13:12 2014 +0200
dispatcher: swap the order between uri and mode parameters in the new
ds_is_from_list(...)
- allow to have ds_is_from_list() only with group id and mode, uri is
the last parameter, still optional
- patch provided by Luis Azedo <luis.azedo(a)factorlusitano.com>
---
modules/dispatcher/dispatcher.c | 41 +++++++++++++++++++++------
modules/dispatcher/doc/dispatcher_admin.xml | 24 ++++++++--------
2 files changed, 44 insertions(+), 21 deletions(-)
diff --git a/modules/dispatcher/dispatcher.c b/modules/dispatcher/dispatcher.c
index 5356f2e..13f3f56 100644
--- a/modules/dispatcher/dispatcher.c
+++ b/modules/dispatcher/dispatcher.c
@@ -159,8 +159,9 @@ static int w_ds_load_update(struct sip_msg*, char*, char*);
static int w_ds_is_from_list0(struct sip_msg*, char*, char*);
static int w_ds_is_from_list1(struct sip_msg*, char*, char*);
+static int w_ds_is_from_list2(struct sip_msg*, char*, char*);
static int w_ds_is_from_list3(struct sip_msg*, char*, char*, char*);
-static int fixup_ds_is_from_list3(void** param, int param_no);
+static int fixup_ds_is_from_list(void** param, int param_no);
static void destroy(void);
@@ -192,8 +193,10 @@ static cmd_export_t cmds[]={
0, 0, REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE},
{"ds_is_from_list", (cmd_function)w_ds_is_from_list1, 1,
fixup_igp_null, 0, ANY_ROUTE},
+ {"ds_is_from_list", (cmd_function)w_ds_is_from_list2, 2,
+ fixup_ds_is_from_list, 0, ANY_ROUTE},
{"ds_is_from_list", (cmd_function)w_ds_is_from_list3, 3,
- fixup_ds_is_from_list3, 0, ANY_ROUTE},
+ fixup_ds_is_from_list, 0, ANY_ROUTE},
{"ds_load_unset", (cmd_function)w_ds_load_unset, 0,
0, 0, ANY_ROUTE},
{"ds_load_update", (cmd_function)w_ds_load_update, 0,
@@ -844,20 +847,34 @@ static int w_ds_is_from_list1(struct sip_msg *msg, char *set, char
*str2)
return ds_is_from_list(msg, s);
}
-static int w_ds_is_from_list3(struct sip_msg *msg, char *set, char *uri, char *mode)
+static int w_ds_is_from_list2(struct sip_msg *msg, char *set, char *mode)
{
int vset;
int vmode;
- str suri;
if(fixup_get_ivalue(msg, (gparam_t*)set, &vset)!=0)
{
LM_ERR("cannot get set id value\n");
return -1;
}
- if(fixup_get_svalue(msg, (gparam_t*)uri, &suri)!=0)
+ if(fixup_get_ivalue(msg, (gparam_t*)mode, &vmode)!=0)
{
- LM_ERR("cannot get uri value\n");
+ LM_ERR("cannot get mode value\n");
+ return -1;
+ }
+
+ return ds_is_addr_from_list(msg, vset, NULL, vmode);
+}
+
+static int w_ds_is_from_list3(struct sip_msg *msg, char *set, char *mode, char *uri)
+{
+ int vset;
+ int vmode;
+ str suri;
+
+ if(fixup_get_ivalue(msg, (gparam_t*)set, &vset)!=0)
+ {
+ LM_ERR("cannot get set id value\n");
return -1;
}
if(fixup_get_ivalue(msg, (gparam_t*)mode, &vmode)!=0)
@@ -865,15 +882,21 @@ static int w_ds_is_from_list3(struct sip_msg *msg, char *set, char
*uri, char *m
LM_ERR("cannot get mode value\n");
return -1;
}
+ if(fixup_get_svalue(msg, (gparam_t*)uri, &suri)!=0)
+ {
+ LM_ERR("cannot get uri value\n");
+ return -1;
+ }
return ds_is_addr_from_list(msg, vset, &suri, vmode);
}
-static int fixup_ds_is_from_list3(void** param, int param_no)
+
+static int fixup_ds_is_from_list(void** param, int param_no)
{
- if(param_no==1 || param_no==3)
+ if(param_no==1 || param_no==2)
return fixup_igp_null(param, 1);
- if(param_no==2)
+ if(param_no==3)
return fixup_spve_null(param, 1);
return 0;
}
diff --git a/modules/dispatcher/doc/dispatcher_admin.xml
b/modules/dispatcher/doc/dispatcher_admin.xml
index 5177a12..11c75ce 100644
--- a/modules/dispatcher/doc/dispatcher_admin.xml
+++ b/modules/dispatcher/doc/dispatcher_admin.xml
@@ -994,7 +994,7 @@ failure_route[tryagain] {
</section>
<section id="dispatcher.f.ds_is_from_list">
<title>
- <function moreinfo="none">ds_is_from_list([groupid [, uri, mode]
])</function>
+ <function moreinfo="none">ds_is_from_list([groupid [, mode [, uri] ]
])</function>
</title>
<para>
This function returns true, if there is a match of source address or uri
@@ -1011,17 +1011,6 @@ failure_route[tryagain] {
</para>
</listitem>
<listitem>
- <para><emphasis>uri</emphasis> (optional) - if is empty or missing,
- the matching is done against source IP, port and protocol.
- Otherwise the value has to be a valid SIP URI, used to match
- against addresses in the dispatcher list. Only IP, port and
- protocol are matches, any additional parameters are ignored.
- The parameter can be a static or dynamic (with variables)
- string. The domain part of the URI can be an IP address or
- a hostname.
- </para>
- </listitem>
- <listitem>
<para><emphasis>mode</emphasis> - (optional) - a bitmask to specify
how the matching should be done. If is 0, all ip, port and
proto are matched. If bit one is set, then port is ignored.
@@ -1030,6 +1019,17 @@ failure_route[tryagain] {
It must be provided if the uri parameter is provided.
</para>
</listitem>
+ <listitem>
+ <para><emphasis>uri</emphasis> (optional) - if is empty or
missing,
+ the matching is done against source IP, port and protocol.
+ Otherwise the value has to be a valid SIP URI, used to match
+ against addresses in the dispatcher list. Only IP, port and
+ protocol are matches, any additional parameters are ignored.
+ The parameter can be a static or dynamic (with variables)
+ string. The domain part of the URI can be an IP address or
+ a hostname.
+ </para>
+ </listitem>
</itemizedlist>
<para>