Advertisement
Guest User

kamailio.cfg

a guest
Oct 14th, 2011
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.31 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 -u rtpproxy: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. route[RELAY] {
  121. if (check_route_param("nat=yes")) {
  122. setbflag(FLB_NATB);
  123. }
  124. if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) {
  125. route(RTPPROXY);
  126. }
  127.  
  128. if (!t_relay()) {
  129. sl_reply_error();
  130. }
  131. exit;
  132. }
  133.  
  134. # Caller NAT detection route
  135. route[NAT] {
  136. force_rport();
  137. if (nat_uac_test("19")) {
  138. if (method=="REGISTER") {
  139. fix_nated_register();
  140. } else {
  141. fix_nated_contact();
  142. }
  143. setflag(FLT_NATS);
  144. }
  145. return;
  146. }
  147.  
  148. # Handle requests within SIP dialogs
  149. route[WITHINDLG] {
  150. if (has_totag()) {
  151. # sequential request withing a dialog should
  152. # take the path determined by record-routing
  153. if (loose_route()) {
  154. if (is_method("BYE")) {
  155. setflag(FLT_ACC); # do accounting ...
  156. setflag(FLT_ACCFAILED); # ... even if the transaction fails
  157. }
  158. route(RELAY);
  159. } else {
  160. if (is_method("SUBSCRIBE") && uri == myself) {
  161. # in-dialog subscribe requests
  162. #route(PRESENCE);
  163. exit;
  164. }
  165. if ( is_method("ACK") ) {
  166. if ( t_check_trans() ) {
  167. # no loose-route, but stateful ACK;
  168. # must be an ACK after a 487
  169. # or e.g. 404 from upstream server
  170. t_relay();
  171. exit;
  172. } else {
  173. # ACK without matching transaction ... ignore and discard
  174. exit;
  175. }
  176. }
  177. sl_send_reply("404","Not here");
  178. }
  179. exit;
  180. }
  181. }
  182.  
  183. # RTPProxy control
  184. route[RTPPROXY] {
  185. if (is_method("BYE")) {
  186. unforce_rtp_proxy();
  187. } else if (is_method("INVITE")){
  188. force_rtp_proxy();
  189. }
  190. if (!has_totag()) add_rr_param(";nat=yes");
  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