### LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR debug=3 log_stderror=no memdbg=5 memlog=5 log_facility=LOG_LOCAL0 fork=yes children=4 /* uncomment the next line to disable TCP (default on) */ #disable_tcp=yes /* uncomment the next line to disable the auto discovery of local aliases based on reverse DNS on IPs (default on) */ #auto_aliases=no /* add local domain aliases */ alias=ALIAS /* uncomment and configure the following line if you want Kamailio to bind on a specific interface/port/proto (default bind on all available) */ mhomed=1 listen=VTRAN:VIP:VPORT listen=tcp:CCEIP:CCEPORT #/* port to listen to # * - can be specified more than once if needed to listen on many ports */ #port=5060 #enable_tls=yes # life time of TCP connection when there is no traffic # - a bit higher than registration expires to cope with UA behind NAT #tcp_connection_lifetime=3605 ####### Modules Section ######## mpath="/usr/local/lib64/kamailio/modules/" loadmodule "db_mysql.so" loadmodule "ipops.so" loadmodule "mi_fifo.so" loadmodule "kex.so" loadmodule "corex.so" loadmodule "tm.so" loadmodule "tmx.so" loadmodule "sl.so" loadmodule "rr.so" loadmodule "pv.so" loadmodule "maxfwd.so" loadmodule "textops.so" loadmodule "siputils.so" loadmodule "xlog.so" loadmodule "sanity.so" loadmodule "ctl.so" loadmodule "cfg_rpc.so" loadmodule "mi_rpc.so" loadmodule "uac.so" loadmodule "rtpproxy.so" loadmodule "dialog.so" #loadmodule "tls.so" # ----------------- setting module-specific parameters --------------- modparam("dialog", "dlg_flag", 1) modparam("dialog", "track_cseq_updates", 1) # ----- uac params ----- modparam("uac", "reg_db_url", "mysql://localhost/kamailio") modparam("uac","auth_username_avp","$avp(auser)") modparam("uac","auth_password_avp","$avp(apass)") modparam("uac","auth_realm_avp","$avp(arealm)") #modparam("uac", "reg_timer_interval", 60) #modparam("uac", "reg_retry_interval", 60) modparam("uac", "reg_db_table", "uacreg") modparam("uac", "reg_contact_addr", "VIP:5060") # ----- tm params ----- # auto-discard branches from previous serial forking leg modparam("tm", "failure_reply_mode", 3) # default retransmission timeout: 30sec modparam("tm", "fr_timer", 30000) # default invite retransmission timeout after 1xx: 120sec modparam("tm", "fr_inv_timer", 120000) # ----- rr params ----- # set next param to 1 to add value to ;lr param (helps with some UAs) modparam("rr", "enable_full_lr", 0) # do not append from tag to the RR (no need for this script) modparam("rr", "append_fromtag", 1) # ----- rtpproxy params ----- modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722") #!ifdef WITH_TLS # ----- tls params ----- #modparam("tls", "config", "/etc/kamailio/tls.cfg") #!endif #!ifdef WITH_DEBUG # ----- debugger params ----- modparam("debugger", "cfgtrace", 1) modparam("debugger", "log_level_name", "exec") #!endif ####### Routing Logic ######## # Main SIP request routing logic # - processing of any incoming SIP request starts with this route # - note: this is the same as route { ... } route { dlg_manage(); t_on_failure("TRUNKAUTH"); # chaeck for options if(uri==myself) { if ((method==OPTIONS) && (! uri=~"sip:.*[@]+.*")) { options_reply(); exit(); } } # per request initial checks route(REQINIT); # do media anchoring route(RTPPROXY); # handle requests within SIP dialogs route(WITHINDLG); ### only initial requests (no To tag) # CANCEL processing if (is_method("CANCEL")) { if (t_check_trans()) t_relay(); exit; } t_check_trans(); # record routing for dialog forming requests (in case they are routed) # - remove preloaded route headers remove_hf("Route"); if (is_method("INVITE|SUBSCRIBE")) record_route(); # handle registrations route(REGISTRAR); if ($rU==$null) { # request with no Username in RURI sl_send_reply("484","Address Incomplete"); exit; } # dispatch destinations route(DISPATCH); } failure_route[TRUNKAUTH] { if (t_is_canceled()) { exit; } if(t_check_status("401|407")) { $avp(arealm) = "AUTH_REALM"; $avp(auser) = "AUTH_USER"; $avp(apass) = "AUTH_PASS"; if (uac_auth()) { xlog("L_INFO", "CSeq diff: $dlg_var(cseq_diff)"); t_relay(); } else { xlog("L_INFO", "UAC_AUTH(): credentials not found"); } exit; } } # Per SIP request initial checks route[REQINIT] { if (!mf_process_maxfwd_header("10")) { sl_send_reply("483","Too Many Hops"); exit; } if(!sanity_check("1511", "7")) { xlog("Malformed SIP message from $si:$sp\n"); exit; } } # Handle requests within SIP dialogs route[WITHINDLG] { 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 } if(is_method("PRACK")) { $var(rack_sequ) = $(hdr(Rack){s.select,0, }{s.int}); $var(rack_meth) = $(hdr(Rack){s.select,2, }); $var(new_rack_cseq) = $(hdr(Rack){s.select,1, }{s.int}) + $(dlg_var(cseq_diff){s.int}); remove_hf("RAck"); insert_hf("RAck: $var(rack_sequ) $var(new_rack_cseq) $var(rack_meth)\r\n"); } route(DISPATCH); } else { if (is_method("SUBSCRIBE") && uri == myself) { # in-dialog subscribe requests exit; } if ( is_method("ACK") ) { if ( t_check_trans() ) { # non loose-route, but stateful ACK; # must be ACK after a 487 or e.g. 404 from upstream server t_relay(); exit; } else { # ACK without matching transaction ... ignore and discard. exit; } } sl_send_reply("404","Not here"); } exit; } } # Handle SIP registrations route[REGISTRAR] { if(!is_method("REGISTER")) return; sl_send_reply("404", "No registrar"); exit; } # Dispatch requests route[DISPATCH] { if(dst_ip == VIP ) { $rd = "MEDIATION_FQDN"; $rp = "MEDIATION_PORT"; $td = $rd; if(!t_relay_to_tcp()) { sl_reply_error(); } } else { $rd = "TRUNK_DOMAIN"; $td = $rd; $du = "sip:SBC_SRV"; remove_hf("Privacy"); remove_hf("P-Asserted-Identity"); subst('/^From:(.*)sip:([^@]*)@([a-zA-Z0-9.]+?)(.*)$/From:\1sip:\2@\3;otg=TRUNK_OTG\4/ig'); if (!t_relay()) { sl_reply_error(); } } exit; } # RTPProxy control route[RTPPROXY] { if (is_method("INVITE")){ if(dst_ip == VIP ) { rtpproxy_manage("rwei"); } else { rtpproxy_manage("rwie"); } } return; } onreply_route { if (af==INET) { rtpproxy_manage("cwei"); } return(1); }