Advertisement
Guest User

kamailio.cfg

a guest
Oct 8th, 2011
1,252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 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. # rtpproxy -l _your_public_ip_ -s udp:localhost:7722
  68. modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")
  69.  
  70. # ----- nathelper params -----
  71. modparam("nathelper", "natping_interval", 30)
  72. modparam("nathelper", "ping_nated_only", 1)
  73. modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
  74. modparam("nathelper", "sipping_from", "sip:pinger@kamailio.org")
  75.  
  76. # params needed for NAT traversal in other modules
  77. modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
  78. modparam("usrloc", "nat_bflag", FLB_NATB)
  79.  
  80. # ----- dispatcher params -----
  81. modparam("dispatcher", "list_file", "/usr/local/etc/kamailio/dispatcher.list")
  82. modparam("dispatcher", "flags", 2)
  83. modparam("dispatcher", "dst_avp", "$avp(AVP_DST)")
  84. modparam("dispatcher", "grp_avp", "$avp(AVP_GRP)")
  85. modparam("dispatcher", "cnt_avp", "$avp(AVP_CNT)")
  86.  
  87. ####### Routing Logic ########
  88.  
  89. # Main SIP request routing logic
  90. route {
  91. if ( !mf_process_maxfwd_header("10") )
  92. {
  93. sl_send_reply("483","To Many Hops");
  94. exit;
  95. }
  96.  
  97. # NAT detection
  98. route(NAT);
  99.  
  100. # handle requests within SIP dialogs
  101. route(WITHINDLG);
  102.  
  103. # select from first dst group by round-robin
  104. if(!ds_select_dst("1", "4"))
  105. {
  106. sl_send_reply("500", "No destination available");
  107. exit;
  108. }
  109.  
  110. t_on_failure("RTF_DISPATCH");
  111.  
  112.  
  113. if(!t_relay())
  114. {
  115. sl_reply_error();
  116. exit;
  117. }
  118. }
  119.  
  120. # Handle requests within SIP dialogs
  121. route[WITHINDLG] {
  122. if (has_totag()) {
  123. # sequential request withing a dialog should
  124. # take the path determined by record-routing
  125. if (loose_route()) {
  126. if (is_method("BYE")) {
  127. setflag(FLT_ACC); # do accounting ...
  128. setflag(FLT_ACCFAILED); # ... even if the transaction fails
  129. }
  130. route(RELAY);
  131. } else {
  132. if (is_method("SUBSCRIBE") && uri == myself) {
  133. # in-dialog subscribe requests
  134. #route(PRESENCE);
  135. exit;
  136. }
  137. if ( is_method("ACK") ) {
  138. if ( t_check_trans() ) {
  139. # no loose-route, but stateful ACK;
  140. # must be an ACK after a 487
  141. # or e.g. 404 from upstream server
  142. t_relay();
  143. exit;
  144. } else {
  145. # ACK without matching transaction ... ignore and discard
  146. exit;
  147. }
  148. }
  149. sl_send_reply("404","Not here");
  150. }
  151. exit;
  152. }
  153. }
  154.  
  155. route[RELAY] {
  156. if (check_route_param("nat=yes")) {
  157. setbflag(FLB_NATB);
  158. }
  159. if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) {
  160. route(RTPPROXY);
  161. }
  162.  
  163. if (!t_relay()) {
  164. sl_reply_error();
  165. }
  166. exit;
  167. }
  168.  
  169. # RTPProxy control
  170. route[RTPPROXY] {
  171. if (is_method("BYE")) {
  172. unforce_rtp_proxy();
  173. } else if (is_method("INVITE")){
  174. force_rtp_proxy();
  175. }
  176. if (!has_totag()) add_rr_param(";nat=yes");
  177. return;
  178. }
  179.  
  180. # Caller NAT detection route
  181. route[NAT] {
  182. force_rport();
  183. if (nat_uac_test("19")) {
  184. if (method=="REGISTER") {
  185. fix_nated_register();
  186. } else {
  187. fix_nated_contact();
  188. }
  189. setflag(FLT_NATS);
  190. }
  191. return;
  192. }
  193.  
  194. # dispatcher failure routing block
  195. failure_route[RTF_DISPATCH] {
  196. if (t_is_canceled()) {
  197. exit;
  198. }
  199. # select next destination only for local timeout
  200. if (t_branch_timeout() && !t_branch_replied())
  201. {
  202. if(ds_next_dst())
  203. {
  204. t_on_failure("RTF_DISPATCH");
  205. t_relay();
  206. exit;
  207. }
  208. }
  209. }
  210.  
  211.  
  212.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement