pv_admin.xml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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" [
  4. <!-- Include general documentation entities -->
  5. <!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
  6. %docentities;
  7. ]>
  8. <!-- Module User's Guide -->
  9. <chapter>
  10. <title>&adminguide;</title>
  11. <section>
  12. <title>Overview</title>
  13. <para>
  14. This module collects the core pseudo-variables that can be used in
  15. configuration file. They are listed in Dokuwiki:
  16. <ulink url="http://www.kamailio.org/wiki/">http://www.kamailio.org/wiki/</ulink>,
  17. in Pseudo-Variables section
  18. </para>
  19. </section>
  20. <section>
  21. <title>Dependencies</title>
  22. <section>
  23. <title>&kamailio; Modules</title>
  24. <para>
  25. The following modules must be loaded before this module:
  26. <itemizedlist>
  27. <listitem>
  28. <para>
  29. <emphasis>No dependencies on other &kamailio; modules</emphasis>.
  30. </para>
  31. </listitem>
  32. </itemizedlist>
  33. </para>
  34. </section>
  35. <section>
  36. <title>External Libraries or Applications</title>
  37. <para>
  38. The following libraries or applications must be installed before running
  39. &kamailio; with this module loaded:
  40. <itemizedlist>
  41. <listitem>
  42. <para>
  43. <emphasis>None</emphasis>.
  44. </para>
  45. </listitem>
  46. </itemizedlist>
  47. </para>
  48. </section>
  49. </section>
  50. <section>
  51. <title>Parameters</title>
  52. <section>
  53. <title><varname>shvset</varname> (string)</title>
  54. <para>
  55. Set the value of a shared variable ($shv(name)). The parameter
  56. can be set many times.
  57. </para>
  58. <para>
  59. The value of the parameter has the format:
  60. _name_ '=' _type_ ':' _value_
  61. </para>
  62. <itemizedlist>
  63. <listitem><para>_name_: shared variable name</para></listitem>
  64. <listitem><para>_type_: type of the value</para>
  65. <itemizedlist>
  66. <listitem><para> <quote>i</quote>: integer value </para></listitem>
  67. <listitem><para> <quote>s</quote>: string value </para></listitem>
  68. </itemizedlist>
  69. </listitem>
  70. <listitem><para>_value_: value to be set</para></listitem>
  71. </itemizedlist>
  72. <para>
  73. Default value is <quote>NULL</quote>.
  74. </para>
  75. <example>
  76. <title><varname>shvset</varname> parameter usage</title>
  77. <programlisting format="linespecific">
  78. ...
  79. modparam("pv", "shvset", "debug=i:1")
  80. modparam("pv", "shvset", "pstngw=s:sip:10.10.10.10")
  81. ...
  82. </programlisting>
  83. </example>
  84. </section>
  85. <section>
  86. <title><varname>varset</varname> (string)</title>
  87. <para>
  88. Set the value of a script variable ($var(name)). The parameter
  89. can be set many times.
  90. </para>
  91. <para>
  92. The value of the parameter has the format:
  93. _name_ '=' _type_ ':' _value_
  94. </para>
  95. <itemizedlist>
  96. <listitem><para>_name_: shared variable name</para></listitem>
  97. <listitem><para>_type_: type of the value</para>
  98. <itemizedlist>
  99. <listitem><para> <quote>i</quote>: integer value </para></listitem>
  100. <listitem><para> <quote>s</quote>: string value </para></listitem>
  101. </itemizedlist>
  102. </listitem>
  103. <listitem><para>_value_: value to be set</para></listitem>
  104. </itemizedlist>
  105. <para>
  106. Default value is <quote>NULL</quote>.
  107. </para>
  108. <example>
  109. <title><varname>varset</varname> parameter usage</title>
  110. <programlisting format="linespecific">
  111. ...
  112. modparam("pv", "varset", "init=i:1")
  113. modparam("pv", "varset", "gw=s:sip:11.11.11.11;transport=tcp")
  114. ...
  115. </programlisting>
  116. </example>
  117. </section>
  118. <section>
  119. <title><varname>avp_aliases</varname> (string)</title>
  120. <para>
  121. Define aliases for PV AVP names.
  122. </para>
  123. <para>
  124. <emphasis>
  125. Default value is NULL.
  126. </emphasis>
  127. </para>
  128. <example>
  129. <title><varname>avp_aliases</varname> parameter usage</title>
  130. <programlisting format="linespecific">
  131. ...
  132. modparam("pv","avp_aliases","email=s:email_addr;tmp=i:100")
  133. ...
  134. </programlisting>
  135. </example>
  136. </section>
  137. </section>
  138. <section>
  139. <title>Functions</title>
  140. <section>
  141. <title><function moreinfo="none">pv_isset(pvar)</function></title>
  142. <para>
  143. Return true if a PV value is different than 'null'.
  144. </para>
  145. <para>Meaning of the parameters is as follows:</para>
  146. <itemizedlist>
  147. <listitem>
  148. <para>
  149. <emphasis>pvar</emphasis> - pvar identifier.
  150. </para>
  151. </listitem>
  152. </itemizedlist>
  153. <para>
  154. This function can be used from ANY_ROUTE.
  155. </para>
  156. <example>
  157. <title><function>pv_isset</function> usage</title>
  158. <programlisting format="linespecific">
  159. ...
  160. if(pv_isset("$avp("s:x")"))
  161. {
  162. ...
  163. }
  164. ...
  165. </programlisting>
  166. </example>
  167. </section>
  168. <section>
  169. <title><function moreinfo="none">pv_unset(pvar)</function></title>
  170. <para>
  171. Unset the value of the PV (e.g., delete AVP, set to null).
  172. </para>
  173. <para>Meaning of the parameters is as follows:</para>
  174. <itemizedlist>
  175. <listitem>
  176. <para>
  177. <emphasis>pvar</emphasis> - pvar identifier.
  178. </para>
  179. </listitem>
  180. </itemizedlist>
  181. <para>
  182. This function can be used from ANY_ROUTE.
  183. </para>
  184. <example>
  185. <title><function>pv_unset</function> usage</title>
  186. <programlisting format="linespecific">
  187. ...
  188. pv_unset("$avp("s:x")");
  189. ...
  190. </programlisting>
  191. </example>
  192. </section>
  193. <section>
  194. <title>
  195. <function moreinfo="none">is_int(pvar)</function>
  196. </title>
  197. <para>
  198. Function checks if pvar argument contains integer value
  199. and returns 1 if it does and -1 otherwise.
  200. </para>
  201. <para>
  202. Function can be used from all kinds of routes.
  203. </para>
  204. <example>
  205. <title><function>is_int()</function> usage</title>
  206. <programlisting format="linespecific">
  207. ...
  208. if (is_int("$var(foo)")) {
  209. xlog("L_INFO", "variable foo contains integer value\n");
  210. }
  211. ...
  212. </programlisting>
  213. </example>
  214. </section>
  215. <section>
  216. <title>
  217. <function moreinfo="none">typeof(pvar, vtype)</function>
  218. </title>
  219. <para>
  220. Returns true if the type of pseudo-variable matches the second
  221. parameter. The second parameter can be: 'int' - type is integer;
  222. 'str' - type is string; 'null' - type is null.
  223. </para>
  224. <para>
  225. Function can be used from ANYROUTE.
  226. </para>
  227. <example>
  228. <title><function>typeof()</function> usage</title>
  229. <programlisting format="linespecific">
  230. ...
  231. if (typeof("$var(foo)", "str")) {
  232. xdbg("variable foo is a string\n");
  233. }
  234. ...
  235. </programlisting>
  236. </example>
  237. </section>
  238. <section>
  239. <title>
  240. <function moreinfo="none">not_empty(pvar)</function>
  241. </title>
  242. <para>
  243. Returns true if the pseudo-variables has the type string and
  244. is not empty value.
  245. </para>
  246. <para>
  247. Function can be used from all kinds of routes.
  248. </para>
  249. <example>
  250. <title><function>not_empty()</function> usage</title>
  251. <programlisting format="linespecific">
  252. ...
  253. if (not_empty("$var(foo)")) {
  254. append_hf("X-Foo: $var(foo)\r\n");
  255. }
  256. ...
  257. </programlisting>
  258. </example>
  259. </section>
  260. </section>
  261. <section>
  262. <title><acronym>MI</acronym> Commands</title>
  263. <section>
  264. <title><function moreinfo="none">shv_set</function></title>
  265. <para>
  266. Set the value of a shared variable ($shv(name)).
  267. </para>
  268. <para>Parameters:</para>
  269. <itemizedlist>
  270. <listitem><para>_name_: shared variable name</para></listitem>
  271. <listitem><para>_type_: type of the value</para>
  272. <itemizedlist>
  273. <listitem><para> <quote>int</quote>: integer value </para></listitem>
  274. <listitem><para> <quote>str</quote>: string value </para></listitem>
  275. </itemizedlist>
  276. </listitem>
  277. <listitem><para>_value_: value to be set</para></listitem>
  278. </itemizedlist>
  279. <para>
  280. MI FIFO Command Format:
  281. </para>
  282. <programlisting format="linespecific">
  283. :shv_set:_reply_fifo_file_
  284. _name_
  285. _type_
  286. _value_
  287. _empty_line_
  288. </programlisting>
  289. <example>
  290. <title><function moreinfo="none">shv_set</function> usage</title>
  291. <programlisting format="linespecific">
  292. ...
  293. $ &ctltool; fifo shv_set debug int 0
  294. ...
  295. </programlisting>
  296. </example>
  297. </section>
  298. <section>
  299. <title><function moreinfo="none">shv_get</function></title>
  300. <para>
  301. Get the value of a shared variable ($shv(name)).
  302. </para>
  303. <para>Parameters:</para>
  304. <itemizedlist>
  305. <listitem><para>_name_: shared variable name. If this parameter
  306. is missing, all shared variables are returned.</para></listitem>
  307. </itemizedlist>
  308. <para>
  309. MI FIFO Command Format:
  310. </para>
  311. <programlisting format="linespecific">
  312. :shv_get:_reply_fifo_file_
  313. _name_
  314. _empty_line_
  315. </programlisting>
  316. <example>
  317. <title><function moreinfo="none">shv_get</function> usage</title>
  318. <programlisting format="linespecific">
  319. ...
  320. $ &ctltool; fifo shv_get debug
  321. $ &ctltool; fifo shv_get
  322. ...
  323. </programlisting>
  324. </example>
  325. </section>
  326. </section>
  327. <section>
  328. <title>RPC Commands</title>
  329. <section>
  330. <title><function moreinfo="none">pv.shvSet</function></title>
  331. <para>
  332. Set the value of a shared variable ($shv(name)).
  333. </para>
  334. <para>Parameters:</para>
  335. <itemizedlist>
  336. <listitem><para>_name_: shared variable name</para></listitem>
  337. <listitem><para>_type_: type of the value</para>
  338. <itemizedlist>
  339. <listitem><para> <quote>int</quote>: integer value </para></listitem>
  340. <listitem><para> <quote>str</quote>: string value </para></listitem>
  341. </itemizedlist>
  342. </listitem>
  343. <listitem><para>_value_: value to be set</para></listitem>
  344. </itemizedlist>
  345. </section>
  346. <section>
  347. <title><function moreinfo="none">pv.shvGet</function></title>
  348. <para>
  349. Get the value of a shared variable ($shv(name)).
  350. </para>
  351. <para>Parameters:</para>
  352. <itemizedlist>
  353. <listitem><para>_name_: shared variable name</para></listitem>
  354. </itemizedlist>
  355. <para>If no name is given, all shared variables are listed</para>
  356. </section>
  357. </section>
  358. </chapter>