Copyright © 2008-2011 Daniel-Constantin Mierla (asipto.com)
Copyright © 2011 Juha Heinanen
Copyright © 2013 Olle E. Johansson, Edvina AB
Table of Contents
List of Examples
shvset
parameter usagevarset
parameter usageavp_aliases
parameter usagepv_isset
usagepv_unset
usageis_int()
usagetypeof()
usagenot_empty()
usagexavp_params_explode
usagesbranch_set_ruri()
usagesbranch_append()
usagesbranch_append()
usagepv_xavp_print()
usageshv_set
usageshv_get
usageTable of Contents
This module collects the core pseudo-variables that can be used in configuration file. They are listed in Dokuwiki: http://www.kamailio.org/wiki/, in Pseudo-Variables section
The following modules must be loaded before this module:
No dependencies on other Kamailio modules.
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_
_name_: shared variable name
_type_: type of the value
“i”: integer value
“s”: string value
_value_: value to be set
Default value is “NULL”.
Example 1.1. shvset
parameter usage
... modparam("pv", "shvset", "debug=i:1") modparam("pv", "shvset", "pstngw=s:sip:10.10.10.10") ...
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_
_name_: shared variable name
_type_: type of the value
“i”: integer value
“s”: string value
_value_: value to be set
Default value is “NULL”.
Example 1.2. varset
parameter usage
... modparam("pv", "varset", "init=i:1") modparam("pv", "varset", "gw=s:sip:11.11.11.11;transport=tcp") ...
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.
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.
Function checks if pvar argument contains integer value and returns 1 if it does and -1 otherwise.
Function can be used from all kinds of routes.
Example 1.6. is_int()
usage
... if (is_int("$var(foo)")) { xlog("L_INFO", "variable foo contains integer value\n"); } ...
Returns true if the type of pseudo-variable matches the second parameter. The second parameter can be: 'int' - type is integer; 'str' - type is string; 'null' - type is null.
Function can be used from ANYROUTE.
Example 1.7. typeof()
usage
... if (typeof("$var(foo)", "str")) { xdbg("variable foo is a string\n"); } ...
Returns true if the pseudo-variables has the type string and is not empty value.
Function can be used from all kinds of routes.
Example 1.8. not_empty()
usage
... if (not_empty("$var(foo)")) { append_hf("X-Foo: $var(foo)\r\n"); } ...
Convert a parameters string in xavp atributes.
The first parameter has to be a string in the format of SIP header parameters (name1=value1;...;nameN=valueN). The second parameter is the name of the root xavp to hold the pairs (nameX,valueX).
The values are stored as string type.
Function can be used from ANY ROUTE.
Example 1.9. xavp_params_explode
usage
... xavp_params_explode("a=b;c=d;e=d", "x"); # results in: # $xavp(x=>a) = "b"; # $xavp(x=>c) = "d"; # $xavp(x=>e) = "f"; ...
Use the attributes from static branch ($sbranch(key) variable) to set request URI and the other fields of the branch associated with request URI (destination URI, path, ...).
Content of the static branch is not reset after this function is executed. It has to be done explicitely with sbranch_reset().
Function can be used from REQUEST_ROUTE, BRANCH_ROUTE or FAILURE_ROUTE.
Example 1.10. sbranch_set_ruri()
usage
... sbranch_reset(); $sbranch(uri) = "sip:127.0.0.1:5080"; $sbranch(dst_uri) = "sip:127.0.0.1:5090"; $sbranch(path) = "sip:127.0.0.1:5090, sip:127.0.0.1:5094"; $sbranch(send_socket) = "udp:127.0.0.1:5060"; sbranch_set_ruri(); ...
Use the attributes from static branch ($sbranch(key) variable) to append a new branch to destination set. It is an alternative to append_branch() that allows setting each attribute specific to the branch.
Content of the static branch is not reset after this function is executed. It has to be done explicitely with sbranch_reset().
Function can be used from REQUEST_ROUTE, BRANCH_ROUTE or FAILURE_ROUTE.
Example 1.11. sbranch_append()
usage
... sbranch_reset(); $sbranch(uri) = "sip:127.0.0.1:5080"; $sbranch(dst_uri) = "sip:127.0.0.1:5090"; $sbranch(send_socket) = "udp:127.0.0.1:5060"; sbranch_append(); ...
Reset the content of static branch ($sbranch(key) variable.
Function can be used from REQUEST_ROUTE, BRANCH_ROUTE or FAILURE_ROUTE.
Set the value of a shared variable ($shv(name)).
Parameters:
_name_: shared variable name
_type_: type of the value
“int”: integer value
“str”: string value
_value_: value to be set
MI FIFO Command Format:
:shv_set:_reply_fifo_file_ _name_ _type_ _value_ _empty_line_
Get the value of a shared variable ($shv(name)).
Parameters:
_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_
Set the value of a shared variable ($shv(name)).
Parameters:
_name_: shared variable name
_type_: type of the value
“int”: integer value
“str”: string value
_value_: value to be set