diff --git a/kamailio.cfg b/kamailio.cfg index 6d98bc3..4f8f5c6 100644 --- a/kamailio.cfg +++ b/kamailio.cfg @@ -5,7 +5,7 @@ loadmodule "rr.so" loadmodule "maxfwd.so" loadmodule "textops.so" loadmodule "rtpengine.so" -#loadmodule "dispatcher.so" +loadmodule "dispatcher.so" loadmodule "nathelper.so" loadmodule "ctl" loadmodule "pv" @@ -25,9 +25,9 @@ log_facility=LOG_LOCAL0 # RTPProxy settings modparam("rtpengine", "rtpengine_sock", "udp:127.0.0.1:2223") # Dispatcher settings -#modparam("dispatcher", "db_url", "mysql://kamailio:kamailiow@localhost/kamailio") +modparam("dispatcher", "db_url", "mysql://kamailio:kamailiow@localhost/kamailio") #modparam("dispatcher", "ds_ping_interval", 10) -#modparam("dispatcher", "ds_ping_method", "OPTIONS") +#modparam("dispatcher", "ds_ping_method", "REGISTER") #modparam("dispatcher", "ds_probing_threshold", 10) #modparam("dispatcher", "ds_inactive_threshold", 10) #modparam("dispatcher", "ds_ping_latency_stats", 1) @@ -45,10 +45,16 @@ modparam("uac","auth_realm_avp","$avp(arealm)") # TM settings modparam("tm", "auto_inv_100_reason", "Trying") + + /* Main SIP request routing logic * - processing of any incoming SIP request starts with this route * - note: this is the same as route { ... } */ request_route { + # Variables + $avp(customerpbxip)="10.0.5.4"; + $avp(sip1)="10.0.5.7"; + $avp(sip2)="10.0.5.5"; # per request initial checks route(REQINIT); @@ -110,17 +116,19 @@ route[RELAY] { } # update $du to set the destination address for proxying based on caller IP - if ($siz=="10.0.5.7") { + if ($siz==$avp(sip1) || $siz==$avp(sip2)) { xlog("Incomming call from SIP provider"); - $du = "sip:" + "10.0.5.4"; +# $du = "sip:" + "10.0.5.4"; + $du = "sip:" + $avp(customerpbxip); } else { xlog("Incomming call from Customer PBX"); - $du = "sip:" + "10.0.5.7"; + # $du = "sip:" + "10.0.5.7"; + ds_select_dst("1","9"); } - if ($siz=="10.0.5.5") { - xlog("Incomming call from SIP provider2"); - $du = "sip:" + "10.0.5.4"; - } +# if ($siz=="10.0.5.5") { +# xlog("Incomming call from SIP provider2"); +# $du = "sip:" + "10.0.5.4"; +# } # If auth is required perform it t_on_failure("TRUNKAUTH"); # Relay