Advertisement
Guest User

kamailio.cfg

a guest
Oct 6th, 2011
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 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. # select from first dst group by round-robin
  97. if(!ds_select_dst("1", "4"))
  98. {
  99. sl_send_reply("500", "No destination available");
  100. exit;
  101. }
  102.  
  103. t_on_failure("RTF_DISPATCH");
  104.  
  105. # handle requests within SIP dialogs
  106. route(WITHINDLG);
  107.  
  108. # if(!t_relay())
  109. # {
  110. # sl_reply_error();
  111. # exit;
  112. # }
  113. }
  114.  
  115. route[RELAY] {
  116. if (check_route_param("nat=yes")) {
  117. setbflag(FLB_NATB);
  118. }
  119. if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) {
  120. route(RTPPROXY);
  121. }
  122.  
  123. /* example how to enable some additional event routes */
  124. if (is_method("INVITE")) {
  125. #t_on_branch("BRANCH_ONE");
  126. t_on_reply("REPLY_ONE");
  127. t_on_failure("FAIL_ONE");
  128. }
  129.  
  130. if (!t_relay()) {
  131. sl_reply_error();
  132. }
  133. exit;
  134. }
  135.  
  136. # Handle requests within SIP dialogs
  137. route[WITHINDLG] {
  138. if (has_totag()) {
  139. # sequential request withing a dialog should
  140. # take the path determined by record-routing
  141. if (loose_route()) {
  142. if (is_method("BYE")) {
  143. setflag(FLT_ACC); # do accounting ...
  144. setflag(FLT_ACCFAILED); # ... even if the transaction fails
  145. }
  146. route(RELAY);
  147. } else {
  148. if (is_method("SUBSCRIBE") && uri == myself) {
  149. # in-dialog subscribe requests
  150. #route(PRESENCE);
  151. exit;
  152. }
  153. if ( is_method("ACK") ) {
  154. if ( t_check_trans() ) {
  155. # no loose-route, but stateful ACK;
  156. # must be an ACK after a 487
  157. # or e.g. 404 from upstream server
  158. t_relay();
  159. exit;
  160. } else {
  161. # ACK without matching transaction ... ignore and discard
  162. exit;
  163. }
  164. }
  165. sl_send_reply("404","Not here");
  166. }
  167. exit;
  168. }
  169. }
  170.  
  171. # Caller NAT detection route
  172. route[NAT] {
  173. force_rport();
  174. if (nat_uac_test("19")) {
  175. if (method=="REGISTER") {
  176. fix_nated_register();
  177. } else {
  178. fix_nated_contact();
  179. }
  180. setflag(FLT_NATS);
  181. }
  182. return;
  183. }
  184.  
  185. # RTPProxy control
  186. route[RTPPROXY] {
  187. if (is_method("BYE")) {
  188. unforce_rtp_proxy();
  189. } else if (is_method("INVITE")){
  190. force_rtp_proxy();
  191. }
  192. if (!has_totag()) add_rr_param(";nat=yes");
  193. return;
  194. }
  195.  
  196. # dispatcher failure routing block
  197. failure_route[RTF_DISPATCH] {
  198. if (t_is_canceled()) {
  199. exit;
  200. }
  201. # select next destination only for local timeout
  202. if (t_branch_timeout() && !t_branch_replied())
  203. {
  204. if(ds_next_dst())
  205. {
  206. t_on_failure("RTF_DISPATCH");
  207. t_relay();
  208. exit;
  209. }
  210. }
  211. }
  212.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement