Advertisement
Guest User

Untitled

a guest
Jan 27th, 2014
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. debug=3
  2. log_stderror=yes
  3. log_facility=LOG_LOCAL0
  4.  
  5. fork=yes
  6. children=4
  7. disable_tcp=yes
  8. auto_aliases=no
  9. sip_warning=yes
  10.  
  11. listen=udp:EXTERNAL_IP:5060
  12. listen=udp:INTERNAL_IP:5060
  13.  
  14. mhomed=1
  15.  
  16.  
  17. group=nobody
  18. user=nobody
  19.  
  20. server_header="SBC"
  21. server_signature = off
  22. user_agent_header="User-Agent: SBC"
  23.  
  24. ####### Modules Section ########
  25.  
  26. #set module path
  27. mpath="/zxa/server/opensips/lib/modules/"
  28.  
  29. loadmodule "db_text.so"
  30. loadmodule "signaling.so"
  31. loadmodule "sl.so"
  32. loadmodule "tm.so"
  33. loadmodule "rr.so"
  34. loadmodule "maxfwd.so"
  35. loadmodule "textops.so"
  36. loadmodule "mi_fifo.so"
  37. loadmodule "usrloc.so"
  38. loadmodule "acc.so"
  39. loadmodule "uri.so"
  40. loadmodule "rtpproxy.so"
  41. loadmodule "nat_traversal.so"
  42. loadmodule "nathelper.so"
  43. #loadmodule "userblacklist.so"
  44.  
  45.  
  46. modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
  47. #modparam("permissions", "default_allow_file", "/zxa/server/opensips/config/permissions.allow")
  48. modparam("nat_traversal", "keepalive_state_file", "/zxa/server/opensips/config/nat_keepalive_state")
  49. modparam("rr", "append_fromtag", 0)
  50. modparam("uri", "use_uri_table", 0)
  51. modparam("rtpproxy","rtpproxy_sock", "udp:127.0.0.1:7980")
  52. modparam("usrloc", "db_mode", 0)
  53.  
  54. modparam("acc", "log_level", 2)
  55. modparam("acc", "log_flag", 2)
  56. modparam("acc", "log_facility", "LOG_LOCAL0")
  57. modparam("acc", "report_cancels", 1)
  58. modparam("acc", "detect_direction", 0)
  59. modparam("acc", "failed_transaction_flag", 4)
  60. modparam("acc", "service_type", 15)
  61.  
  62.  
  63.  
  64. ####### Routing Logic ########
  65.  
  66. # main request routing logic
  67.  
  68. route{
  69.  
  70. xlog("=== TOP ===\n");
  71. xlog("%%%% tu= $tu | fu= $fu | od= $od | ReceivedINT: $Ri | SourceIP: $si %%%\n");
  72.  
  73. #if (!check_address("1","$si","$sp","$proto"))
  74. #{
  75. # xlog("=== ACCESS FAILED ===\n");
  76. # xlog("=== $si| $sp | $proto ===\n");
  77. # sl_send_reply("403","Forbidden A");
  78. # exit;
  79. #}
  80.  
  81. if (!mf_process_maxfwd_header("10"))
  82. {
  83. xlog("=== TOO MANY HOPS ===\n");
  84. sl_send_reply("483","Too Many Hops");
  85. exit;
  86. }
  87.  
  88. #---- NAT Detection ----#
  89. force_rport();
  90. if (nat_uac_test("18")) && !($od =~ "^10\.*") {
  91. xlog("***** NAT YES *****\n");
  92. fix_nated_contact();
  93. xlog("fix sdp\n");
  94. fix_nated_sdp("8","EXTERNAL_IP");
  95. setflag(5);
  96. }
  97.  
  98. #CANCEL processing
  99. if (is_method("CANCEL"))
  100. {
  101. xlog("=== CANCEL ===\n");
  102. if (t_check_trans())
  103. t_relay();
  104. exit;
  105. }
  106.  
  107. if (is_method("PUBLISH"))
  108. {
  109. sl_send_reply("503", "Service Unavailable");
  110. exit;
  111. }
  112.  
  113. if (has_totag())
  114. {
  115. xlog("=== HAS TO TAG ===\n");
  116.  
  117. if (loose_route())
  118. {
  119.  
  120. xlog("=== HAS LOOSE ===\n");
  121.  
  122. if (is_method("BYE"))
  123. {
  124. xlog("=== LOOSE BYE ===\n");
  125. setflag(1); # Accounting bye
  126.  
  127. } else if (is_method("INVITE")) {
  128.  
  129. xlog("=== RE-INVITE LOOSE ===\n");
  130.  
  131. if( $od =~ "^10\.*")
  132. {
  133. xlog("^^^^ DEST INTERNAL ^^^^\n");
  134. $avp(gw_attrs) = "internal";
  135. }
  136. record_route();
  137. }
  138.  
  139. xlog("In loouse going to Route 1\n");
  140. route(1);
  141.  
  142. } else {
  143.  
  144. if ( is_method("ACK") )
  145. {
  146. xlog("=== LOOSE ELSE ACK ===\n");
  147.  
  148. if ( t_check_trans() )
  149. {
  150. t_relay();
  151. exit;
  152. } else {
  153. xlog("=== LOOSE Discard ACK ===\n");
  154. exit;
  155. }
  156. }
  157.  
  158. sl_send_reply("404","Not here");
  159. }
  160.  
  161. exit;
  162. }
  163.  
  164. t_check_trans();
  165.  
  166. if (loose_route())
  167. {
  168. xlog("L_ERR","Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]\n");
  169.  
  170. if (!is_method("ACK"))
  171. {
  172. sl_send_reply("403","Preload Route denied");
  173. exit;
  174. }
  175. }
  176.  
  177. # record routing
  178. if (!is_method("REGISTER|MESSAGE"))
  179. {
  180. record_route();
  181. }
  182.  
  183.  
  184.  
  185. if ($rU==NULL)
  186. {
  187. # request with no Username in RURI
  188. sl_send_reply("484","Address Incomplete");
  189. exit;
  190. }
  191.  
  192. if (is_method("INVITE") && (!has_totag()) )
  193. {
  194. xlog("((((((((( NEW CALL ))))))))))\n");
  195.  
  196.  
  197.  
  198. route(1);
  199.  
  200. send_reply("420", "Invalid Extension");
  201. exit;
  202. }
  203. }
  204.  
  205. route[1] {
  206.  
  207. rewritehostport("OUTBOUNT SIP");
  208.  
  209. #---- RTP Proxy handling ---#
  210. xlog("=== ROUTE 1 ===\n");
  211.  
  212.  
  213. if (isflagset(5)){
  214. search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');
  215. }
  216.  
  217. if (subst_uri('/(sip:.*);nat=yes/\1/')){
  218. setbflag(6);
  219. }
  220.  
  221. if (is_method("BYE|CANCEL"))
  222. {
  223. unforce_rtp_proxy();
  224. }
  225.  
  226. if (has_body("application/sdp"))
  227. {
  228.  
  229. if ( $avp(gw_attrs) != "internal" )
  230. {
  231. append_hf("P-hint: EI \r\n");
  232. rtpproxy_offer("EI","EXTERNAL_IP");
  233. } else {
  234. append_hf("P-hint: IE \r\n");
  235. rtpproxy_offer("IE","INTERNAL_IP");
  236. }
  237. }
  238. force_send_socket("EXTERNAL_IP");
  239. t_on_branch("1");
  240. t_on_reply("1");
  241. t_on_failure("1");
  242.  
  243. if (!t_relay())
  244. {
  245. sl_reply_error();
  246. }
  247.  
  248. exit;
  249.  
  250. }
  251.  
  252. branch_route[1] {
  253.  
  254. xlog("new branch at $ru\n");
  255. }
  256.  
  257. onreply_route[1] {
  258.  
  259. xlog("=== ON REPLY ROUTE 2 rs= $rs | fu= $fu | od= $od | si= $si | Ri= $Ri ===\n");
  260.  
  261.  
  262. if ( status=~"(180)|(183)|(2[0-9][0-9])" )
  263. {
  264.  
  265. if ($Ri == "INTERNAL_IP")
  266. {
  267. append_hf("P-hint: RR EI \r\n");
  268. rtpproxy_answer("EI","EXTERNAL_IP");
  269. } else {
  270. append_hf("P-hint: RR IE \r\n");
  271. rtpproxy_answer("IE","INTERNAL_IP");
  272. }
  273. }
  274.  
  275. if (isbflagset(6)) {
  276. fix_nated_contact();
  277. }
  278. }
  279.  
  280. failure_route[1] {
  281. xlog("=== FAIL ROUTE 2 ===\n");
  282.  
  283. unforce_rtp_proxy();
  284.  
  285. if (t_was_cancelled())
  286. {
  287. exit;
  288. }
  289.  
  290. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement