functions.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
  4. <section id="cpl-c.functions" xmlns:xi="http://www.w3.org/2001/XInclude">
  5. <sectioninfo>
  6. </sectioninfo>
  7. <title>Functions</title>
  8. <section id="cpl_run_script">
  9. <title>
  10. <function>cpl_run_script(type,mode)</function>
  11. </title>
  12. <para>
  13. Starts the execution of the CPL script. The user name is fetched
  14. from new_uri or requested uri or from To header -in this order-
  15. (for incoming execution) or from FROM header (for outgoing
  16. execution). Regarding the stateful/stateless message processing,
  17. the function is very flexible, being able to run in different modes
  18. (see below the"mode" parameter). Normally this function will end
  19. script execution. There is no guaranty that the CPL script
  20. interpretation ended when ser script ended also (for the same
  21. INVITE ;-)) - this can happen when the CPL script does a PROXY and
  22. the script interpretation pause after proxying and it will be
  23. resume when some reply is received (this can happen in a different
  24. process of SER). If the function returns to script, the SIP server
  25. should continue with the normal behavior as if no script existed.
  26. When some error is returned, the function itself haven't sent any
  27. SIP error reply (this can be done from script).
  28. </para>
  29. <para>Meaning of the parameters is as follows:</para>
  30. <itemizedlist>
  31. <listitem>
  32. <para>
  33. <emphasis>type</emphasis> - which part of the script should
  34. be run; set it to "incoming" for having the incoming part
  35. of script executed (when an INVITE is received) or to
  36. "outgoing" for running the outgoing part of script (when a
  37. user is generating an INVITE - call).
  38. </para>
  39. </listitem>
  40. <listitem>
  41. <para>
  42. <emphasis>mode</emphasis> - sets the interpreter mode as
  43. stateless/stateful behavior. The following modes are
  44. accepted:
  45. </para>
  46. <itemizedlist>
  47. <listitem>
  48. <para>
  49. <emphasis>IS_STATELESS</emphasis> - the current
  50. INVITE has no transaction created yet. All
  51. replies (redirection or deny) will be done
  52. is a stateless way. The execution will
  53. switch to stateful only when proxy is
  54. done. So, if the function returns, will be
  55. in stateless mode.
  56. </para>
  57. </listitem>
  58. <listitem>
  59. <para>
  60. <emphasis>IS_STATEFUL</emphasis> - the current
  61. INVITE has already a transaction
  62. associated. All signaling operations
  63. (replies or proxy) will be done in stateful
  64. way.So, if the function returns, will be in
  65. stateful mode.
  66. </para>
  67. </listitem>
  68. <listitem>
  69. <para>
  70. <emphasis>FORCE_STATEFUL</emphasis> - the current
  71. INVITE has no transaction created yet. All
  72. signaling operations will be done is a
  73. stateful way (on signaling, the transaction
  74. will be created from within the
  75. interpreter). So, if the function returns,
  76. will be in stateless mode.
  77. </para>
  78. </listitem>
  79. </itemizedlist>
  80. <note>
  81. <para>
  82. is_stateful is very difficult to manage from the
  83. routing script (script processing can continue in
  84. stateful mode); is_stateless is the fastest and
  85. consumes less resources (transaction is created only if
  86. proxying is done), but there is only a minimal
  87. protection against retransmissions (since replies are
  88. send statelessly); force_stateful is a good compromise
  89. - all signaling is done stateful (retransmission
  90. protection) and in the same time, if returning to
  91. script, it will be in stateless mode (easy to continue
  92. the routing script execution)
  93. </para>
  94. </note>
  95. </listitem>
  96. </itemizedlist>
  97. <example>
  98. <title><function>cpl_run_script</function> usage</title>
  99. <programlisting>
  100. ...
  101. cpl_run_script("incoming","force_stateful");
  102. ...
  103. </programlisting>
  104. </example>
  105. </section>
  106. <section id="cpl_process_register">
  107. <title>
  108. <function moreinfo="none">cpl_process_register()</function>
  109. </title>
  110. <para>
  111. This function MUST be called only for REGISTER requests. It checks
  112. if the current REGISTER request is related or not with CPL script
  113. upload/download/ remove. If it is, all the needed operation will be
  114. done. For checking if the REGISTER is CPL related, the function
  115. looks fist to "Content-Type" header. If it exists and has a the
  116. mime type set to "application/cpl+xml" means this is a CPL script
  117. upload/remove operation. The distinction between to case is made by
  118. looking at "Content-Disposition" header; id its value is
  119. "script;action=store", means it's an upload; if it's
  120. "script;action=remove", means it's a remove operation; other values
  121. are considered to be errors. If no "Content-Type" header is
  122. present, the function looks to "Accept" header and if it contains
  123. the "*" or "application/cpl-xml" the request it will be consider
  124. one for downloading CPL scripts. The functions returns to script
  125. only if the REGISTER is not related to CPL. In other case, the
  126. function will send by itself the necessary replies (stateless -
  127. using sl), including for errors.
  128. </para>
  129. </section>
  130. </section>