Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # $Id: opensips.cfg 5503 2009-03-22 16:22:32Z bogdan_iancu $
- #
- # Copyright 2010 Voice System
- #
- # This file is part of opensip LiveCD.
- #
- # opensips LiveCD is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version
- #
- # opensips LiveCD is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- #
- # Please refer to the Core CookBook at:
- # http://www.opensips.org/Resources/DocsCookbooks
- # for a explanation of possible statements, functions and parameters.
- #
- ####### Global Parameters #########
- debug=3
- log_stderror=no
- log_facility=LOG_LOCAL0
- fork=yes
- children=4
- /* uncomment the following lines to enable debugging */
- #debug=9
- #log_stderror=yes
- listen=udp:192.168.26.5:5060
- ####### Modules Section ########
- #set module path
- mpath="/lib/opensips/modules/"
- loadmodule "db_mysql.so"
- loadmodule "signaling.so"
- loadmodule "sl.so"
- loadmodule "tm.so"
- loadmodule "rr.so"
- loadmodule "maxfwd.so"
- loadmodule "usrloc.so"
- loadmodule "registrar.so"
- loadmodule "textops.so"
- loadmodule "mi_fifo.so"
- loadmodule "uri.so"
- loadmodule "acc.so"
- loadmodule "auth.so"
- loadmodule "auth_db.so"
- loadmodule "alias_db.so"
- loadmodule "domain.so"
- loadmodule "group.so"
- loadmodule "drouting.so"
- loadmodule "dialog.so"
- loadmodule "avpops.so"
- loadmodule "dialplan.so"
- loadmodule "nathelper.so"
- loadmodule "mi_xmlrpc.so"
- loadmodule "presence.so"
- loadmodule "presence_xml.so"
- # ----------------- setting module-specific parameters ---------------
- # ----- mi_fifo params -----
- modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
- modparam("mi_fifo", "fifo_mode", 0666)
- # ----- rr params -----
- # add value to ;lr param to cope with most of the UAs
- #modparam("rr", "enable_full_lr", 1)
- # do not append from tag to the RR (no need for this script)
- modparam("rr", "append_fromtag", 0)
- # ----- usrloc params -----
- modparam("usrloc", "db_mode", 2)
- modparam("usrloc", "db_url",
- "mysql://opensips:opensipsrw@127.0.0.1/opensips")
- # ----- acc params -----
- modparam("acc", "early_media", 0)
- modparam("acc", "report_ack", 0)
- modparam("acc", "report_cancels", 0)
- modparam("acc", "detect_direction", 0)
- modparam("acc", "failed_transaction_flag", 3)
- modparam("acc", "db_flag", 1)
- modparam("acc", "db_missed_flag", 2)
- modparam("acc", "db_url",
- "mysql://opensips:opensipsrw@127.0.0.1/opensips")
- modparam("acc", "db_extra", "caller_id=$avp(s:caller);callee_id=$avp(s:callee)")
- # ----- auth_db params -----
- modparam("auth_db", "calculate_ha1", yes)
- modparam("auth_db", "password_column", "password")
- modparam("auth_db", "db_url",
- "mysql://opensips:opensipsrw@127.0.0.1/opensips")
- # ----- alias_db params -----
- modparam("alias_db", "db_url",
- "mysql://opensips:opensipsrw@127.0.0.1/opensips")
- # ----- domain params -----
- modparam("domain", "db_url",
- "mysql://opensips:opensipsrw@127.0.0.1/opensips")
- modparam("domain", "db_mode", 1) # Use caching
- # ----- group parameters ---- #
- modparam("group", "use_domain", 1)
- modparam("group", "table", "grp")
- modparam("group", "db_url",
- "mysql://opensips:opensipsrw@127.0.0.1/opensips")
- # ----- multi-module params -----
- modparam("auth_db|usrloc|uri_db", "use_domain", 1)
- # ----- drouting params -----
- modparam("drouting", "use_domain", 1)
- modparam("drouting","db_url",
- "mysql://opensips:opensipsrw@localhost/opensips")
- # ---- dialplan params ----
- modparam("auth_db", "load_credentials", "")
- modparam("dialplan", "db_url",
- "mysql://opensips:opensipsrw@localhost/opensips")
- ## attribute of the matched line will be store in the $avp(s:dest)
- modparam("dialplan", "attrs_pvar", "$avp(s:dest)")
- #------ avpops params -----
- modparam("avpops", "db_url",
- "mysql://opensips:opensipsrw@localhost/opensips")
- modparam("avpops", "avp_table", "usr_preferences")
- #------ tm params ----
- modparam("tm", "fr_inv_timer",20)
- modparam("tm", "fr_timer", 5)
- #------ nat parameters ----
- modparam("registrar","received_avp", "$avp(i:42)")
- modparam("usrloc","nat_bflag", 6)
- modparam("nathelper","received_avp", "$avp(i:42)")
- modparam("nathelper", "natping_interval", 5)
- modparam("nathelper", "ping_nated_only", 1)
- modparam("nathelper", "sipping_bflag", 7)
- modparam("nathelper", "sipping_from", "sip:pinger@192.168.26.5:5060")
- modparam("nathelper", "db_url",
- "mysql://opensips:opensipsrw@localhost/opensips")
- # ----- presence params -----
- modparam("presence|presence_xml", "db_url",
- "mysql://opensips:opensipsrw@localhost/opensips")
- modparam("presence_xml", "force_active", 1)
- modparam("presence", "server_address", "sip:192.168.26.5:5090")
- # ----- presence params -----
- modparam("dialog", "db_url",
- "mysql://opensips:opensipsrw@localhost/opensips")
- modparam("dialog", "dlg_match_mode", 1)
- modparam("dialog", "db_mode", 2)
- ####### Routing Logic ########
- # main request routing logic
- route{
- if (!mf_process_maxfwd_header("10")) {
- send_reply("483","Too Many Hops");
- exit;
- }
- #---- NAT Detection ----#
- force_rport();
- if (nat_uac_test("19")) {
- if (is_method("REGISTER")) {
- fix_nated_register();
- } else {
- fix_nated_contact();
- #---- Insert nat=yes at the end of the Contact header ----#
- #---- This helps with REINVITEs, ----#
- #--- nat=yes will be included in the R-URI for sequential requests ---#
- search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');
- }
- setflag(5);
- }
- #---- Sequential requests section ----#
- if (has_totag()) {
- # sequential request withing a dialog should
- # take the path determined by record-routing
- if (loose_route()) {
- if (is_method("BYE")) {
- setflag(1); # do accounting ...
- setflag(3); # ... even if the transaction fails
- } else if (is_method("INVITE")) {
- record_route();
- }
- route(generic_relay);
- } else {
- if (is_method("SUBSCRIBE") && $rd == "192.168.26.5") {
- # in-dialog subscribe requests
- route(presence_handling);
- exit;
- }
- if ( is_method("ACK") ) {
- if ( t_check_trans() ) {
- t_relay();
- exit;
- } else {
- exit;
- }
- }
- send_reply("404","Not here");
- }
- exit;
- }
- #---- initial requests section ----#
- if (is_method("CANCEL")) {
- if (t_check_trans())
- t_relay();
- exit;
- }
- #---- catch retransmissions ----#
- t_check_trans();
- #---- check request relaying ----#
- if ( !is_from_local() && !is_uri_host_local() ) {
- send_reply("403","No relaying");
- exit;
- }
- #---- authenticate caller if local ----#
- if (!is_method("REGISTER") && is_from_local()) {
- if(!is_from_gw()){
- if (!proxy_authorize("", "subscriber")) {
- proxy_challenge("", "0");
- exit;
- }
- if (!db_check_from()) {
- send_reply("403","Forbidden auth ID");
- exit;
- }
- consume_credentials();
- # caller authenticated
- }
- }
- #---- preloaded route checking ----#
- if (loose_route()) {
- xlog("L_ERR",
- "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
- if (!is_method("ACK"))
- send_reply("403","Preload Route denied");
- exit;
- }
- #---- record routing ----#
- if (!is_method("REGISTER|MESSAGE"))
- record_route();
- #---- account only INVITEs -----#
- if (is_method("INVITE")) {
- setflag(1); # do accounting
- $avp(s:caller) = $fu;
- create_dialog();
- }
- #---- Routing to external domains ----#
- if (!is_uri_host_local()) {
- $avp(s:callee) = $ru;
- route(generic_relay);
- exit;
- }
- #--- presence diversion ----#
- if (is_method("PUBLISH|SUBSCRIBE")) {
- route(presence_handling);
- exit;
- }
- #--- registration handling ----#
- if (is_method("REGISTER")) {
- # authenticate the REGISTER requests
- if (!www_authorize("", "subscriber")) {
- www_challenge("", "0");
- exit;
- }
- if (!db_check_to()) {
- send_reply("403","Forbidden auth ID");
- exit;
- }
- #---- Request is behind NAT(flag5) save with bflag 6 ----#
- #---- Use bflag 7 to start SIP pinging (Options) ----#
- if (isflagset(5)) {
- setbflag(6);
- setbflag(7);
- };
- if (!save("location"))
- sl_reply_error();
- exit;
- }
- if ($rU==NULL) {
- # request with no Username in RURI
- send_reply("484","Address Incomplete");
- exit;
- }
- # apply DB based aliases
- alias_db_lookup("dbaliases");
- #--- handle local numbers ----#
- if(!dp_translate("0","$ruri.user/$ruri.user")){
- send_reply("420", "Invalid Destination");
- exit;
- }
- xlog("$avp(s:dest)");
- $avp(s:callee) = $ru;
- if ($avp(s:dest)=="usrloc") {
- #Route to usrloc
- route(user_location);
- }
- if ($avp(s:dest)=="pstn") {
- #route to pstn
- route(pstn_routing);
- }
- if ($avp(s:dest)=="media") {
- #route to media server
- route(media_routing);
- }
- send_reply("420", "Invalid Extension");
- exit;
- }
- route[generic_relay] {
- # for INVITEs enable some additional helper routes
- #---- Helper route, if nat=yes in the R-URI set flag 6 ----#
- #---- This is used to Process REINVITES ----#
- if (subst_uri('/((sip:.*)||(sip:.*:.*));nat=yes/\1/')){
- setbflag(6);
- };
- #---- If caller(flag 5) or callee(flag 6) are behind NAT ---#
- #---- Call the route(6) to force the use of the RTP Proxy ---#
- if (isflagset(5)||isbflagset(6)) {
- route(nat_fixups);
- };
- if (!t_relay()) {
- sl_reply_error();
- };
- exit;
- }
- route[presence_handling]
- {
- if (!t_newtran()){
- sl_reply_error();
- exit;
- };
- if(is_method("PUBLISH")) {
- handle_publish();
- }
- else
- if( is_method("SUBSCRIBE")) {
- handle_subscribe();
- }
- exit;
- }
- route[user_location]{
- if (!lookup("location", "m")) {
- switch ($retcode) {
- case -1:
- case -3:
- t_newtran();
- send_reply("404", "Not Found");
- exit;
- case -2:
- send_reply("405", "Method Not Allowed");
- exit;
- }
- }
- # when routing via usrloc, log the missed calls also
- setflag(2); # Account missed calls
- t_on_failure("user_failure");
- route(generic_relay);
- }
- route[pstn_routing] {
- if (!db_is_user_in("from","pstn") ) {
- send_reply("403", "No pstn calls");
- exit;
- }
- if(!do_routing("0","0")){
- send_reply("503", "No destination for the prefix");
- exit;
- }
- t_on_failure("gw_failure");
- route(generic_relay);
- }
- route[media_routing] {
- #---- Route to media servers ----#
- #xlog("route to media servers");
- rewritehostport("192.168.26.5:5080");
- route(generic_relay);
- }
- route[nat_fixups] {
- #---- RTP Proxy handling ---#
- if (is_method("BYE|CANCEL")) {
- unforce_rtp_proxy();
- } else if (is_method("INVITE")){
- #---- Activates the RTP Proxy for the CALLEE ---#
- force_rtp_proxy();
- };
- # catch and fix replies
- t_on_reply("2");
- }
- onreply_route[2] {
- #xlog("incoming reply\n");
- #---- Handling of the SDP for the 200 or 183 reply ----#
- #---- If behind nat (flags 5 or 6) start RTP Proxy ----#
- #---- Activates the RTP Proxy for the CALLER ----#
- if ( is_method("INVITE") &&
- (isflagset(5) || isbflagset(6)) &&
- has_body("application/sdp") ){
- force_rtp_proxy();
- }
- #---- If the CALLEE is behind NAT, fix the CONTACT HF ----#
- if (isbflagset(6)) {
- fix_nated_contact();
- search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');
- }
- exit;
- }
- failure_route[user_failure] {
- #---- If a failure has ocurred, deactivate the RTP Proxy ----#
- if (isflagset(5) || isbflagset(6)){
- unforce_rtp_proxy();
- }
- if (t_was_cancelled()) {
- exit;
- }
- if ( db_is_user_in("from","voicemail") ) {
- # Redirect busy calls to a media server
- $ru = $avp(s:callee);
- sethostport("192.168.26.5:5080");
- t_relay();
- }
- }
- failure_route[gw_failure] {
- if (t_was_cancelled()) {
- exit;
- }
- if ( t_check_status("(56)[0-9][0-9]") ) {
- if (use_next_gw()) {
- xlog ("next gateway $ru \n");
- t_relay();
- exit;
- } else {
- t_reply("503", "Service not available, no more gws");
- exit;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement