<html><body><span style="font-family:Verdana; color:#000000; font-size:10pt;"><blockquote id="replyBlockquote" webmail="1" style="border-left: 2px solid blue; margin-left: 8px; padding-left: 8px; font-size:10pt; color:black; font-family:verdana;"><div id="wmQuoteWrapper"><span style="font-family:Verdana; color:#000000; font-size:10pt;"><div>Hello<br>&nbsp;I have been having issues with kamailio and asterisk realtime. I have used all the configurations posted, but it just has not worked for me. What I am trying to do is to use asterisk as PSTN &amp; voicemail for kamailio. But I keep getting this 401 not authorized from asterisk like this:</div><div><br></div><div>========</div><div><div>--- (19 headers 19 lines) ---</div><div>Sending to 99.89.26.17:5060 (NAT)</div><div>Using INVITE request as basis request - LCklNT_HoIeTxCB_8cSIf9efRNvkcR</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &gt; doing dnsmgr_lookup for '99.89.26.17'</div><div>&nbsp;&nbsp; &nbsp;-- adding dns manager for '99.89.26.17'</div><div>Scheduling destruction of SIP dialog '3d67147a652fe8641c536eb92383ad74@99.89.26.17' in 32000 ms (Method: NOTIFY)</div><div>Reliably Transmitting (NAT) to 99.89.26.17:5060:</div><div>NOTIFY sip:1000@99.89.26.17 SIP/2.0</div><div>Via: SIP/2.0/UDP 99.89.26.18:5060;branch=z9hG4bK00545e8e;rport</div><div>Max-Forwards: 70</div><div>From: "asterisk" &lt;sip:1000@99.89.26.17&gt;;tag=as4d28adb7</div><div>To: &lt;sip:1000@99.89.26.17&gt;</div><div>Contact: &lt;sip:1000@99.89.26.18:5060&gt;</div><div>Call-ID: 3d67147a652fe8641c536eb92383ad74@99.89.26.17</div><div>CSeq: 102 NOTIFY</div><div>User-Agent: Asterisk PBX</div><div>Event: message-summary</div><div>Content-Type: application/simple-message-summary</div><div>Content-Length: 84</div><div><br></div><div>Messages-Waiting: no</div><div>Message-Account: sip:1@99.89.26.17</div><div>Voice-Message: 0/0 (0/0)</div><div><br></div><div>---</div><div>Found peer '1000' for '1000' from 99.89.26.17:5060</div><div><br></div><div>&lt;--- Reliably Transmitting (NAT) to 99.89.26.17:5060 ---&gt;</div><div>SIP/2.0 401 Unauthorized</div><div>Via: SIP/2.0/UDP 99.89.26.17;branch=z9hG4bK354f.e07b39b2.0;received=99.89.26.17;rport=5060</div><div>Via: SIP/2.0/UDP 192.168.1.101:5060;branch=z9hG4bKj4sndhbgkh863bu8fpr61tb;rport=5060</div><div>From: &lt;sip:1000@99.89.26.17&gt;;tag=5tnt79v6phhc689kd5vh</div><div>To: &lt;sip:+2348023098407@99.89.26.17;user=phone&gt;;tag=as21d7a164</div><div>Call-ID: LCklNT_HoIeTxCB_8cSIf9efRNvkcR</div><div>CSeq: 1710 INVITE</div><div>Server: Asterisk PBX</div><div>Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH</div><div>Supported: replaces, timer</div><div>WWW-Authenticate: Digest algorithm=MD5, realm="99.89.26.17", nonce="16c11ac7"</div><div>Content-Length: 0</div><div style=""><br style=""></div><div></div><div>========</div><div><br></div><div>asterisk and kamailio are on different server, and I have put the IP of asterisk in trusted table in kamailio db. My kamailio.cfg is:</div><div><br></div><div><br></div><div><br></div><div><div>#!KAMAILIO</div></div><div>#</div><div># $Id$</div><div><br></div><div><br></div><div>#!define WITH_MYSQL</div><div>#!define WITH_AUTH</div><div>#!define WITH_USRLOCDB</div><div>#!define WITH_PRESENCE</div><div>#!define WITH_NAT</div><div>#!define WITH_PSTN</div><div>#!define WITH_ACCDB</div><div><br></div><div><br></div><div>####### Global Parameters #########</div><div><br></div><div>#!ifdef WITH_DEBUG</div><div>debug=4</div><div>log_stderror=yes</div><div>#!else</div><div>debug=3</div><div>log_stderror=no</div><div>#!endif</div><div><br></div><div>memdbg=3</div><div>memlog=3</div><div><br></div><div>log_facility=LOG_LOCAL0</div><div><br></div><div>fork=yes</div><div>children=4</div><div><br></div><div>/* uncomment the next line to disable TCP (default on) */</div><div>#disable_tcp=yes</div><div><br></div><div>/* uncomment the next line to disable the auto discovery of local aliases</div><div>&nbsp;&nbsp; based on revers DNS on IPs (default on) */</div><div>#auto_aliases=no</div><div><br></div><div><br></div><div>/* uncomment and configure the following line if you want Kamailio to</div><div>&nbsp;&nbsp; bind on a specific interface/port/proto (default bind on all available) */</div><div>listen=udp:99.89.26.17:5060</div><div>advertised_address=99.89.26.17</div><div>alias=udp:99.89.26.17:5060</div><div>port=5060</div><div><br></div><div><br></div><div><br></div><div>####### Modules Section ########</div><div><br></div><div>mpath="/usr/local/lib/kamailio/modules_k/:/usr/local/lib/kamailio/modules/"</div><div><br></div><div>#!ifdef WITH_MYSQL</div><div>loadmodule "db_mysql.so"</div><div>#!endif</div><div style=""><div>loadmodule "mi_fifo.so"</div><div>loadmodule "kex.so"</div><div>loadmodule "tm.so"</div><div>loadmodule "tmx.so"</div><div>loadmodule "sl.so"</div><div>loadmodule "rr.so"</div><div>loadmodule "pv.so"</div><div>loadmodule "maxfwd.so"</div><div>loadmodule "usrloc.so"</div><div>loadmodule "registrar.so"</div><div>loadmodule "textops.so"</div><div>loadmodule "uri_db.so"</div><div>loadmodule "siputils.so"</div><div>loadmodule "xlog.so"</div><div>loadmodule "sanity.so"</div><div>loadmodule "ctl.so"</div><div>loadmodule "mi_rpc.so"</div><div>loadmodule "acc.so"</div><div>loadmodule "uac.so"</div><div><br></div><div>#!ifdef WITH_AUTH</div><div>loadmodule "auth.so"</div><div>loadmodule "auth_db.so"</div><div>#!endif&nbsp;</div><div><br></div><div>loadmodule "alias_db.so"</div><div>loadmodule "domain.so"</div><div><br></div><div>#!ifdef WITH_PRESENCE</div><div>loadmodule "presence.so"</div><div>loadmodule "presence_xml.so"</div><div>#!endif</div><div><br></div><div>#!ifdef WITH_NAT</div><div>loadmodule "nathelper.so"</div><div>#!endif</div><div><br></div><div>loadmodule "permissions.so"</div><div><br></div><div># ----------------- setting module-specific parameters ---------------</div><div><br></div><div><br></div><div># ----- mi_fifo params -----</div><div>modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")</div><div><br></div><div><br></div><div># ----- rr params -----</div><div>modparam("rr", "enable_full_lr", 1) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# add value to ;lr param to cope with most of the UAs</div><div>modparam("rr", "append_fromtag", 1)</div><div><br></div><div><br></div><div># ----- registrar params -----</div><div>modparam("registrar", "method_filtering", 1)</div><div>#modparam("registrar", "append_branches", 0)</div><div>#modparam("registrar", "max_contacts", 10)</div><div style=""><div># ----- uri_db params -----</div><div>modparam("uri_db", "use_uri_table", 0)</div><div>modparam("uri_db", "db_url", "mysql://openser:openserrw@localhost/openser")</div><div><br></div><div><br></div><div># ----- acc params -----</div><div><br></div><div>&nbsp;&nbsp;# Usage of flags is as follows:</div><div>&nbsp;&nbsp;# &nbsp; 1 == should account(all to gateway),</div><div>&nbsp;&nbsp;# &nbsp; 2 == should report on missed calls (transactions to kamailio users),</div><div>&nbsp;&nbsp;# &nbsp; 3 == failed transactions</div><div>&nbsp;&nbsp;# &nbsp; 4 == destination user wishes to use voicemail</div><div>&nbsp;&nbsp;# &nbsp; 6 == nathelper &nbsp;</div><div>&nbsp;&nbsp;#</div><div><br></div><div>modparam("acc", "early_media", 1)</div><div>modparam("acc", "report_ack", 1)</div><div>modparam("acc", "report_cancels", 1)</div><div>modparam("acc", "detect_direction", 0)</div><div>modparam("acc", "failed_transaction_flag", 3)</div><div>modparam("acc", "log_flag", 1)</div><div>modparam("acc", "db_flag", 1)</div><div>modparam("acc", "log_missed_flag", 2)</div><div>modparam("acc", "db_missed_flag", 2)</div><div>modparam("acc", "log_extra", "src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")</div><div>modparam("acc", "db_url","mysql://openser:openserrw@localhost/openser")</div><div>modparam("acc", "db_extra","src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")</div><div>modparam("acc", "db_table_acc", "acc")</div><div>modparam("acc", "db_table_missed_calls", "missed_calls")</div><div>#!endif</div><div><br></div><div># ----- usrloc params -----</div><div>/* enable DB persistency for location entries */</div><div>#!ifdef WITH_USRLOCDB</div><div>modparam("usrloc", "db_mode", &nbsp; 2)</div><div>modparam("usrloc", "db_url", "mysql://openser:openserrw@localhost/openser")</div><div>modparam("usrloc", "domain_column", "domain")</div><div>modparam("usrloc", "user_column", "username")</div><div>modparam("usrloc", "matching_mode", 0)</div><div>#!endif</div><div><br></div><div><br></div><div># ----- auth_db params -----</div><div>/* enable the DB based authentication */</div><div>#!ifdef WITH_AUTH</div><div>modparam("auth_db", "calculate_ha1", yes)</div><div>modparam("auth_db", "password_column", "password")</div><div>modparam("auth_db", "db_url","mysql://openser:openserrw@localhost/openser")</div><div>modparam("auth_db", "load_credentials", "")</div><div>#!endif</div><div><br></div><div><br></div><div># ----- alias_db params -----</div><div style=""><div>/* uncomment the following lines if you want to enable the DB based</div><div>&nbsp;&nbsp; aliases */</div><div>modparam("alias_db", "db_url", &nbsp;"mysql://openser:openserrw@localhost/openser")</div><div><br></div><div><br></div><div># ----- domain params -----</div><div>/* uncomment the following lines to enable multi-domain detection</div><div>&nbsp;&nbsp; support */</div><div>modparam("domain", "db_url", &nbsp; &nbsp;"mysql://openser:openserrw@localhost/openser")</div><div>modparam("domain", "db_mode", 0) &nbsp; # do not use caching</div><div>modparam("domain", "domain_col", "domain")</div><div>modparam("domain", "domain_table", "domain")</div><div>&nbsp;&nbsp;</div><div>&nbsp;&nbsp;</div><div># ----- multi-module params -----</div><div>/* uncomment the following line if you want to enable multi-domain support</div><div>&nbsp;&nbsp; in the modules (dafault off) */</div><div>modparam("alias_db|auth_db|usrloc|uri_db", "use_domain", 1)</div><div><br></div><div><br></div><div># ----- presence params -----</div><div>/* enable presence server support */</div><div>#!ifdef WITH_PRESENCE</div><div>modparam("presence|presence_xml", "db_url","mysql://openser:openserrw@localhost/openser")</div><div>modparam("presence_xml", "force_active", 1)</div><div>modparam("presence", "server_address", "sip:99.89.26.17:5060")</div><div>#!endif</div><div><br></div><div><br></div><div># ----- nathelper -----</div><div>#!ifdef WITH_NAT</div><div>modparam("nathelper", "rtpproxy_sock", "udp:99.89.26.17:7722 udp:99.89.26.17:7723")</div><div>modparam("nathelper", "natping_interval", 30)</div><div>modparam("nathelper", "ping_nated_only", 1)</div><div>modparam("nathelper", "sipping_bflag", 7)</div><div>modparam("nathelper", "sipping_from", "sip:<a target="_blank" href="mailto:pinger@kamailio.org">pinger@kamailio.org</a>")</div><div>modparam("registrar|nathelper", "received_avp", "$avp(i:80)")</div><div>modparam("usrloc", "nat_bflag", 6)</div><div>#!endif</div><div><br></div><div><br></div><div>#------tm timeout for voicemail params--------</div><div>modparam("tm", "fr_timer", 10000)</div><div>modparam("tm", "fr_inv_timer", 20000)</div><div><br></div><div>#------permissions-------</div><div>modparam("permissions", "db_url","mysql://openser:openserrw@localhost/openser")</div><div>modparam("permissions", "db_mode", 0) &nbsp; &nbsp; #do not allow caching</div><div>modparam("permissions", "trusted_table", "trusted")</div><div>modparam("permissions", "source_col", "src_ip")</div><div>modparam("permissions", "proto_col", "proto")</div><div>modparam("permissions", "from_col", "from_pattern")</div><div>modparam("permissions", "peer_tag_avp", "$avp(i:707)")</div><div>modparam("permissions", "tag_col", "tag")</div><div style=""><div>#----------uac params -------------</div><div>modparam("uac", "credential", "kamailio:99.89.26.17:kamailio")</div><div>modparam("uac","from_restore_mode","auto")</div><div><br></div><div><br></div><div>####### Routing Logic ########</div><div><br></div><div>&nbsp;&nbsp;&nbsp;</div><div># main request routing logic</div><div><br></div><div>route{</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!mf_process_maxfwd_header("10")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("483","Too Many Hops");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if(!sanity_check("1511", "7"))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("Malformed SIP message from $si:$sp\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# -----------------------------------------------------------------</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# Record Route Section</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# -----------------------------------------------------------------</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if ((method=="INVITE|SUBSCRIBE") &amp;&amp; nat_uac_test("19")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: I am in invite-subscribe\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;remove_hf("Route");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;record_route_preset("99.89.26.17:5060");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} else if (!is_method("REGISTER")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;record_route();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;};</div><div><br></div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# -----------------------------------------------------------------</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# Call Tear Down Section</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# -----------------------------------------------------------------</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (is_method("BYE") || is_method("CANCEL")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: I am in bye-cancel\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;unforce_rtp_proxy();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;};</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# -----------------------------------------------------------------</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# Loose Route Section</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# -----------------------------------------------------------------</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (loose_route()) {</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: I am in loose route\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (is_method("BYE")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: method is BYE in loose route\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setflag(1); # do accounting ...</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setflag(3); # ... even if the transaction fails</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div style=""><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((method=="INVITE" || method=="REFER") &amp;&amp; !has_totag()) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: method is $rm and no totag in loose route\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("403", "Forbidden");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;};</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (is_method("INVITE") || is_method("NOTIFY")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!allow_trusted("$si", "$(proto{s.toupper})")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","!allow_trusted. rs $rs si $si rm $rm ru $ru tu $tu fu $fu rr $rr\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!proxy_authorize("99.89.26.17","subscriber")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_challenge("99.89.26.17","0");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else if (!check_from()) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("403", "Forbidden Auth ID");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;};</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;consume_credentials();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;};</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (nat_uac_test("19")){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setflag(6);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;force_rport();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fix_nated_contact();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;force_rtp_proxy("l");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;};</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(RELAY);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;};</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# -----------------------------------------------------------------</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# Call Type Processing Section</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# -----------------------------------------------------------------</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!is_uri_host_local()) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: I am in !is_uri_host_local\n");&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;append_hf("P-hint: outbound\r\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (is_from_local() || allow_trusted("$si", "$(proto{s.toupper})")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: I am in is_from_local || allow_trusted in !is_uri_host_local method\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(NAT);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(RELAY);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: 403 Forbidden from is_uri_host_local\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("403", "Forbidden");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;};</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;};</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (is_method("ACK")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: method is ack\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sl_send_reply("200", "Acknowledged");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(RELAY);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div style=""><div>&nbsp;&nbsp; &nbsp; } else if (is_method("CANCEL")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: method is cancel\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(RELAY);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} else if (is_method("INVITE")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: method is invite\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setflag(1); # do accounting</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(INVITE);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} else if (is_method("REGISTER")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: method is register\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setflag(1); #do accounting</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(REGISTER);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} else if (is_method("NOTIFY")){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("200", "Understood");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} else if (is_method("OPTIONS")){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("200", "Got it");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} else if (is_method("BYE")){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: method is bye\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("200", "Bye for now");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#route(RELAY);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;lookup("aliases");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!is_uri_host_local()) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(NAT);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(RELAY);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!lookup("location")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: no user found in location table\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("404", "User Not Found");&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;route(RELAY);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div># ---------------------------------------------------------------</div><div># Relay route - default message Handler</div><div># ---------------------------------------------------------------</div><div>route[RELAY] { &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: I am in relay route\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;t_on_reply("REPLY_ONE");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;t_on_failure("FAIL_ONE");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!t_relay()) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (is_method("INVITE") || is_method("ACK")) {</div><div style=""><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unforce_rtp_proxy();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_reply_error();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div># -----------------------------------------------------------------</div><div># REGISTER Message Handler</div><div># -----------------------------------------------------------------</div><div>route[REGISTER] {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: now in register route\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!search("^Contact:[ ]*\*") &amp;&amp; nat_uac_test("19")){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setflag(6);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fix_nated_register();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;force_rport();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("100", "Trying to register");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!www_authorize("99.89.26.17","subscriber")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: now in register route - www_authorize is not true, challenge\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;www_challenge("99.89.26.17","0");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!check_to()) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: now in register route - check_to failed\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("401", "Unauthorized");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;consume_credentials();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!save("location")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_reply_error();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>#------------------------------------------------------------</div><div># Invite method route &nbsp;&nbsp;</div><div>#-----------------------------------------------------------</div><div>route[INVITE] { &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: I am in invite route\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!allow_trusted("$si", "$(proto{s.toupper})")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: now in invite route, then we should challened bc we're not in trusted table\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!proxy_authorize("99.89.26.17","subscriber")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_challenge("99.89.26.17","0");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else if (!check_from()) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("403", "Use From=ID");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div style=""><br style=""></div></div></div></div></div></div></div></div><div></div><div><br></div><div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;consume_credentials();</div></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (nat_uac_test("19")){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setflag(6);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;force_rport();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fix_nated_contact();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;lookup("aliases");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!is_uri_host_local()) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-debug: why am I here?\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(NAT);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(RELAY);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>/* &nbsp; &nbsp; &nbsp;if (uri=~"^sip:1[0-9]{10}@") {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;strip(1);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}*/</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!lookup("location")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (uri=~"^sip:(\+|011)[0-9]*@") { &nbsp; # International Format PSTN</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-debug: international\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(NAT);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(PSTN);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (uri=~"^sip:[0-9]{10}@") { # Domestic PSTN</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-debug: domestic\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(NAT);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(PSTN);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (uri=~"sip:1@"){ &nbsp; &nbsp; &nbsp;# check voicemail</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-debug: *98 for voicemail reached\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(NAT);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;route(PSTN);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("404", "User Not Found");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;route(NAT);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;route(RELAY);</div><div>}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div style=""><br style=""></div><div></div><div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div><div># ------------------------------------------------------------</div><div># Presence server route</div><div># ------------------------------------------------------------</div><div>route[PRESENCE]</div><div>{</div><div>#!ifdef WITH_PRESENCE</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: I am in presense route\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!t_newtran())</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_reply_error();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;};</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if(is_method("PUBLISH"))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;handle_publish();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;t_release();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} </div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if( is_method("SUBSCRIBE"))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{ &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;handle_subscribe();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;t_release();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;exit;</div><div>#!endif</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# if presence enabled, this part will not be executed</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (is_method("PUBLISH") || $rU==$null)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("404", "Not here");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return;</div><div>}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </div><div># ------------------------------------------------------------</div><div># Caller NAT detection route</div><div># ------------------------------------------------------------</div><div>route[NAT]{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: I am in NAT route\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (isbflagset(6)){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;force_rport();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fix_nated_contact();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;force_rtp_proxy();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;</div><div># -----------------------------------------------------------</div><div># PSTN GW routing &nbsp; &nbsp; &nbsp; </div><div># -----------------------------------------------------------</div><div style=""><br style=""></div><div></div><div><br></div><div><div>route[PSTN] {</div></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: now in PSTN route\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;/*rewritehostport("99.89.26.18:5060");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;route(RELAY);*/</div><div>&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;t_on_failure("FAIL_ONE");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# reset flag to mark no authentication yet performed &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;#resetflag(7); &nbsp; </div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# forward to PSTN</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;t_relay_to_udp("99.89.26.18","5060");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;exit;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </div><div>#-----------------------------------------------------------</div><div># On-reply route</div><div>#-----------------------------------------------------------</div><div>onreply_route[REPLY_ONE] {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: I am in reply route\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (isbflagset(6) &amp;&amp; status=~"(180)|(183)|2[0-9][0-9]"){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!search("^Content-Length:[ ]*0")){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;force_rtp_proxy();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (nat_uac_test("19")){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fix_nated_contact();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div># -------------------------------------------------------------</div><div># Sample failure route</div><div># --------------------------------------------------------------</div><div>failure_route[FAIL_ONE] {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO","chuks-test: I am in failure route\n");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (is_method("INVITE") &amp;&amp; isbflagset("6") ) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;unforce_rtp_proxy();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if(t_check_status("401|407")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (uac_auth()){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#setflag(7); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# mark that auth was performed</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;t_on_failure("FAIL_ONE"); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # trigger again the failure route</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;append_branch(); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# repeat the request with auth response this time</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;t_relay();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (t_check_status("3[0-9][0-9]")) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;t_reply("404","Not found");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;</div><div style=""><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;/*</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (t_is_canceled()) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}else{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO", "INFO: CALL TO VOICEMAIL");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#revert_uri();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewritehostport("99.89.26.18:5060");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;append_branch();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setflag(2);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;t_relay();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}*/</div><div>} &nbsp; &nbsp; &nbsp; &nbsp;</div><div><br></div><div><br></div><div style="">===========================</div></div><div style=""><br></div><div style=""><br></div></div><div><br></div><blockquote id="replyBlockquote" webmail="1" style="border-left: 2px solid blue; margin-left: 8px; padding-left: 8px; font-size:10pt; color:black; font-family:verdana;"><div id="wmQuoteWrapper"><font class="Apple-style-span" face="verdana, geneva"><br></font> </div> </blockquote></span> 
</div>
</blockquote></span></body></html>