hello<br><br>I am using kamailio with asterisk as gateway...<br><br>I found one way audio problem...<br><br>Please find attached log on pastbin... <a href="http://pastebin.com/f25e3f34a">http://pastebin.com/f25e3f34a</a><br>
<br>Here is my configuration file<br clear="all"><br><br>listen = <a href="http://sipstaging.testing.com">sipstaging.testing.com</a><br>port = 5060<br>mpath = "/lib/kamailio/modules"<br>#children = 8<br>debug = 7<br>
fork = yes<br>#group = "openser"<br>#user = "openser"<br>#disable_tcp = no<br>#log_facility = LOG_DAEMON<br>log_facility = LOG_LOCAL0<br>log_stderror = no<br>#tcp_children = 4<br>#mhomed = no<br>#server_signature = yes<br>
#sock_group = "openser"<br>#sock_mode = 0600<br>#sock_user = "openser"<br>#unix_sock = "/tmp/openser.sock"<br>#unix_sock_children = 1<br>#reply_to_via = no<br>#sip_warning = no<br>#check_via = no<br>
dns = no<br>rev_dns = no<br>#disable_core_dump = no<br>#dns_try_ipv6 = yes<br>#dns_use_search_list = yes<br><br>#Chandrakant<br>#loadmodule "exec.so"<br>#loadmodule "presence.so"<br>#modparam("presence", "db_url", "mysql://<a href="http://openser:openserrw@voicemailserver.testingpbx.com/openser">openser:openserrw@voicemailserver.testingpbx.com/openser</a>")<br>
#modparam("presence", "force_active", 1 );<br>#modparam("presence", "max_expires", 3600 )<br><br>#modparam("presence", "server_address", "sip:<a href="http://voicemailserver.testingpbx.com:5060">voicemailserver.testingpbx.com:5060</a>" )<br>
<br>#loadmodule "presence_mwi.so"<br><br><br>loadmodule "usrloc.so"<br>modparam("usrloc", "user_column", "username")<br>modparam("usrloc", "domain_column", "domain")<br>
modparam("usrloc", "contact_column", "contact")<br>modparam("usrloc", "expires_column", "expires")<br>modparam("usrloc", "q_column", "q")<br>
modparam("usrloc", "callid_column", "callid")<br>modparam("usrloc", "cseq_column", "cseq")<br>modparam("usrloc", "methods_column", "methods")<br>
modparam("usrloc", "flags_column", "flags")<br>modparam("usrloc", "user_agent_column", "user_agent")<br>modparam("usrloc", "received_column", "received")<br>
modparam("usrloc", "socket_column", "socket")<br>modparam("usrloc", "use_domain", 0)<br>modparam("usrloc", "desc_time_order", 0)<br>modparam("usrloc", "timer_interval", 60)<br>
modparam("usrloc", "db_url", "mysql://<a href="http://openser:openserrw@voicemailserver.testingpbx.com/openser">openser:openserrw@voicemailserver.testingpbx.com/openser</a>")<br>modparam("usrloc", "db_mode", 1)<br>
modparam("usrloc", "matching_mode", 0)<br>modparam("usrloc", "cseq_delay", 20)<br>modparam("usrloc", "nat_bflag", 6)<br><br>loadmodule "pv.so"<br><br>loadmodule "registrar.so"<br>
modparam("registrar", "default_expires", 3600)<br>modparam("registrar", "min_expires", 60)<br>modparam("registrar", "max_expires", 0)<br>modparam("registrar", "default_q", 0)<br>
modparam("registrar", "append_branches", 1)<br>modparam("registrar", "case_sensitive", 0)<br>modparam("registrar", "received_param", "received")<br>modparam("registrar", "max_contacts", 3)<br>
modparam("registrar", "retry_after", 0)<br>modparam("registrar", "method_filtering", 0)<br>modparam("registrar", "path_mode", 2)<br>modparam("registrar", "path_use_received", 0)<br>
modparam("registrar", "received_avp", "$avp(i:801)")<br><br>loadmodule "rr.so"<br>modparam("rr", "enable_full_lr", 0)<br>modparam("rr", "append_fromtag", 1)<br>
modparam("rr", "enable_double_rr", 1)<br>modparam("rr", "add_username", 0)<br><br>loadmodule "tm.so"<br>modparam("tm", "fr_timer", 3)<br>modparam("tm", "fr_inv_timer", 35)<br>
modparam("tm", "wt_timer", 5)<br>modparam("tm", "delete_timer", 2)<br>#modparam("tm", "noisy_ctimer", 1)<br>modparam("tm", "ruri_matching", 1)<br>
modparam("tm", "via1_matching", 1)<br>modparam("tm", "unix_tx_timeout", 2)<br>modparam("tm", "restart_fr_on_each_reply", 1)<br>modparam("tm", "pass_provisional_replies", 0)<br>
modparam("tm", "fr_inv_timer_avp", "$avp(s:callee_fr_inv_timer)")<br><br>loadmodule "xlog.so"<br>modparam("xlog", "buf_size", 4096)<br>modparam("xlog", "force_color", 0)<br>
<br>loadmodule "mi_fifo.so"<br>modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")<br>#modparam("mi_fifo", "fifo_mode", 0660)<br>#modparam("mi_fifo", "fifo_group", "openser")<br>
#modparam("mi_fifo", "fifo_user", "openser")<br>#modparam("mi_fifo", "reply_dir", "/tmp/")<br>#modparam("mi_fifo", "reply_indent", "\t")<br>
<br>loadmodule "domain.so"<br>modparam("domain", "db_url", "mysql://<a href="http://openser:openserrw@voicemailserver.testingpbx.com/openser">openser:openserrw@voicemailserver.testingpbx.com/openser</a>")<br>
modparam("domain", "db_mode", 1)<br>modparam("domain", "domain_table", "domain")<br>modparam("domain", "domain_col", "domain")<br><br>loadmodule "nathelper.so"<br>
modparam("nathelper", "natping_interval", 60)<br>modparam("nathelper", "ping_nated_only", 1)<br>modparam("nathelper", "rtpproxy_sock", "unix:/var/run/rtpproxy.sock")<br>
#modparam("nathelper", "rtpproxy_disable", 0)<br>modparam("nathelper", "rtpproxy_disable_tout", 60)<br>modparam("nathelper", "rtpproxy_tout", 1)<br>modparam("nathelper", "rtpproxy_retr", 5)<br>
modparam("nathelper", "sipping_method", "OPTIONS")<br>modparam("nathelper", "received_avp", "$avp(i:801)")<br><br>loadmodule "textops.so"<br><br>#loadmodule "uri.so"<br>
<br>loadmodule "sl.so"<br>modparam("sl", "enable_stats", 1)<br><br>loadmodule "maxfwd.so"<br>modparam("maxfwd", "max_limit", 256)<br><br>loadmodule "db_mysql.so"<br>
modparam("db_mysql", "ping_interval", 300)<br>modparam("db_mysql", "auto_reconnect", 1)<br><br>loadmodule "auth.so"<br>modparam("auth", "nonce_expire", 300)<br>
modparam("auth", "rpid_suffix", ";party=calling;id-type=subscriber;screen=yes")<br>modparam("auth", "rpid_avp", "$avp(s:rpid)")<br><br>loadmodule "auth_db.so"<br>
modparam("auth_db", "db_url", "mysql://<a href="http://openser:openserrw@voicemailserver.testingpbx.com/openser">openser:openserrw@voicemailserver.testingpbx.com/openser</a>")<br>modparam("auth_db", "user_column", "username")<br>
modparam("auth_db", "domain_column", "domain")<br>modparam("auth_db", "password_column", "password")<br>modparam("auth_db", "password_column_2", "ha1b")<br>
modparam("auth_db", "calculate_ha1", 1)<br>modparam("auth_db", "use_domain", 1)<br>modparam("auth_db", "load_credentials", "$avp(s:caller_uuid)=uuid")<br>
<br>loadmodule "uri_db.so"<br>modparam("uri_db", "db_url", "mysql://<a href="http://openser:openserrw@voicemailserver.testingpbx.com/openser">openser:openserrw@voicemailserver.testingpbx.com/openser</a>")<br>
#modparam("uri_db", "db_table", "uri")<br>#modparam("uri_db", "user_column", "username")<br>#modparam("uri_db", "domain_column", "domain")<br>
#modparam("uri_db", "uriuser_column", "uri_user")<br>#modparam("uri_db", "subscriber_table", "subscriber")<br>#modparam("uri_db", "subscriber_user_column", "username")<br>
#modparam("uri_db", "subscriber_domain_column", "domain")<br>#modparam("uri_db", "use_uri_table", 0)<br>#modparam("uri_db", "use_domain", 1)<br><br>loadmodule "avpops.so"<br>
modparam("avpops", "db_url", "mysql://<a href="http://openser:openserrw@voicemailserver.testingpbx.com/openser">openser:openserrw@voicemailserver.testingpbx.com/openser</a>")<br>modparam("avpops", "avp_table", "usr_preferences")<br>
modparam("avpops", "use_domain", 1)<br>modparam("avpops", "uuid_column", "uuid")<br>modparam("avpops", "username_column", "username")<br>modparam("avpops", "domain_column", "domain")<br>
modparam("avpops", "attribute_column", "attribute")<br>modparam("avpops", "value_column", "value")<br>modparam("avpops", "type_column", "type")<br>
<br>loadmodule "lcr.so"<br>modparam("lcr", "db_url", "mysql://<a href="http://openser:openserrw@voicemailserver.testingpbx.com/openser">openser:openserrw@voicemailserver.testingpbx.com/openser</a>")<br>
modparam("lcr", "gw_table", "gw")<br>modparam("lcr", "gw_name_column", "gw_name")<br>modparam("lcr", "ip_addr_column", "ip_addr")<br>
modparam("lcr", "port_column", "port")<br>modparam("lcr", "uri_scheme_column", "uri_scheme")<br>modparam("lcr", "transport_column", "transport")<br>
modparam("lcr", "grp_id_column", "grp_id")<br>modparam("lcr", "lcr_table", "lcr")<br>modparam("lcr", "strip_column", "strip")<br>modparam("lcr", "prefix_column", "prefix")<br>
modparam("lcr", "from_uri_column", "from_uri")<br>modparam("lcr", "priority_column", "priority")<br>modparam("lcr", "flags_avp", "$avp(i:712)")<br>
modparam("lcr", "gw_uri_avp", "$avp(i:1400)")<br>modparam("lcr", "ruri_user_avp", "$avp(i:1402)")<br>#modparam("lcr", "contact_avp", "$avp(1401)")<br>
modparam("lcr", "fr_inv_timer_avp", "$avp(s:fr_inv_timer_avp)")<br>modparam("lcr", "fr_inv_timer", 90)<br>modparam("lcr", "fr_inv_timer_next", 30)<br>modparam("lcr", "rpid_avp", "$avp(s:rpid)")<br>
<br>loadmodule "alias_db.so"<br>modparam("alias_db", "db_url", "mysql://<a href="http://openser:openserrw@voicemailserver.testingpbx.com/openser">openser:openserrw@voicemailserver.testingpbx.com/openser</a>")<br>
modparam("alias_db", "user_column", "username")<br>modparam("alias_db", "domain_column", "domain")<br>modparam("alias_db", "alias_user_column", "alias_username")<br>
modparam("alias_db", "alias_domain_column", "alias_domain")<br>modparam("alias_db", "use_domain", 0)<br><br>loadmodule "uac.so"<br>modparam("uac", "rr_store_param", "vsf")<br>
modparam("uac", "from_restore_mode", "auto")<br>modparam("uac", "from_passwd", "s1p:Wiz4rd!")<br><br>loadmodule "acc.so"<br>modparam("acc", "db_url", "mysql://<a href="http://openser:openserrw@voicemailserver.testingpbx.com/openser">openser:openserrw@voicemailserver.testingpbx.com/openser</a>")<br>
# flag to record to db<br>modparam("acc", "db_flag", 1)<br>modparam("acc", "db_missed_flag", 2)<br># flag to log to syslog<br>modparam("acc", "log_flag", 1)<br>modparam("acc", "log_missed_flag", 2)<br>
# use extra accounting to record caller and callee username/domain<br># - take them from From URI and R-URI<br>modparam("acc", "log_extra", "src_user=$fU;src_domain=$fd;dst_user=$rU;dst_domain=$rd")<br>
modparam("acc", "db_extra", "src_user=$fU;src_domain=$fd;dst_user=$rU;dst_domain=$rd")<br><br>#loadmodule "nat_traversal.so"<br>########################################################################<br>
# Request route 'main'<br>########################################################################<br>route[0]<br>{<br>xlog("L_INFO","***** IN route[0]\n");<br> xlog("L_INFO", "New request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
force_rport();<br> if(msg:len > max_len)<br> {<br> <br> xlog("L_INFO", "Message too big - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> sl_send_reply("513", "Message Too Big");<br>
xlog("L_INFO","***** OUT route[0.1]\n");<br> exit;<br> }<br> if (!mf_process_maxfwd_header("10"))<br> {<br> <br> xlog("L_INFO", "Too many hops - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
sl_send_reply("483", "Too Many Hops");<br>xlog("L_INFO","***** OUT route[0.2]\n");<br> exit;<br> }<br> if(!is_method("REGISTER"))<br> {<br> if(nat_uac_test("19"))<br>
{<br> record_route(";nat=yes");<br> }<br> else<br> {<br> record_route();<br> }<br> }<br> # allow NOTIFY messages only from the Asterisk server<br># if (is_method("NOTIFY")) {<br>
# if (!t_relay()) {<br># sl_reply_error();<br># exit;<br># }<br> # }<br> <br><br> if (is_method("SUBSCRIBE")) {<br>
# challenge/response<br> if (!www_authorize("", "subscriber")) {<br> www_challenge("", "0");<br>xlog("L_INFO","***** OUT route[0.3]\n");<br>
exit;<br> }<br><br> # notify the Asterisk server to update the UAs MWI. I<br> # believe most UAs that support SUBSCRIBE will <br> # periodically send a SUBSCRIBE message. These cause<br>
# the Asterisk server to update their MWI.<br># xlog("L_INFO","******************************** $ru\n" );<br># exec_msg("/usr/bin/mwi/subscribe $ru");<br> exit;<br>
xlog("L_INFO","***** OUT route[0.4]\n");<br> }<br><br> if(is_method("CANCEL") || is_method("BYE"))<br> {<br> unforce_rtp_proxy();<br><br> }<br> if(loose_route())<br>
{<br> # if(!has_totag())<br> # {<br> # <br> # xlog("L_INFO", "Initial loose-routing rejected - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> # sl_send_reply("403", "Initial Loose-Routing Rejected");<br>
# exit;<br> # }<br> if(nat_uac_test("19") || search("^Route:.*;nat=yes"))<br> {<br> fix_nated_contact();<br> setbflag(6);<br> }<br> <br>
route(8);<br> }<br> if(is_method("REGISTER"))<br> {<br> route(7);<br> }<br> if(is_method("INVITE"))<br> {<br> route(9);<br> }<br> if(is_method("CANCEL") || is_method("ACK"))<br>
{<br> route(13);<br> }<br> <br> route(14);<br>xlog("L_INFO","***** OUT route[0]\n");<br>}<br><br>########################################################################<br># Request route 'clear-usr-preferences-caller'<br>
########################################################################<br>route[1]<br>{<br>xlog("L_INFO","***** IN route[1]\n");<br> xlog("L_INFO", "Clear caller preferences - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
avp_delete("$avp(s:caller_cli)/g");<br> avp_delete("$avp(s:clir)/g");<br>xlog("L_INFO","***** OUT route[1]\n"); <br>}<br><br>########################################################################<br>
# Request route 'clear-usr-preferences-callee'<br>########################################################################<br>route[2]<br>{<br>xlog("L_INFO","***** IN route[2]\n");<br> xlog("L_INFO", "Clear callee preferences - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
avp_delete("$avp(s:callee_fr_inv_timer)/g");<br> avp_delete("$avp(s:cfu)/g");<br> avp_delete("$avp(s:cfc)/g");<br>xlog("L_INFO","***** OUT route[2]\n");<br>}<br>
<br>########################################################################<br># Request route 'usr-preferences-caller'<br>########################################################################<br>route[3]<br>{<br>
xlog("L_INFO","***** IN route[3]\n");<br> route(1);<br> xlog("L_INFO", "Load caller preferences for uuid '$avp(s:caller_uuid)' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
# load caller avps<br> avp_db_load("$avp(s:caller_uuid)", "*");<br> avp_copy("$avp(s:cli)", "$avp(s:caller_cli)/d");<br> if(is_avp_set("$avp(s:clir)/n") && avp_check("$avp(s:clir)", "eq/i:1"))<br>
{<br> # mark for anonymization<br> setflag(28);<br> }<br>xlog("L_INFO","***** OUT route[3]\n");<br>}<br><br>########################################################################<br>
# Request route 'usr-preferences-callee'<br>########################################################################<br>route[4]<br>{<br>xlog("L_INFO","***** IN route[4]\n");<br> xlog("L_INFO", "Load callee preferences for uuid '$avp(s:callee_uuid)' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
# load callee avps<br> avp_db_load("$avp(s:callee_uuid)", "*");<br> if(is_avp_set("$avp(s:cfu)/s"))<br> {<br> <br> xlog("L_INFO", "Call-forward-unconditional to '$avp(s:cfu)' found - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
avp_delete("$avp(s:caller_uuid)/g");<br> avp_copy("$avp(s:callee_uuid)", "$avp(s:caller_uuid)/d");<br> avp_pushto("$ru", "$avp(s:cfu)");<br> <br>
route(3);<br> route(10);<br>xlog("L_INFO","***** OUT route[4.1]\n");<br> exit;<br> }<br> if(is_avp_set("$avp(s:ringtimeout)/n"))<br> {<br> <br> xlog("L_INFO", "Setting ring timeout to $avp(s:ringtimeout) secs - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
avp_copy("$avp(s:ringtimeout)", "$avp(s:callee_fr_inv_timer)/d");<br> }<br>xlog("L_INFO","***** OUT route[4]\n");<br>}<br><br>########################################################################<br>
# Request route 'clir'<br>########################################################################<br>route[5]<br>{<br>xlog("L_INFO","***** IN route[5]\n");<br> if(isflagset(28) && !isflagset(27))<br>
{<br> setflag(27);<br> <br> xlog("L_INFO", "Anonymize caller - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> uac_replace_from("Anonymous","sip:anonymous@anonymous.invalid");<br>
if(is_present_hf("Privacy"))<br> {<br> remove_hf("Privacy");<br> }<br> append_hf("Privacy: id\r\n");<br> }<br>xlog("L_INFO","***** OUT route[5]\n");<br>
}<br><br>########################################################################<br># Request route 'stop-rtp-proxy'<br>########################################################################<br>route[6]<br>{<br>
xlog("L_INFO","***** IN route[6]\n");<br> if(isflagset(22))<br> {<br> unforce_rtp_proxy();<br> }<br>xlog("L_INFO","***** OUT route[6]\n");<br>}<br><br>########################################################################<br>
# Request route 'base-route-register'<br>########################################################################<br>route[7]<br>{<br>xlog("L_INFO","***** IN route[7]\n");<br> sl_send_reply("100", "Trying");<br>
if(!www_authorize("", "subscriber")) <br> {<br> <br> xlog("L_INFO", "Register authentication failed - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> www_challenge("", "0");<br>
xlog("L_INFO","***** OUT route[7.1]\n");<br> exit;<br> }<br> if(!check_to()) <br> {<br> <br> xlog("L_INFO", "Spoofed To-URI detected - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
sl_send_reply("403", "Spoofed To-URI Detected");<br>xlog("L_INFO","***** OUT route[7.2]\n");<br> exit;<br> }<br> consume_credentials();<br> if(!search("^Contact:[ ]*\*") && nat_uac_test("19")) <br>
{<br> fix_nated_register();<br> setbflag(6);<br> }<br> if(!save("location")) <br> {<br> <br> xlog("L_ERR", "Saving contact failed - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
sl_reply_error();<br>xlog("L_INFO","***** OUT route[7.3]\n");<br> exit;<br> }<br> <br> xlog("L_INFO", "Registration successful - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
xlog("L_INFO","***** OUT route[7]\n");<br> exit;<br> <br>}<br><br>########################################################################<br># Request route 'base-outbound'<br>########################################################################<br>
route[8]<br>{<br>xlog("L_INFO","***** IN route[8]\n");<br> if(is_present_hf("P-Asserted-Identity"))<br> {<br> remove_hf("P-Asserted-Identity");<br> }<br> if(is_present_hf("Remote-Party-ID"))<br>
{<br> remove_hf("Remote-Party-ID");<br> }<br> if(is_avp_set("$avp(s:caller_cli)/s"))<br> {<br> if(!isflagset(28))<br> {<br> <br> xlog("L_INFO", "Set caller CLI '$avp(s:caller_cli)' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
append_hf("P-Asserted-Identity: <$avp(s:caller_cli)>\r\n");<br> }<br> }<br> <br> route(5);<br> if(isbflagset(6))<br> {<br> if(!isflagset(22) && !search("^Content-Length:[ ]*0"))<br>
{<br> setflag(22);<br> force_rtp_proxy();<br> }<br> <br> t_on_reply("2");<br> }<br> else<br> {<br> <br> t_on_reply("1");<br> }<br>
if(!isflagset(21))<br> {<br> <br> t_on_failure("2");<br> }<br> if(isflagset(29))<br> {<br> append_branch();<br> }<br> if(is_present_hf("Proxy-Authorization"))<br>
{<br> consume_credentials();<br> }<br> <br> xlog("L_INFO", "Request leaving server, D-URI='$du' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> # no 100 (we already sent it) and no DNS blacklisting<br>
if(!t_relay("0x05"))<br> {<br> sl_reply_error();<br> if(is_method("INVITE") && isbflagset(6))<br> {<br> unforce_rtp_proxy();<br> }<br> }<br>xlog("L_INFO","***** OUT route[8]\n");<br>
exit;<br> <br>}<br><br>########################################################################<br># Request route 'base-route-invite'<br>########################################################################<br>
route[9]<br>{<br>xlog("L_INFO","***** IN route[9]\n");<br> sl_send_reply("100", "Trying");<br> if(from_gw())<br> {<br> $avp(s:caller_uuid)="0";<br> <br>
xlog("L_INFO", "Call from PSTN' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> setflag(23);<br> $avp(s:ringtimeout)=1000;<br> <br> route(3);<br> if(nat_uac_test("19"))<br>
{<br> fix_nated_contact();<br> setbflag(6);<br> }<br><br> route(51); <br> }<br> else<br> {<br> if(!proxy_authorize("", "subscriber")) <br>
{<br> <br> xlog("L_INFO", "Proxy authentication failed - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> proxy_challenge("", "0");<br>xlog("L_INFO","***** OUT route[9.1]\n");<br>
exit;<br> }<br> if(!check_from()) <br> {<br> <br> xlog("L_INFO", "Spoofed From-URI detected - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> sl_send_reply("403", "Spoofed From-URI Detected");<br>
xlog("L_INFO","***** OUT route[9.2]\n");<br> exit;<br> }<br> <br> route(3);<br> if(nat_uac_test("19"))<br> {<br> fix_nated_contact();<br>
setbflag(6);<br> }<br> route(10);<br> }<br> <br># route(3);<br># if(nat_uac_test("19")) <br># {<br># fix_nated_contact();<br># setbflag(6);<br>
# }<br> <br># route(10);<br>xlog("L_INFO","***** OUT route[9]\n");<br>}<br><br>########################################################################<br># Request route 'invite-find-callee'<br>
########################################################################<br>route[10]<br>{<br> xlog("L_INFO","***** IN route[10]\n");<br> if(alias_db_lookup("dbaliases"))<br> {<br> <br>
xlog("L_INFO", "Callee was aliased - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> }<br> <br> route(2);<br> if(!is_domain_local("$rd"))<br> {<br> setflag(20);<br>
$avp(s:callee_uuid) = "0";<br> route(12);<br> }<br> avp_delete("$avp(s:callee_uuid)");<br> avp_db_query("select uuid from subscriber where username = '$rU'", "$avp(s:callee_uuid)");<br>
if(is_avp_set("$avp(s:callee_uuid)/s"))<br> {<br> <br> xlog("L_INFO", "Callee is local, uuid='$avp(s:callee_uuid)' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
route(11);<br> }<br> else<br> {<br> $avp(s:callee_uuid) = "0";<br> <br> xlog("L_INFO", "Callee is not local - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
<br> xlog("L_INFO", ">>>>>>>>>>>>>>>>>>>>LENGTH - STORED = $var(X) RURI=$rU len=$(rU{s.len}) \n");<br> if($rU=="*86")<br>
{<br> route(12);<br> }<br> else<br> {<br> if($(rU{s.len})<=7)<br> {<br> route(11);<br>
}<br> else<br> {<br> route(12);<br> }<br> }<br><br> }<br>xlog("L_INFO","***** OUT route[10]\n");<br>
exit;<br> <br>}<br><br>########################################################################<br># Request route 'invite-to-internal'<br>########################################################################<br>
<br>route[11]<br>{<br>xlog("L_INFO","***** IN route[11]\n");<br> route(4);<br><br> revert_uri();<br> seturi("sip:*<a href="mailto:89@openser.org">89@openser.org</a>");<br><br><br> rewritehostport("<a href="http://voicemailserver.testingpbx.com:5060">voicemailserver.testingpbx.com:5060</a>");<br>
route(8);<br><br> #if(!lookup("location")) <br> #{<br> <br> # xlog("L_INFO", "Local user offline - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> # sl_send_reply("404", "User Offline");<br>
# route(50);<br> #}<br> #else<br> #{<br> <br> # xlog("L_INFO", "Local user online - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> # #route(8);<br> # route(50);<br>
#}<br><br> xlog("L_INFO","***** OUT route[11]\n");<br> exit;<br> <br>}<br><br>##############################<br># TEST ROUTE 51<br>###########################<br>route[51]<br>{<br> if(alias_db_lookup("dbaliases"))<br>
{<br> <br> xlog("L_INFO", "Callee was aliased - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> }<br> <br> route(2);<br> if(!is_domain_local("$rd"))<br> {<br>
setflag(20);<br> $avp(s:callee_uuid) = "0";<br> <br> route(12);<br> }<br> avp_delete("$avp(s:callee_uuid)");<br> avp_db_query("select uuid from subscriber where username = '$rU'", "$avp(s:callee_uuid)");<br>
if(is_avp_set("$avp(s:callee_uuid)/s"))<br> {<br> <br> xlog("L_INFO", "Callee is local, uuid='$avp(s:callee_uuid)' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
route(52);<br> }<br> else<br> {<br> $avp(s:callee_uuid) = "0";<br> <br> xlog("L_INFO", "Callee is not local - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
route(12);<br> }<br> exit;<br> <br>}<br><br>##########################<br>#TEST 52<br>##############################<br>route[52]<br>{<br> route(4);<br> if(!lookup("location")) <br> {<br>
<br> xlog("L_INFO", "Local user offline - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> sl_send_reply("404", "User Offline");<br> }<br> else<br> {<br>
<br> xlog("L_INFO", "Local user online - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> route(8);<br> }<br> exit;<br> <br>}<br>########################################################################<br>
# Request route 'invite-to-external'<br>########################################################################<br>route[12]<br>{<br>xlog("L_INFO","***** IN route[12]\n");<br> if(isflagset(20))<br>
{<br> <br> xlog("L_INFO", "Call to foreign domain - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> route(8);<br>xlog("L_INFO","***** OUT route[12.1]\n");<br>
exit;<br> }<br> if(!isflagset(23))<br> {<br> <br> if(uri =~ "^sip:\*86@.*")<br> {<br> xlog("L_INFO", "User accessing Voicemail - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
rewritehostport("<a href="http://voicemailserver.testingpbx.com:5060">voicemailserver.testingpbx.com:5060</a>");<br> route(8);<br> }<br><br><br> # don't allow calls relaying from PSTN to PSTN, if not explicitely forwarded<br>
<br> else if(uri =~ "^sip:[0-9]+@")<br> { <br> # only route numeric users to PSTN<br> if(!load_gws())<br> {<br> <br> xlog("L_ERR", "Error loading PSTN gateways - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
sl_send_reply("503", "PSTN Termination Currently Unavailable");<br> xlog("L_INFO","***** OUT route[12.2]\n");<br> exit;<br> }<br>
if(!next_gw())<br> {<br> <br> xlog("L_ERR", "No PSTN gateways available - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> sl_send_reply("503", "PSTN Termination Currently Unavailable");<br>
xlog("L_INFO","***** OUT route[12.3]\n");<br> exit;<br> }<br> setflag(21);<br> t_on_failure("1");<br> route(8);<br><br>
}<br> }<br> <br> xlog("L_INFO", "Call to unknown user - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> sl_send_reply("404", "User Not Found");<br> xlog("L_INFO","***** OUT route[12]\n");<br>
exit;<br> <br>}<br><br>########################################################################<br># Request route 'base-route-local'<br>########################################################################<br>
route[13]<br>{<br>xlog("L_INFO","***** IN route[13]\n");<br> t_on_reply("1");<br> if(t_check_trans())<br> {<br> <br> xlog("L_INFO", "Request leaving server - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
}<br> else<br> {<br><br> xlog("L_INFO", "Dropping mis-routed request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>xlog("L_INFO","***** OUT route[13.1]\n");<br>
exit;<br> }<br> if(!t_relay())<br> {<br> sl_reply_error();<br> }<br>xlog("L_INFO","***** OUT route[13]\n");<br> exit;<br> <br>}<br><br><br>########################################################################<br>
# Request route 'base-route-generic'<br>########################################################################<br>route[14]<br>{<br>xlog("L_INFO","***** IN route[14]\n");<br> xlog("L_INFO", "Method not supported - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
sl_send_reply("501", "Method Not Supported Here");<br>xlog("L_INFO","***** OUT route[14]\n");<br> exit;<br> <br>}<br><br>########################################################################<br>
# Request route 'base-filter-failover'<br>########################################################################<br>route[15]<br>{<br>xlog("L_INFO","***** IN route[15]\n");<br> if(!t_check_status("408|500|503"))<br>
{<br> <br> xlog("L_INFO", "No failover routing needed for this response code - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> route(6);<br>xlog("L_INFO","***** OUT route[15.1]\n");<br>
exit;<br> }<br>xlog("L_INFO","***** OUT route[15]\n");<br>}<br><br><br>########################################################################<br>#Send the call out<br>########################################################################<br>
<br>route[16]<br>{<br>xlog("L_INFO","***** IN route[16]\n");<br>#send the call outward<br><br> if(method=="INVITE" && !isflagset(10))<br> {<br> t_on_failure("2");<br> };<br>
<br> if (!t_relay()) <br> {<br> xlog("L_WARN", "ERROR: t_relay failed");<br> sl_reply_error();<br> };<br>xlog("L_INFO","***** OUT route[16]\n");<br>}<br><br>########################################################################<br>
# Request route 'Voicemail and Asterisk for further processing'<br>########################################################################<br>failure_route[3]<br>{<br>xlog("L_INFO","***** IN failure route[3]\n");<br>
if(!t_was_cancelled())<br> {<br> revert_uri();<br> rewritehostport("<a href="http://voicemailserver.testingpbx.com:5060">voicemailserver.testingpbx.com:5060</a>");<br> append_branch();<br>
#PREVENT SOME CRAZY VOICEMAIL LOOP<br> xlog("L_INFO", "No Answer Sending the call to Voicemail - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> setflag(10);<br> route(8);<br>
}<br>xlog("L_INFO","***** OUT failure route[3]\n");<br>}<br>########################################################################<br># Reply route 'base-standard-reply'<br>########################################################################<br>
onreply_route[1]<br>{<br>xlog("L_INFO","***** IN onreply route[1]\n");<br> xlog("L_INFO", "Reply - S=$rs D=$rr F=$fu T=$tu IP=$si ID=$ci\n");<br>xlog("L_INFO","***** OUT onreply route[1]\n");<br>
exit;<br> <br>}<br><br>########################################################################<br># Reply route 'base-nat-reply'<br>########################################################################<br>
onreply_route[2]<br>{<br>xlog("L_INFO","***** IN onreply route[2]\n");<br> xlog("L_INFO", "NAT-Reply - S=$rs D=$rr F=$fu T=$tu IP=$si ID=$ci\n");<br> if(nat_uac_test("1"))<br>
{<br> fix_nated_contact();<br> }<br><br> if(isbflagset(6) && status=~"(180)|(183)|2[0-9][0-9]") <br> {<br> if(!search("^Content-Length:[ ]*0"))<br> {<br> force_rtp_proxy();<br>
}<br> }<br>xlog("L_INFO","***** OUT onreply route[2]\n");<br> exit;<br> <br>}<br><br>########################################################################<br># Failure route 'pstn-failover'<br>
########################################################################<br>failure_route[1]<br>{<br>xlog("L_INFO","***** IN failure route[1]\n");<br> xlog("L_INFO", "Failure route for PSTN entered - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
route(15);<br> if(!next_gw())<br> {<br> <br> xlog("L_ERR", "Failed to select next PSTN gateway - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> route(6);<br>xlog("L_INFO","***** OUT failure route[1.1]\n");<br>
exit;<br> }<br> <br> t_on_failure("3");<br> route(8);<br>xlog("L_INFO","***** OUT failure route[1]\n");<br>}<br><br>########################################################################<br>
# Failure route 'base-standard-failure'<br>########################################################################<br>failure_route[2]<br>{<br>xlog("L_INFO","***** IN failure route[2]\n");<br>
if(!t_was_cancelled())<br> {<br> revert_uri();<br> seturi("sip:*<a href="mailto:87@openser.org">87@openser.org</a>");<br> rewritehostport("<a href="http://voicemailserver.testingpbx.com:5060">voicemailserver.testingpbx.com:5060</a>");<br>
append_branch();<br> xlog("L_INFO","Call to Voicemail");<br> setflag(10);<br> route(10);<br> }<br> if(t_check_status("422|481|487"))<br> {<br> <br>
xlog("L_INFO", "Final reply - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> route(6);<br>xlog("L_INFO","***** OUT failure route[2.1]\n");<br> exit;<br> }<br>
<br> t_on_branch("1");<br> xlog("L_INFO", "Redirect from UAC intercepted - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> route(10);<br> if($avp(s:cfc) != NULL)<br> {<br>
avp_pushto("$ru", "$avp(s:cfc)");<br> setflag(29);<br> append_branch();<br> <br> t_on_branch("1");<br> xlog("L_INFO", "CFC detected - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
route(10);<br> }<br> <br> route(15);<br> route(6);<br>xlog("L_INFO","***** OUT failure route[2]\n");<br>}<br><br>########################################################################<br>
# Branch route 'cfc-drop-local'<br>########################################################################<br>branch_route[1]<br>{<br>xlog("L_INFO","***** IN branch route[1]\n");<br> if(is_domain_local("$rd"))<br>
{<br> xlog("L_INFO", "Dropping local branch - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br> drop();<br> }<br>xlog("L_INFO","***** OUT branch route[1]\n");<br>
}<br><br><br><br><br>-- <br>Regards,<br><br>Chandrakant Solanki<br>