functions.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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="print.functions" xmlns:xi="http://www.w3.org/2001/XInclude">
  5. <sectioninfo>
  6. </sectioninfo>
  7. <title>Functions</title>
  8. <section id="tcpops.f.tcp_keepalive_enable">
  9. <title>
  10. <function>tcp_keepalive_enable([conid], idle, count, interval)</function>
  11. </title>
  12. <para>
  13. Enables keepalive on a TCP connection.
  14. </para>
  15. <para>Meaning of the parameters is as follows:</para>
  16. <itemizedlist>
  17. <listitem>
  18. <para><emphasis>conid</emphasis> (optionnal): the kamailio internal
  19. connection id on which TCP keepalive will be enabled. If no parameter
  20. is given, the keepalive mechanism will be enabled on the current message
  21. source connection.
  22. </para>
  23. </listitem>
  24. <listitem>
  25. <para><emphasis>idle</emphasis> (seconds): the time before the first
  26. keepalive packet is sent out.
  27. </para>
  28. </listitem>
  29. <listitem>
  30. <para><emphasis>count</emphasis>: number of non-acked keepalive before
  31. reseting the connection.
  32. </para>
  33. </listitem>
  34. <listitem>
  35. <para><emphasis>interval</emphasis> (seconds): time between two keepalive
  36. probes.
  37. </para>
  38. </listitem>
  39. </itemizedlist>
  40. <para>Retuns 1 on success, -1 on failure.</para>
  41. <example>
  42. <title><function>tcp_keepalive_enable</function> usage</title>
  43. <programlisting><![CDATA[
  44. request_route {
  45. if (is_method("INVITE")) {
  46. $avp(caller_conid) = $conid;
  47. t_on_reply("foo");
  48. }
  49. ...
  50. }
  51. onreply_route[foo] {
  52. if (is_method("INVITE") && status == 200) {
  53. # enable on callee's connection
  54. tcp_keepalive_enable("60", "5", "5");
  55. # enable on caller's connection
  56. tcp_keepalive_enable("$avp(caller_conid)", "60", "5", "2");
  57. }
  58. ...
  59. }
  60. ]]></programlisting>
  61. </example>
  62. </section>
  63. <section id="tcpops.f.tcp_keepalive_disable">
  64. <title>
  65. <function>tcp_keepalive_disable([conid])</function>
  66. </title>
  67. <para>
  68. Disables keepalive on a TCP connection.
  69. </para>
  70. <para>Meaning of the parameters is as follows:</para>
  71. <itemizedlist>
  72. <listitem>
  73. <para><emphasis>conid</emphasis> (optionnal): the kamailio internal
  74. connection id on which TCP keepalive will be disabled. If no parameter
  75. is given, the keepalive mechanism will be disabled on the current message
  76. source connection.
  77. </para>
  78. </listitem>
  79. </itemizedlist>
  80. <para>Retuns 1 on success, -1 on failure.</para>
  81. <example>
  82. <title><function>tcp_keepalive_disable</function> usage</title>
  83. <programlisting><![CDATA[
  84. request_route {
  85. ...
  86. if (is_method("BYE")) {
  87. $avp(bye_conid) = $conid;
  88. t_on_reply("foo");
  89. }
  90. ...
  91. }
  92. onreply_route[foo] {
  93. ...
  94. if (is_method("BYE") && status == 200) {
  95. tcp_keepalive_disable();
  96. tcp_keepalive_disable("$avp(bye_conid)");
  97. }
  98. ...
  99. }
  100. ]]></programlisting>
  101. </example>
  102. </section>
  103. <section id="tcpops.f.tcp_set_connection_lifetime">
  104. <title>
  105. <function>tcp_set_connection_lifetime([conid], lifetime)</function>
  106. </title>
  107. <para>
  108. Sets the connection lifetime of a connection (TCP).
  109. </para>
  110. <para>Meaning of the parameters is as follows:</para>
  111. <itemizedlist>
  112. <listitem>
  113. <para><emphasis>conid</emphasis> (optionnal): the kamailio internal
  114. connection id on which to set the new lifetime. If no parameter
  115. is given, it will be set on the current message source connection.
  116. </para>
  117. </listitem>
  118. <listitem>
  119. <para><emphasis>lifetime</emphasis> (seconds): the new connection lifetime.
  120. </para>
  121. </listitem>
  122. </itemizedlist>
  123. <para>Retuns 1 on success, -1 on failure.</para>
  124. <example>
  125. <title><function>tcp_set_connection_lifetime</function> usage</title>
  126. <programlisting><![CDATA[
  127. ...
  128. # use 10s as default lifetime
  129. tcp_connection_lifetime=10
  130. ...
  131. request_route {
  132. ...
  133. if (is_method("REGISTER") && pv_www_authenticate("$td", "xxx", "0")) {
  134. # raise the TCP lifetime to a bigger value
  135. tcp_set_connection_lifetime("3605");
  136. }
  137. ...
  138. }
  139. ]]></programlisting>
  140. </example>
  141. </section>
  142. </section>