siputils_admin.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  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 implement various functions and checks related to SIP message
  15. handling and URI handling.
  16. </para>
  17. <para>
  18. It offers some functions related to handle ringing. In a parallel forking
  19. scenario you get several 183s with SDP. You don't want that your customers
  20. hear more than one ringtone or answer machine in parallel on the phone.
  21. So its necessary to drop the 183 in this cases and send a 180 instead.
  22. </para>
  23. <para>
  24. This module also provides a function to answer OPTIONS requests which
  25. are directed to the server itself. This means an OPTIONS request
  26. which has the address of the server in the request URI, and no
  27. username in the URI. The request will be answered with a 200 OK
  28. with the capabilities of the server.
  29. </para>
  30. <para>
  31. To answer OPTIONS request directed to your server is the easiest
  32. way for is-alive-tests on the SIP (application) layer from remote
  33. (similar to ICMP echo requests, also known as <quote>ping</quote>,
  34. on the network layer).
  35. </para>
  36. </section>
  37. <section>
  38. <title>Dependencies</title>
  39. <section>
  40. <title>&kamailio; Modules</title>
  41. <para>
  42. The following modules must be loaded before this module:
  43. <itemizedlist>
  44. <listitem>
  45. <para>
  46. <emphasis>sl</emphasis> -- Stateless replies.
  47. </para>
  48. </listitem>
  49. </itemizedlist>
  50. </para>
  51. </section>
  52. <section>
  53. <title>External Libraries or Applications</title>
  54. <para>
  55. The following libraries or applications must be installed before
  56. running &kamailio; with this module loaded:
  57. <itemizedlist>
  58. <listitem>
  59. <para>
  60. <emphasis>None</emphasis>.
  61. </para>
  62. </listitem>
  63. </itemizedlist>
  64. </para>
  65. </section>
  66. </section>
  67. <section>
  68. <title>Parameters</title>
  69. <section>
  70. <title><varname>ring_timeout</varname> (int)</title>
  71. <para>
  72. Timeout value in seconds, define how long the call-id is stored in the internal list kept for replacing 183 messages with 180.
  73. A reasonable value is <quote>30</quote>.
  74. </para>
  75. <para>
  76. <emphasis>
  77. Default value is <quote>0</quote>. This means functionality is disabled.
  78. </emphasis>
  79. </para>
  80. <example>
  81. <title>Set <varname>ring_timeout</varname> parameter</title>
  82. <programlisting format="linespecific">
  83. ...
  84. modparam("siputils", "ring_timeout", 30)
  85. ...
  86. </programlisting>
  87. </example>
  88. </section>
  89. <section>
  90. <title><varname>options_accept</varname> (string)</title>
  91. <para>
  92. This parameter is the content of the Accept header field.
  93. Note: it is not clearly written in RFC3261 if a proxy should
  94. accept any content (the default <quote>*/*</quote>) because
  95. it does not care about content. Or if it does not accept
  96. any content, which is <quote></quote>.
  97. </para>
  98. <para>
  99. <emphasis>
  100. Default value is <quote>*/*</quote>.
  101. </emphasis>
  102. </para>
  103. <example>
  104. <title>Set <varname>options_accept</varname> parameter</title>
  105. <programlisting format="linespecific">
  106. ...
  107. modparam("siputils", "options_accept", "application/*")
  108. ...
  109. </programlisting>
  110. </example>
  111. </section>
  112. <section>
  113. <title><varname>options_accept_encoding</varname> (string)</title>
  114. <para>
  115. This parameter is the content of the Accept-Encoding header field.
  116. Please do not change the default value because &kamailio;
  117. does not support any encodings yet.
  118. </para>
  119. <para>
  120. <emphasis>
  121. Default value is <quote></quote>.
  122. </emphasis>
  123. </para>
  124. <example>
  125. <title>Set <varname>options_accept_encoding</varname> parameter</title>
  126. <programlisting format="linespecific">
  127. ...
  128. modparam("siputils", "options_accept_encoding", "gzip")
  129. ...
  130. </programlisting>
  131. </example>
  132. </section>
  133. <section>
  134. <title><varname>contact_flds_separator</varname> (string)</title>
  135. <para>
  136. First char of this parameter is used as separator for encoding/decoding
  137. Contact header.
  138. </para>
  139. <warning>
  140. <para>
  141. First char of this field must be set to a value which is not used
  142. inside username,password or other fields of contact. Otherwise it
  143. is possible for the decoding step to fail/produce wrong results.
  144. </para>
  145. </warning>
  146. <para>
  147. <emphasis>
  148. Default value is <quote>*</quote>.
  149. </emphasis>
  150. </para>
  151. <example>
  152. <title>Set <varname>contact_flds_separator</varname> parameter</title>
  153. <programlisting format="linespecific">
  154. ...
  155. modparam("siputils", "contact_flds_separator", "-")
  156. ...
  157. </programlisting>
  158. </example>
  159. <para>
  160. then an encoded uri might look
  161. sip:user-password-ip-port-protocol@PublicIP
  162. </para>
  163. </section>
  164. <section>
  165. <title><varname>options_accept_language</varname> (string)</title>
  166. <para>
  167. This parameter is the content of the Accept-Language header field.
  168. You can set any language code which you prefer for error
  169. descriptions from other devices, but presumably there are not
  170. many devices around which support other languages than the
  171. default English.
  172. </para>
  173. <para>
  174. <emphasis>
  175. Default value is <quote>en</quote>.
  176. </emphasis>
  177. </para>
  178. <example>
  179. <title>Set <varname>options_accept_language</varname> parameter</title>
  180. <programlisting format="linespecific">
  181. ...
  182. modparam("siputils", "options_accept_language", "de")
  183. ...
  184. </programlisting>
  185. </example>
  186. </section>
  187. <section>
  188. <title><varname>options_support</varname> (string)</title>
  189. <para>
  190. This parameter is the content of the Support header field,
  191. indicating SIP extensions.
  192. Please do not change the default value, because &kamailio; currently
  193. does not support any of the SIP extensions registered at the IANA.
  194. </para>
  195. <para>
  196. <emphasis>
  197. Default value is <quote></quote>.
  198. </emphasis>
  199. </para>
  200. <example>
  201. <title>Set <varname>options_support</varname> parameter</title>
  202. <programlisting format="linespecific">
  203. ...
  204. modparam("siputils", "options_support", "100rel")
  205. ...
  206. </programlisting>
  207. </example>
  208. </section>
  209. <section>
  210. <title><varname>rpid_prefix</varname> (string)</title>
  211. <para>
  212. Prefix to be added to Remote-Party-ID header field just before
  213. the URI returned from either radius or database.
  214. </para>
  215. <para>
  216. Default value is <quote></quote>.
  217. </para>
  218. <example>
  219. <title>rpid_prefix parameter example</title>
  220. <programlisting format="linespecific">
  221. modparam("auth", "rpid_prefix", "Whatever &lt;")
  222. </programlisting>
  223. </example>
  224. </section>
  225. <section>
  226. <title><varname>rpid_suffix</varname> (string)</title>
  227. <para>
  228. Suffix to be added to Remote-Party-ID header field after the URI
  229. returned from either radius or database.
  230. </para>
  231. <para>
  232. Default value is
  233. <quote>;party=calling;id-type=subscriber;screen=yes</quote>.
  234. </para>
  235. <example>
  236. <title>rpid_suffix parameter example</title>
  237. <programlisting format="linespecific">
  238. modparam("auth", "rpid_suffix", "@1.2.3.4>")
  239. </programlisting>
  240. </example>
  241. </section>
  242. <section>
  243. <title><varname>rpid_avp</varname> (string)</title>
  244. <para>
  245. Full AVP specification for the AVP which
  246. stores the RPID value. It used to transport the RPID value from
  247. authentication backend modules (auth_db or auth_radius) or from
  248. script to the auth function append_rpid_hf and is_rpid_user_e164.
  249. </para>
  250. <para>
  251. If defined to NULL string, all RPID functions will fail at
  252. runtime.
  253. </para>
  254. <para>
  255. Default value is <quote>$avp(s:rpid)</quote>.
  256. </para>
  257. <example>
  258. <title>rpid_avp parameter example</title>
  259. <programlisting format="linespecific">
  260. modparam("auth", "rpid_avp", "$avp(myrpid)")
  261. </programlisting>
  262. </example>
  263. </section>
  264. </section>
  265. <section>
  266. <title>Functions</title>
  267. <section id="siputils.f.ring_insert_callid">
  268. <title>
  269. <function moreinfo="none">ring_insert_callid()</function>
  270. </title>
  271. <para>
  272. Inserting the call-id in the internal list, which is checked when
  273. further replies arrive. Any 183 reply that is received during the
  274. timeout value will be converted to a 180 message. Please note that you
  275. need to set a positive timeout value in order to use this function.
  276. </para>
  277. <para>
  278. The function returns TRUE on success, and FALSE during processing failures.
  279. </para>
  280. <para>
  281. This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
  282. </para>
  283. <example>
  284. <title><function>ring_insert_callid()</function> usage</title>
  285. <programlisting format="linespecific">
  286. ...
  287. ring_insert_callid();
  288. ...
  289. </programlisting>
  290. </example>
  291. </section>
  292. <section id="siputils.f.options_reply">
  293. <title>
  294. <function moreinfo="none">options_reply()</function>
  295. </title>
  296. <para>
  297. This function checks if the request method is OPTIONS and
  298. if the request URI does not contain an username. If both
  299. is true the request will be answered stateless with
  300. <quote>200 OK</quote> and the capabilities from the modules
  301. parameters.
  302. </para>
  303. <para>
  304. It sends <quote>500 Server Internal Error</quote> for some errors
  305. and returns false if it is called for a wrong request.
  306. </para>
  307. <para>
  308. The check for the request method and the missing username is
  309. optional because it is also done by the function itself. But
  310. you should not call this function outside the myself check
  311. because in this case the function could answer OPTIONS requests
  312. which are sent to you as outbound proxy but with an other
  313. destination then your proxy (this check is currently missing
  314. in the function).
  315. </para>
  316. <para>
  317. This function can be used from REQUEST_ROUTE.
  318. </para>
  319. <example>
  320. <title><function>options_reply</function> usage</title>
  321. <programlisting format="linespecific">
  322. ...
  323. if (uri==myself) {
  324. if ((method==OPTIONS) &amp;&amp; (! uri=~"sip:.*[@]+.*")) {
  325. options_reply();
  326. }
  327. }
  328. ...
  329. </programlisting>
  330. </example>
  331. </section>
  332. <section id="siputils.f.is_user">
  333. <title>
  334. <function moreinfo="none">is_user(username)</function>
  335. </title>
  336. <para>
  337. Check if the username in credentials matches the given username.
  338. </para>
  339. <para>Meaning of the parameters is as follows:</para>
  340. <itemizedlist>
  341. <listitem>
  342. <para><emphasis>username</emphasis> - Username string.
  343. </para>
  344. </listitem>
  345. </itemizedlist>
  346. <para>
  347. This function can be used from REQUEST_ROUTE.
  348. </para>
  349. <example>
  350. <title><function>is_user</function> usage</title>
  351. <programlisting format="linespecific">
  352. ...
  353. if (is_user("john")) {
  354. ...
  355. };
  356. ...
  357. </programlisting>
  358. </example>
  359. </section>
  360. <section id="siputils.f.has_totag()">
  361. <title>
  362. <function moreinfo="none">has_totag()</function>
  363. </title>
  364. <para>
  365. Check if To header field uri contains tag parameter.
  366. </para>
  367. <para>
  368. This function can be used from ANY_ROUTE.
  369. </para>
  370. <example>
  371. <title><function>has_totag</function> usage</title>
  372. <programlisting format="linespecific">
  373. ...
  374. if (has_totag()) {
  375. ...
  376. };
  377. ...
  378. </programlisting>
  379. </example>
  380. </section>
  381. <section>
  382. <title id="siputils.f.uri_param">
  383. <function moreinfo="none">uri_param(param)</function>
  384. </title>
  385. <para>
  386. Find if Request URI has a given parameter with no value
  387. </para>
  388. <para>Meaning of the parameters is as follows:</para>
  389. <itemizedlist>
  390. <listitem>
  391. <para><emphasis>param</emphasis> - parameter name to look for.
  392. </para>
  393. </listitem>
  394. </itemizedlist>
  395. <para>
  396. This function can be used from REQUEST_ROUTE.
  397. </para>
  398. <example>
  399. <title><function>uri_param</function> usage</title>
  400. <programlisting format="linespecific">
  401. ...
  402. if (uri_param("param1")) {
  403. ...
  404. };
  405. ...
  406. </programlisting>
  407. </example>
  408. </section>
  409. <section id="siputils.f.uri_param_value">
  410. <title>
  411. <function moreinfo="none">uri_param(param,value)</function>
  412. </title>
  413. <para>
  414. Find if Request URI has a given parameter with matching value
  415. </para>
  416. <para>Meaning of the parameters is as follows:</para>
  417. <itemizedlist>
  418. <listitem>
  419. <para><emphasis>param</emphasis> - parameter name to look for.
  420. </para>
  421. </listitem>
  422. <listitem>
  423. <para><emphasis>value</emphasis> - parameter value to match.
  424. </para>
  425. </listitem>
  426. </itemizedlist>
  427. <para>
  428. This function can be used from REQUEST_ROUTE.
  429. </para>
  430. <example>
  431. <title><function>uri_param</function> usage</title>
  432. <programlisting format="linespecific">
  433. ...
  434. if (uri_param("param1","value1")) {
  435. ...
  436. };
  437. ...
  438. </programlisting>
  439. </example>
  440. </section>
  441. <section id="siputils.f.add_uri_param">
  442. <title>
  443. <function moreinfo="none">add_uri_param(param)</function>
  444. </title>
  445. <para>
  446. Add to RURI a parameter (name=value);
  447. </para>
  448. <para>Meaning of the parameters is as follows:</para>
  449. <itemizedlist>
  450. <listitem>
  451. <para><emphasis>param</emphasis> - parameter to be appended in
  452. <quote>name=value</quote> format.
  453. </para>
  454. </listitem>
  455. </itemizedlist>
  456. <para>
  457. This function can be used from REQUEST_ROUTE.
  458. </para>
  459. <example>
  460. <title><function>add_uri_param</function> usage</title>
  461. <programlisting format="linespecific">
  462. ...
  463. add_uri_param("nat=yes");
  464. ...
  465. </programlisting>
  466. </example>
  467. </section>
  468. <section id="siputils.f.get_uri_param">
  469. <title>
  470. <function moreinfo="none">get_uri_param(name, var)</function>
  471. </title>
  472. <para>
  473. Get the value of RURI parameter.
  474. </para>
  475. <para>Meaning of the parameters is as follows:</para>
  476. <itemizedlist>
  477. <listitem>
  478. <para><emphasis>name</emphasis> - the name of R-URI parameter</para>
  479. </listitem>
  480. <listitem>
  481. <para><emphasis>var</emphasis> - the variable where to store the
  482. value of the parameter</para>
  483. </listitem>
  484. </itemizedlist>
  485. <para>
  486. This function can be used from REQUEST_ROUTE.
  487. </para>
  488. <example>
  489. <title><function>add_uri_param</function> usage</title>
  490. <programlisting format="linespecific">
  491. ...
  492. get_uri_param("nat", "$var(nat)");
  493. ...
  494. </programlisting>
  495. </example>
  496. </section>
  497. <section id="siputils.f.tel2sip">
  498. <title>
  499. <function moreinfo="none">tel2sip(uri, hostpart, result)</function>
  500. </title>
  501. <para>
  502. Converts URI in first param (pseudo variable or string) to
  503. SIP URI, if it is a tel URI. If conversion was done,
  504. writes resulting SIP URI to third param (pseudo variable).
  505. Returns 1 if conversion succeeded or if no conversion
  506. was needed.
  507. </para>
  508. <para>
  509. The conversion follows the rules in RFC 3261 section 19.1.6:
  510. <itemizedlist>
  511. <listitem>
  512. <para>Visual separators ( "-", ".", "(", ")" ) are removed from tel URI number before converting it to SIP URI userinfo.</para>
  513. </listitem>
  514. <listitem>
  515. <para>tel URI parameters are downcased before appending them to SIP URI userinfo</para>
  516. </listitem>
  517. </itemizedlist>
  518. </para>
  519. <para>
  520. The SIP URI hostpart is taken from second param
  521. (pseudo variable or string).
  522. </para>
  523. <para>
  524. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
  525. BRANCH_ROUTE, or ONREPLY_ROUTE.
  526. </para>
  527. <example>
  528. <title><function>tel2sip</function> usage</title>
  529. <programlisting format="linespecific">
  530. ...
  531. # $ru: tel:+(34)-999-888-777
  532. # $fu: sip:[email protected]
  533. tel2sip("$ru", $fd", "$ru");
  534. # $ru: sip:[email protected];user=phone
  535. # $ru: tel:+12-(34)-56-78;Ext=200;ISUB=+123-456
  536. # $fu: sip:[email protected]
  537. tel2sip("$ru", $fd", "$ru");
  538. # $ru: sip:+12345678;ext=200;[email protected];user=phone
  539. ...
  540. </programlisting>
  541. </example>
  542. </section>
  543. <section id="siputils.f.is_e164">
  544. <title>
  545. <function moreinfo="none">is_e164(pseudo-variable)</function>
  546. </title>
  547. <para>
  548. Checks if string value of pseudo variable argument is an
  549. E164 number.
  550. </para>
  551. <para>
  552. This function can be used from REQUEST_ROUTE,
  553. FAILURE_ROUTE, and LOCAL_ROUTE.
  554. </para>
  555. <example>
  556. <title><function>is_e164</function> usage</title>
  557. <programlisting format="linespecific">
  558. ...
  559. if (is_164("$fU")) { # Check From header URI user part
  560. ...
  561. }
  562. if (is_e164("$avp(i:705)") {
  563. # Check stgring value stored in avp i:705
  564. ...
  565. };
  566. ...
  567. </programlisting>
  568. </example>
  569. </section>
  570. <section id="siputils.f.is_uri_user_e164">
  571. <title>
  572. <function moreinfo="none">is_uri_user_e164(pseudo-variable)</function>
  573. </title>
  574. <para>
  575. Checks if userpart of URI stored in pseudo variable is
  576. E164 number.
  577. </para>
  578. <para>
  579. This function can be used from ANY_ROUTE.
  580. </para>
  581. <example>
  582. <title><function>is_uri_user_e164</function> usage</title>
  583. <programlisting format="linespecific">
  584. ...
  585. if (is_uri_user_e164("$fu")) { # Check From header URI user part
  586. ...
  587. }
  588. if (is_uri_user_e164("$avp(i:705)") {
  589. # Check user part of URI stored in avp i:705
  590. ...
  591. };
  592. ...
  593. </programlisting>
  594. </example>
  595. </section>
  596. <section id="siputils.f.encode_contact">
  597. <title>
  598. <function moreinfo="none">encode_contact(encoding_prefix,hostpart)</function>
  599. </title>
  600. <para>
  601. This function will encode uri-s inside Contact header in the following
  602. manner
  603. sip:username:password@ip:port;transport=protocol goes
  604. sip:encoding_prefix*username*ip*port*protocol@hostpart.
  605. </para>
  606. <para>
  607. * is the default separator and can be changed by setting the contact_flds_separator
  608. module parameter.
  609. </para>
  610. <para>
  611. Note: This function discards all of the URI parameters. Thus, none of the parameters
  612. (except the transport parameter which is encoded into the userpart) can be restored.
  613. </para>
  614. <para>
  615. The function returns negative on error, 1 on success.
  616. </para>
  617. <para>Meaning of the parameters is as follows:</para>
  618. <itemizedlist>
  619. <listitem>
  620. <para><emphasis>encoding_prefix</emphasis> - Something to allow us
  621. to determine that a contact is encoded.
  622. </para>
  623. </listitem>
  624. <listitem>
  625. <para><emphasis>hostpart</emphasis> - An IP address or a hostname.
  626. </para>
  627. </listitem>
  628. </itemizedlist>
  629. <para>
  630. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE.
  631. </para>
  632. <example>
  633. <title><function>encode_contact</function> usage</title>
  634. <programlisting format="linespecific">
  635. ...
  636. if (src_ip == 10.0.0.0/8) encode_contact("natted_client","1.2.3.4");
  637. ...
  638. </programlisting>
  639. </example>
  640. </section>
  641. <section id="siputils.f.decode_contact">
  642. <title>
  643. <function moreinfo="none">decode_contact()</function>
  644. </title>
  645. <para>
  646. This function will decode the request URI. If the RURI is in the format
  647. sip:encoding_prefix*username*ip*port*protocol@hostpart it will be decoded to
  648. sip:username:password@ip:port;transport=protocol It uses the default
  649. set parameter for contact encoding separator.
  650. </para>
  651. <para>
  652. The function returns negative on error, 1 on success.
  653. </para>
  654. <para>Meaning of the parameters is as follows:</para>
  655. <para>
  656. This function can be used from REQUEST_ROUTE.
  657. </para>
  658. <example>
  659. <title><function>decode_contact</function> usage</title>
  660. <programlisting format="linespecific">
  661. ...
  662. if (uri =~ "^sip:natted_client") { decode_contact(); }
  663. ...
  664. </programlisting>
  665. </example>
  666. </section>
  667. <section id="siputils.f.decode_contact_header">
  668. <title>
  669. <function moreinfo="none">decode_contact_header()</function>
  670. </title>
  671. <para>
  672. This function will decode &uri;s inside Contact header. If the URI in the format
  673. sip:encoding_prefix*username*ip*port*protocol@hostpart it will be decoded to
  674. sip:username:password@ip:port;transport=protocol. It uses the
  675. default set parameter for contact encoding separator.
  676. </para>
  677. <para>
  678. The function returns negative on error, 1 on success.
  679. </para>
  680. <para>Meaning of the parameters is as follows:</para>
  681. <para>
  682. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE.
  683. </para>
  684. <example>
  685. <title><function>decode_contact_header</function> usage</title>
  686. <programlisting format="linespecific">
  687. ...
  688. reply_route[2] {
  689. ...
  690. decode_contact_header();
  691. ...
  692. }
  693. ...
  694. </programlisting>
  695. </example>
  696. </section>
  697. <section id="siputils.f.cmp_uri">
  698. <title>
  699. <function moreinfo="none">cmp_uri(str1, str2)</function>
  700. </title>
  701. <para>
  702. The function returns <emphasis>true</emphasis> if
  703. the two parameters matches as SIP URI.
  704. </para>
  705. <para>
  706. This function can be used from ANY_ROUTE.
  707. </para>
  708. <example>
  709. <title><function>cmp_uri</function> usage</title>
  710. <programlisting format="linespecific">
  711. ...
  712. if(cmp_uri("$ru", "sip:[email protected]"))
  713. {
  714. # do interesting stuff here
  715. }
  716. ...
  717. </programlisting>
  718. </example>
  719. </section>
  720. <section id="siputils.f.cmp_aor">
  721. <title>
  722. <function moreinfo="none">cmp_aor(str1, str2)</function>
  723. </title>
  724. <para>
  725. The function returns <emphasis>true</emphasis> if
  726. the two parameters matches as AoR. The parameters have to be SIP
  727. URIs.
  728. </para>
  729. <para>
  730. This function can be used from ANY_ROUTE.
  731. </para>
  732. <example>
  733. <title><function>cmp_aor</function> usage</title>
  734. <programlisting format="linespecific">
  735. ...
  736. if(cmp_aor("[email protected]", "sip:kamailio@$fd"))
  737. {
  738. # do interesting stuff here
  739. }
  740. ...
  741. </programlisting>
  742. </example>
  743. </section>
  744. <section id="siputils.f.append_rpid_hf">
  745. <title>
  746. <function moreinfo="none">append_rpid_hf()</function></title>
  747. <para>
  748. Appends to the message a Remote-Party-ID header that contains header
  749. 'Remote-Party-ID: ' followed by the saved value of the SIP URI
  750. received from the database or radius server followed by the value of
  751. module parameter radius_rpid_suffix. The function does nothing if
  752. no saved SIP URI exists.
  753. </para>
  754. <para>
  755. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
  756. BRANCH_ROUTE.
  757. </para>
  758. <example>
  759. <title>append_rpid_hf usage</title>
  760. <programlisting format="linespecific">
  761. ...
  762. append_rpid_hf(); # Append Remote-Party-ID header field
  763. ...
  764. </programlisting>
  765. </example>
  766. </section>
  767. <section id="siputils.f.append_rpid_hf_params">
  768. <title>
  769. <function moreinfo="none">append_rpid_hf(prefix, suffix)</function>
  770. </title>
  771. <para>
  772. This function is the same as
  773. <xref linkend="siputils.f.append_rpid_hf"/>. The only difference is
  774. that it accepts two parameters--prefix and suffix to be added to
  775. Remote-Party-ID header field. This function ignores rpid_prefix and
  776. rpid_suffix parameters, instead of that allows to set them in every
  777. call.
  778. </para>
  779. <para>Meaning of the parameters is as follows:</para>
  780. <itemizedlist>
  781. <listitem>
  782. <para><emphasis>prefix</emphasis> - Prefix of the
  783. Remote-Party-ID URI. The string will be added at the begining of
  784. body of the header field, just before the URI.
  785. </para>
  786. </listitem>
  787. <listitem>
  788. <para><emphasis>suffix</emphasis> - Suffix of the Remote-Party-ID
  789. header field. The string will be appended at the end of the
  790. header field. It can be used to set various URI parameters,
  791. for example.
  792. </para>
  793. </listitem>
  794. </itemizedlist>
  795. <para>
  796. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
  797. BRANCH_ROUTE.
  798. </para>
  799. <example>
  800. <title>append_rpid_hf(prefix, suffix) usage</title>
  801. <programlisting format="linespecific">
  802. ...
  803. # Append Remote-Party-ID header field
  804. append_rpid_hf("", ";party=calling;id-type=subscriber;screen=yes");
  805. ...
  806. </programlisting>
  807. </example>
  808. </section>
  809. <section>
  810. <title id="siputils.f.is_rpid_user_e164">
  811. <function moreinfo="none">is_rpid_user_e164()</function>
  812. </title>
  813. <para>
  814. The function checks if the SIP URI received from the database or
  815. radius server and will potentially be used in Remote-Party-ID header
  816. field contains an E164 number (+followed by up to 15 decimal digits)
  817. in its user part. Check fails, if no such SIP URI exists
  818. (i.e. radius server or database didn't provide this information).
  819. </para>
  820. <para>
  821. This function can be used from REQUEST_ROUTE.
  822. </para>
  823. <example>
  824. <title>is_rpid_user_e164 usage</title>
  825. <programlisting format="linespecific">
  826. ...
  827. if (is_rpid_user_e164()) {
  828. # do something here
  829. };
  830. ...
  831. </programlisting>
  832. </example>
  833. </section>
  834. <section id="siputils.f.set_uri_user">
  835. <title>
  836. <function moreinfo="none">set_uri_user(uri, user)</function>
  837. </title>
  838. <para>
  839. Sets userpart of SIP URI stored in writable pseudo variable
  840. 'uri' to value of pseudo variable 'user'.
  841. </para>
  842. <para>
  843. This function can be used from ANY_ROUTE.
  844. </para>
  845. <example>
  846. <title>set_uri_user usage</title>
  847. <programlisting format="linespecific">
  848. ...
  849. $var(uri) = "sip:user@host";
  850. $var(user) = "new_user";
  851. set_uri_user("$var(uri)", "$var(user)");
  852. ...
  853. </programlisting>
  854. </example>
  855. </section>
  856. <section id="siputils.f.set_uri_host">
  857. <title>
  858. <function moreinfo="none">set_uri_host(uri, host)</function>
  859. </title>
  860. <para>
  861. Sets hostpart of SIP URI stored in writable pseudo variable
  862. 'uri' to value of pseudo variable 'host'.
  863. </para>
  864. <para>
  865. This function can be used from ANY_ROUTE.
  866. </para>
  867. <example>
  868. <title>set_uri_host usage</title>
  869. <programlisting format="linespecific">
  870. ...
  871. $var(uri) = "sip:user@host";
  872. $var(host) = "new_host";
  873. set_uri_host("$var(uri)", "$var(host)");
  874. ...
  875. </programlisting>
  876. </example>
  877. </section>
  878. <section id="siputils.f.is_request">
  879. <title>
  880. <function moreinfo="none">is_request()</function>
  881. </title>
  882. <para>
  883. Return true if the SIP message is a request.
  884. </para>
  885. <para>
  886. This function can be used from ANY_ROUTE.
  887. </para>
  888. <example>
  889. <title><function>is_request</function> usage</title>
  890. <programlisting format="linespecific">
  891. ...
  892. if (is_request()) {
  893. ...
  894. }
  895. ...
  896. </programlisting>
  897. </example>
  898. </section>
  899. <section id="siputils.f.is_reply">
  900. <title>
  901. <function moreinfo="none">is_reply()</function>
  902. </title>
  903. <para>
  904. Return true if the SIP message is a reply.
  905. </para>
  906. <para>
  907. This function can be used from ANY_ROUTE.
  908. </para>
  909. <example>
  910. <title><function>is_reply</function> usage</title>
  911. <programlisting format="linespecific">
  912. ...
  913. if (is_reply()) {
  914. ...
  915. }
  916. ...
  917. </programlisting>
  918. </example>
  919. </section>
  920. <section id="siputils.f.is_gruu">
  921. <title>
  922. <function moreinfo="none">is_gruu([uri])</function>
  923. </title>
  924. <para>
  925. The function returns true if the uri is GRUU ('gr' parameter
  926. is present): 1 - pub-gruu; 2 - temp-gruu.
  927. </para>
  928. <para>Meaning of the parameters is as follows:</para>
  929. <itemizedlist>
  930. <listitem>
  931. <para><emphasis>uri</emphasis> - the SIP URI to check for
  932. GRUU parameter. It is optional, when missing, the value
  933. of R-URI is used.
  934. </para>
  935. </listitem>
  936. </itemizedlist>
  937. <para>
  938. This function can be used from ANY_ROUTE.
  939. </para>
  940. <example>
  941. <title>is_gruu() usage</title>
  942. <programlisting format="linespecific">
  943. ...
  944. if(is_gruu()) { ... }
  945. ...
  946. </programlisting>
  947. </example>
  948. </section>
  949. <section id="siputils.f.is_supported">
  950. <title>
  951. <function moreinfo="none">is_supported(option)</function>
  952. </title>
  953. <para>
  954. Function returns true if given option is listed
  955. in Supported header(s) (if any) of the request.
  956. Currently the following options are known: path,
  957. 100rel, timer, eventlist, gruu, and outbound.
  958. </para>
  959. <para>
  960. This function can be used from ANY_ROUTE.
  961. </para>
  962. <example>
  963. <title>is_supported() usage</title>
  964. <programlisting format="linespecific">
  965. ...
  966. if (is_supported("outbound")) { ... }
  967. ...
  968. </programlisting>
  969. </example>
  970. </section>
  971. <section id="siputils.f.is_first_hop">
  972. <title>
  973. <function moreinfo="none">is_first_hop()</function>
  974. </title>
  975. <para>
  976. The function returns true if the proxy is first hop after the
  977. original sender. For incoming SIP requests, it means there is only
  978. one Via header. For incoming SIP replies, it means that top
  979. Record-Route URI is 'myself' and source address is not matching it
  980. (to avoid detecting in case of local loops). Note that it does not
  981. detect spirals, which can have the condition for replies true also
  982. in the case of additional SIP reply receival.
  983. </para>
  984. <para>
  985. This function can be used from ANY_ROUTE.
  986. </para>
  987. <example>
  988. <title>is_first_hop() usage</title>
  989. <programlisting format="linespecific">
  990. ...
  991. if(is_first_hop()) { ... }
  992. ...
  993. </programlisting>
  994. </example>
  995. </section>
  996. </section>
  997. </chapter>