Module: sip-router
Branch: andrei/type_conversion
Commit: 970e1f64e93410101a3dcf8914151388991ba800
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=970e1f6…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Tue Apr 28 09:50:07 2009 +0200
core expr eval: defined @select
- a select can now be undefined (defined @select when run_select
returns >0 or error => true)
- RV_CACHE_SELECT introduced
---
rvalue.c | 21 +++++++++++++++------
rvalue.h | 3 ++-
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/rvalue.c b/rvalue.c
index 897fb4d..aa99131 100644
--- a/rvalue.c
+++ b/rvalue.c
@@ -1386,9 +1386,11 @@ error:
/** checks if rv is defined.
* @param res - set to the result 1 - defined, 0 not defined
* @return 0 on success, -1 on error
- * Can use cached rvalues (c1).
- * Note: a rv can be undefined if it's an undefined avp or pvar or
+ * Can use cached rvalues (cache).
+ * Note: a rv can be undefined if it's an undefined avp or pvar or select or
* if it's NONE
+ * Note2: an error in the avp, pvar or select search is equivalent to
+ * undefined (and it's not reported)
*/
inline static int rv_defined(struct run_act_ctx* h,
struct sip_msg* msg, int* res,
@@ -1397,13 +1399,21 @@ inline static int rv_defined(struct run_act_ctx* h,
avp_t* r_avp;
int_str avp_val;
pv_value_t pval;
+ str tmp;
*res=1;
switch(rv->type){
+ case RV_SEL:
+ if (unlikely(cache && cache->cache_type==RV_CACHE_SELECT)){
+ *res=(cache->val_type!=RV_NONE);
+ }else
+ /* run select returns 0 on success, -1 on error and >0 on
+ undefined. error is considered undefined */
+ *res=(run_select(&tmp, &rv->v.sel, msg)==0);
+ break;
case RV_AVP:
if (unlikely(cache && cache->cache_type==RV_CACHE_AVP)){
- if (cache->val_type==RV_NONE)
- *res=0;
+ *res=(cache->val_type!=RV_NONE);
}else{
r_avp = search_avp_by_index(rv->v.avps.type, rv->v.avps.name,
&avp_val, rv->v.avps.index);
@@ -1415,8 +1425,7 @@ inline static int rv_defined(struct run_act_ctx* h,
case RV_PVAR:
/* PV_VAL_NULL or pv_get_spec_value error => undef */
if (unlikely(cache && cache->cache_type==RV_CACHE_PVAR)){
- if (cache->val_type==RV_NONE)
- *res=0;
+ *res=(cache->val_type==RV_NONE);
}else{
memset(&pval, 0, sizeof(pval));
if (likely(pv_get_spec_value(msg, &rv->v.pvs, &pval)==0)){
diff --git a/rvalue.h b/rvalue.h
index a9dbe0d..e99d1f8 100644
--- a/rvalue.h
+++ b/rvalue.h
@@ -118,7 +118,8 @@ struct rval_expr{
enum rval_cache_type{
RV_CACHE_EMPTY,
RV_CACHE_PVAR,
- RV_CACHE_AVP
+ RV_CACHE_AVP,
+ RV_CACHE_SELECT
};
/** value cache for a rvalue struct.
When updating your local branch (e.g. master) with the repository
version, please always add --rebase to git pull
(e.g. git pull --ff --rebase origin master).
This will avoid generating confusing useless merge messages
(like Merge branch 'master' of ssh://git.sip-router.org/sip-router).
Example:
$ git push origin master:master
To ssh://git.sip-router.org/sip-router
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to
'ssh://git.sip-router.org/sip-router'
# failed because the local master branch is not up to date
# => update it
$ git pull --ff --rebase origin master
# retry the push
$ git push origin master:master
As an alternative, git can be configured to always rebase when pull-ing
on a certain local branch, e.g. for master:
git config branch.master.rebase true
See https://sip-router.org/wiki/git/commit-into-master for more detailed
info.
Andrei
Module: sip-router
Branch: master
Commit: 12a8f3f8fcd8956ec7c968d7a1e2895035d05cba
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=12a8f3f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Apr 27 13:15:22 2009 +0200
pv: regenerate readme
---
modules_k/pv/README | 154 ++++++++++++++++++++++++++++++-----------
modules_k/pv/doc/pv_admin.xml | 55 ++++++++++++++-
2 files changed, 166 insertions(+), 43 deletions(-)
diff --git a/modules_k/pv/README b/modules_k/pv/README
index 19ba9a5..9c6ef99 100644
--- a/modules_k/pv/README
+++ b/modules_k/pv/README
@@ -12,66 +12,101 @@ Daniel-Constantin Mierla
<daniel(a)asipto.com>
Copyright � 2008 Daniel-Constantin Mierla (asipto.com)
- __________________________________________________________
+ __________________________________________________________________
Table of Contents
1. Admin Guide
- 1.1. Overview
- 1.2. Dependencies
+ 1. Overview
+ 2. Dependencies
- 1.2.1. Kamailio Modules
- 1.2.2. External Libraries or Applications
+ 2.1. Kamailio Modules
+ 2.2. External Libraries or Applications
- 1.3. Exported Parameters
+ 3. Exported Parameters
- 1.3.1. shvset (string)
- 1.3.2. varset (string)
+ 3.1. shvset (string)
+ 3.2. varset (string)
- 1.4. Exported Functions
- 1.5. MI Commands
+ 4. Exported Functions
- 1.5.1. shv_set
- 1.5.2. shv_get
+ 4.1. pv_isset(pvar)
+ 4.2. pv_unset(pvar)
+
+ 5. MI Commands
+
+ 5.1. shv_set
+ 5.2. shv_get
List of Examples
1.1. shvset parameter usage
1.2. varset parameter usage
- 1.3. shv_set usage
- 1.4. shv_get usage
+ 1.3. pv_isset usage
+ 1.4. pv_unset usage
+ 1.5. shv_set usage
+ 1.6. shv_get usage
Chapter 1. Admin Guide
-1.1. Overview
+ Table of Contents
+
+ 1. Overview
+ 2. Dependencies
+
+ 2.1. Kamailio Modules
+ 2.2. External Libraries or Applications
+
+ 3. Exported Parameters
+
+ 3.1. shvset (string)
+ 3.2. varset (string)
+
+ 4. Exported Functions
- This module collects the core pseudo-variables that can be used
- in configuration file. They are listed in Dokuwiki:
+ 4.1. pv_isset(pvar)
+ 4.2. pv_unset(pvar)
+
+ 5. MI Commands
+
+ 5.1. shv_set
+ 5.2. shv_get
+
+1. Overview
+
+ This module collects the core pseudo-variables that can be used in
+ configuration file. They are listed in Dokuwiki:
http://www.kamailio.org/dokuwiki/, in Pseudo-Variables section
-1.2. Dependencies
+2. Dependencies
-1.2.1. Kamailio Modules
+ 2.1. Kamailio Modules
+ 2.2. External Libraries or Applications
+
+2.1. Kamailio Modules
The following modules must be loaded before this module:
* No dependencies on other Kamailio modules.
-1.2.2. External Libraries or Applications
+2.2. External Libraries or Applications
- The following libraries or applications must be installed
- before running Kamailio with this module loaded:
+ The following libraries or applications must be installed before
+ running Kamailio with this module loaded:
* None.
-1.3. Exported Parameters
+3. Exported Parameters
+
+ 3.1. shvset (string)
+ 3.2. varset (string)
-1.3.1. shvset (string)
+3.1. shvset (string)
- Set the value of a shared variable ($shv(name)). The parameter
- can be set many times.
+ Set the value of a shared variable ($shv(name)). The parameter can be
+ set many times.
- The value of the parameter has the format: _name_ '=' _type_
- ':' _value_
+ The value of the parameter has the format: _name_ '=' _type_ ':'
+ _value_
* _name_: shared variable name
* _type_: type of the value
+ "i": integer value
@@ -86,13 +121,13 @@ modparam("pv", "shvset", "debug=i:1")
modparam("pv", "shvset", "pstngw=s:sip:10.10.10.10")
...
-1.3.2. varset (string)
+3.2. varset (string)
- Set the value of a script variable ($var(name)). The parameter
- can be set many times.
+ Set the value of a script variable ($var(name)). The parameter can be
+ set many times.
- The value of the parameter has the format: _name_ '=' _type_
- ':' _value_
+ The value of the parameter has the format: _name_ '=' _type_ ':'
+ _value_
* _name_: shared variable name
* _type_: type of the value
+ "i": integer value
@@ -107,13 +142,48 @@ modparam("pv", "varset", "init=i:1")
modparam("pv", "varset", "gw=s:sip:11.11.11.11;transport=tcp")
...
-1.4. Exported Functions
+4. Exported Functions
+
+ 4.1. pv_isset(pvar)
+ 4.2. pv_unset(pvar)
+
+4.1. pv_isset(pvar)
+
+ Return true if a PV value is different than 'null'.
+
+ Meaning of the parameters is as follows:
+ * pvar - pvar identifier.
+
+ This function can be used from ANY_ROUTE.
+
+ Example 1.3. pv_isset usage
+...
+if(pv_isset("$avp("s:x")"))
+{
+ ...
+}
+...
+
+4.2. pv_unset(pvar)
+
+ Unset the value of the PV (e.g., delete AVP, set to null).
+
+ Meaning of the parameters is as follows:
+ * pvar - pvar identifier.
+
+ This function can be used from ANY_ROUTE.
+
+ Example 1.4. pv_unset usage
+...
+pv_unset("$avp("s:x")");
+...
- None
+5. MI Commands
-1.5. MI Commands
+ 5.1. shv_set
+ 5.2. shv_get
-1.5.1. shv_set
+5.1. shv_set
Set the value of a shared variable ($shv(name)).
@@ -131,25 +201,25 @@ modparam("pv", "varset", "gw=s:sip:11.11.11.11;transport=tcp")
_value_
_empty_line_
- Example 1.3. shv_set usage
+ Example 1.5. shv_set usage
...
$ kamctl fifo shv_set debug int 0
...
-1.5.2. shv_get
+5.2. shv_get
Get the value of a shared variable ($shv(name)).
Parameters:
- * _name_: shared variable name. If this parameter is missing,
- all shared variables are returned.
+ * _name_: shared variable name. If this parameter is missing, all
+ shared variables are returned.
MI FIFO Command Format:
:shv_get:_reply_fifo_file_
_name_
_empty_line_
- Example 1.4. shv_get usage
+ Example 1.6. shv_get usage
...
$ kamctl fifo shv_get debug
$ kamctl fifo shv_get
diff --git a/modules_k/pv/doc/pv_admin.xml b/modules_k/pv/doc/pv_admin.xml
index 501b086..f8b50ad 100644
--- a/modules_k/pv/doc/pv_admin.xml
+++ b/modules_k/pv/doc/pv_admin.xml
@@ -127,8 +127,61 @@ modparam("pv", "varset", "gw=s:sip:11.11.11.11;transport=tcp")
</section>
<section>
<title>Exported Functions</title>
- <para>None</para>
+ <section>
+ <title><function moreinfo="none">pv_isset(pvar)</function></title>
+ <para>
+ Return true if a PV value is different than 'null'.
+ </para>
+ <para>Meaning of the parameters is as follows:</para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <emphasis>pvar</emphasis> - pvar identifier.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ This function can be used from ANY_ROUTE.
+ </para>
+ <example>
+ <title><function>pv_isset</function> usage</title>
+ <programlisting format="linespecific">
+...
+if(pv_isset("$avp("s:x")"))
+{
+ ...
+}
+...
+</programlisting>
+ </example>
+ </section>
+ <section>
+ <title><function moreinfo="none">pv_unset(pvar)</function></title>
+ <para>
+ Unset the value of the PV (e.g., delete AVP, set to null).
+ </para>
+ <para>Meaning of the parameters is as follows:</para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <emphasis>pvar</emphasis> - pvar identifier.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ This function can be used from ANY_ROUTE.
+ </para>
+ <example>
+ <title><function>pv_unset</function> usage</title>
+ <programlisting format="linespecific">
+...
+pv_unset("$avp("s:x")");
+...
+</programlisting>
+ </example>
+ </section>
</section>
+
<section>
<title><acronym>MI</acronym> Commands</title>
<section>