README 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. 1. Iptrtpproxy module
  2. Tomas Mandys
  3. Iptel.org
  4. Copyright © 2007 Tomas Mandys
  5. Revision History
  6. Revision $Revision$ $Date$
  7. __________________________________________________________________
  8. 1.1. Overview
  9. 1.2. Dependencies
  10. 1.3. Parameters
  11. 1.3.1. config (string)
  12. 1.3.2. switchboard (string)
  13. 1.4. Functions
  14. 1.4.1. iptrtpproxy_alloc(gate_a_to_b, switchboard_id)
  15. 1.4.2. iptrtpproxy_update(gate_a_to_b, session_ids)
  16. 1.4.3. iptrtpproxy_adjust_timeout(gate_a_to_b, session_ids)
  17. 1.4.4. iptrtpproxy_delete(session_ids)
  18. 1.4.5. iptrtpproxy_find(gate_a, gate_b)
  19. 1.4.6. @iptrtpproxy.session_ids
  20. 1.4.7. @iptrtpproxy.sdp_ip
  21. 1.4.8. @iptrtpproxy.switchboard
  22. 1.4.9. @iptrtpproxy.direction
  23. 1.1. Overview
  24. It provides similar functionality as nathelper but communicates with
  25. netfilter kernel xt_RTPPROXY module using libipt_RTPPROXY userspace
  26. library. See http://www.2p.cz/en/netfilter_rtp_proxy All RTP streams
  27. are manipulated directly in kernel space, no data are copied from
  28. kernel to userspace and back, it reduces load and delay.
  29. The ser module is written as light-weighted, there is not implemented
  30. any dialog managment as in nathelper, the reason is that such API
  31. should be provided by core or specialized dialog manager module.
  32. Because such module is not in CVS, session information may be stored in
  33. extra attributes of avp_db module and session id itself in record route
  34. as cookie, see rr module.
  35. It should be able to support all cases as re-invites when SIP client
  36. offers media change in SDP and when number of medias in offer/answer
  37. are different.
  38. Nathelper may be still used for testing if client is behind the NAT.
  39. Limitations:
  40. * only IPv4 addresses are supported.
  41. * more media streams per session supported
  42. 1.2. Dependencies
  43. The following libraries or applications must be installed before
  44. running SER with this module loaded:
  45. * netfilter xt_RTPROXY & libipt_RTPPROXY, see
  46. http://www.2p.cz/en/netfilter_rtp_proxy
  47. 1.3. Parameters
  48. 1.3.1. config (string)
  49. References iptrtpproxy.cfg, see iptrtpproxy_helper. Default value is
  50. /etc/iptrtpproxy.cfg.
  51. 1.3.2. switchboard (string)
  52. References xt_RTPPROXY switchboard for usage by ser module.
  53. The format is:
  54. name "=" value * ( ";" name "=" value )
  55. name = "name" | "*" | ( "ringing-timeout " ) | ( ( "learning-timeout-" | "alw
  56. ays-learn-") ("a" | "b") )
  57. The meaning of parameters is described in libipt_RTPROXY and
  58. iptrtpproxy documentation. ringing timeout is explicit timeout in sec
  59. regarding ringing. Ringing requires manual callee action, i.e. it may
  60. takes long time. Default value is 60 sec.
  61. The name" is identifier that will be used by script functions and
  62. references switchboard. It's mandatory parameter. More switchboards may
  63. be declared. The special name * set values for all switchboards.
  64. Example 1. Declare switchboard
  65. ...
  66. modparam("iptrtpproxy", "config", "/etc/iptrtpproxy.cfg");
  67. modparam("iptrtpproxy", "switchboard", "name=*;learning-timeout-a=10;lea
  68. rning-timeout-b=10;ringing-timeout=90");
  69. modparam("iptrtpproxy", "switchboard", "name=my;ringing-timeout=60");
  70. ...
  71. 1.4. Functions
  72. 1.4.1. iptrtpproxy_alloc(gate_a_to_b, switchboard_id)
  73. Parses SDP content and allocates for each RTP media stream one RTP
  74. proxy session. SDP is updates to reflect allocated sessions.
  75. * if gate_a_to_b bit 0 is set then SDP regards to gate-a to gate-b
  76. direction. If bit 1 is set then ringing timeout is used instead of
  77. learning timeout for particular gate timeout.
  78. * switchboard_id is reference to a switchboard with name declared as
  79. switchboard modparam. If empty then use switchboard found by
  80. iptrtpproxy_find (equal using @iptrtpproxy.switchboard).
  81. * function returns true is a session was created, identifier is
  82. available via select @iptrtpproxy.session_ids.
  83. Example 2. iptrtpproxy_alloc usage
  84. ...
  85. if (iptrtpproxy_alloc("1", "my")) {
  86. $sess_ids = @iptrtpproxy.session_ids;
  87. # save sess_ids in dialog
  88. }
  89. ...
  90. 1.4.2. iptrtpproxy_update(gate_a_to_b, session_ids)
  91. Parses SDP content and updates sessions provided by session_ids and
  92. updates SDP. If succesfull then session_ids may be changed (in case
  93. e.g. media stream has port zero particular session is released), the
  94. result of @iptrtpproxy.session_ids should be stored for future
  95. in-dialog usage.
  96. * if gate_a_to_b bit 0 is set then SDP regards to gate-a to gate-b
  97. direction. If bit 1 is set then ringing timeout is used instead of
  98. learning timeout for particular gate timeout.
  99. Example 3. iptrtpproxy_update usage
  100. ...
  101. # load $sess_ids from dialog
  102. if (iptrtpproxy_update("0", $sess_ids)) {
  103. $sess_ids = @iptrtpproxy.session_ids;
  104. # save sess_ids in dialog
  105. }
  106. ...
  107. 1.4.3. iptrtpproxy_adjust_timeout(gate_a_to_b, session_ids)
  108. Adjust timeout for particular gate. It's useful in "200 OK" decrease
  109. timeout to learning timeout if INVITE has set (long) ringing timeout.
  110. * if gate_a_to_b bit 0 is set then it regards to gate-a to gate-b
  111. direction. If bit 1 is set then ringing timeout is used instead of
  112. learning timeout for particular gate timeout.
  113. Example 4. iptrtpproxy_adjust_timeout usage
  114. ...
  115. # load $sess_ids from dialog
  116. if (iptrtpproxy_adjust_timeout("0", $sess_ids)) {
  117. }
  118. ...
  119. 1.4.4. iptrtpproxy_delete(session_ids)
  120. Delete sessions identified by session_ids. May be used when dialog is
  121. being destroyed (BYE) or when INVITE failed in failure route.
  122. Example 5. iptrtpproxy_delete usage
  123. ...
  124. # load $sess_ids from dialog
  125. iptrtpproxy_delete($sess_ids);
  126. ...
  127. 1.4.5. iptrtpproxy_find(gate_a, gate_b)
  128. Find corresponding switchboard and set @iptrtpproxy.switchboard and
  129. @iptrtpproxy.direction.
  130. * if gate_a/b switchboard identification
  131. * function returns true if switch was found
  132. Example 6. iptrtpproxy_find usage
  133. ...
  134. if (iptrtpproxy_find("@received.ip", "@next_hop.src_ip")) {
  135. if (iptrtpproxy_alloc("1", "")) {
  136. $sess_ids = @iptrtpproxy.session_ids;
  137. }
  138. }
  139. ...
  140. 1.4.6. @iptrtpproxy.session_ids
  141. Returns sessions allocated/updated in iptrtpproxy_alloc/update.
  142. The format is:
  143. switchboard_name [ ":" [ session_id *( "," session_id) ] ]
  144. session_id = *( [0-9] ) ; empty when no session allocated
  145. 1.4.7. @iptrtpproxy.sdp_ip
  146. Return first rewritten IP provided in SDP c= line.
  147. 1.4.8. @iptrtpproxy.switchboard
  148. Switchboard found by iptrtpproxy_find.
  149. 1.4.9. @iptrtpproxy.direction
  150. Direction determined by iptrtpproxy_find. 1..gate A->B, 0..gate B->A