1 <?xml version="1.0" encoding='ISO-8859-1'?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
5 <!-- Include general documentation entities -->
6 <!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
10 <!-- Module User's Guide -->
14 <title>&adminguide;</title>
17 <title>Overview</title>
19 This module collects the core pseudo-variables that can be used in
20 configuration file. They are listed in wiki: &kamwikilink;
21 in Pseudo-Variables section
25 <title>Dependencies</title>
27 <title>&kamailio; Modules</title>
29 The following modules must be loaded before this module:
33 <emphasis>No dependencies on other &kamailio; modules</emphasis>.
40 <title>External Libraries or Applications</title>
42 The following libraries or applications must be installed before running
43 &kamailio; with this module loaded:
47 <emphasis>None</emphasis>.
55 <title>Parameters</title>
56 <section id="pv.p.shvset">
57 <title><varname>shvset</varname> (string)</title>
59 Set the value of a shared variable ($shv(name)). The parameter
60 can be set many times.
63 The value of the parameter has the format:
64 _name_ '=' _type_ ':' _value_
67 <listitem><para>_name_: shared variable name</para></listitem>
69 <listitem><para>_type_: type of the value</para>
71 <listitem><para> <quote>i</quote>: integer value </para></listitem>
72 <listitem><para> <quote>s</quote>: string value </para></listitem>
76 <listitem><para>_value_: value to be set</para></listitem>
79 Default value is <quote>NULL</quote>.
82 <title><varname>shvset</varname> parameter usage</title>
83 <programlisting format="linespecific">
85 modparam("pv", "shvset", "debug=i:1")
86 modparam("pv", "shvset", "pstngw=s:sip:10.10.10.10")
91 <section id="pv.p.varset">
92 <title><varname>varset</varname> (string)</title>
94 Set the value of a script variable ($var(name)). The parameter
95 can be set many times.
98 The value of the parameter has the format:
99 _name_ '=' _type_ ':' _value_
102 <listitem><para>_name_: shared variable name</para></listitem>
104 <listitem><para>_type_: type of the value</para>
106 <listitem><para> <quote>i</quote>: integer value </para></listitem>
107 <listitem><para> <quote>s</quote>: string value </para></listitem>
111 <listitem><para>_value_: value to be set</para></listitem>
114 Default value is <quote>NULL</quote>.
117 <title><varname>varset</varname> parameter usage</title>
118 <programlisting format="linespecific">
120 modparam("pv", "varset", "init=i:1")
121 modparam("pv", "varset", "gw=s:sip:11.11.11.11;transport=tcp")
126 <section id="pv.p.avp_aliases">
127 <title><varname>avp_aliases</varname> (string)</title>
129 Define aliases for PV AVP names.
133 Default value is NULL.
137 <title><varname>avp_aliases</varname> parameter usage</title>
138 <programlisting format="linespecific">
140 modparam("pv","avp_aliases","email=s:email_addr;tmp=i:100")
147 <title>Functions</title>
148 <section id="pv.f.pv_isset">
149 <title><function moreinfo="none">pv_isset(pvar)</function></title>
151 Return true if a PV value is different than 'null'.
153 <para>Meaning of the parameters is as follows:</para>
157 <emphasis>pvar</emphasis> - pvar identifier.
162 This function can be used from ANY_ROUTE.
165 <title><function>pv_isset</function> usage</title>
166 <programlisting format="linespecific">
168 if(pv_isset("$avp(s:x)"))
176 <section id="pv.f.pv_unset">
177 <title><function moreinfo="none">pv_unset(pvar)</function></title>
179 Unset the value of the PV (e.g., delete AVP, set to null).
181 <para>Meaning of the parameters is as follows:</para>
185 <emphasis>pvar</emphasis> - pvar identifier.
190 This function can be used from ANY_ROUTE.
193 <title><function>pv_unset</function> usage</title>
194 <programlisting format="linespecific">
196 pv_unset("$avp(s:x)");
201 <section id="pv.f.is_int">
203 <function moreinfo="none">is_int(pvar)</function>
206 Function checks if pvar argument contains integer value
207 and returns 1 if it does and -1 otherwise.
210 Function can be used from all kinds of routes.
213 <title><function>is_int()</function> usage</title>
214 <programlisting format="linespecific">
216 if (is_int("$var(foo)")) {
217 xlog("L_INFO", "variable foo contains integer value\n");
223 <section id="pv.f.typeof">
225 <function moreinfo="none">typeof(pvar, vtype)</function>
228 Returns true if the type of pseudo-variable matches the second
229 parameter. The second parameter can be: 'int' - type is integer;
230 'str' - type is string; 'null' - type is null.
233 Function can be used from ANYROUTE.
236 <title><function>typeof()</function> usage</title>
237 <programlisting format="linespecific">
239 if (typeof("$var(foo)", "str")) {
240 xdbg("variable foo is a string\n");
246 <section id="pv.f.not_empty">
248 <function moreinfo="none">not_empty(pvar)</function>
251 Returns true if the pseudo-variables has the type string and
255 Function can be used from all kinds of routes.
258 <title><function>not_empty()</function> usage</title>
259 <programlisting format="linespecific">
261 if (not_empty("$var(foo)")) {
262 append_hf("X-Foo: $var(foo)\r\n");
268 <section id="pv.f.xavp_params_explode">
270 <function moreinfo="none">xavp_params_explode(sparams, xname)</function>
273 Convert a parameters string in xavp atributes.
276 The first parameter has to be a string in the format of SIP header
277 parameters (name1=value1;...;nameN=valueN). The second parameter
278 is the name of the root xavp to hold the pairs (nameX,valueX).
281 The values are stored as string type.
284 Function can be used from ANY ROUTE.
287 <title><function>xavp_params_explode</function> usage</title>
288 <programlisting format="linespecific">
290 xavp_params_explode("a=b;c=d;e=d", "x");
292 # $xavp(x=>a) = "b";
293 # $xavp(x=>c) = "d";
294 # $xavp(x=>e) = "f";
299 <section id="pv.f.sbranch_set_ruri">
301 <function moreinfo="none">sbranch_set_ruri()</function>
304 Use the attributes from static branch ($sbranch(key) variable) to
305 set request URI and the other fields of the branch associated with
306 request URI (destination URI, path, ...).
309 Content of the static branch is not reset after this function is
310 executed. It has to be done explicitely with sbranch_reset().
313 Function can be used from REQUEST_ROUTE, BRANCH_ROUTE or FAILURE_ROUTE.
316 <title><function>sbranch_set_ruri()</function> usage</title>
317 <programlisting format="linespecific">
320 $sbranch(uri) = "sip:127.0.0.1:5080";
321 $sbranch(dst_uri) = "sip:127.0.0.1:5090";
322 $sbranch(path) = "sip:127.0.0.1:5090, sip:127.0.0.1:5094";
323 $sbranch(send_socket) = "udp:127.0.0.1:5060";
329 <section id="pv.f.sbranch_append">
331 <function moreinfo="none">sbranch_append()</function>
334 Use the attributes from static branch ($sbranch(key) variable) to
335 append a new branch to destination set. It is an alternative to
336 append_branch() that allows setting each attribute specific to
340 Content of the static branch is not reset after this function is
341 executed. It has to be done explicitely with sbranch_reset().
344 Function can be used from REQUEST_ROUTE, BRANCH_ROUTE or FAILURE_ROUTE.
347 <title><function>sbranch_append()</function> usage</title>
348 <programlisting format="linespecific">
351 $sbranch(uri) = "sip:127.0.0.1:5080";
352 $sbranch(dst_uri) = "sip:127.0.0.1:5090";
353 $sbranch(send_socket) = "udp:127.0.0.1:5060";
359 <section id="pv.f.sbranch_reset">
361 <function moreinfo="none">sbranch_reset()</function>
364 Reset the content of static branch ($sbranch(key) variable.
367 Function can be used from REQUEST_ROUTE, BRANCH_ROUTE or FAILURE_ROUTE.
370 <title><function>sbranch_append()</function> usage</title>
371 <programlisting format="linespecific">
378 <section id="pv.f.pv_xavp_print">
380 <function moreinfo="none">pv_xavp_print()</function>
383 Print all XAVPs to the syslog using INFO log level.
386 Function can be used from ANY_ROUTE.
389 <title><function>pv_xavp_print()</function> usage</title>
390 <programlisting format="linespecific">
397 <section id="pv.f.pv_var_to_xavp">
399 <function moreinfo="none">pv_var_to_xavp(varname, xname)</function>
402 Copy the script variable value into an xavp.
405 First parameter can be '*' in order to copy all script variables.
406 Second parameter is the name of the destination xavp.
407 If xavp already exists it will be reset first.
410 Both parameters can contain variables that are evaluated at
414 Function can be used from ANY_ROUTE.
417 <title><function>pv_var_to_xavp()</function> usage</title>
418 <programlisting format="linespecific">
421 $var("foo") = "foo indeed";
422 pv_var_to_xavp("temp", "ok");
424 $xavp("ok[0]=>temp") now is 3
426 pv_var_to_xavp("*", "ok");
428 $xavp("ok[0]=>temp") now is 3
429 $xavp("ok[0]=>foo") now is "foo indeed"
434 <section id="pv.f.pv_xavp_to_var">
436 <function moreinfo="none">pv_xavp_to_var(xname)</function>
439 Copy xavp values into vars. Reverse of pv_var_to_xavp().
442 Both parameters can contain variables that are evaluated at
446 Function can be used from ANY_ROUTE.
449 <title><function>pv_xavp_to_var()</function> usage</title>
450 <programlisting format="linespecific">
452 $xavp("bar=>temp") = 3;
453 $xavp("bar[0]=>foo") = "foo indeed";
454 pv_xavp_to_var("bar");
456 $var("temp") now is 3
457 $var("foo") now is "foo indeed"
462 <section id="pv.f.pv_evalx">
464 <function moreinfo="none">pv_evalx(dst, fmt)</function>
467 The fmt string is evaluated twice for exiting variables,
468 the result is stored in dst variable. The dst must be the
469 name of a writable variable. The fmt can contain variables
470 that have a value containing other variables.
474 Function can be used from ANY_ROUTE.
477 <title><function>pv_xavp_to_var()</function> usage</title>
478 <programlisting format="linespecific">
482 pv_evalx("$var(z)", "$var(y) one");
484 # - the value of $var(z) is "test one"
492 <title>RPC Commands</title>
493 <section id="pv.rpc.shvSet">
494 <title><function moreinfo="none">pv.shvSet</function></title>
496 Set the value of a shared variable ($shv(name)).
498 <para>Parameters:</para>
500 <listitem><para>_name_: shared variable name</para></listitem>
502 <listitem><para>_type_: type of the value</para>
504 <listitem><para> <quote>int</quote>: integer value </para></listitem>
505 <listitem><para> <quote>str</quote>: string value </para></listitem>
509 <listitem><para>_value_: value to be set</para></listitem>
512 <title><function moreinfo="none">pv.shvSet</function> usage</title>
513 <programlisting format="linespecific">
515 $ &kamcmd; pv.shvSet debug int 3
520 <section id="pv.rpc.shvGet">
521 <title><function moreinfo="none">pv.shvGet</function></title>
523 Get the value of a shared variable ($shv(name)).
525 <para>Parameters:</para>
527 <listitem><para>_name_: shared variable name</para></listitem>
529 <para>If no name is given, all shared variables are listed.</para>
531 <title><function moreinfo="none">pv.shvGet</function> usage</title>
532 <programlisting format="linespecific">
534 $ &kamcmd; pv.shvGet debug