Advertisement
haloha

opensips.cfg

Mar 23rd, 2011
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.29 KB | None | 0 0
  1. ####### Global Parameters #########
  2.  
  3. debug=3
  4. log_stderror=no
  5. log_facility=LOG_LOCAL0
  6.  
  7. fork=yes
  8. children=4
  9.  
  10. port=5060
  11.  
  12. /* uncomment and configure the following line if you want opensips to
  13. bind on a specific interface/port/proto (default bind on all available) */
  14. #listen=udp:192.168.1.2:5060
  15. listen=udp:example.com
  16.  
  17. ####### Modules Section ########
  18.  
  19. #set module path
  20. mpath="/usr/lib/opensips/modules/"
  21.  
  22. /* uncomment next line for MySQL DB support */
  23. loadmodule "db_mysql.so"
  24. loadmodule "signaling.so"
  25. loadmodule "sl.so"
  26. loadmodule "tm.so"
  27. loadmodule "rr.so"
  28. loadmodule "maxfwd.so"
  29. loadmodule "usrloc.so"
  30. loadmodule "dialog.so"
  31. loadmodule "registrar.so"
  32. loadmodule "textops.so"
  33. loadmodule "mi_fifo.so"
  34. loadmodule "uri.so"
  35. loadmodule "acc.so"
  36.  
  37. loadmodule "aaa_radius.so"
  38. loadmodule "call_control.so"
  39. loadmodule "mi_datagram.so"
  40. loadmodule "auth.so"
  41. loadmodule "auth_db.so"
  42.  
  43. # ----------------- setting module-specific parameters ---------------
  44.  
  45. # ----- mi_fifo params -----
  46. modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
  47. modparam("mi_datagram", "socket_name", "/tmp/opensips.sock")
  48. modparam("mi_datagram", "children_count", 10)
  49. modparam("mi_datagram", "unix_socket_mode", 0600)
  50.  
  51. # ----- rr params -----
  52. # add value to ;lr param to cope with most of the UAs
  53. modparam("rr", "enable_full_lr", 1)
  54. # do not append from tag to the RR (no need for this script)
  55. modparam("rr", "append_fromtag", 0)
  56.  
  57. # ----- registrar params -----
  58. /* uncomment the next line not to allow more than 10 contacts per AOR */
  59. #modparam("registrar", "max_contacts", 10)
  60.  
  61. # ----- usrloc params -----
  62. #modparam("usrloc", "db_mode", 0)
  63. /* uncomment the following lines if you want to enable DB persistency
  64. for location entries */
  65. modparam("usrloc", "db_mode", 2)
  66. modparam("usrloc", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
  67.  
  68. # ----- uri params -----
  69. modparam("uri", "use_uri_table", 0)
  70.  
  71. # ----- acc params -----
  72. #############CDRTool##############
  73. modparam("aaa_radius", "radius_config", "/etc/radiusclient-ng/radiusclient.conf")
  74. modparam("acc", "aaa_url", "radius:/etc/radiusclient-ng/radiusclient.conf")
  75. modparam("acc", "aaa_flag", 1)
  76. modparam("acc", "aaa_extra", "User-Name=$Au; \
  77. Calling-Station-Id=$from; \
  78. Called-Station-Id=$to; \
  79. Sip-Translated-Request-URI=$ru; \
  80. Canonical-URI=$avp(s:can_uri); \
  81. Billing-Party=$avp(s:billing_party); \
  82. Divert-Reason=$avp(s:divert_reason); \
  83. User-Agent=$hdr(user-agent); \
  84. Contact=$hdr(contact); \
  85. Event=$hdr(event); \
  86. ENUM-TLD=$avp(s:enum_tld); \
  87. From-Header=$hdr(from); \
  88. SIP-Application-Type=$avp(s:sip_application_type)")
  89. # ----- auth_db params -----
  90. /* uncomment the following lines if you want to enable the DB based
  91. authentication */
  92. modparam("auth_db", "calculate_ha1", yes)
  93. modparam("auth_db", "password_column", "password")
  94. modparam("auth_db", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
  95. modparam("auth_db", "load_credentials", "")
  96.  
  97. ####### Routing Logic ########
  98.  
  99.  
  100. # main request routing logic
  101.  
  102. route{
  103.  
  104. if (!mf_process_maxfwd_header("10")) {
  105. sl_send_reply("483","Too Many Hops");
  106. exit;
  107. }
  108.  
  109. if (has_totag()) {
  110. # sequential request withing a dialog should
  111. # take the path determined by record-routing
  112. if (loose_route()) {
  113. if (is_method("BYE")) {
  114. setflag(1); # do accounting ...
  115. } else if (is_method("INVITE")) {
  116. # even if in most of the cases is useless, do RR for
  117. # re-INVITEs alos, as some buggy clients do change route set
  118. # during the dialog.
  119. record_route();
  120. }
  121. # route it out to whatever destination was set by loose_route()
  122. # in $du (destination URI).
  123. route(1);
  124. } else {
  125. /* uncomment the following lines if you want to enable presence */
  126. ##if (is_method("SUBSCRIBE") && $rd == "your.server.ip.address") {
  127. ## # in-dialog subscribe requests
  128. ## route(2);
  129. ## exit;
  130. ##}
  131. if ( is_method("ACK") ) {
  132. if ( t_check_trans() ) {
  133. # non loose-route, but stateful ACK; must be an ACK after
  134. # a 487 or e.g. 404 from upstream server
  135. t_relay();
  136. exit;
  137. } else {
  138. # ACK without matching transaction ->
  139. # ignore and discard
  140. exit;
  141. }
  142. }
  143. sl_send_reply("404","Not here");
  144. }
  145. exit;
  146. }
  147.  
  148. #initial requests
  149. if ((method=="INVITE" && !has_totag())) {
  150. create_dialog();
  151. setflag(1);
  152. $avp(s:can_uri) = $ru;
  153. $avp(s:billing_party) = $Au;
  154. $avp(s:sip_application_type) = "audio";
  155. $avp(s:enum_tld) = "E164";
  156.  
  157. # you need to call this function at the first INVITE
  158. call_control();
  159. switch ($retcode) {
  160. case 2:
  161. # Call with no limit
  162. case 1:
  163. # Call with a limit under callcontrol management (either prepaid
  164. # or postpaid)
  165. break;
  166. case -1:
  167. # Not enough credit (prepaid call)
  168. xlog("L_INFO", "Call control: not enough credit for prepaid call\n");
  169. sl_send_reply("402", "Not enough credit");
  170. exit;
  171. break;
  172. case -2:
  173. # Locked by call in progress (prepaid call)
  174. xlog("L_INFO", "Call control: prepaid call locked by another call in progress\n");
  175. sl_send_reply("403", "Call locked by another call in progress");
  176. exit;
  177. break;
  178. default:
  179. # Internal error (message parsing, communication, ...)
  180. xlog("L_INFO", "Call control: internal server error\n");
  181. sl_send_reply("500", "Internal server error");
  182. exit;
  183. }
  184. }
  185.  
  186. # CANCEL processing
  187. if (is_method("CANCEL"))
  188. {
  189. if (t_check_trans())
  190. t_relay();
  191. exit;
  192. }
  193.  
  194. t_check_trans();
  195.  
  196. # authenticate if from local subscriber (uncomment to enable auth)
  197. # authenticate all initial non-REGISTER request that pretend to be
  198. # generated by local subscriber (domain from FROM URI is local)
  199. ##if (!(method=="REGISTER") && from_uri==myself) /*no multidomain version*/
  200. ##if (!(method=="REGISTER") && is_from_local()) /*multidomain version*/
  201. ##{
  202. ## if (!proxy_authorize("", "subscriber")) {
  203. ## proxy_challenge("", "0");
  204. ## exit;
  205. ## }
  206. ## if (!db_check_from()) {
  207. ## sl_send_reply("403","Forbidden auth ID");
  208. ## exit;
  209. ## }
  210. ##
  211. ## consume_credentials();
  212. ## # caller authenticated
  213. ##}
  214.  
  215. # preloaded route checking
  216. if (loose_route()) {
  217. xlog("L_ERR",
  218. "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
  219. if (!is_method("ACK"))
  220. sl_send_reply("403","Preload Route denied");
  221. exit;
  222. }
  223.  
  224. # record routing
  225. if (!is_method("REGISTER|MESSAGE"))
  226. record_route();
  227.  
  228. if (!uri==myself)
  229. {
  230. append_hf("P-hint: outbound\r\n");
  231. route(1);
  232. }
  233.  
  234. # requests for my domain
  235.  
  236. if (is_method("PUBLISH"))
  237. {
  238. sl_send_reply("503", "Service Unavailable");
  239. exit;
  240. }
  241.  
  242.  
  243. if (is_method("REGISTER"))
  244. {
  245. # authenticate the REGISTER requests (uncomment to enable auth)
  246. if (!www_authorize("", "subscriber"))
  247. {
  248. www_challenge("", "0");
  249. exit;
  250. }
  251.  
  252. if (!db_check_to())
  253. {
  254. sl_send_reply("403","Forbidden auth ID");
  255. exit;
  256. }
  257.  
  258. if (!save("location"))
  259. sl_reply_error();
  260.  
  261. exit;
  262. }
  263.  
  264. if ($rU==NULL) {
  265. # request with no Username in RURI
  266. sl_send_reply("484","Address Incomplete");
  267. exit;
  268. }
  269.  
  270. # do lookup with method filtering
  271. if (!lookup("location","m")) {
  272. switch ($retcode) {
  273. case -1:
  274. case -3:
  275. t_newtran();
  276. t_reply("404", "Not Found");
  277. exit;
  278. case -2:
  279. sl_send_reply("405", "Method Not Allowed");
  280. exit;
  281. }
  282. }
  283.  
  284. route(1);
  285. }
  286.  
  287. route[1] {
  288. # for INVITEs enable some additional helper routes
  289. if (is_method("INVITE")) {
  290. t_on_branch("2");
  291. t_on_reply("2");
  292. t_on_failure("1");
  293. }
  294.  
  295. if (!t_relay()) {
  296. sl_reply_error();
  297. };
  298. exit;
  299. }
  300.  
  301. branch_route[2] {
  302. xlog("new branch at $ru\n");
  303. }
  304.  
  305. onreply_route[2] {
  306. xlog("incoming reply\n");
  307. }
  308.  
  309. failure_route[1] {
  310. if (t_was_cancelled()) {
  311. exit;
  312. }
  313. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement