Advertisement
Guest User

opensips-16

a guest
Nov 19th, 2011
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.47 KB | None | 0 0
  1.  
  2. debug=3
  3. log_stderror=no
  4. log_facility=LOG_LOCAL0
  5.  
  6. fork=yes
  7. children=4
  8. disable_tcp=yes
  9. auto_aliases=yes
  10. sip_warning=yes
  11.  
  12. port=5060
  13. listen=udp:XXX.XXX.XXX.XXX:5060
  14.  
  15. group=nobody
  16. user=nobody
  17.  
  18.  
  19. ####### Modules Section ########
  20.  
  21. #set module path
  22. mpath="/usr/local/lib64/opensips/modules/"
  23.  
  24. /* uncomment next line for MySQL DB support */
  25. loadmodule "db_mysql.so"
  26. loadmodule "signaling.so"
  27. loadmodule "sl.so"
  28. loadmodule "tm.so"
  29. loadmodule "rr.so"
  30. loadmodule "maxfwd.so"
  31. loadmodule "usrloc.so"
  32. loadmodule "registrar.so"
  33. loadmodule "textops.so"
  34. loadmodule "mi_fifo.so"
  35. loadmodule "uri.so"
  36. loadmodule "acc.so"
  37. loadmodule "auth.so"
  38. loadmodule "auth_db.so"
  39. loadmodule "alias_db.so"
  40. loadmodule "domain.so"
  41. loadmodule "drouting.so"
  42. loadmodule "avpops.so"
  43. loadmodule "dialplan.so"
  44. loadmodule "permissions.so"
  45. loadmodule "dialog.so"
  46. loadmodule "nathelper.so"
  47. loadmodule "siptrace.so"
  48. loadmodule "nat_traversal.so"
  49. loadmodule "userblacklist.so"
  50. loadmodule "aaa_radius.so"
  51.  
  52. modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
  53. modparam("rr", "enable_full_lr", 1)
  54. modparam("rr", "append_fromtag", 0)
  55. modparam("usrloc", "db_mode", 2)
  56. modparam("usrloc", "db_url","mysql://X:X@localhost/opensips16")
  57. modparam("usrloc","nat_bflag", 6)
  58. modparam("uri", "use_uri_table", 0)
  59.  
  60. modparam("acc", "report_ack", 0)
  61. modparam("acc", "log_level", 2)
  62. modparam("acc", "report_cancels", 1)
  63. modparam("acc", "detect_direction", 0)
  64. modparam("acc", "failed_transaction_flag", 3)
  65. modparam("acc", "aaa_url", "radius:/usr/local/etc/radiusclient-ng/radiusclient.conf")
  66. modparam("acc", "aaa_flag", 1)
  67. modparam("acc", "aaa_missed_flag", 0)
  68. modparam("acc", "aaa_extra", "User-Name=$Au;
  69. Calling-Station-Id=$from;
  70. Called-Station-Id=$to;
  71. Sip-Translated-Request-URI=$ru;
  72. Sip-RPid=$avp(s:rpid);
  73. Source-IP=$avp(s:source_ip);
  74. Source-Port=$avp(s:source_port);
  75. SIP-Proxy-IP=$avp(s:sip_proxy_ip);
  76. Canonical-URI=$avp(s:can_uri);
  77. Billing-Party=$avp(s:billing_party);
  78. Divert-Reason=$avp(s:divert_reason);
  79. User-Agent=$hdr(user-agent);
  80. Contact=$hdr(contact);
  81. Event=$hdr(event);
  82. ENUM-TLD=$avp(s:enum_tld)")
  83.  
  84. modparam("auth_db", "calculate_ha1", yes)
  85. modparam("auth_db", "password_column", "password")
  86. modparam("auth_db", "db_url","mysql://X:X@localhost/opensips16")
  87. modparam("auth_db", "load_credentials", "")
  88.  
  89. modparam("alias_db", "db_url","mysql://X:X@localhost/opensips16")
  90. modparam("domain", "db_url","mysql://X:X@localhost/opensips16")
  91. modparam("domain", "db_mode", 1) # Use caching
  92.  
  93. modparam("drouting", "use_domain", 1)
  94. modparam("drouting","db_url", "mysql://X:X@localhost/opensips16")
  95.  
  96. modparam("avpops", "db_url", "mysql://X:X@localhost/opensips16")
  97. modparam("avpops", "avp_table", "usr_preferences")
  98.  
  99. modparam("dialplan", "db_url","mysql://X:X@localhost/opensips16")
  100. modparam("dialplan", "attrs_pvar", "$avp(s:dest)")
  101.  
  102. modparam("permissions", "db_url","mysql://X:X@localhost/opensips16")
  103.  
  104. modparam("nathelper","rtpproxy_sock", "udp:xxx.xxx.xxx.xxx:7777")
  105. #modparam("nathelper","rtpproxy_sock", "unix:/var/run/rtpproxy.sock")
  106. modparam("nathelper","natping_interval", 30)
  107. modparam("nathelper","ping_nated_only", 0)
  108. modparam("nathelper","sipping_bflag", 7)
  109. modparam("nathelper","sipping_from", "sip:[email protected]")
  110. modparam("nathelper","received_avp", "$avp(i:42)")
  111.  
  112. modparam("registrar","received_avp", "$avp(i:42)")
  113. modparam("registrar", "max_contacts", 10)
  114.  
  115. modparam("siptrace", "db_url", "mysql://X:X@localhost/opensips16")
  116. modparam("siptrace", "trace_on", 1)
  117. modparam("siptrace", "trace_flag", 2)
  118. modparam("siptrace", "traced_user_avp", "$avp(s:traceuser)")
  119. modparam("siptrace", "trace_local_ip", "XXX.XXX.XXX.XXX")
  120.  
  121. modparam("userblacklist", "db_url","mysql://X:X@localhost/opensips16")
  122.  
  123. ####### Routing Logic ########
  124.  
  125.  
  126. # main request routing logic
  127.  
  128. route{
  129. xlog("New Call for route [ fu=$fu/ tu=$tu /ru=$ru/ ci=$ci]");
  130. if (!mf_process_maxfwd_header("10")) {
  131. sl_send_reply("483","Too Many Hops");
  132. exit;
  133. }
  134.  
  135. if (has_totag()) {
  136.  
  137. if (loose_route()) {
  138. if (is_method("BYE")) {
  139. setflag(1); # do accounting ...
  140. setflag(3); # account fails
  141. } else if (is_method("INVITE")) {
  142. record_route();
  143. }
  144.  
  145. route(1);
  146.  
  147. } else {
  148.  
  149. if ( is_method("ACK") ) {
  150. if ( t_check_trans() ) {
  151.  
  152. t_relay();
  153. exit;
  154.  
  155. } else {
  156.  
  157. exit;
  158. }
  159. }
  160. sl_send_reply("404","Not here");
  161. }
  162. exit;
  163. }
  164.  
  165. #initial requests
  166.  
  167. # CANCEL processing
  168. if (is_method("CANCEL"))
  169. {
  170. if (t_check_trans())
  171. t_relay();
  172. exit;
  173. }
  174.  
  175. t_check_trans();
  176.  
  177.  
  178. if (!(method=="REGISTER") && is_from_local()) /*multidomain version*/
  179. {
  180. if (!proxy_authorize("", "subscriber")) {
  181. proxy_challenge("", "0");
  182. exit;
  183. }
  184. if (!db_check_from()) {
  185. sl_send_reply("403","Forbidden auth ID");
  186. exit;
  187. }
  188.  
  189. consume_credentials();
  190. # caller authenticated
  191. }
  192.  
  193. # preloaded route checking
  194. if (loose_route()) {
  195. xlog("L_ERR","Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
  196. if (!is_method("ACK"))
  197. sl_send_reply("403","Preload Route denied");
  198. exit;
  199. }
  200.  
  201. # record routing
  202. if (!is_method("REGISTER|MESSAGE"))
  203. record_route();
  204.  
  205. # account only INVITEs
  206. if (is_method("INVITE")) {
  207.  
  208. xlog("set acc");
  209. setflag(1); # do accounting
  210. setflag(3); # Account failed transactions
  211. $avp(s:can_uri) = $ru;
  212. }
  213.  
  214. if (!is_uri_host_local())
  215. {
  216. append_hf("P-hint: outbound\r\n");
  217. route(1);
  218. }
  219.  
  220.  
  221. if (is_method("PUBLISH"))
  222. {
  223. sl_send_reply("503", "Service Unavailable");
  224. exit;
  225. }
  226.  
  227.  
  228. if (is_method("REGISTER"))
  229. {
  230.  
  231. if (!www_authorize("", "subscriber"))
  232. {
  233. www_challenge("", "0");
  234. exit;
  235. }
  236.  
  237. if (!db_check_to())
  238. {
  239. sl_send_reply("403","Forbidden auth ID");
  240. exit;
  241. }
  242.  
  243. if (!save("location"))
  244. sl_reply_error();
  245.  
  246. exit;
  247. }
  248.  
  249. if ($rU==NULL) {
  250. # request with no Username in RURI
  251. sl_send_reply("484","Address Incomplete");
  252. exit;
  253. }
  254.  
  255. if(avp_db_load("$fu","$avp(s:trace)")) {
  256. $avp(s:traceuser)=$fu;
  257. setflag(22);
  258. sip_trace();
  259. xlog("L_INFO","User $fu being traced");
  260. }
  261.  
  262.  
  263. if(!dp_translate("1","$rU/$rU")){
  264. xlog("Invalid Destination :$rU/$rU");
  265. send_reply("420", "Invalid Destination");
  266. exit;
  267. }
  268.  
  269. xlog("info: $avp(s:dest)");
  270.  
  271. if ($avp(s:dest)=="usrloc") {
  272. #Route to usrloc
  273. route(3);
  274. }
  275.  
  276. if ($avp(s:dest)=="pstn") {
  277. #route to pstn
  278. route(4);
  279. }
  280.  
  281. if ($avp(s:dest)=="media") {
  282. #route to media server
  283. route(5);
  284. }
  285.  
  286. send_reply("420", "Invalid Extension");
  287. exit;
  288. }
  289.  
  290.  
  291. route[1] {
  292.  
  293. if (!check_blacklist("userblacklist")) {
  294. sl_send_reply("403", "DID Forbidden");
  295. exit;
  296. }
  297.  
  298. xlog("Enter route 1");
  299.  
  300.  
  301. if (has_body("application/sdp")) {
  302. xlog("Route1 on RTP");
  303. rtpproxy_offer();
  304. }
  305.  
  306.  
  307.  
  308. if (is_method("INVITE")) {
  309.  
  310. t_on_branch("2");
  311. t_on_reply("2");
  312. t_on_failure("1");
  313.  
  314. }
  315.  
  316. if (!t_relay()) {
  317. sl_reply_error();
  318. }
  319. exit;
  320. }
  321.  
  322. route[2] {
  323.  
  324. #if (has_body("application/sdp")) {
  325. #
  326. # if (client_nat_test("3")) {
  327. # xlog("--->internal<---");
  328. # rtpproxy_offer();
  329. # } else {
  330. # xlog("--->ext<---");
  331. # rtpproxy_offer();
  332. # }
  333. #}
  334.  
  335.  
  336. route(1);
  337. }
  338.  
  339.  
  340. route[3]{
  341.  
  342. xlog("Enter Route 3 USRLOC");
  343. alias_db_lookup("dbaliases");
  344. if (!lookup("location", "m")) {
  345. switch ($retcode) {
  346. case -1:
  347. case -3:
  348. t_newtran();
  349. t_reply("404", "Not Found");
  350. exit;
  351. case -2:
  352. sl_send_reply("405", "Method Not Allowed");
  353. exit;
  354. }
  355. }
  356.  
  357. route(1);
  358. }
  359.  
  360.  
  361. route[4] {
  362.  
  363. #---- PSTN route ----#
  364. if(!check_source_address("0")) {
  365.  
  366. if (!db_check_from()) {
  367. xlog("Forbidden auth ID route 4");
  368. xlog("Forbidden rs= $rs/ rb= $rb / fd= $fd / fu= $fu / rr= $rr / rs= $rs / Ri= $Ri / si= $si");
  369. sl_send_reply("403","Forbidden");
  370. exit;
  371. }
  372. }
  373.  
  374. if(!do_routing("0")){
  375. xlog("No rules found matching the URI prefix");
  376. send_reply("503", "No rules found matching the URI prefix");
  377. exit;
  378. }
  379.  
  380. # flag 10 – failure route
  381. setflag(10);
  382. route(1);
  383. }
  384.  
  385.  
  386. route[5] {
  387. #---- Route to media servers ----#
  388. xlog("route to media servers");
  389. }
  390.  
  391.  
  392. failure_route[1] {
  393.  
  394. unforce_rtp_proxy();
  395.  
  396. if (t_was_cancelled()) {
  397. exit;
  398. }
  399. if(isflagset(10)){
  400. if (use_next_gw()) {
  401. #xlog ("next gateway $ru \n");
  402. t_on_failure("1");
  403. t_relay();
  404. exit;
  405. } else {
  406. t_reply("503", "Service not available, no more gateways");
  407. exit;
  408. }
  409. }
  410. }
  411.  
  412.  
  413. branch_route[2] {
  414.  
  415. xlog("new branch at $ru\n");
  416.  
  417. }
  418.  
  419. onreply_route[2] {
  420.  
  421. xlog("ACK with rs= $rs/ rb= $rb / fd= $fd / fu= $fu / rr= $rr / rs= $rs / Ri= $Ri / si= $si");
  422.  
  423.  
  424. if ($rs == "200" && $si == "xxx.xxx.xxx.xxx") {
  425. xlog("==ACC== $si | $rs ");
  426. setflag(1); # do accounting
  427. }
  428.  
  429. if (has_body("application/sdp")) {
  430. xlog("reply 2 turn on rtp");
  431. rtpproxy_answer();
  432. }
  433.  
  434. }
  435.  
  436.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement