Advertisement
Guest User

Untitled

a guest
Jun 28th, 2023
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.17 KB | None | 0 0
  1. # opensips 3.2 carrir interconnect
  2. log_level=3
  3. log_stderror=no
  4. log_facility=LOG_LOCAL5
  5. #log_stderror=yes # (cmd line: -E)
  6. #TCP parameters
  7. tcp_workers=8
  8. #tcp_send_timeout=1
  9. tcp_connect_timeout=1
  10. memlog=2
  11. disable_dns_blacklist=no
  12.  
  13. tcp_max_connections=2048
  14.  
  15. #user_agent_header="User-Agent: WebAstra"
  16.  
  17.  
  18.  
  19. socket=udp:x.x.x.x:5508 AS "ec2-3-2-2-226.i3clogic.com":5508
  20. socket=udp:x.x.x.x:5505 AS "ec2-3-2-2-226.i3clogic.com":5505
  21.  
  22.  
  23.  
  24. #alias="carrier-interconnect-7x.i3clogic.com"
  25. #alias="carrier-interconnect-7x.i3clogic.com:5508"
  26.  
  27.  
  28. # ------------------ module loading ----------------------------------
  29.  
  30. #set module path
  31.  
  32. mpath="/usr/local/src/lib64/opensips/modules/"
  33.  
  34.  
  35.  
  36. # Uncomment this if you want to use SQL database
  37. loadmodule "db_mysql.so"
  38.  
  39. loadmodule "sl.so"
  40. loadmodule "tm.so"
  41. loadmodule "proto_udp.so"
  42. loadmodule "proto_tcp.so"
  43. loadmodule "path.so"
  44. loadmodule "rr.so"
  45. loadmodule "signaling.so"
  46. loadmodule "dialog.so"
  47. loadmodule "maxfwd.so"
  48. loadmodule "textops.so"
  49. loadmodule "sipmsgops.so"
  50. loadmodule "mi_fifo.so"
  51. loadmodule "avpops.so"
  52. #loadmodule "uri.so"
  53. loadmodule "drouting.so"
  54. loadmodule "usrloc.so"
  55. loadmodule "registrar.so"
  56. loadmodule "auth.so"
  57. loadmodule "auth_db.so"
  58. loadmodule "msilo.so"
  59. loadmodule "alias_db.so"
  60. loadmodule "nathelper.so"
  61. loadmodule "nat_traversal.so"
  62. loadmodule "acc.so"
  63. loadmodule "dialplan.so"
  64. loadmodule "uac.so"
  65.  
  66. loadmodule "cachedb_local.so"
  67.  
  68. ## for opensips-cli sip. sql status command
  69. #loadmodule "event_stream.so"
  70. #loadmodule "jsonrpc.so"
  71.  
  72. #loadmodule "httpd.so"
  73.  
  74. #modparam("httpd", "port", 8000)
  75. ## for opensips-cli trace command
  76. #loadmodule "tracer.so"
  77.  
  78. ## for homer encapsulation protocol
  79. #loadmodule "proto_hep.so"
  80.  
  81.  
  82. loadmodule "sipcapture.so"
  83.  
  84. #modparam("proto_hep", "hep_async", 1)
  85. #modparam("proto_hep", "homer5_on", 1)
  86. #modparam("proto_hep", "hep_capture_id", 1)
  87.  
  88. #modparam("proto_hep", "hep_id","[hep_dst] 192.81.213.2:9060; transport=tcp; version=3")
  89.  
  90. #modparam("tracer", "trace_on", 1)
  91. #modparam("tracer", "trace_id", "[tid]uri=hep:hep_dst")
  92.  
  93.  
  94. #modparam("proto_tcp", "trace_destination", "hep_dst")
  95.  
  96. #### RTPengine protocol
  97. loadmodule "rtpengine.so"
  98.  
  99. ### adding aws rtpengine
  100. modparam("rtpengine", "db_url", "mysql://root:3Cl0g1&c@localhost/opensips")
  101.  
  102. modparam("rtpengine", "rtpengine_disable_tout", 10)
  103. modparam("rtpengine", "rtpengine_tout", 2)
  104.  
  105. # ----------------- setting module-specific parameters --------------
  106.  
  107.  
  108. modparam("tm", "fr_timeout", 5)
  109. modparam("tm", "fr_inv_timeout", 120)
  110. modparam("tm", "restart_fr_on_each_reply", 0)
  111. modparam("tm", "onreply_avp_mode", 1)
  112.  
  113. #modparam("registrar", "max_expires", 120)
  114.  
  115. # -- mi_fifo params --
  116.  
  117. modparam("mi_fifo", "fifo_name", "/opt/opensips_fifo")
  118. # -- usrloc params --
  119.  
  120. #modparam("usrloc", "db_mode", 0)
  121.  
  122. # Uncomment this if you want to use SQL database
  123. # for persistent storage and comment the previous line
  124. modparam("usrloc", "working_mode_preset", "single-instance-sql-write-back")
  125. modparam("usrloc", "regen_broken_contactid", 1)
  126. # -- auth params --
  127. # Uncomment if you are using auth module
  128. #
  129.  
  130. modparam("auth","username_spec","$avp(54)")
  131. modparam("auth","password_spec","$avp(55)")
  132. modparam("auth","calculate_ha1",1)
  133.  
  134. modparam("auth_db", "use_domain", 1)
  135. modparam("auth_db", "calculate_ha1", yes)
  136. modparam("auth_db", "password_column", "password")
  137. modparam("auth_db", "db_url","mysql://root:3Cl0g1&c@localhost/opensips")
  138. modparam("auth_db", "load_credentials", "$avp(55)=password")
  139.  
  140.  
  141. ### domain module reload
  142. loadmodule "domain.so"
  143. modparam("domain", "db_url", "mysql://root:3Cl0g1&c@localhost/opensips")
  144. modparam("domain", "db_mode", 1)
  145.  
  146. # -- rr params --
  147. # add value to ;lr param to make some broken UAs happy
  148. modparam("rr", "append_fromtag", 1)
  149.  
  150. modparam("auth_db|usrloc|lcr|msilo|alias_db", "db_url", "mysql://root:3Cl0g1&c@localhost/opensips")
  151.  
  152. modparam("registrar", "max_expires", 3600)
  153.  
  154. modparam("drouting|dialog","db_url","mysql://root:3Cl0g1&c@localhost/opensips")
  155.  
  156. modparam("avpops","avp_table","avptable")
  157. modparam("avpops","db_url","mysql://root:3Cl0g1&c@localhost/opensips")
  158.  
  159. #-----loading dialplan module ------------
  160. modparam("dialplan","db_url", "mysql://root:3Cl0g1&c@localhost/opensips")
  161. modparam("dialplan", "table_name", "dialplan")
  162. modparam("dialplan", "dpid_col", "dpid")
  163. modparam("dialplan", "pr_col", "pr")
  164. modparam("dialplan", "match_op_col", "match_op")
  165. modparam("dialplan", "match_exp_col", "match_exp")
  166. modparam("dialplan", "match_flags_col", "match_flags")
  167. modparam("dialplan", "subst_exp_col", "subst_exp")
  168. modparam("dialplan", "repl_exp_col", "repl_exp")
  169. modparam("dialplan", "disabled_col", "disabled")
  170. modparam("dialplan", "attrs_col", "attrs")
  171.  
  172. #------- dialog module loading -------------------
  173. #modparam("dialog", "dlg_flag", 4)
  174. #modparam("dialog", "profile_timeout", "100")
  175.  
  176. #----------- loading acc module --------------
  177.  
  178. #modparam("acc", "db_url", "mysql://root:3Cl0g1&c@localhost/opensips")
  179. #modparam("acc", "db_flag", 2)
  180. #modparam("acc", "log_level", 2)
  181. #modparam("acc", "cdr_flag", 1)
  182. modparam("acc", "log_facility", "LOG_LOCAL5")
  183.  
  184. #--- load dynamic routing modul --------------
  185. modparam("drouting", "use_domain", 1)
  186. modparam("drouting", "drd_table", "dr_gateways")
  187. modparam("drouting", "drr_table", "dr_rules")
  188. modparam("drouting", "drg_table", "dr_groups")
  189. modparam("drouting", "drc_table", "dr_carriers")
  190.  
  191. #--------------- uac module loading -------------------
  192. modparam("uac","restore_mode","auto")
  193.  
  194.  
  195.  
  196.  
  197. # ------------------------- request routing logic -------------------
  198.  
  199. # main routing logic
  200.  
  201. route{
  202.  
  203.  
  204.  
  205. $var(c)="NULL";
  206. $var(d)="NULL";
  207. $var(e)="NULL";
  208. $var(f)="NULL";
  209.  
  210. # initial sanity checks -- messages with
  211. # max_forwards==0, or excessively long requests
  212. if (!mf_process_maxfwd_header(10)) {
  213. sl_send_reply(483,"Too Many Hops");
  214. exit;
  215. };
  216.  
  217. if ($ml >= 2048 ) {
  218. sl_send_reply(513, "Message too big");
  219. exit;
  220. };
  221.  
  222. if ($rm=="SUBSCRIBE") {
  223. sl_send_reply(405, "Method not allowed");
  224. exit;
  225. }
  226. if ($rm=="NOTIFY") {
  227. sl_send_reply(405, "Method not allowed");
  228. exit;
  229. }
  230. if ($rm=="OPTIONS") {
  231. sl_send_reply(200, "OK");
  232. exit;
  233. }
  234.  
  235. # Uncomment this to enable sip trace
  236.  
  237. if (!$rm=="REGISTER")
  238. record_route();
  239.  
  240. if (loose_route()) {
  241. # setflag(2);
  242. # setflag(1);
  243. route(1);
  244. };
  245.  
  246. if (!is_domain_local("$rd")) {
  247. # drop packets, look at orig file for original config
  248. route(1);
  249. exit;
  250. }
  251.  
  252. if (is_domain_local("$rd")) {
  253. force_rport();
  254.  
  255.  
  256. #List the method which need to be challenged
  257. if ( is_method("REGISTER")) {
  258.  
  259.  
  260. if(($hdr(User-Agent)!~"scanner")||($hdr(User-Agent)!~"SJphone")) # to stop scanners
  261. {
  262.  
  263. if(is_present_hf("X-Info"))
  264. {
  265. $var(x)=$hdr(X-Info);
  266. $var(y)=$(var(x){s.select,0,;});
  267. $var(z)=$(var(x){s.select,1,;});
  268. $var(y)=$(var(y){s.select,1,=});
  269. $var(z)=$(var(z){s.select,1,=});
  270. if($(var(y){s.int})!=0)
  271. {
  272. save("location","p1n$var(z)");
  273. exit;
  274. }else{
  275. save("location","rp1");
  276. append_to_reply("Contact: $ct \r\n");
  277. xlog( "L_NOTICE", "Contact & $ct \n" );
  278. sl_send_reply(200,"OK");
  279. exit;
  280. }
  281. }else{
  282.  
  283. save("location","p1c5");
  284. exit;
  285. }
  286. ; save("location","fc10p1");
  287. m_dump("$fu");
  288. }
  289. exit;
  290. }
  291.  
  292.  
  293. if ( is_method("CANCEL") )
  294. {
  295. rtpengine_delete();
  296. xlog( "L_WARN", "Source IP cancel : $si To Uri : $tu From : $fU Request URI: $oU Call ID:$ci" );
  297. if ( t_check_trans() ){
  298. t_relay();
  299. }
  300. else {
  301. t_reply(200,"OK");
  302. }
  303. exit;
  304. }
  305.  
  306.  
  307. if (is_method("BYE")) {
  308. # setflag(2);
  309. # setflag(1);
  310. rtpengine_delete();
  311. xlog( "L_WARN", "Source IP BYE : $si To Uri : $tu From : $fU Request URI: $oU Call ID:$ci" );
  312. t_relay();
  313. exit;
  314. }
  315.  
  316. if (is_method("INVITE")) {
  317.  
  318. if(is_present_hf("X-Info"))
  319. {
  320. $var(c)=$hdr(X-Info);
  321. $var(d)=$(var(c){s.select,2,;});
  322. $var(e)=$(var(c){s.select,3,;});
  323. $var(f)=$(var(c){s.select,4,;});
  324. }
  325. #Set the flag for counting the dialogs. We user flag=4 for counting dialogs
  326. # setflag(4);
  327. # setflag(2);
  328. # setflag(1);
  329. xlog( "L_NOTICE", "CallCenter_Info & $ci,$var(c) \n" );
  330. xlog( "L_NOTICE", "3CLogicCDR & $ci,$fU,$oU,$rd \n" );
  331. #Set the flag for session timers
  332.  
  333. if($oU=="" || ($oU=="") || ($oU==""))
  334. {
  335. xlog( "L_WARN", "Source IP sas : $si To Uri : $tu From : $fU Request URI: $oU Call ID:$ci Call For Opus" );
  336. sethostport("20.0.1.1:6080");
  337. route(1);
  338. exit;
  339. }
  340.  
  341. if ($tU=="200150") {
  342. xlog("L_INFO : Send timeout by default \n");
  343. sl_send_reply(408,"Request Timeout");
  344. exit;
  345. }
  346. if($oU=="sim2000000151" || $oU=="200160" || $oU=="200140" )
  347. {
  348. xlog( "L_WARN", "Source IP sas : $si To Uri : $tu From : $fU Call ID:$ci Number tag call routed to Asterisk" );
  349. sethostport("54.80.78.1:5080");
  350. route(outbound);
  351. exit;
  352. }
  353.  
  354.  
  355. if(is_from_gw() || ($rd=="eks.i3clogic.com") || ($rp=="5505"))
  356. {
  357.  
  358. xlog( "L_WARN", "Source IP sas : $si To Uri : $tu From : $fU Request URI: $oU Call ID:$ci" );
  359. sethostport("eks-free1.i3clogic.com:6080");
  360. route(inbound);
  361. exit;
  362. }
  363.  
  364.  
  365. else {
  366.  
  367. xlog( "L_WARN", "Source IP sas : $si To Uri : $tu From : $fU Request URI: $oU Call ID:$ci" );
  368. # alias_db_lookup("dbaliases");
  369.  
  370. if($oU=="121212" || $oU=="121213")
  371. {
  372. route(10);
  373. exit;
  374. }
  375. if ( !lookup("location")){
  376. sl_send_reply(404,"NO Match Found");
  377. xlog( "L_WARN", "Source IP : $si To Uri : $tu From : $fU Request URI: $oU Call ID:$ci: NO Match Found" );
  378. exit;
  379. }
  380. route(outbound);
  381. exit;
  382.  
  383. }
  384. }
  385.  
  386. route(10);
  387. };
  388.  
  389. }
  390.  
  391. route[inbound]{
  392.  
  393.  
  394.  
  395. if (is_method("INVITE")) {
  396. t_on_branch("handle_nat_inbound");
  397. t_on_reply("handle_nat_inbound");
  398. }
  399. else if ($rm=="BYE|CANCEL") {
  400. rtpengine_delete();
  401. }
  402.  
  403. if (!t_relay()) {
  404. send_reply(500,"Internal Error");
  405. };
  406. exit;
  407.  
  408. }
  409.  
  410. branch_route[handle_nat_inbound]{
  411.  
  412. xlog( "L_NOTICE", "RTPENGINE_OFFER_EXECUTED Source IP : $si To Uri : $tu From : $fU Request URI: $oU Call ID:$ci: In route-inbound" );
  413. rtpengine_use_set(0);
  414. $var(rtpengine_flags)="in-iface=external out-iface=internal";
  415. rtpengine_offer("$var(rtpengine_flags)");
  416.  
  417. }
  418.  
  419. onreply_route[handle_nat_inbound]{
  420.  
  421. xlog( "L_NOTICE", "RTPENGINE_OFFER_EXECUTED Source IP : $si To Uri : $tu From : $fU Request URI: $oU Call ID:$ci: In onreply inbound" );
  422. $var(rtpengine_flags)="in-iface=internal out-iface=external";
  423. rtpengine_offer("$var(rtpengine_flags)");
  424.  
  425. }
  426.  
  427.  
  428. route[outbound]{
  429.  
  430. if (is_method("INVITE")) {
  431. t_on_branch("handle_nat_outbound");
  432. t_on_reply("handle_nat_outbound");
  433. }
  434. else if ($rm=="BYE|CANCEL") {
  435. rtpengine_delete();
  436. }
  437. if (!t_relay()) {
  438. send_reply(500,"Internal Error");
  439. };
  440. exit;
  441.  
  442. }
  443.  
  444. branch_route[handle_nat_outbound]{
  445.  
  446. xlog( "L_NOTICE", "RTPENGINE_OFFER_EXECUTED Source IP : $si To Uri : $tu From : $fU Request URI: $oU Call ID:$ci: In route-outbound" );
  447. rtpengine_use_set(0);
  448. $var(rtpengine_flags)="in-iface=internal out-iface=external";
  449. rtpengine_offer("$var(rtpengine_flags)");
  450.  
  451. }
  452.  
  453. onreply_route[handle_nat_outbound]{
  454.  
  455. xlog( "L_NOTICE", "RTPENGINE_OFFER_EXECUTED Source IP : $si To Uri : $tu From : $fU Request URI: $oU Call ID:$ci: In onreply outbound" );
  456. $var(rtpengine_flags)="in-iface=external out-iface=internal";
  457. rtpengine_offer("$var(rtpengine_flags)");
  458.  
  459. }
  460.  
  461. route[1]{
  462. #rtpengine_offer();
  463.  
  464. if(nat_uac_test(7)) {
  465. fix_nated_contact();
  466. };
  467. t_on_reply("1");
  468.  
  469. xlog("L_NOTICE", " Source IP sasmi ($socket_in(ip)) : callID $ci : method $rm \n");
  470.  
  471. if (!t_relay()) {
  472. sl_reply_error();
  473. }
  474.  
  475. exit;
  476. }
  477.  
  478. route[10]
  479. {
  480.  
  481. $avp(src) = $rd;
  482. dp_translate(5, $avp(src), $var(y), $var(attrs));
  483. xlog(" $avp(src) translated to var $var(y) with attributes: '$var(attrs)'\n");
  484. $avp(grp)=$(var(y){s.int});
  485.  
  486.  
  487. if (!do_routing($avp(grp))) {
  488. xlog("do_routing: No rules matching the URI $rd \n");
  489. sl_send_reply(503,"No rules matching the URI");
  490. exit;
  491. }
  492.  
  493.  
  494. if (is_method("INVITE")) {
  495. t_on_failure("10");
  496. }
  497. route(outbound);
  498.  
  499. }
  500.  
  501.  
  502. onreply_route[1] {
  503.  
  504. rtpengine_answer();
  505.  
  506. if( t_check_status ("18[0-9]") ) {
  507. t_on_failure("4");
  508.  
  509. }
  510.  
  511. xlog("L_NOTICE", " Source IP On-Reply-Route ($socket_in(ip)) : callID $ci : method $rm \n");
  512. if (nat_uac_test(1)) {
  513. fix_nated_contact();
  514. };
  515. }
  516.  
  517.  
  518. failure_route[10] {
  519.  
  520.  
  521. xlog("DEBUG: DROUTING failure route active\n");
  522. if (t_check_status("408|402|50[234]")) {
  523. # route to the next gateway
  524. xlog("DEBUG: DROUTING use next gateway \n");
  525. if (use_next_gw()) {
  526. # prepare for lcr failover
  527. xlog( "L_NOTICE", "[$Tf] ACC: $ci Next gateway $fU -> $tU via $rd\n" );
  528. # t_on_reply("1");
  529. # t_on_failure("10");
  530. # send from 5060 for primus gateways
  531. if (!t_relay()){
  532. exit;
  533. }
  534. } else {
  535. xlog( "L_WARN", "[$Tf] FR: $ci No more buscuits in the biscuit tin -> 503.\n" );
  536. t_reply(503, "Service unavailable -- no more gateways");
  537. exit;
  538. };
  539.  
  540. };
  541. exit;
  542. }
  543.  
  544. failure_route[3] {
  545. # the previous contact is no goodi
  546.  
  547. if (t_check_status("408|404|486|50[234]|603")) {
  548. # route to the next contact
  549. if (next_branches()) {
  550. # prepare for lcr failover
  551. xlog( "L_NOTICE", "[$Tf] FR: $ci Next contact $fU -> $tU via $rd\n" );
  552. #t_on_reply("1");
  553. t_on_failure("3");
  554. if (!t_relay()){
  555. exit;
  556. }
  557. } else {
  558. xlog( "L_WARN", "[$Tf] FR: $ci No more buscuits in the biscuit tin -> 503.\n" );
  559. #t_reply("503", "Service unavailable -- no more gateways");
  560. exit;
  561. };
  562.  
  563. };
  564. exit;
  565. }
  566.  
  567. failure_route[4] {
  568. xlog("L_NOTICE","could not complete");
  569. }
  570.  
  571. failure_route[redirect] {
  572. if ($var(requestDomain)=="impact4.3ccloud.com"){
  573. sethostport("impact3.3ccloud.com:5507");
  574. t_reply(302, "Redirect");
  575. exit;
  576. }
  577. }
  578.  
  579.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement