Advertisement
Guest User

Untitled

a guest
Oct 6th, 2011
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.49 KB | None | 0 0
  1. ####### Global Parameters #########
  2.  
  3. debug=2
  4. log_stderror=no
  5.  
  6. memdbg=5
  7. memlog=5
  8.  
  9. log_facility=LOG_LOCAL0
  10.  
  11. fork=yes
  12. children=4
  13.  
  14. port=5060
  15.  
  16. # - flags
  17. # FLT_ - per transaction (message) flags
  18. # FLB_ - per branch flags
  19. #!define FLT_ACC 1
  20. #!define FLT_ACCMISSED 2
  21. #!define FLT_ACCFAILED 3
  22. #!define FLT_NATS 5
  23.  
  24. #!define FLB_NATB 6
  25. #!define FLB_NATSIPPING 7
  26.  
  27. ####### Modules Section ########
  28.  
  29. # set paths to location of modules
  30. mpath="/usr/local/lib64/kamailio/modules_k/:/usr/local/lib64/kamailio/modules/"
  31.  
  32. loadmodule "mi_fifo.so"
  33. loadmodule "kex.so"
  34. loadmodule "tm.so"
  35. loadmodule "tmx.so"
  36. loadmodule "sl.so"
  37. loadmodule "rr.so"
  38. loadmodule "pv.so"
  39. loadmodule "maxfwd.so"
  40. loadmodule "usrloc.so"
  41. loadmodule "registrar.so"
  42. loadmodule "textops.so"
  43. loadmodule "siputils.so"
  44. loadmodule "xlog.so"
  45. loadmodule "sanity.so"
  46. loadmodule "ctl.so"
  47. loadmodule "mi_rpc.so"
  48. loadmodule "acc.so"
  49. loadmodule "nathelper.so"
  50. loadmodule "rtpproxy.so"
  51. loadmodule "dispatcher.so"
  52.  
  53. # ----------------- setting module-specific parameters ---------------
  54.  
  55. # ----- mi_fifo params -----
  56. modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
  57.  
  58. # ----- tm params -----
  59. # auto-discard branches from previous serial forking leg
  60. modparam("tm", "failure_reply_mode", 3)
  61. # default retransmission timeout: 30sec
  62. modparam("tm", "fr_timer", 30000)
  63. # default invite retransmission timeout after 1xx: 120sec
  64. modparam("tm", "fr_inv_timer", 120000)
  65.  
  66. # ----- rtpproxy params -----
  67. modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")
  68.  
  69. # ----- nathelper params -----
  70. modparam("nathelper", "natping_interval", 30)
  71. modparam("nathelper", "ping_nated_only", 1)
  72. modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
  73. modparam("nathelper", "sipping_from", "sip:pinger@kamailio.org")
  74.  
  75. # params needed for NAT traversal in other modules
  76. modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
  77. modparam("usrloc", "nat_bflag", FLB_NATB)
  78.  
  79. # ----- dispatcher params -----
  80. modparam("dispatcher", "list_file", "/usr/local/etc/kamailio/dispatcher.list")
  81. modparam("dispatcher", "flags", 2)
  82. modparam("dispatcher", "dst_avp", "$avp(AVP_DST)")
  83. modparam("dispatcher", "grp_avp", "$avp(AVP_GRP)")
  84. modparam("dispatcher", "cnt_avp", "$avp(AVP_CNT)")
  85.  
  86. ####### Routing Logic ########
  87.  
  88. # Main SIP request routing logic
  89. route {
  90. if ( !mf_process_maxfwd_header("10") )
  91. {
  92. sl_send_reply("483","To Many Hops");
  93. exit;
  94. }
  95.  
  96. # handle requests within SIP dialogs
  97. route(WITHINDLG);
  98.  
  99. # select from first dst group by round-robin
  100. if(!ds_select_dst("1", "4"))
  101. {
  102. sl_send_reply("500", "No destination available");
  103. exit;
  104. }
  105.  
  106. t_on_failure("RTF_DISPATCH");
  107.  
  108.  
  109. if(!t_relay())
  110. {
  111. sl_reply_error();
  112. exit;
  113. }
  114. }
  115.  
  116. route[RELAY] {
  117. if (check_route_param("nat=yes")) {
  118. setbflag(FLB_NATB);
  119. }
  120. if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) {
  121. route(RTPPROXY);
  122. }
  123.  
  124. if (!t_relay()) {
  125. sl_reply_error();
  126. }
  127. exit;
  128. }
  129.  
  130. # Handle requests within SIP dialogs
  131. route[WITHINDLG] {
  132. if (has_totag()) {
  133. # sequential request withing a dialog should
  134. # take the path determined by record-routing
  135. if (loose_route()) {
  136. if (is_method("BYE")) {
  137. setflag(FLT_ACC); # do accounting ...
  138. setflag(FLT_ACCFAILED); # ... even if the transaction fails
  139. }
  140. route(RELAY);
  141. } else {
  142. if (is_method("SUBSCRIBE") && uri == myself) {
  143. # in-dialog subscribe requests
  144. #route(PRESENCE);
  145. exit;
  146. }
  147. if ( is_method("ACK") ) {
  148. if ( t_check_trans() ) {
  149. # no loose-route, but stateful ACK;
  150. # must be an ACK after a 487
  151. # or e.g. 404 from upstream server
  152. t_relay();
  153. exit;
  154. } else {
  155. # ACK without matching transaction ... ignore and discard
  156. exit;
  157. }
  158. }
  159. sl_send_reply("404","Not here");
  160. }
  161. exit;
  162. }
  163. }
  164.  
  165. # Caller NAT detection route
  166. route[NAT] {
  167. force_rport();
  168. if (nat_uac_test("19")) {
  169. if (method=="REGISTER") {
  170. fix_nated_register();
  171. } else {
  172. fix_nated_contact();
  173. }
  174. setflag(FLT_NATS);
  175. }
  176. return;
  177. }
  178.  
  179. # RTPProxy control
  180. route[RTPPROXY] {
  181. if (is_method("BYE")) {
  182. unforce_rtp_proxy();
  183. } else if (is_method("INVITE")){
  184. force_rtp_proxy();
  185. }
  186. if (!has_totag()) add_rr_param(";nat=yes");
  187. return;
  188. }
  189.  
  190. # dispatcher failure routing block
  191. failure_route[RTF_DISPATCH] {
  192. if (t_is_canceled()) {
  193. exit;
  194. }
  195. # select next destination only for local timeout
  196. if (t_branch_timeout() && !t_branch_replied())
  197. {
  198. if(ds_next_dst())
  199. {
  200. t_on_failure("RTF_DISPATCH");
  201. t_relay();
  202. exit;
  203. }
  204. }
  205. }
  206.  
  207.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement