textops_admin.xml 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511
  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. The module implements text based operations over the SIP message
  15. processed by &kamailio;. SIP is a text based protocol and the module
  16. provides a large set of very useful functions to manipulate the
  17. message at text level, e.g., regular expression search and replace,
  18. Perl-like substitutions, checks for method type, header presence,
  19. insert of new header and date, etc.
  20. </para>
  21. <section>
  22. <title>Known Limitations</title>
  23. <para>
  24. search ignores folded lines. For example,
  25. search(<quote>(From|f):.*@foo.bar</quote>)
  26. doesn't match the following From header field:
  27. </para>
  28. <programlisting format="linespecific">
  29. From: medabeda
  30. &lt;sip:[email protected]&gt;;tag=1234
  31. </programlisting>
  32. </section>
  33. </section>
  34. <section>
  35. <title>Dependencies</title>
  36. <section>
  37. <title>&kamailio; Modules</title>
  38. <para>
  39. The following modules must be loaded before this module:
  40. <itemizedlist>
  41. <listitem>
  42. <para>
  43. <emphasis>No dependencies on other &kamailio; modules</emphasis>.
  44. </para>
  45. </listitem>
  46. </itemizedlist>
  47. </para>
  48. </section>
  49. <section>
  50. <title>External Libraries or Applications</title>
  51. <para>
  52. The following libraries or applications must be installed before
  53. running &kamailio; with this module loaded:
  54. <itemizedlist>
  55. <listitem>
  56. <para>
  57. <emphasis>None</emphasis>.
  58. </para>
  59. </listitem>
  60. </itemizedlist>
  61. </para>
  62. </section>
  63. </section>
  64. <section>
  65. <title>Functions</title>
  66. <section id="textops.f.search">
  67. <title>
  68. <function moreinfo="none">search(re)</function>
  69. </title>
  70. <para>
  71. Searches for the re in the message.
  72. </para>
  73. <para>Meaning of the parameters is as follows:</para>
  74. <itemizedlist>
  75. <listitem>
  76. <para><emphasis>re</emphasis> - Regular expression.
  77. </para>
  78. </listitem>
  79. </itemizedlist>
  80. <para>
  81. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  82. FAILURE_ROUTE, BRANCH_ROUTE.
  83. </para>
  84. <example>
  85. <title><function>search</function> usage</title>
  86. <programlisting format="linespecific">
  87. ...
  88. if ( search("[Ss][Ii][Pp]") ) { /*....*/ };
  89. ...
  90. </programlisting>
  91. </example>
  92. </section>
  93. <section id="textops.f.search_body">
  94. <title>
  95. <function moreinfo="none">search_body(re)</function>
  96. </title>
  97. <para>
  98. Searches for the re in the body of the message.
  99. </para>
  100. <para>Meaning of the parameters is as follows:</para>
  101. <itemizedlist>
  102. <listitem>
  103. <para><emphasis>re</emphasis> - Regular expression.
  104. </para>
  105. </listitem>
  106. </itemizedlist>
  107. <para>
  108. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  109. FAILURE_ROUTE, BRANCH_ROUTE.
  110. </para>
  111. <example>
  112. <title><function>search_body</function> usage</title>
  113. <programlisting format="linespecific">
  114. ...
  115. if ( search_body("[Ss][Ii][Pp]") ) { /*....*/ };
  116. ...
  117. </programlisting>
  118. </example>
  119. </section>
  120. <section id="textops.f.search_hf">
  121. <title>
  122. <function moreinfo="none">search_hf(hf, re, flags)</function>
  123. </title>
  124. <para>
  125. Searches for the re in the body of a header field.
  126. </para>
  127. <para>Meaning of the parameters is as follows:</para>
  128. <itemizedlist>
  129. <listitem>
  130. <para><emphasis>hf</emphasis> - header field name.
  131. </para>
  132. </listitem>
  133. <listitem>
  134. <para><emphasis>re</emphasis> - regular expression.
  135. </para>
  136. </listitem>
  137. <listitem>
  138. <para><emphasis>flags</emphasis> - control flags - it
  139. has to be one of: a - all headers matching the
  140. name; f - only first header matching the name;
  141. l - only the last header matching the name.
  142. </para>
  143. </listitem>
  144. </itemizedlist>
  145. <para>
  146. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  147. FAILURE_ROUTE, BRANCH_ROUTE.
  148. </para>
  149. <example>
  150. <title><function>search_body</function> usage</title>
  151. <programlisting format="linespecific">
  152. ...
  153. if ( search_hf("From", ":test@", "a") ) { /*....*/ };
  154. ...
  155. </programlisting>
  156. </example>
  157. </section>
  158. <section id="textops.f.search_append">
  159. <title>
  160. <function moreinfo="none">search_append(re, txt)</function>
  161. </title>
  162. <para>
  163. Searches for the first match of re and appends txt after it.
  164. </para>
  165. <para>Meaning of the parameters is as follows:</para>
  166. <itemizedlist>
  167. <listitem>
  168. <para><emphasis>re</emphasis> - Regular expression.
  169. </para>
  170. </listitem>
  171. <listitem>
  172. <para><emphasis>txt</emphasis> - String to be appended.
  173. </para>
  174. </listitem>
  175. </itemizedlist>
  176. <para>
  177. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  178. FAILURE_ROUTE, BRANCH_ROUTE.
  179. </para>
  180. <example>
  181. <title><function>search_append</function> usage</title>
  182. <programlisting format="linespecific">
  183. ...
  184. search_append("[Oo]pen[Ss]er", " SIP Proxy");
  185. ...
  186. </programlisting>
  187. </example>
  188. </section>
  189. <section id="textops.f.search_append_body">
  190. <title>
  191. <function moreinfo="none">search_append_body(re, txt)</function>
  192. </title>
  193. <para>
  194. Searches for the first match of re in the body of the message
  195. and appends txt after it.
  196. </para>
  197. <para>Meaning of the parameters is as follows:</para>
  198. <itemizedlist>
  199. <listitem>
  200. <para><emphasis>re</emphasis> - Regular expression.
  201. </para>
  202. </listitem>
  203. <listitem>
  204. <para><emphasis>txt</emphasis> - String to be appended.
  205. </para>
  206. </listitem>
  207. </itemizedlist>
  208. <para>
  209. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  210. FAILURE_ROUTE, BRANCH_ROUTE.
  211. </para>
  212. <example>
  213. <title><function>search_append_body</function> usage</title>
  214. <programlisting format="linespecific">
  215. ...
  216. search_append_body("[Oo]pen[Ss]er", " SIP Proxy");
  217. ...
  218. </programlisting>
  219. </example>
  220. </section>
  221. <section id="textops.f.replace">
  222. <title>
  223. <function moreinfo="none">replace(re, txt)</function>
  224. </title>
  225. <para>
  226. Replaces the first occurrence of re with txt.
  227. </para>
  228. <para>Meaning of the parameters is as follows:</para>
  229. <itemizedlist>
  230. <listitem>
  231. <para><emphasis>re</emphasis> - Regular expression.
  232. </para>
  233. </listitem>
  234. <listitem>
  235. <para><emphasis>txt</emphasis> - String.
  236. </para>
  237. </listitem>
  238. </itemizedlist>
  239. <para>
  240. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  241. FAILURE_ROUTE, BRANCH_ROUTE.
  242. </para>
  243. <example>
  244. <title><function>replace</function> usage</title>
  245. <programlisting format="linespecific">
  246. ...
  247. replace("openser", "&kamailio; SIP Proxy");
  248. ...
  249. </programlisting>
  250. </example>
  251. </section>
  252. <section id="textops.f.replace_body">
  253. <title>
  254. <function moreinfo="none">replace_body(re, txt)</function>
  255. </title>
  256. <para>
  257. Replaces the first occurrence of re in the body of the message
  258. with txt.
  259. </para>
  260. <para>Meaning of the parameters is as follows:</para>
  261. <itemizedlist>
  262. <listitem>
  263. <para><emphasis>re</emphasis> - Regular expression.
  264. </para>
  265. </listitem>
  266. <listitem>
  267. <para><emphasis>txt</emphasis> - String.
  268. </para>
  269. </listitem>
  270. </itemizedlist>
  271. <para>
  272. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  273. FAILURE_ROUTE, BRANCH_ROUTE.
  274. </para>
  275. <example>
  276. <title><function>replace_body</function> usage</title>
  277. <programlisting format="linespecific">
  278. ...
  279. replace_body("openser", "&kamailio; SIP Proxy");
  280. ...
  281. </programlisting>
  282. </example>
  283. </section>
  284. <section id="textops.f.replace_all">
  285. <title>
  286. <function moreinfo="none">replace_all(re, txt)</function>
  287. </title>
  288. <para>
  289. Replaces all occurrence of re with txt.
  290. </para>
  291. <para>Meaning of the parameters is as follows:</para>
  292. <itemizedlist>
  293. <listitem>
  294. <para><emphasis>re</emphasis> - Regular expression.
  295. </para>
  296. </listitem>
  297. <listitem>
  298. <para><emphasis>txt</emphasis> - String.
  299. </para>
  300. </listitem>
  301. </itemizedlist>
  302. <para>
  303. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  304. FAILURE_ROUTE, BRANCH_ROUTE.
  305. </para>
  306. <example>
  307. <title><function>replace_all</function> usage</title>
  308. <programlisting format="linespecific">
  309. ...
  310. replace_all("openser", "&kamailio; SIP Proxy");
  311. ...
  312. </programlisting>
  313. </example>
  314. </section>
  315. <section id="textops.f.replace_body_all">
  316. <title>
  317. <function moreinfo="none">replace_body_all(re, txt)</function>
  318. </title>
  319. <para>
  320. Replaces all occurrence of re in the body of the message
  321. with txt. Matching is done on a per-line basis.
  322. </para>
  323. <para>Meaning of the parameters is as follows:</para>
  324. <itemizedlist>
  325. <listitem>
  326. <para><emphasis>re</emphasis> - Regular expression.
  327. </para>
  328. </listitem>
  329. <listitem>
  330. <para><emphasis>txt</emphasis> - String.
  331. </para>
  332. </listitem>
  333. </itemizedlist>
  334. <para>
  335. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  336. FAILURE_ROUTE, BRANCH_ROUTE.
  337. </para>
  338. <example>
  339. <title><function>replace_body_all</function> usage</title>
  340. <programlisting format="linespecific">
  341. ...
  342. replace_body_all("openser", "&kamailio; SIP Proxy");
  343. ...
  344. </programlisting>
  345. </example>
  346. </section>
  347. <section id="textops.f.replace_body_atonce">
  348. <title>
  349. <function moreinfo="none">replace_body_atonce(re, txt)</function>
  350. </title>
  351. <para>
  352. Replaces all occurrence of re in the body of the message
  353. with txt. Matching is done over the whole body.
  354. </para>
  355. <para>Meaning of the parameters is as follows:</para>
  356. <itemizedlist>
  357. <listitem>
  358. <para><emphasis>re</emphasis> - Regular expression.
  359. </para>
  360. </listitem>
  361. <listitem>
  362. <para><emphasis>txt</emphasis> - String.
  363. </para>
  364. </listitem>
  365. </itemizedlist>
  366. <para>
  367. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  368. FAILURE_ROUTE, BRANCH_ROUTE.
  369. </para>
  370. <example>
  371. <title><function>replace_body_atonce</function> usage</title>
  372. <programlisting format="linespecific">
  373. ...
  374. # strip the whole body from the message:
  375. if(has_body() &amp;&amp; replace_body_atonce("^.+$", ""))
  376. remove_hf("Content-Type");
  377. ...
  378. </programlisting>
  379. </example>
  380. </section>
  381. <section id="textops.f.subst">
  382. <title>
  383. <function moreinfo="none">subst('/re/repl/flags')</function>
  384. </title>
  385. <para>
  386. Replaces re with repl (sed or perl like).
  387. </para>
  388. <para>Meaning of the parameters is as follows:</para>
  389. <itemizedlist>
  390. <listitem>
  391. <para><emphasis>'/re/repl/flags'</emphasis> - sed like regular
  392. expression. flags can be a combination of i (case insensitive),
  393. g (global) or s (match newline don't treat it as end of line).
  394. </para>
  395. <para>
  396. 're' - is regular expresion
  397. </para>
  398. <para>
  399. 'repl' - is replacement string - may contain pseudo-varibales
  400. </para>
  401. <para>
  402. 'flags' - substitution flags (i - ignore case, g - global)
  403. </para>
  404. </listitem>
  405. </itemizedlist>
  406. <para>
  407. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  408. FAILURE_ROUTE, BRANCH_ROUTE.
  409. </para>
  410. <example>
  411. <title><function>subst</function> usage</title>
  412. <programlisting format="linespecific">
  413. ...
  414. # replace the uri in to: with the message uri (just an example)
  415. if ( subst('/^To:(.*)sip:[^@]*@[a-zA-Z0-9.]+(.*)$/t:\1\u\2/ig') ) {};
  416. # replace the uri in to: with the value of avp sip_address (just an example)
  417. if ( subst('/^To:(.*)sip:[^@]*@[a-zA-Z0-9.]+(.*)$/t:\1$avp(sip_address)\2/ig') ) {};
  418. ...
  419. </programlisting>
  420. </example>
  421. </section>
  422. <section id="textops.f.subst_uri">
  423. <title>
  424. <function moreinfo="none">subst_uri('/re/repl/flags')</function>
  425. </title>
  426. <para>
  427. Runs the re substitution on the message uri (like subst but works
  428. only on the uri)
  429. </para>
  430. <para>Meaning of the parameters is as follows:</para>
  431. <itemizedlist>
  432. <listitem>
  433. <para><emphasis>'/re/repl/flags'</emphasis> - sed like regular
  434. expression. flags can be a combination of i (case insensitive),
  435. g (global) or s (match newline don't treat it as end of line).
  436. </para>
  437. <para>
  438. 're' - is regular expresion
  439. </para>
  440. <para>
  441. 'repl' - is replacement string - may contain pseudo-varibales
  442. </para>
  443. <para>
  444. 'flags' - substitution flags (i - ignore case, g - global)
  445. </para>
  446. </listitem>
  447. </itemizedlist>
  448. <para>
  449. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  450. FAILURE_ROUTE, BRANCH_ROUTE.
  451. </para>
  452. <example>
  453. <title><function>subst_uri</function> usage</title>
  454. <programlisting format="linespecific">
  455. ...
  456. # adds 3463 prefix to numeric uris, and save the original uri (\0 match)
  457. # as a parameter: orig_uri (just an example)
  458. if (subst_uri('/^sip:([0-9]+)@(.*)$/sip:3463\1@\2;orig_uri=\0/i')){$
  459. # adds the avp 'uri_prefix' as prefix to numeric uris, and save the original
  460. # uri (\0 match) as a parameter: orig_uri (just an example)
  461. if (subst_uri('/^sip:([0-9]+)@(.*)$/sip:$avp(uri_prefix)\1@\2;orig_uri=\0/i')){$
  462. ...
  463. </programlisting>
  464. </example>
  465. </section>
  466. <section id="textops.f.subst_user">
  467. <title>
  468. <function moreinfo="none">subst_user('/re/repl/flags')</function>
  469. </title>
  470. <para>
  471. Runs the re substitution on the message uri (like subst_uri but works
  472. only on the user portion of the uri)
  473. </para>
  474. <para>Meaning of the parameters is as follows:</para>
  475. <itemizedlist>
  476. <listitem>
  477. <para><emphasis>'/re/repl/flags'</emphasis> - sed like regular
  478. expression. flags can be a combination of i (case insensitive),
  479. g (global) or s (match newline don't treat it as end of line).
  480. </para>
  481. <para>
  482. 're' - is regular expresion
  483. </para>
  484. <para>
  485. 'repl' - is replacement string - may contain pseudo-varibales
  486. </para>
  487. <para>
  488. 'flags' - substitution flags (i - ignore case, g - global)
  489. </para>
  490. </listitem>
  491. </itemizedlist>
  492. <para>
  493. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  494. FAILURE_ROUTE, BRANCH_ROUTE.
  495. </para>
  496. <example>
  497. <title><function>subst</function> usage</title>
  498. <programlisting format="linespecific">
  499. ...
  500. # adds 3463 prefix to uris ending with 3642 (just an example)
  501. if (subst_user('/3642$/36423463/')){$
  502. ...
  503. # adds avp 'user_prefix' as prefix to username in r-uri ending with 3642
  504. if (subst_user('/(.*)3642$/$avp(user_prefix)\13642/')){$
  505. ...
  506. </programlisting>
  507. </example>
  508. </section>
  509. <section id="textops.f.subst_body">
  510. <title>
  511. <function moreinfo="none">subst_body('/re/repl/flags')</function>
  512. </title>
  513. <para>
  514. Replaces re with repl (sed or perl like) in the body of the message.
  515. </para>
  516. <para>Meaning of the parameters is as follows:</para>
  517. <itemizedlist>
  518. <listitem>
  519. <para><emphasis>'/re/repl/flags'</emphasis> - sed like regular
  520. expression. flags can be a combination of i (case insensitive),
  521. g (global) or s (match newline don't treat it as end of line).
  522. </para>
  523. <para>
  524. 're' - is regular expresion
  525. </para>
  526. <para>
  527. 'repl' - is replacement string - may contain pseudo-varibales
  528. </para>
  529. <para>
  530. 'flags' - substitution flags (i - ignore case, g - global)
  531. </para>
  532. </listitem>
  533. </itemizedlist>
  534. <para>
  535. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  536. FAILURE_ROUTE, BRANCH_ROUTE.
  537. </para>
  538. <example>
  539. <title><function>subst_body</function> usage</title>
  540. <programlisting format="linespecific">
  541. ...
  542. if ( subst_body('/^o=(.*) /o=$fU /') ) {};
  543. ...
  544. </programlisting>
  545. </example>
  546. </section>
  547. <section id="textops.f.subst_hf">
  548. <title>
  549. <function moreinfo="none">subst_hf(hf, subexp, flags)</function>
  550. </title>
  551. <para>
  552. Perl-like substitutions in the body of a header field.
  553. </para>
  554. <para>Meaning of the parameters is as follows:</para>
  555. <itemizedlist>
  556. <listitem>
  557. <para><emphasis>hf</emphasis> - header field name.
  558. </para>
  559. </listitem>
  560. <listitem>
  561. <para><emphasis>subexp</emphasis> - substitution expression
  562. in the same format as of the 'subst' function parameter.
  563. </para>
  564. </listitem>
  565. <listitem>
  566. <para><emphasis>flags</emphasis> - control flags - it
  567. has to be one of: a - all headers matching the
  568. name; f - only first header matching the name;
  569. l - only the last header matching the name.
  570. </para>
  571. </listitem>
  572. </itemizedlist>
  573. <para>
  574. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  575. FAILURE_ROUTE, BRANCH_ROUTE.
  576. </para>
  577. <example>
  578. <title><function>search_body</function> usage</title>
  579. <programlisting format="linespecific">
  580. ...
  581. if ( subst_hf("From", "/:test@/:best@/", "a") ) { /*....*/ };
  582. ...
  583. </programlisting>
  584. </example>
  585. </section>
  586. <section id="textops.f.set_body">
  587. <title>
  588. <function moreinfo="none">set_body(txt,content_type)</function>
  589. </title>
  590. <para>
  591. Set body to a SIP message.
  592. </para>
  593. <para>Meaning of the parameters is as follows:</para>
  594. <itemizedlist>
  595. <listitem>
  596. <para><emphasis>txt</emphasis> - text for the body, can include
  597. pseudo-variables.
  598. </para>
  599. </listitem>
  600. <listitem>
  601. <para><emphasis>content_type</emphasis> - value of Content-Type header,
  602. can include pseudo-variables.
  603. </para>
  604. </listitem>
  605. </itemizedlist>
  606. <para>
  607. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  608. FAILURE_ROUTE, BRANCH_ROUTE.
  609. </para>
  610. <example>
  611. <title><function>set_body</function> usage</title>
  612. <programlisting format="linespecific">
  613. ...
  614. set_body("test", "text/plain");
  615. ...
  616. </programlisting>
  617. </example>
  618. </section>
  619. <section id="textops.f.set_reply_body">
  620. <title>
  621. <function moreinfo="none">set_reply_body(txt,content_type)</function>
  622. </title>
  623. <para>
  624. Set body to a SIP reply to be generated by &kamailio;.
  625. </para>
  626. <para>Meaning of the parameters is as follows:</para>
  627. <itemizedlist>
  628. <listitem>
  629. <para><emphasis>txt</emphasis> - text for the body, can include
  630. pseudo-variables.
  631. </para>
  632. </listitem>
  633. <listitem>
  634. <para><emphasis>content_type</emphasis> - value of Content-Type header,
  635. can include pseudo-variables.
  636. </para>
  637. </listitem>
  638. </itemizedlist>
  639. <para>
  640. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
  641. </para>
  642. <example>
  643. <title><function>set_reply_body</function> usage</title>
  644. <programlisting format="linespecific">
  645. ...
  646. set_reply_body("test", "text/plain");
  647. ...
  648. </programlisting>
  649. </example>
  650. </section>
  651. <section id="textops.f.filter_body">
  652. <title>
  653. <function moreinfo="none">filter_body(content_type)</function>
  654. </title>
  655. <para>
  656. Filters multipart/mixed body by leaving out all other body
  657. parts except the first body part of given type.
  658. </para>
  659. <para>Meaning of the parameters is as follows:</para>
  660. <itemizedlist>
  661. <listitem>
  662. <para><emphasis>content_type</emphasis> -
  663. Content type to be left in the body.
  664. </para>
  665. </listitem>
  666. </itemizedlist>
  667. <para>
  668. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  669. FAILURE_ROUTE, BRANCH_ROUTE.
  670. </para>
  671. <example>
  672. <title><function>filter_body</function> usage</title>
  673. <programlisting format="linespecific">
  674. ...
  675. if (has_body("multipart/mixed")) {
  676. if (filter_body("application/sdp") {
  677. remove_hf("Content-Type");
  678. append_hf("Content-Type: application/sdp\r\n");
  679. } else {
  680. xlog("Body part application/sdp not found\n");
  681. }
  682. }
  683. ...
  684. </programlisting>
  685. </example>
  686. </section>
  687. <section id="textops.f.append_to_reply">
  688. <title>
  689. <function moreinfo="none">append_to_reply(txt)</function>
  690. </title>
  691. <para>
  692. Append txt as header to the reply.
  693. </para>
  694. <para>Meaning of the parameters is as follows:</para>
  695. <itemizedlist>
  696. <listitem>
  697. <para><emphasis>txt</emphasis> - String which may contains
  698. pseudo-variables.
  699. </para>
  700. </listitem>
  701. </itemizedlist>
  702. <para>
  703. This function can be used from REQUEST_ROUTE, BRANCH_ROUTE,
  704. FAILURE_ROUTE, ERROR_ROUTE.
  705. </para>
  706. <example>
  707. <title><function>append_to_reply</function> usage</title>
  708. <programlisting format="linespecific">
  709. ...
  710. append_to_reply("Foo: bar\r\n");
  711. append_to_reply("Foo: $rm at $Ts\r\n");
  712. ...
  713. </programlisting>
  714. </example>
  715. </section>
  716. <section id="textops.f.append_hf">
  717. <title>
  718. <function moreinfo="none">append_hf(txt[, hdr])</function>
  719. </title>
  720. <para>
  721. Appends 'txt' as header after first header field or after
  722. last 'hdr' header field.
  723. </para>
  724. <para>Meaning of the parameters is as follows:</para>
  725. <itemizedlist>
  726. <listitem>
  727. <para><emphasis>txt</emphasis> - Header field to be appended. The
  728. value can contain pseudo-variables which will be replaced at run
  729. time.
  730. </para>
  731. </listitem>
  732. <listitem>
  733. <para><emphasis>hdr</emphasis> - Header name after which the 'txt'
  734. is appended.
  735. </para>
  736. </listitem>
  737. </itemizedlist>
  738. <para>
  739. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  740. FAILURE_ROUTE, BRANCH_ROUTE.
  741. </para>
  742. <example>
  743. <title><function>append_hf</function> usage</title>
  744. <programlisting format="linespecific">
  745. ...
  746. append_hf("P-hint: VOICEMAIL\r\n");
  747. append_hf("From-username: $fU\r\n", "Call-ID");
  748. ...
  749. </programlisting>
  750. </example>
  751. </section>
  752. <section id="textops.f.insert_hf">
  753. <title>
  754. <function moreinfo="none">insert_hf(txt[, hdr])</function>
  755. </title>
  756. <para>
  757. Inserts 'txt' as header before the first header field or before
  758. first 'hdr' header field if 'hdr' is given.
  759. </para>
  760. <para>Meaning of the parameters is as follows:</para>
  761. <itemizedlist>
  762. <listitem>
  763. <para><emphasis>txt</emphasis> - Header field to be inserted. The
  764. value can contain pseudo-variables which will be replaced at run
  765. time.
  766. </para>
  767. </listitem>
  768. <listitem>
  769. <para><emphasis>hdr</emphasis> - Header name before which the 'txt'
  770. is inserted.
  771. </para>
  772. </listitem>
  773. </itemizedlist>
  774. <para>
  775. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  776. FAILURE_ROUTE, BRANCH_ROUTE.
  777. </para>
  778. <example>
  779. <title><function>insert_hf</function> usage</title>
  780. <programlisting format="linespecific">
  781. ...
  782. insert_hf("P-hint: VOICEMAIL\r\n");
  783. insert_hf("To-username: $tU\r\n");
  784. insert_hf("P-hint: VOICEMAIL\r\n", "Call-ID");
  785. insert_hf("To-username: $tU\r\n", "Call-ID");
  786. ...
  787. </programlisting>
  788. </example>
  789. </section>
  790. <section id="textops.f.append_urihf">
  791. <title>
  792. <function moreinfo="none">append_urihf(prefix, suffix)</function>
  793. </title>
  794. <para>
  795. Append header field name with original <acronym>Request-URI</acronym>
  796. in middle.
  797. </para>
  798. <para>Meaning of the parameters is as follows:</para>
  799. <itemizedlist>
  800. <listitem>
  801. <para><emphasis>prefix</emphasis> - string (usually at least
  802. header field name).
  803. </para>
  804. </listitem>
  805. <listitem>
  806. <para><emphasis>suffix</emphasis> - string (usually at least
  807. line terminator).
  808. </para>
  809. </listitem>
  810. </itemizedlist>
  811. <para>
  812. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
  813. BRANCH_ROUTE.
  814. </para>
  815. <example>
  816. <title><function>append_urihf</function> usage</title>
  817. <programlisting format="linespecific">
  818. ...
  819. append_urihf("CC-Diversion: ", "\r\n");
  820. ...
  821. </programlisting>
  822. </example>
  823. </section>
  824. <section id="textops.f.is_present_hf">
  825. <title>
  826. <function moreinfo="none">is_present_hf(hf_name)</function>
  827. </title>
  828. <para>
  829. Return true if a header field is present in message.
  830. </para>
  831. <note>
  832. <para>
  833. The function is also able to distinguish the compact names. For
  834. exmaple <quote>From</quote> will match with <quote>f</quote>
  835. </para>
  836. </note>
  837. <para>Meaning of the parameters is as follows:</para>
  838. <itemizedlist>
  839. <listitem>
  840. <para><emphasis>hf_name</emphasis> - Header field name.(long or
  841. compact form)
  842. </para>
  843. </listitem>
  844. </itemizedlist>
  845. <para>
  846. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  847. FAILURE_ROUTE, BRANCH_ROUTE.
  848. </para>
  849. <example>
  850. <title><function>is_present_hf</function> usage</title>
  851. <programlisting format="linespecific">
  852. ...
  853. if (is_present_hf("From")) log(1, "From HF Present");
  854. ...
  855. </programlisting>
  856. </example>
  857. </section>
  858. <section id="textops.f.is_present_hf_re">
  859. <title>
  860. <function moreinfo="none">is_present_hf_re(hf_name_re)</function>
  861. </title>
  862. <para>
  863. Return true if a header field whose name matches regular expression
  864. 'hf_name_re' is present in message.
  865. </para>
  866. <para>Meaning of the parameters is as follows:</para>
  867. <itemizedlist>
  868. <listitem>
  869. <para><emphasis>hf_name_re</emphasis> - Regular expression to
  870. match header field name.
  871. </para>
  872. </listitem>
  873. </itemizedlist>
  874. <para>
  875. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  876. FAILURE_ROUTE, BRANCH_ROUTE.
  877. </para>
  878. <example>
  879. <title><function>is_present_hf_re</function> usage</title>
  880. <programlisting format="linespecific">
  881. ...
  882. if (is_present_hf_re("^P-")) log(1, "There are headers starting with P-\n");
  883. ...
  884. </programlisting>
  885. </example>
  886. </section>
  887. <section id="textops.f.append_time">
  888. <title>
  889. <function moreinfo="none">append_time()</function>
  890. </title>
  891. <para>
  892. Adds a time header to the reply of the request. You must use it
  893. before functions that are likely to send a reply, e.g., save()
  894. from 'registrar' module. Header format is:
  895. <quote>Date: %a, %d %b %Y %H:%M:%S GMT</quote>, with the legend:
  896. <itemizedlist>
  897. <listitem>
  898. <para><emphasis>%a</emphasis> abbreviated week of day name (locale)
  899. </para>
  900. </listitem>
  901. <listitem>
  902. <para><emphasis>%d</emphasis> day of month as decimal number
  903. </para>
  904. </listitem>
  905. <listitem>
  906. <para><emphasis>%b</emphasis> abbreviated month name (locale)
  907. </para>
  908. </listitem>
  909. <listitem>
  910. <para><emphasis>%Y</emphasis> year with century
  911. </para>
  912. </listitem>
  913. <listitem>
  914. <para><emphasis>%H</emphasis> hour
  915. </para>
  916. </listitem>
  917. <listitem>
  918. <para><emphasis>%M</emphasis> minutes
  919. </para>
  920. </listitem>
  921. <listitem>
  922. <para><emphasis>%S</emphasis> seconds
  923. </para>
  924. </listitem>
  925. </itemizedlist>
  926. </para>
  927. <para>
  928. Return true if a header was succesfully appended.
  929. </para>
  930. <para>
  931. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
  932. BRANCH_ROUTE.
  933. </para>
  934. <example>
  935. <title><function>append_time</function> usage</title>
  936. <programlisting format="linespecific">
  937. ...
  938. append_time();
  939. ...
  940. </programlisting>
  941. </example>
  942. </section>
  943. <section id="textops.f.append_time_to_request">
  944. <title>
  945. <function moreinfo="none">append_time_to_request()</function>
  946. </title>
  947. <para>
  948. Adds a time header to the request. Header format is:
  949. <quote>Date: %a, %d %b %Y %H:%M:%S GMT</quote>, with the legend:
  950. <itemizedlist>
  951. <listitem>
  952. <para><emphasis>%a</emphasis> abbreviated week of day name (locale)
  953. </para>
  954. </listitem>
  955. <listitem>
  956. <para><emphasis>%d</emphasis> day of month as decimal number
  957. </para>
  958. </listitem>
  959. <listitem>
  960. <para><emphasis>%b</emphasis> abbreviated month name (locale)
  961. </para>
  962. </listitem>
  963. <listitem>
  964. <para><emphasis>%Y</emphasis> year with century
  965. </para>
  966. </listitem>
  967. <listitem>
  968. <para><emphasis>%H</emphasis> hour
  969. </para>
  970. </listitem>
  971. <listitem>
  972. <para><emphasis>%M</emphasis> minutes
  973. </para>
  974. </listitem>
  975. <listitem>
  976. <para><emphasis>%S</emphasis> seconds
  977. </para>
  978. </listitem>
  979. </itemizedlist>
  980. </para>
  981. <para>
  982. Return true if a header was succesfully appended.
  983. </para>
  984. <para>
  985. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  986. FAILURE_ROUTE, BRANCH_ROUTE.
  987. </para>
  988. <example>
  989. <title><function>append_time_to_request</function> usage</title>
  990. <programlisting format="linespecific">
  991. ...
  992. if(!is_present_hf("Date"))
  993. append_time_to_request();
  994. ...
  995. </programlisting>
  996. </example>
  997. </section>
  998. <section id="textops.f.is_method">
  999. <title>
  1000. <function moreinfo="none">is_method(name)</function>
  1001. </title>
  1002. <para>
  1003. Check if the method of the message matches the name. If name is a
  1004. known method (invite, cancel, ack, bye, options, info, update, register,
  1005. message, subscribe, notify, refer, prack), the function performs method
  1006. ID testing (integer comparison) instead of ignore case string
  1007. comparison.
  1008. </para>
  1009. <para>
  1010. The 'name' can be a list of methods in the form of
  1011. 'method1|method2|...'. In this case, the function returns true if the
  1012. SIP message's method is one from the list. IMPORTANT NOTE: in the list
  1013. must be only methods defined in &kamailio; with ID (invite, cancel, ack,
  1014. bye, options, info, update, register, message, subscribe, notify,
  1015. refer, prack, publish; for more see:
  1016. <ulink url="http://www.iana.org/assignments/sip-parameters">
  1017. http://www.iana.org/assignments/sip-parameters</ulink>).
  1018. </para>
  1019. <para>
  1020. If used for replies, the function tests the value of method field from
  1021. CSeq header.
  1022. </para>
  1023. <para>Meaning of the parameters is as follows:</para>
  1024. <itemizedlist>
  1025. <listitem>
  1026. <para><emphasis>name</emphasis> - SIP method name
  1027. </para>
  1028. </listitem>
  1029. </itemizedlist>
  1030. <para>
  1031. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  1032. FAILURE_ROUTE, and BRANCH_ROUTE.
  1033. </para>
  1034. <example>
  1035. <title><function>is_method</function> usage</title>
  1036. <programlisting format="linespecific">
  1037. ...
  1038. if(is_method("INVITE"))
  1039. {
  1040. # process INVITEs here
  1041. }
  1042. if(is_method("OPTION|UPDATE"))
  1043. {
  1044. # process OPTIONs and UPDATEs here
  1045. }
  1046. ...
  1047. </programlisting>
  1048. </example>
  1049. </section>
  1050. <section id="textops.f.remove_hf">
  1051. <title>
  1052. <function moreinfo="none">remove_hf(hname)</function>
  1053. </title>
  1054. <para>
  1055. Remove from message all headers with name <quote>hname</quote>.
  1056. Header matching is case-insensitive. Matches and removes also
  1057. the compact header forms.
  1058. </para>
  1059. <para>
  1060. Returns true if at least one header is found and removed.
  1061. </para>
  1062. <para>Meaning of the parameters is as follows:</para>
  1063. <itemizedlist>
  1064. <listitem>
  1065. <para><emphasis>hname</emphasis> - header name to be removed.
  1066. </para>
  1067. </listitem>
  1068. </itemizedlist>
  1069. <para>
  1070. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  1071. FAILURE_ROUTE and BRANCH_ROUTE.
  1072. </para>
  1073. <example>
  1074. <title><function>remove_hf</function> usage</title>
  1075. <programlisting format="linespecific">
  1076. ...
  1077. if(remove_hf("User-Agent"))
  1078. {
  1079. # User Agent header removed
  1080. }
  1081. # compact form: remove "Contact" or "m" header
  1082. remove_hf("Contact")
  1083. # compact form: remove "Contact" or "m" header
  1084. remove_hf("m")
  1085. ...
  1086. </programlisting>
  1087. </example>
  1088. </section>
  1089. <section id="textops.f.remove_hf_re">
  1090. <title>
  1091. <function moreinfo="none">remove_hf_re(re)</function>
  1092. </title>
  1093. <para>
  1094. Remove from message all headers with name matching regular
  1095. expression <quote>re</quote>
  1096. </para>
  1097. <para>
  1098. Returns true if at least one header is found and removed.
  1099. </para>
  1100. <para>Meaning of the parameters is as follows:</para>
  1101. <itemizedlist>
  1102. <listitem>
  1103. <para><emphasis>re</emphasis> - regular expression to match
  1104. the header name to be removed.
  1105. </para>
  1106. </listitem>
  1107. </itemizedlist>
  1108. <para>
  1109. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  1110. FAILURE_ROUTE and BRANCH_ROUTE.
  1111. </para>
  1112. <example>
  1113. <title><function>remove_hf_re</function> usage</title>
  1114. <programlisting format="linespecific">
  1115. ...
  1116. if(remove_hf_re("^P-"))
  1117. {
  1118. # All headers starting with "P-" removed
  1119. }
  1120. ...
  1121. </programlisting>
  1122. </example>
  1123. </section>
  1124. <section id="textops.f.has_body">
  1125. <title>
  1126. <function moreinfo="none">has_body()</function>,
  1127. <function moreinfo="none">has_body(mime)</function>
  1128. </title>
  1129. <para>
  1130. The function returns <emphasis>true</emphasis> if the SIP message
  1131. has a body attached. The checked includes also the
  1132. <quote>Content-Length</quote> header presence and value.
  1133. </para>
  1134. <para>
  1135. If a parameter is given, the mime described will be also checked against
  1136. the <quote>Content-Type</quote> header.
  1137. </para>
  1138. <para>Meaning of the parameters is as follows:</para>
  1139. <itemizedlist>
  1140. <listitem>
  1141. <para><emphasis>mime</emphasis> - mime to be checked against the
  1142. <quote>Content-Type</quote> header. If not present or 0, this
  1143. check will be disabled.
  1144. </para>
  1145. </listitem>
  1146. </itemizedlist>
  1147. <para>
  1148. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  1149. FAILURE_ROUTE and BRANCH_ROUTE.
  1150. </para>
  1151. <example>
  1152. <title><function>has_body</function> usage</title>
  1153. <programlisting format="linespecific">
  1154. ...
  1155. if(has_body("application/sdp"))
  1156. {
  1157. # do interesting stuff here
  1158. }
  1159. ...
  1160. </programlisting>
  1161. </example>
  1162. </section>
  1163. <section id="textops.f.is_audio_on_hold">
  1164. <title>
  1165. <function moreinfo="none">is_audio_on_hold()</function>
  1166. </title>
  1167. <para>
  1168. The function returns <emphasis>true</emphasis> if the SIP message
  1169. has a body attached and at least one audio stream in on hold.
  1170. </para>
  1171. <para>
  1172. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  1173. FAILURE_ROUTE and BRANCH_ROUTE.
  1174. </para>
  1175. <example>
  1176. <title><function>is_audio_on_hold</function> usage</title>
  1177. <programlisting format="linespecific">
  1178. ...
  1179. if(is_audio_on_hold())
  1180. {
  1181. # do interesting stuff here
  1182. }
  1183. ...
  1184. </programlisting>
  1185. </example>
  1186. </section>
  1187. <section id="textops.f.is_privacy">
  1188. <title>
  1189. <function moreinfo="none">is_privacy(privacy_type)</function>
  1190. </title>
  1191. <para>
  1192. The function returns <emphasis>true</emphasis> if
  1193. the SIP message has a Privacy header field that includes
  1194. the given privacy_type among its privacy values. See
  1195. <ulink url="http://www.iana.org/assignments/sip-priv-values">
  1196. http://www.iana.org/assignments/sip-priv-values</ulink>
  1197. for possible privacy type values.
  1198. </para>
  1199. <para>
  1200. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  1201. FAILURE_ROUTE and BRANCH_ROUTE.
  1202. </para>
  1203. <example>
  1204. <title><function>is_privacy</function> usage</title>
  1205. <programlisting format="linespecific">
  1206. ...
  1207. if(is_privacy("id"))
  1208. {
  1209. # do interesting stuff here
  1210. }
  1211. ...
  1212. </programlisting>
  1213. </example>
  1214. </section>
  1215. <section id="textops.f.in_list">
  1216. <title>
  1217. <function moreinfo="none">in_list(subject, list, separator)</function>
  1218. </title>
  1219. <para>
  1220. Function checks if subject string is found in list string where list items are separated by separator string. Subject and list strings may contain pseudo variables. Separator string needs to be one character long. Returns 1 if subject is found and -1 otherwise.
  1221. </para>
  1222. <para>
  1223. Function can be used from all kinds of routes.
  1224. </para>
  1225. <example>
  1226. <title><function>in_list()</function> usage</title>
  1227. <programlisting format="linespecific">
  1228. ...
  1229. $var(subject) = "fi";
  1230. $var(list) = "dk,fi,no,se";
  1231. if (in_list("$var(subject)", "$var(list)", ",") {
  1232. xlog("L_INFO", "subject is found in list\n");
  1233. }
  1234. ...
  1235. </programlisting>
  1236. </example>
  1237. </section>
  1238. <section id="textops.f.cmp_str">
  1239. <title>
  1240. <function moreinfo="none">cmp_str(str1, str2)</function>
  1241. </title>
  1242. <para>
  1243. The function returns <emphasis>true</emphasis> if
  1244. the two parameters matches as string case sensitive comparison.
  1245. </para>
  1246. <para>
  1247. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  1248. FAILURE_ROUTE and BRANCH_ROUTE.
  1249. </para>
  1250. <example>
  1251. <title><function>cmp_str</function> usage</title>
  1252. <programlisting format="linespecific">
  1253. ...
  1254. if(cmp_str("$rU", "kamailio"))
  1255. {
  1256. # do interesting stuff here
  1257. }
  1258. ...
  1259. </programlisting>
  1260. </example>
  1261. </section>
  1262. <section id="textops.f.cmp_istr">
  1263. <title>
  1264. <function moreinfo="none">cmp_istr(str1, str2)</function>
  1265. </title>
  1266. <para>
  1267. The function returns <emphasis>true</emphasis> if
  1268. the two parameters matches as string case insensitive comparison.
  1269. </para>
  1270. <para>
  1271. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  1272. FAILURE_ROUTE and BRANCH_ROUTE.
  1273. </para>
  1274. <example>
  1275. <title><function>cmp_str</function> usage</title>
  1276. <programlisting format="linespecific">
  1277. ...
  1278. if(cmp_istr("$rU@you", "kamailio@YOU"))
  1279. {
  1280. # do interesting stuff here
  1281. }
  1282. ...
  1283. </programlisting>
  1284. </example>
  1285. </section>
  1286. <section id="textops.f.starts_with">
  1287. <title>
  1288. <function moreinfo="none">starts_with(str1, str2)</function>
  1289. </title>
  1290. <para>
  1291. The function returns <emphasis>true</emphasis> if
  1292. the first string starts with the second string.
  1293. </para>
  1294. <para>
  1295. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  1296. FAILURE_ROUTE and BRANCH_ROUTE.
  1297. </para>
  1298. <example>
  1299. <title><function>starts_with</function> usage</title>
  1300. <programlisting format="linespecific">
  1301. ...
  1302. if (starts_with("$rU", "+358"))
  1303. {
  1304. # do interesting stuff here
  1305. }
  1306. ...
  1307. </programlisting>
  1308. </example>
  1309. </section>
  1310. <section id="textops.f.set_body_multipart">
  1311. <title>
  1312. <function moreinfo="none">set_body_multipart([txt,content_type][,boundary])</function>
  1313. </title>
  1314. <para>
  1315. Set multipart body to a SIP message. If called with no parameters, will convert
  1316. present body to multipart.
  1317. </para>
  1318. <para>Meaning of the parameters is as follows:</para>
  1319. <itemizedlist>
  1320. <listitem>
  1321. <para><emphasis>txt</emphasis> - text for the body, can include
  1322. pseudo-variables.
  1323. </para>
  1324. </listitem>
  1325. <listitem>
  1326. <para><emphasis>content_type</emphasis> - value of Content-Type header,
  1327. can include pseudo-variables.
  1328. </para>
  1329. </listitem>
  1330. <listitem>
  1331. <para><emphasis>boundary</emphasis> - string to use as boundary,
  1332. can include pseudo-variables. Default: unique-boundary-1
  1333. </para>
  1334. </listitem>
  1335. </itemizedlist>
  1336. <para>
  1337. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
  1338. </para>
  1339. <para>
  1340. The core will take care of the last boundary ending "--". Detecting wich one is
  1341. the last and fixing the others if needed.
  1342. </para>
  1343. <example>
  1344. <title><function>set_body_multipart</function> usage</title>
  1345. <programlisting format="linespecific">
  1346. ...
  1347. set_body_multipart("test", "text/plain", "delimiter");
  1348. ...
  1349. Will produce:
  1350. ...
  1351. Content-Type: multipart/mixed;boundary="delimiter"
  1352. Mime-Version: 1.0
  1353. --delimiter
  1354. Content-Type: text/plain
  1355. text
  1356. --delimiter
  1357. ...
  1358. </programlisting>
  1359. </example>
  1360. </section>
  1361. <section id="textops.f.append_body_part">
  1362. <title>
  1363. <function moreinfo="none">append_body_part(txt,content_type[, content_disposition])</function>
  1364. </title>
  1365. <para>
  1366. Append a part on multipart body SIP message. Will use "unique-boundary-1" as boundary.
  1367. </para>
  1368. <para>Meaning of the parameters is as follows:</para>
  1369. <itemizedlist>
  1370. <listitem>
  1371. <para><emphasis>txt</emphasis> - text for the multipart body, can include
  1372. pseudo-variables.
  1373. </para>
  1374. </listitem>
  1375. <listitem>
  1376. <para><emphasis>content_type</emphasis> - value of Content-Type header,
  1377. can include pseudo-variables.
  1378. </para>
  1379. </listitem>
  1380. <listitem>
  1381. <para><emphasis>content_disposition</emphasis> - value of Content-Disposition header,
  1382. can include pseudo-variables.
  1383. </para>
  1384. </listitem>
  1385. </itemizedlist>
  1386. <para>
  1387. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
  1388. </para>
  1389. <para>
  1390. The core will take care of the last boundary ending "--". Detecting wich one is
  1391. the last and fixing the others if needed.
  1392. </para>
  1393. <example>
  1394. <title><function>append_body_part</function> usage</title>
  1395. <programlisting format="linespecific">
  1396. ...
  1397. $var(b) = "7e Od 04 55 75 69 20 4d 61 6b 65 43 61 6c 6c"
  1398. append_body_part("$var(b)", "application/vnd.cirpack.isdn-ext", "signal;handling=required");
  1399. ...
  1400. Will append this the body:
  1401. ...
  1402. Content-Type: application/vnd.cirpack.isdn-ext
  1403. Content-Disposition: signal;handling=required
  1404. 7e Od 04 55 75 69 20 4d 61 6b 65 43 61 6c 6c
  1405. --unique-boundary-1
  1406. ...
  1407. </programlisting>
  1408. </example>
  1409. </section>
  1410. <section id="textops.f.remove_body_part">
  1411. <title>
  1412. <function moreinfo="none">remove_body_part(content_type)</function>
  1413. </title>
  1414. <para>
  1415. Remove a part on a multipart body SIP message.
  1416. </para>
  1417. <para>Meaning of the parameters is as follows:</para>
  1418. <itemizedlist>
  1419. <listitem>
  1420. <para><emphasis>content_type</emphasis> - value of Content-Type header
  1421. of the part to be removed. If more than one exists the first
  1422. occurrence will be removed.
  1423. </para>
  1424. </listitem>
  1425. </itemizedlist>
  1426. <para>
  1427. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
  1428. </para>
  1429. <para>
  1430. The core will take care of the last boundary ending "--". Detecting wich one is
  1431. the last and fixing the others if needed.
  1432. </para>
  1433. <example>
  1434. <title><function>remove_body_part</function> usage</title>
  1435. <programlisting format="linespecific">
  1436. ...
  1437. remove_body_part("application/vnd.cirpack.isdn-ext");
  1438. ...
  1439. </programlisting>
  1440. </example>
  1441. </section>
  1442. </section>
  1443. <section>
  1444. <title>Known Limitations</title>
  1445. <para>
  1446. Search functions are applied to the original request,
  1447. i.e., they ignore all changes resulting from message
  1448. processing in &kamailio; script.
  1449. </para>
  1450. </section>
  1451. </chapter>