Advertisement
Guest User

Alex Balashov

a guest
Oct 15th, 2008
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 KB | None | 0 0
  1. ####### Global Parameters #########
  2.  
  3. debug=3
  4. log_stderror=yes
  5. log_facility=LOG_LOCAL0
  6. fork=no
  7. children=5
  8.  
  9. /* uncomment the next line to disable TCP (default on) */
  10. disable_tcp=yes
  11.  
  12. /* uncomment the next line to enable the auto temporary blacklisting of
  13. not available destinations (default disabled) */
  14. disable_dns_blacklist=yes
  15.  
  16. /* uncomment the next line to enable IPv6 lookup after IPv4 dns
  17. lookup failures (default disabled) */
  18. #dns_try_ipv6=yes
  19.  
  20. /* uncomment the next line to disable the auto discovery of local aliases
  21. based on revers DNS on IPs (default on) */
  22.  
  23. #auto_aliases=no
  24.  
  25. port=5060
  26. #listen=udp:192.168.1.2:5060
  27. listen=215.22.22.22:5060
  28. ####### Modules Section ########
  29.  
  30. # Set module path.
  31.  
  32. mpath="/usr/local/lib/kamailio/modules/"
  33.  
  34. loadmodule "sl.so"
  35. loadmodule "tm.so"
  36. loadmodule "rr.so"
  37. loadmodule "maxfwd.so"
  38. loadmodule "textops.so"
  39. loadmodule "mi_fifo.so"
  40. loadmodule "uri.so"
  41. loadmodule "xlog.so"
  42. loadmodule "options.so"
  43. loadmodule "dialog.so"
  44.  
  45. ### --- Module-specific parameters --- ###
  46.  
  47.  
  48. # ----- mi_fifo params -----
  49.  
  50. modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
  51.  
  52. # ---- tm params ---- #
  53.  
  54. modparam("tm", "enable_stats", 0)
  55.  
  56. # ----- rr params -----
  57.  
  58. # add value to ;lr param to cope with most of the UAs
  59. modparam("rr", "enable_full_lr", 1)
  60. # do not append from tag to the RR (no need for this script)
  61. modparam("rr", "append_fromtag", 0)
  62.  
  63. # ----- dialog params ----- #
  64.  
  65. modparam("dialog", "enable_stats", 0)
  66. modparam("dialog", "hash_size", 128)
  67. modparam("dialog", "rr_param", "dlgcor")
  68. modparam("dialog", "dlg_flag", 2)
  69. modparam("dialog", "default_timeout", 120000)
  70. modparam("dialog", "dlg_match_mode", 2)
  71. modparam("dialog", "profiles_with_value", "incoming")
  72.  
  73.  
  74. #############################
  75. ### REQUEST ROUTING LOGIC ###
  76. #############################
  77.  
  78. ## -- Main REQUEST-ROUTE -- ##
  79.  
  80. route {
  81.  
  82. if (!mf_process_maxfwd_header("10")) {
  83. sl_send_reply("483","Too Many Hops");
  84. exit;
  85. }
  86.  
  87. # Reply to OPTIONS pings as necessary.
  88.  
  89. if(is_method("OPTIONS")) {
  90. sl_send_reply("200", "OK");
  91. exit;
  92. }
  93.  
  94. # Add Record-route header if appropriate.
  95.  
  96. if(!is_method("REGISTER|OPTIONS"))
  97. record_route();
  98.  
  99. # if(loose_route()) {
  100. # xlog("L_INFO", "[LOOSE -->] Performing loose routing for $rm\n");
  101. #
  102. # if(has_totag()) {
  103. # xlog("L_INFO", "[LOOSE -->] This request is in-dialog - to-tag present.\n");
  104. # } else {
  105. # xlog("L_INFO", "[LOOSE -->] This request is out-of-dialog - no to-tag.\n");
  106. # }
  107. # }
  108.  
  109. if(src_ip == 198.225.86.10) {
  110. if(is_method("INVITE")) {
  111. rewritehostport("210.23.22.23:5060");
  112. xlog("L_INFO", "Relaying $rm from $rd to $ru\n");
  113.  
  114. setflag(2);
  115. set_dlg_profile("incoming", "$fU");
  116.  
  117. xlog("[D] Added new dialog for $fU\n");
  118.  
  119. t_on_reply("1");
  120. t_on_failure("1");
  121.  
  122. if(!t_relay()) {
  123. sl_reply_error();
  124. exit;
  125. }
  126.  
  127.  
  128. } else {
  129.  
  130. xlog("L_INFO", "[SWITCH] Relaying $rm from $rd to $ru (DTAG=$fU)\n");
  131. if(is_in_profile("incoming", "$fU")) {
  132. xlog("L_INFO", "[SWITCH] [D] This $rm request is in-dialog for a dialog for $fU\n");
  133. } else {
  134. xlog("L_INFO", "[SWITCH] [D] No dialog affinity for this $rm\n");
  135. }
  136.  
  137. t_on_reply("2");
  138.  
  139. if(!t_relay()) {
  140. sl_reply_error();
  141. exit;
  142. }
  143.  
  144. get_profile_size("incoming", "7709600101", "$avp(S:dlg_sz)");
  145.  
  146. xlog("L_INFO", "[SWITCH] [D] Profile size for 7709600101 now: $avp(S:dlg_sz)\n");
  147.  
  148. }
  149.  
  150. } else {
  151. xlog("L_INFO", "[Z-END] Relaying $rm to $ru (DTAG=$fU)\n");
  152.  
  153. if(is_in_profile("incoming", "$fU")) {
  154. xlog("L_INFO", "[Z-END] [D] This request is in-dialog for a dialog for $fU\n");
  155. }
  156.  
  157. t_on_reply("2");
  158.  
  159. if(!t_relay()) {
  160. sl_reply_error();
  161. exit;
  162. }
  163. }
  164. }
  165.  
  166.  
  167. ### -- FAILURE-ROUTE for INVITEs -- ###
  168.  
  169. failure_route[1] {
  170. xlog("L_INFO", "[FAILURE-ROUTE 1] Removing dialog for cause $rs\n");
  171.  
  172. if(is_in_profile("incoming", "$fU"))
  173. unset_dlg_profile("incoming", "$fU");
  174. }
  175.  
  176.  
  177. ### -- ONREPLY-ROUTE for INVITEs -- ###
  178.  
  179. onreply_route[1] {
  180. if(t_check_status("^1.+")) {
  181. xlog("L_INFO", "[ONREPLY-ROUTE 1] Provisional reply $rs received.\n");
  182. exit;
  183. }
  184.  
  185. else if(t_check_status("200")) {
  186. xlog("L_INFO", "[ONREPLY-ROUTE 1] 200 OK received for $fU\n");
  187. }
  188.  
  189. if(is_in_profile("incoming", "$fU")) {
  190. xlog("L_INFO", "[ONREPLY-ROUTE 1] $rm/$rs is part of dialog for $fU\n");
  191. get_profile_size("incoming", "$fU", "$avp(S:dlg_sz)");
  192. xlog("L_INFO", "[ONREPLY-ROUTE 1] Dialog profile size is: $avp(S:dlg_sz)\n");
  193. }
  194. }
  195.  
  196. ### -- ONREPLY-ROUTE for BYEs and CANCELs -- ###
  197.  
  198. onreply_route[2] {
  199. xlog("L_INFO", "[ONREPLY-ROUTE 2] Received $rs for $rm\n");
  200. }
  201.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement