iptrtpproxy.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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="iptrtpproxy" xmlns:xi="http://www.w3.org/2001/XInclude">
  5. <sectioninfo>
  6. <authorgroup>
  7. <author>
  8. <firstname>Tomas</firstname>
  9. <surname>Mandys</surname>
  10. <affiliation><orgname>Iptel.org</orgname></affiliation>
  11. <address>
  12. <email>tomas dot mandys at iptel dot org</email>
  13. </address>
  14. </author>
  15. </authorgroup>
  16. <copyright>
  17. <year>2007</year>
  18. <holder>Tomas Mandys</holder>
  19. </copyright>
  20. <revhistory>
  21. <revision>
  22. <revnumber>$Revision$</revnumber>
  23. <date>$Date$</date>
  24. </revision>
  25. </revhistory>
  26. </sectioninfo>
  27. <title>Iptrtpproxy module</title>
  28. <section id="iptrtpproxy.overview">
  29. <title>Overview</title>
  30. <para>
  31. It provides similar functionality as <emphasis>nathelper</emphasis> but
  32. communicates with <emphasis>netfilter</emphasis> kernel <emphasis>xt_RTPPROXY</emphasis> module using
  33. <emphasis>libipt_RTPPROXY</emphasis> userspace library.
  34. See <ulink url="http://www.2p.cz/en/netfilter_rtp_proxy">http://www.2p.cz/en/netfilter_rtp_proxy</ulink>
  35. All RTP streams are
  36. manipulated directly in kernel space, no data are copied from
  37. kernel to userspace and back, it reduces load and delay.
  38. </para>
  39. <para>
  40. The ser module is written as light-weighted, there is not implemented
  41. any dialog managment as in <emphasis>nathelper</emphasis>, the reason is that such API
  42. should be provided by core or specialized dialog manager module.
  43. Because such module is not in CVS, session information may be stored
  44. in extra attributes of <emphasis>avp_db</emphasis> module and
  45. session id itself in record route as cookie, see <emphasis>rr</emphasis> module.
  46. </para>
  47. <para>
  48. It should be able to support all cases as re-invites when SIP client offers media change in SDP and
  49. when number of medias in offer/answer are different.
  50. </para>
  51. <para>
  52. <emphasis>Nathelper</emphasis> may be still used for testing if client is behind the NAT.
  53. </para>
  54. <para>
  55. Limitations:
  56. <itemizedlist>
  57. <listitem>
  58. <para>
  59. only IPv4 addresses are supported.
  60. </para>
  61. </listitem>
  62. <listitem>
  63. <para>
  64. more media streams per session supported
  65. </para>
  66. </listitem>
  67. </itemizedlist>
  68. </para>
  69. </section>
  70. <section id="iptrtpproxy.dep">
  71. <title>Dependencies</title>
  72. <para>
  73. The following libraries or applications must be installed before
  74. running SER with this module loaded:
  75. <itemizedlist>
  76. <listitem>
  77. <para>
  78. netfilter xt_RTPROXY &amp; libipt_RTPPROXY,
  79. see <ulink url="http://www.2p.cz/en/netfilter_rtp_proxy">http://www.2p.cz/en/netfilter_rtp_proxy</ulink>
  80. </para>
  81. </listitem>
  82. </itemizedlist>
  83. </para>
  84. </section>
  85. <section id="iptrtpproxy.parameters">
  86. <title>Parameters</title>
  87. <section id="config">
  88. <title><varname>config</varname> (string)</title>
  89. <para>
  90. References <emphasis>iptrtpproxy.cfg</emphasis>, see <emphasis>iptrtpproxy_helper</emphasis>. Default value
  91. is <emphasis>/etc/iptrtpproxy.cfg</emphasis>.
  92. </para>
  93. </section>
  94. <section id="switchboard">
  95. <title><varname>switchboard</varname> (string)</title>
  96. <para>
  97. References <emphasis>xt_RTPPROXY</emphasis> switchboard for usage by ser module.
  98. </para>
  99. <para>
  100. The format is:
  101. </para>
  102. <programlisting>
  103. name "=" value * ( ";" name "=" value )
  104. name = "name" | "*" | ( "ringing-timeout " ) | ( ( "learning-timeout-" | "always-learn-") ("a" | "b") )
  105. </programlisting>
  106. <para>
  107. The meaning of parameters is described in <emphasis>libipt_RTPROXY</emphasis> and <emphasis>iptrtpproxy</emphasis> documentation.
  108. <emphasis>ringing timeout</emphasis> is explicit timeout in sec regarding ringing. Ringing requires manual callee action, i.e.
  109. it may takes long time. Default value is 60 sec.
  110. </para>
  111. <para>
  112. The <emphasis>name</emphasis>" is identifier that will be used by script functions and references switchboard.
  113. It's mandatory parameter. More switchboards may be declared. The special name <emphasis>*</emphasis> set values
  114. for all switchboards.
  115. </para>
  116. <example>
  117. <title>Declare <varname>switchboard</varname></title>
  118. <programlisting>
  119. ...
  120. modparam("iptrtpproxy", "config", "/etc/iptrtpproxy.cfg");
  121. modparam("iptrtpproxy", "switchboard", "name=*;learning-timeout-a=10;learning-timeout-b=10;ringing-timeout=90");
  122. modparam("iptrtpproxy", "switchboard", "name=my;ringing-timeout=60");
  123. ...
  124. </programlisting>
  125. </example>
  126. </section>
  127. </section>
  128. <section id="iptrtpproxy.functions">
  129. <title>Functions</title>
  130. <section id="iptrtpproxy_alloc">
  131. <title>
  132. <function>iptrtpproxy_alloc(gate_a_to_b, switchboard_id)</function>
  133. </title>
  134. <para>
  135. Parses SDP content and allocates for each RTP media stream one RTP proxy session.
  136. SDP is updates to reflect allocated sessions.
  137. </para>
  138. <itemizedlist>
  139. <listitem>
  140. <para>
  141. if <emphasis>gate_a_to_b</emphasis> bit 0 is set
  142. then SDP regards to gate-a to gate-b direction.
  143. If bit 1 is set then <emphasis>ringing timeout</emphasis>
  144. is used instead of <emphasis>learning timeout</emphasis> for
  145. particular gate timeout.
  146. </para>
  147. </listitem>
  148. <listitem>
  149. <para>
  150. <emphasis>switchboard_id</emphasis> is reference to a switchboard with name declared as
  151. <varname>switchboard</varname> modparam. If empty then use switchboard found by
  152. <function>iptrtpproxy_find</function> (equal using <function>@iptrtpproxy.switchboard</function>).
  153. </para>
  154. </listitem>
  155. <listitem>
  156. <para>
  157. function returns true is a session was created, identifier is available
  158. via select <function>@iptrtpproxy.session_ids</function>.
  159. </para>
  160. </listitem>
  161. </itemizedlist>
  162. <example>
  163. <title><function>iptrtpproxy_alloc</function> usage</title>
  164. <programlisting>
  165. ...
  166. if (iptrtpproxy_alloc("1", "my")) {
  167. $sess_ids = @iptrtpproxy.session_ids;
  168. # save sess_ids in dialog
  169. }
  170. ...
  171. </programlisting>
  172. </example>
  173. </section>
  174. <section id="iptrtpproxy_update">
  175. <title>
  176. <function>iptrtpproxy_update(gate_a_to_b, session_ids)</function>
  177. </title>
  178. <para>
  179. Parses SDP content and updates sessions provided by <emphasis>session_ids</emphasis> and
  180. updates SDP. If succesfull then session_ids may be changed (in case e.g. media
  181. stream has port zero particular session is released), the
  182. result of <function>@iptrtpproxy.session_ids</function> should be stored for future in-dialog usage.
  183. </para>
  184. <itemizedlist>
  185. <listitem>
  186. <para>
  187. if <emphasis>gate_a_to_b</emphasis> bit 0 is set
  188. then SDP regards to gate-a to gate-b direction.
  189. If bit 1 is set then <emphasis>ringing timeout</emphasis>
  190. is used instead of <emphasis>learning timeout</emphasis> for
  191. particular gate timeout.
  192. </para>
  193. </listitem>
  194. </itemizedlist>
  195. <example>
  196. <title><function>iptrtpproxy_update</function> usage</title>
  197. <programlisting>
  198. ...
  199. # load $sess_ids from dialog
  200. if (iptrtpproxy_update("0", $sess_ids)) {
  201. $sess_ids = @iptrtpproxy.session_ids;
  202. # save sess_ids in dialog
  203. }
  204. ...
  205. </programlisting>
  206. </example>
  207. </section>
  208. <section id="iptrtpproxy_adjust_timeout">
  209. <title>
  210. <function>iptrtpproxy_adjust_timeout(gate_a_to_b, session_ids)</function>
  211. </title>
  212. <para>
  213. Adjust timeout for particular gate. It's useful in "200 OK"
  214. decrease timeout to learning timeout if INVITE has set (long) <emphasis>ringing timeout</emphasis>.
  215. </para>
  216. <itemizedlist>
  217. <listitem>
  218. <para>
  219. if <emphasis>gate_a_to_b</emphasis> bit 0 is set
  220. then it regards to gate-a to gate-b direction.
  221. If bit 1 is set then <emphasis>ringing timeout</emphasis>
  222. is used instead of <emphasis>learning timeout</emphasis> for
  223. particular gate timeout.
  224. </para>
  225. </listitem>
  226. </itemizedlist>
  227. <example>
  228. <title><function>iptrtpproxy_adjust_timeout</function> usage</title>
  229. <programlisting>
  230. ...
  231. # load $sess_ids from dialog
  232. if (iptrtpproxy_adjust_timeout("0", $sess_ids)) {
  233. }
  234. ...
  235. </programlisting>
  236. </example>
  237. </section>
  238. <section id="iptrtpproxy_delete">
  239. <title>
  240. <function>iptrtpproxy_delete(session_ids)</function>
  241. </title>
  242. <para>
  243. Delete sessions identified by <emphasis>session_ids</emphasis>. May be used when dialog is being
  244. destroyed (BYE) or when INVITE failed in failure route.
  245. </para>
  246. <example>
  247. <title><function>iptrtpproxy_delete</function> usage</title>
  248. <programlisting>
  249. ...
  250. # load $sess_ids from dialog
  251. iptrtpproxy_delete($sess_ids);
  252. ...
  253. </programlisting>
  254. </example>
  255. </section>
  256. <section id="iptrtpproxy_find">
  257. <title>
  258. <function>iptrtpproxy_find(gate_a, gate_b)</function>
  259. </title>
  260. <para>
  261. Find corresponding switchboard and set <function>@iptrtpproxy.switchboard</function>
  262. and <function>@iptrtpproxy.direction</function>.
  263. </para>
  264. <itemizedlist>
  265. <listitem>
  266. <para>
  267. if <emphasis>gate_a/b</emphasis> switchboard identification
  268. </para>
  269. </listitem>
  270. <listitem>
  271. <para>
  272. function returns true if switch was found
  273. </para>
  274. </listitem>
  275. </itemizedlist>
  276. <example>
  277. <title><function>iptrtpproxy_find</function> usage</title>
  278. <programlisting>
  279. ...
  280. if (iptrtpproxy_find("@received.ip", "@next_hop.src_ip")) {
  281. if (iptrtpproxy_alloc("1", "")) {
  282. $sess_ids = @iptrtpproxy.session_ids;
  283. }
  284. }
  285. ...
  286. </programlisting>
  287. </example>
  288. </section>
  289. <section id="iptrtpproxy.session_ids">
  290. <title>
  291. <function>@iptrtpproxy.session_ids</function>
  292. </title>
  293. <para>
  294. Returns sessions allocated/updated in <function>iptrtpproxy_alloc/update</function>.
  295. </para>
  296. <para>
  297. The format is:
  298. </para>
  299. <programlisting>
  300. switchboard_name [ ":" [ session_id *( "," session_id) ] ]
  301. session_id = *( [0-9] ) ; empty when no session allocated
  302. </programlisting>
  303. </section>
  304. <section id="iptrtpproxy.sdp_ip">
  305. <title>
  306. <function>@iptrtpproxy.sdp_ip</function>
  307. </title>
  308. <para>
  309. Return first rewritten IP provided in SDP <emphasis>c=</emphasis> line.
  310. </para>
  311. </section>
  312. <section id="iptrtpproxy.switchboard">
  313. <title>
  314. <function>@iptrtpproxy.switchboard</function>
  315. </title>
  316. <para>
  317. Switchboard found by <function>iptrtpproxy_find</function>.
  318. </para>
  319. </section>
  320. <section id="iptrtpproxy.direction">
  321. <title>
  322. <function>@iptrtpproxy.direction</function>
  323. </title>
  324. <para>
  325. Direction determined by <function>iptrtpproxy_find</function>. 1..gate A->B, 0..gate B->A
  326. </para>
  327. </section>
  328. </section>
  329. </section>