Accidently replied directly to clause. So here is a summary:<br>Sent core dump and system spec info like openser ver.<br>Klaus suggested upgrading to the latest openser 1.2 svn code, trying again, include pert part of openser.cfg
, sip packet capture, and making a bug report.<br><br>So I&#39;m now using latest svn of openser 1.2 as of 11/12/07 on a different server (the backup server)<br>Problem still persists.<br><br>gdb of one of the core dumps is included below.
<br>Below that is a nuterized (my personal server and gateway info cleaned out) openser.cfg<br><br>Thanks<br>
Dave<br>
<br>Below is the gdb of one of the cores:<br><br>Using host libthread_db library &quot;/lib/libthread_db.so.1&quot;.<br>warning: Can&#39;t read pathname for load map: Input/output error.<br>Core was generated by `/usr/local/sbin/openser&#39;.
<br>Program terminated with signal 11, Segmentation fault.<br>#0&nbsp; 0x0808f152 in comp_scriptvar (msg=&lt;value optimized out&gt;,<br>&nbsp;&nbsp;&nbsp; op=&lt;value optimized out&gt;, left=&lt;value optimized out&gt;, right=0x817ab9c)<br>
&nbsp;&nbsp;&nbsp; at route.c:748<br>748&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; backup&nbsp; = s1-&gt;s[s1-&gt;len]; s1-&gt;s[s1-&gt;len] = &#39;\0&#39;;<br><br><br>openser.cfg:<br><br>#<br># $Id: openser.cfg,v 1.6 2006/02/15 18:23:46 bogdan_iancu Exp $
<br>#<br># simple quick-start config script<br>#<br><br># ----------- global configuration parameters ------------------------<br><br>debug=3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # debug level (cmd line: -dddddddddd)<br>fork=yes<br>log_stderror=no&nbsp;&nbsp;&nbsp; # (cmd line: -E)
<br>log_facility=LOG_LOCAL7<br>log_name=&quot;openser&quot;<br><br># Uncomment these lines to enter debugging mode <br>#fork=no<br>#log_stderror=yes<br>#listen=eth0<br>#<br>check_via=no&nbsp;&nbsp;&nbsp; # (cmd. line: -v)<br>dns=yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # (cmd. line: -r)
<br>rev_dns=no&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # (cmd. line: -R)<br>port=5060<br>children=4<br>disable_dns_blacklist=yes<br><br>#listen=udp:eth0<br>#fifo=&quot;/tmp/openser_fifo&quot;<br>#fifo_db_url=&quot;postgres://seronstar:garney@208.76.152.52/seronstar&quot;
<br><br>#<br># uncomment the following lines for TLS support<br>#disable_tls = 0<br>#listen = tls:your_IP:5061<br>#tls_verify = 1<br>#tls_require_certificate = 0<br>#tls_method = TLSv1<br>#tls_certificate = &quot;/var/tmp/portage/net-misc/openser-
1.1.0/image///etc/openser/tls/user/user-cert.pem&quot;<br>#tls_private_key = &quot;/var/tmp/portage/net-misc/openser-1.1.0/image///etc/openser/tls/user/user-privkey.pem&quot;<br>#tls_ca_list = &quot;/var/tmp/portage/net-misc/openser-
1.1.0/image///etc/openser/tls/user/user-calist.pem&quot;<br><br>#<br># ------------------ module loading ----------------------------------<br><br>mpath=&quot;/usr/local/lib/openser/modules/&quot;<br># Uncomment this if you want to use MySQL database
<br>#loadmodule &quot;mysql.so&quot;<br><br>loadmodule &quot;postgres.so&quot;<br>loadmodule &quot;mysql.so&quot;<br>loadmodule &quot;mi_fifo.so&quot;<br>loadmodule &quot;xlog.so&quot;<br>loadmodule &quot;sl.so&quot;<br>loadmodule &quot;
tm.so&quot;<br>loadmodule &quot;rr.so&quot;<br>loadmodule &quot;maxfwd.so&quot;<br>loadmodule &quot;usrloc.so&quot;<br>loadmodule &quot;registrar.so&quot;<br>loadmodule &quot;textops.so&quot;<br>loadmodule &quot;avpops.so
&quot;<br>loadmodule &quot;group.so&quot;<br>loadmodule &quot;uri.so&quot;<br>loadmodule &quot;uri_db.so&quot;<br>loadmodule &quot;alias_db.so&quot;<br># Uncomment this if you want digest authentication<br># postgres.so must be loaded !
<br>loadmodule &quot;auth.so&quot;<br>loadmodule &quot;auth_db.so&quot;<br>loadmodule &quot;acc.so&quot;<br>loadmodule &quot;uac.so&quot;<br>loadmodule &quot;diversion.so&quot;<br>loadmodule &quot;mediaproxy.so&quot;<br>loadmodule &quot;
domain.so&quot;<br>loadmodule &quot;lcr.so&quot;<br><br><br># ----------------- setting module-specific parameters ---------------<br><br># -- usrloc params --<br>#modparam(&quot;usrloc&quot;, &quot;db_mode&quot;,&nbsp;&nbsp; 0)<br>
# Uncomment this if you want to use SQL database <br># for persistent storage and comment the previous line<br>modparam(&quot;usrloc&quot;, &quot;db_mode&quot;, 2)<br>modparam(&quot;usrloc&quot;, &quot;nat_bflag&quot;, 6)
<br><br>#modparam(&quot;usrloc|avpops|auth_db|group|acc|uri_db|alias_db&quot;,<br>#modparam(&quot;usrloc|auth_db|group|acc|uri_db|alias_db|avpops&quot;,<br>modparam(&quot;usrloc|auth_db|group|acc|uri_db|alias_db|avpops|domain|lcr&quot;,
<br>&nbsp;&nbsp;&nbsp; &quot;db_url&quot;,&quot;<a href="http://mysql://openser:openser@dbserver.myserver.net/openser">mysql://openser:openser@dbserver.myserver.net/openser</a>&quot;)<br><br>#&nbsp;&nbsp;&nbsp; &quot;db_url&quot;,&quot;<a href="http://postgres://openser:openser@dbserver.myserver.net/openser">
postgres://openser:openser@dbserver.myserver.net/openser</a>&quot;)<br><br>#modparam(&quot;avpops&quot;, &quot;avp_table&quot;, &quot;avp_table&quot;)<br>modparam(&quot;avpops&quot;, &quot;avp_table&quot;, &quot;usr_preferences&quot;)
<br><br># UAC (User Agent Client) module provides some basic UAC functionalities like FROM header manipulation (anonymization) or client authentication.<br>modparam(&quot;uac&quot;, &quot;rr_store_param&quot;, &quot;vsf&quot;)
<br>modparam(&quot;uac&quot;, &quot;from_restore_mode&quot;, &quot;auto&quot;)<br><br># -- auth params --<br># Uncomment if you are using auth module<br>modparam(&quot;auth_db&quot;, &quot;calculate_ha1&quot;, yes)<br>modparam(&quot;auth_db&quot;, &quot;load_credentials&quot;, &quot;$avp(s:rpid)=rpid;email_address&quot;)
<br>modparam(&quot;auth&quot;, &quot;rpid_avp&quot;, &quot;$avp(s:rpid)&quot;)<br>#<br># If you set &quot;calculate_ha1&quot; parameter to yes (which true in this config), <br># uncomment also the following parameter)<br>
#<br>modparam(&quot;auth_db&quot;, &quot;password_column&quot;, &quot;password&quot;)<br><br>modparam(&quot;tm&quot;, &quot;fr_inv_timer_avp&quot;, &quot;$avp(i:25)&quot;)<br>modparam(&quot;tm&quot;, &quot;fr_timer&quot;, 2)
<br><br># -- rr params --<br># add value to ;lr param to make some broken UAs happy<br>#modparam(&quot;rr&quot;, &quot;enable_full_lr&quot;, 1)<br>#modparam(&quot;rr&quot;, &quot;append_fromtag&quot;, 1)<br><br><br># -- FIFO options starting with openser 
1.2<br>modparam(&quot;mi_fifo&quot;, &quot;fifo_name&quot;, &quot;/tmp/openser_fifo&quot;)<br>modparam(&quot;mi_fifo&quot;, &quot;fifo_mode&quot;, 0600)<br>#modparam(&quot;mi_fifo&quot;, &quot;fifo_group&quot;, 0)<br>#modparam(&quot;mi_fifo&quot;, &quot;fifo_group&quot;, &quot;root&quot;)
<br>#modparam(&quot;mi_fifo&quot;, &quot;fifo_user&quot;, 0)<br>#modparam(&quot;mi_fifo&quot;, &quot;fifo_user&quot;, &quot;root&quot;)<br>modparam(&quot;mi_fifo&quot;, &quot;reply_dir&quot;, &quot;/tmp/&quot;)<br><br><br>
modparam(&quot;mediaproxy&quot;, &quot;mediaproxy_socket&quot;, &quot;/var/run/proxydispatcher.sock&quot;)<br>modparam(&quot;domain&quot;, &quot;db_mode&quot;, 1)<br><br>modparam(&quot;acc&quot;, &quot;early_media&quot;, 0)
<br>modparam(&quot;acc&quot;, &quot;failed_transaction_flag&quot;, 24)<br>modparam(&quot;acc&quot;, &quot;report_ack&quot;, 0)<br>modparam(&quot;acc&quot;, &quot;report_cancels&quot;, 0)<br>modparam(&quot;acc&quot;, &quot;log_flag&quot;, 0)
<br>modparam(&quot;acc&quot;, &quot;log_missed_flag&quot;, 0)<br>modparam(&quot;acc&quot;, &quot;log_level&quot;, 2)<br>modparam(&quot;acc&quot;, &quot;db_flag&quot;, 25)<br>modparam(&quot;acc&quot;, &quot;db_missed_flag&quot;, 0)
<br>modparam(&quot;acc&quot;, &quot;db_table_acc&quot;, &quot;acc&quot;)<br>modparam(&quot;acc&quot;, &quot;db_table_missed_calls&quot;, &quot;missed_calls&quot;)<br>modparam(&quot;acc&quot;, &quot;detect_direction&quot;, 1)
<br>modparam(&quot;acc&quot;, &quot;db_extra&quot;, &quot;src_user=$fU;src_domain=$fd;dst_user=$rU;dst_domain=$rd&quot;)<br>#modparam(&quot;acc&quot;, &quot;multi_leg_info&quot;, &quot;diversion_user=$di{url.user};diversion_domain=$di{
uri.domain}&quot;)<br>modparam(&quot;acc&quot;, &quot;multi_leg_info&quot;, &quot;diversion_user=$avp(s:diversion_user);diversion_domain=$avp(s:diversion_domain)&quot;)<br><br>modparam(&quot;lcr&quot;,&quot;gw_uri_avp&quot;,&quot;gw_uri_avp&quot;)
<br><br>modparam(&quot;lcr&quot;, &quot;gw_table&quot;, &quot;gw&quot;)<br>modparam(&quot;lcr&quot;, &quot;gw_name_column&quot;, &quot;gw_name&quot;)<br>modparam(&quot;lcr&quot;, &quot;ip_addr_column&quot;, &quot;ip_addr&quot;)
<br>modparam(&quot;lcr&quot;, &quot;port_column&quot;, &quot;port&quot;)<br>modparam(&quot;lcr&quot;, &quot;uri_scheme_column&quot;, &quot;uri_scheme&quot;)<br>modparam(&quot;lcr&quot;, &quot;transport_column&quot;, &quot;transport&quot;)
<br>modparam(&quot;lcr&quot;, &quot;grp_id_column&quot;, &quot;grp_id&quot;)<br>modparam(&quot;lcr&quot;, &quot;lcr_table&quot;, &quot;lcr&quot;)<br>modparam(&quot;lcr&quot;, &quot;strip_column&quot;, &quot;strip&quot;)<br>
modparam(&quot;lcr&quot;, &quot;prefix_column&quot;, &quot;prefix&quot;)<br>modparam(&quot;lcr&quot;, &quot;from_uri_column&quot;, &quot;from_uri&quot;)<br>modparam(&quot;lcr&quot;, &quot;priority_column&quot;, &quot;priority&quot;)
<br>#modparam(&quot;lcr&quot;, &quot;gw_uri_avp&quot;, &quot;1400&quot;)<br>modparam(&quot;lcr&quot;, &quot;ruri_user_avp&quot;, &quot;1402&quot;)<br>modparam(&quot;lcr&quot;, &quot;contact_avp&quot;, &quot;1401&quot;)<br>
modparam(&quot;lcr&quot;, &quot;fr_inv_timer_avp&quot;, &quot;s:fr_inv_timer_avp&quot;)<br>modparam(&quot;lcr&quot;, &quot;fr_inv_timer&quot;, 90)<br>modparam(&quot;lcr&quot;, &quot;fr_inv_timer_next&quot;, 30)<br>modparam(&quot;lcr&quot;, &quot;rpid_avp&quot;, &quot;s:rpid&quot;)
<br><br># -------------------------&nbsp; what set?flags mean --------------------<br><br>## General Flags ##<br><br># setflag(1); # from PSTN gateway<br># setflag(2); # from local user<br># setflag(3); # user NOT allowed to make pstn calls
<br># setflag(4); # user account IS disabled<br># setflag(24); # account failed transactions<br># setflag(25); # account successful transactions<br><br>## Branch Flags<br># setbflag(22); # mark media proxy as started<br><br>
# -------------------------&nbsp; request routing logic -------------------<br><br># main routing logic<br><br><br>route{<br><br>&nbsp;&nbsp;&nbsp; # initial sanity checks -- messages with<br>&nbsp;&nbsp;&nbsp; # max_forwards==0, or excessively long requests
<br>&nbsp;&nbsp;&nbsp; if (!mf_process_maxfwd_header(&quot;10&quot;)) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sl_send_reply(&quot;483&quot;,&quot;Too Many Hops&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Sanity Check: Too Many Hops\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exit;
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;ignored break\n&quot;);<br>&nbsp;&nbsp;&nbsp; };<br><br>&nbsp;&nbsp;&nbsp; if (msg:len &gt;=&nbsp; 2048 ) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sl_send_reply(&quot;513&quot;, &quot;Message too big&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Sanity Check: Message too big\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exit;<br>&nbsp;&nbsp;&nbsp; };<br><br>&nbsp;&nbsp;&nbsp; # we record-route all messages -- to make sure that<br>&nbsp;&nbsp;&nbsp; # subsequent messages will go through our proxy; that&#39;s<br>&nbsp;&nbsp;&nbsp; # particularly good if upstream and downstream entities<br>
&nbsp;&nbsp;&nbsp; # use different transport protocol<br>&nbsp;&nbsp;&nbsp; if (is_method(&quot;OPTIONS&quot;) || is_method(&quot;NOTIFY&quot;))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exit;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; if (method!=&quot;REGISTER&quot; &amp;&amp; method!=&quot;ACK&quot;) {
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; record_route();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;start route logic: r-uri &lt;$ru&gt; f-uri &lt;$fu&gt; f-Usr &lt;$fU&gt; FromDisplay $fn\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Recording Route: r-uri &lt;$ru&gt;\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setflag(24); # account failed transactions<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setflag(25); # account successful transactions<br>&nbsp;&nbsp;&nbsp; };<br><br>&nbsp;&nbsp;&nbsp; # subsequent messages withing a dialog should take the<br>&nbsp;&nbsp;&nbsp; # path determined by record-routing
<br>&nbsp;&nbsp;&nbsp; if (loose_route()) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # mark routing logic in request<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; append_hf(&quot;P-hint: rr-enforced\r\n&quot;); <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;following previous route: r-uri &lt;$ru&gt;\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(is_method(&quot;BYE&quot;))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setflag(24); # account failed transactions<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setflag(25); # account successful transactions<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(1);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exit;
<br>&nbsp;&nbsp;&nbsp; };<br><br>&nbsp;&nbsp;&nbsp; if (uri==myself) <br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;message to me, Req Meth $rm\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (method==&quot;REGISTER&quot;) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(5);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; };<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setflag(24); # account failed transactions
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setflag(25); # account successful transactions<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(is_method(&quot;CANCEL&quot;)&nbsp; || is_method(&quot;ACK&quot;))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(t_check_trans())<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(1);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Dropping mis-routed request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exit;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(from_uri==myself)<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # need to make this detect an infinite loop, sometimes simulring may send to loop to call other phone numbers<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Dropping local loop-back oops - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n&quot;);
<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; drop();<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # guilty until proven innocent... don&#39;t let call go to PSTN unless the server or user is authorized for that through later checks.<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setflag(3) ; # user not allowed to make pstn calls
<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #if ( from_gw(&quot;1&quot;) )<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( uri =~ &quot;<a href="http://sip.myserver.net">sip.myserver.net</a>&quot; &amp;&amp; is_present_hf(&quot;Remote-Party-ID&quot;) )<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Looks like it came from a verizon gateway server, aka PSTN\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setflag(1); # from PSTN Gateway<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Its NOT from a verizon gateway server, aka PSTN\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( ! isflagset(1) ) # if not from PSTN
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(9) ; # load settings for calling user.<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( ! isflagset(2) ) # if NOT local user<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(10) ; # check for and load settings for calling domain.
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ($rP=~&quot;tcp&quot;) <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_printf(&quot;$avp(s:DestURI)&quot;, &quot;sip:$rU@$rd;transport=UDP&quot; );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_pushto(&quot;$ru&quot;, &quot;$avp(s:DestURI)&quot; );
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(3); # Clean it up and send it our user if appropriate.<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(4); # Send our little one to the world and hope it survives :&#39;( <br><br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>error_route {<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;--- error route class=$(
err.class) level=$(err.level) info=$(<a href="http://err.info">err.info</a>) rcode=$(err.rcode) rreason=$(err.rreason) ---\n&quot;);<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;--- error from [$si:$sp]\n+++++\n$mb\n++++\n&quot;);
<br>&nbsp;&nbsp;&nbsp; #sl_send_reply(&quot;$err.rcode&quot;, &quot;$err.rreason&quot;);<br>&nbsp;&nbsp;&nbsp; route(7); # stop media proxy<br>&nbsp;&nbsp;&nbsp; exit;<br>}<br><br>route[1] {<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Request leaving server - M=$rm RURI=$ru Proto=$dP F=$fu T=$tu IP=$si ID=$ci\n&quot;);
<br>&nbsp;&nbsp;&nbsp; # for TC51 ( when device unreachable proper 403 is not returned )<br>&nbsp;&nbsp;&nbsp; #sl_send_reply(&quot;100&quot;, &quot;Giving a try&quot;);<br>&nbsp;&nbsp;&nbsp; #sl_send_reply(&quot;403&quot;, &quot;Not Reachable&quot;);<br>&nbsp;&nbsp;&nbsp; #drop() ;
<br>&nbsp;&nbsp;&nbsp; #t_on_failure(&quot;1&quot;);<br>&nbsp;&nbsp;&nbsp; if ( ! uri==myself )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( is_method(&quot;INVITE&quot;))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(6); # start media proxy<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( is_method(&quot;CANCEL&quot;)) <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(7); # stop media proxy
<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; t_on_reply(&quot;1&quot;);<br>&nbsp;&nbsp;&nbsp; if(isflagset(24) || isflagset(25))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(8); # populate accounting info<br>&nbsp;&nbsp;&nbsp; $avp(i:25)=5000 ;<br>&nbsp;&nbsp;&nbsp; if (!t_relay()) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # This section doesn&#39;t seem to be reached even on failures.
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Failed sending to: $ru\n&quot;);&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;--- error route class=$(err.class) level=$(err.level) info=$(<a href="http://err.info">err.info</a>
) rcode=$(err.rcode) rreason=$(err.rreason) ---\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;--- error from [$si:$sp] \n +++++\n$mb\n++++\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sl_send_reply(&quot;$err.rcode&quot;, &quot;$err.rreason&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(7); # stop media proxy<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; exit;<br>}<br><br>route[2] {<br>&nbsp;&nbsp;&nbsp; xlog(&quot;Now in route_2\n&quot;);<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Checking if $rU is one of our numbers\n&quot;);<br>&nbsp;&nbsp;&nbsp; $avp(s:Original_User) = $rU ;
<br>&nbsp;&nbsp;&nbsp; &nbsp;# ok to load avps for potential TO user,<br>&nbsp;&nbsp;&nbsp; &nbsp;#&nbsp; If the user doesn&#39;t exist the avp&#39;s for the from user won&#39;t be over writen<br>&nbsp;&nbsp;&nbsp; &nbsp;#&nbsp; and we are not pulling the from specific user preferences.<br>
&nbsp;&nbsp;&nbsp; if ( avp_db_load(&quot;$ru/username&quot;,&quot;*/usr_preferences_to&quot;) )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;avp_db_load was successfull\n&quot;);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;avp_db_load failed with return code: $rc\n&quot;);
<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; if (is_avp_set(&quot;$avp(s:call_forward)&quot;))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # hard forward to new user/number<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;$rU is hard forwarded to $avp(s:call_forward) \n&quot;);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; add_diversion(&quot;user-unavailable&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # set user that we will load new from user preferences for.<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $avp(s:from_usr_tmp) = $ru;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(9); # load from user preferences<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_pushto(&quot;$ru/username&quot;, &quot;$avp(s:call_forward)&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; rewritehost(&quot;<a href="http://127.0.0.1">127.0.0.1</a>&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_delete(&quot;$avp(s:via)/g&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # look up for if new number is one of ours and has settings<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_db_load(&quot;$ru{
uri.user}/username&quot;,&quot;*/usr_preferences_to&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(8); # set vars for accounting diversion info.<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #avp_db_load(&quot;$avp(s:call_forward)/username&quot;,&quot;*/usr_preferences_to&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # TODO: should do a loop to check for new num forwarding and make sure not infinite loop.<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; if (alias_db_lookup(&quot;dbaliases&quot;))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (!uri==myself) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_pushto(&quot;$ru/username&quot;, &quot;$avp(s:Original_User)&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;routing for gateway_dbaliases: r-uri &lt;$ru&gt;\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(1);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;dbaliases changed user to $rU&gt;\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;dbaliases lookup failed w/ return code=$rc&nbsp; for r-uri &lt;$ru&gt;\n&quot;);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; if ( is_avp_set(&quot;$avp(s:num_alias)&quot;))
<br>&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_pushto(&quot;$ru/username&quot;, &quot;$avp(s:num_alias)&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;redirecting to another number: $avp(s:num_alias)\n&quot;);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; if ( is_avp_set(&quot;$avp(s:via)&quot;)) {
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_pushto(&quot;$ru/domain&quot;, &quot;$avp(s:via)&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;$rU is reached through server: $avp(s:via)\n&quot;);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; if (!uri==myself)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;routing to default server: $rd\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(1);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;checking devices registered here in location table: r-uri &lt;$ru&gt;\n&quot;);<br>&nbsp;&nbsp;&nbsp; #lookup(&quot;location&quot;);<br>&nbsp;&nbsp;&nbsp; if (!uri==myself) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;routing from info in location table\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_pushto(&quot;$ru/username&quot;, &quot;$avp(s:Original_User)&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(1);<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>route[3] {<br>&nbsp;&nbsp;&nbsp; xlog(&quot;Now in route_3\n&quot;);<br>&nbsp;&nbsp;&nbsp; # Check if it belongs to us first 
<br>&nbsp;&nbsp;&nbsp; if ( uri=~&quot;sip:[0-9]{7}@&quot; ) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Handle 7 digit numbers<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # by temp adding areacode from calling num <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # and run it against databases with our nums.<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Caller dialed 7 digits. Checking if callers area code + $rU is one of our numbers\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $avp(s:FromUser)=$fU;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $avp(s:OriginalDestinationNumber)=$rU;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;avp-cid $avp(s:FromUser) avp-ariacode $avp(s:AreaCode) f-uri &lt;$fu&gt;\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_subst(&quot;$avp(s:FromUser)/$avp(s:AreaCode)&quot;,&quot;/^([0-9]{3}).*/\1/&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;avp-fU $avp(s:FromUser) avp-ariacode $avp(s:AreaCode) f-uri &lt;$fu&gt;\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_printf(&quot;$avp(s:NewTenDigDest)&quot;,&quot;$avp(s:AreaCode)$rU&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;about to push avp NewTenDigDest: $avp(s:NewTenDigDest)&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_pushto(&quot;$ru/username&quot;,&quot;$avp(s:NewTenDigDest)&quot;);<br>&nbsp;&nbsp;&nbsp; } else if ( uri=~&quot;sip:\+&quot; || uri=~&quot;sip:\+{0,1}1[0-9]{10}@&quot; ) <br>&nbsp;&nbsp;&nbsp; {&nbsp; # clean num to 10 digit<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Remove &quot;+&quot; from front of incoming number.
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # it must have come in from verizon<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $avp(s:OriginalDestinationNumber)=$rU;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Requested number starts with +1, clean it off: $rU\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $avp(s:OriginalDestinationNumber)=$rU;
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #xlog(&quot;L_INFO&quot;, &quot;avp-cid $avp(s:OriginalDestinationNumber) avp-ariacode $avp(s:NewTenDigDest) f-uri &lt;$fu&gt;\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_subst(&quot;$avp(s:OriginalDestinationNumber)/$avp(s:NewTenDigDest)&quot;,&quot;/.*([0-9]{10})$/\1/&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_pushto(&quot;$ru/username&quot;,&quot;$avp(s:NewTenDigDest)&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;avp-NewTenDigDest $avp(s:NewTenDigDest) avp-cleaned $avp(s:OriginalDestinationNumber) r-uri &lt;$ru&gt;\n&quot;);
<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; route(2); # Check db if Dest num is for us.<br>&nbsp;&nbsp;&nbsp; xlog(&quot;Back from route_2\n&quot;);<br>&nbsp;&nbsp;&nbsp; if (is_avp_set(&quot;$avp(s:call_forward)&quot;) )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;Forwarding call and new num is not ours.. out to the world you go! Ha Ha Ha!\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(4);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; if ( is_avp_set(&quot;$avp(s:OriginalDestinationNumber)&quot;) &amp;&amp; ! is_avp_set(&quot;$avp(s:call_forward)&quot;) )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # restore original num incase there is more processing needed by calling process.
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_pushto(&quot;$ru/username&quot;,&quot;$avp(s:OriginalDestinationNumber)&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;Restored original num: ru -&gt; $ru&quot;);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; route(4); # Send our little one to the world and hope it survives :&#39;( 
<br>&nbsp;&nbsp;&nbsp; <br>}<br><br>route[4] {<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;In route-4: r-uri &lt;$ru&gt;\n&quot;);<br>&nbsp;&nbsp;&nbsp; # routing to world.<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;no location defined for uri: r-uri &lt;$ru&gt;\n&quot;);
<br>&nbsp;&nbsp;&nbsp; #Call destination is PSTN, so send it to the gateway<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;CALL: PSTN gateway\n&quot;);<br>&nbsp;&nbsp;&nbsp; xlog(&quot;Before set: avp-rpid is $avp(s:rpid)&quot;);<br>&nbsp;&nbsp;&nbsp; if ( ! from_uri=~&quot;sip:\+&quot; )
<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_printf(&quot;$avp(s:rpid)&quot;,&quot;<a href="mailto:sip:+1$fU@sip.myserver.net">sip:+1$fU@sip.myserver.net</a>&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;NOT from ser test phone. setting avp-rpid to $avp(s:rpid)&quot;);
<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_printf(&quot;$avp(s:rpid)&quot;,&quot;<a href="mailto:sip:$fU@sip.myserver.net">sip:$fU@sip.myserver.net</a>&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;NOT from ser test phone. setting avp-i13 to $avp(s:rpid)&quot;);
<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; if(is_present_hf(&quot;P-Asserted-Identity&quot;)) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; remove_hf(&quot;P-Asserted-Identity&quot;);<br>&nbsp;&nbsp;&nbsp; }<br>#&nbsp;&nbsp;&nbsp; if( ! (is_present_hf(&quot;Remote-Party-ID&quot;) &amp;&amp; $re =~ &quot;sip:\+[1-9]+&quot; ) ) 
<br>#&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( is_present_hf(&quot;Remote-Party-ID&quot;) )<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; remove_hf(&quot;Remote-Party-ID&quot;); <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; append_hf(&quot;Remote-Party-ID: &lt;$avp(s:rpid)&gt;;privacy=$avp(s:privacy)\r\n&quot;) ; # Append Remote-Party-ID header field
<br>#&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;: f-uri before with +1: f-uri &lt;$fu&gt;\n&quot;);<br>&nbsp;&nbsp;&nbsp; uac_replace_from(&quot;$avp(s:rpid)&quot;) ;<br>#&nbsp;&nbsp;&nbsp; if (!load_gws(&quot;1&quot;))<br>#&nbsp;&nbsp;&nbsp; {<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #sl_send_reply(&quot;500&quot;, &quot;Server Internal Error - Cannot load gateways from group 1&quot;);
<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #exit;<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;: Gateways failed to load from group 1\n&quot;);<br>#&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; avp_printf(&quot;$avp(s:first_gw)&quot;,&quot;sip:$rU@&lt;first-gw-addr&gt;&quot;);<br>&nbsp;&nbsp;&nbsp; avp_printf(&quot;$avp(s:first_gw)&quot;,&quot;sip:$rU@&lt;second-gw-addr&gt;&quot;);
<br>#&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;: Gateways loaded -- gw_uri_avp = $avp(s:gw_uri_avp)\n&quot;);<br>#&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;: Added entry to Gateways avp gw_uri_avp = $avp(s:gw_uri_avp)\n&quot;);<br>#&nbsp;&nbsp;&nbsp; if ( next_gw() )
<br>#&nbsp;&nbsp;&nbsp; {<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;: Gateways loaded, gw_uri_avp = $avp(s:gw_uri_avp)\n&quot;);<br>#&nbsp;&nbsp;&nbsp; }<br>#&nbsp;&nbsp;&nbsp; else<br>#&nbsp;&nbsp;&nbsp; {<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;: Gateway query returned nothing, gw_uri_avp = $avp(s:gw_uri_avp)\n&quot;);
<br>#&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; #t_on_branch(&quot;1&quot;);<br>&nbsp;&nbsp;&nbsp; t_on_failure(&quot;1&quot;);<br>&nbsp;&nbsp;&nbsp; avp_pushto(&quot;$ru&quot;,&quot;$avp(s:first_gw)&quot;); # new branch for this uri<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;: first_gw branching --&nbsp; $avp(s:first_gw)\n&quot;);
<br>&nbsp;&nbsp;&nbsp; avp_delete(&quot;$avp(s:first_gw)&quot;);<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;: first_gw &#39;next-time&#39; branch to --&nbsp; $avp(s:first_gw)\n&quot;);<br>&nbsp;&nbsp;&nbsp; route(1) ;<br>}<br><br>route[5] {<br>&nbsp;&nbsp;&nbsp; # useing digest authentication
<br>&nbsp;&nbsp;&nbsp; if (!www_authorize(&quot;&quot;, &quot;subscriber&quot;)) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;user didn&#39;t send credentials: f-uri &lt;$fu&gt; r-uri &lt;$ru&gt;\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; www_challenge(&quot;&quot;, &quot;0&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exit;<br>&nbsp;&nbsp;&nbsp; };<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;user registered: f-uri &lt;$fu&gt;\n&quot;);<br>&nbsp;&nbsp;&nbsp; if (!src_ip==&lt;other-loadballance-host-ip&gt;) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; t_replicate(&quot;sip:&lt;other-loadballance-host-ip&gt;:5060&quot;);
<br>&nbsp;&nbsp;&nbsp; };<br><br>&nbsp;&nbsp;&nbsp; save(&quot;location&quot;);<br>&nbsp;&nbsp;&nbsp; exit;<br>}<br><br>route[6] {<br>&nbsp;&nbsp;&nbsp; # force media proxy start<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;in route 6: Start Media Proxy\n&quot;);<br>&nbsp;&nbsp;&nbsp; setbflag(22); # mark media proxy as started
<br>&nbsp;&nbsp;&nbsp; if(! isbflagset(22))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Starting Media Proxy\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(use_media_proxy())<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Started Media Proxy\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;FAILED to start Media Proxy\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br><br>#&nbsp;&nbsp;&nbsp; setbflag(22); # mark media proxy as started.<br>#&nbsp;&nbsp;&nbsp; use_media_proxy();
<br>}<br><br>route[7] {<br>&nbsp;&nbsp;&nbsp; # force media proxy stop<br>&nbsp;&nbsp;&nbsp; if (isbflagset(22))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; end_media_session();<br>}<br><br>route[8] <br>{<br>#modparam(&quot;acc&quot;, &quot;multi_leg_info&quot;, &quot;diversion_user=$avp(s:diversion_user);diversion_domain=$avp(s:diversion_domain)&quot;)
<br>&nbsp;&nbsp;&nbsp; if ( is_present_hf(&quot;Diversion&quot;))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $avp(s:diversion_user)=$di{url.user};<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $avp(s:diversion_domain)=$di{uri.domain};<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>route[9]<br>{<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;In Route 9.\n&quot;);
<br>&nbsp;&nbsp;&nbsp; if ( ! is_avp_set(&quot;$avp(s:from_usr_tmp)&quot; ) )<br>&nbsp;&nbsp;&nbsp; #if ( $var(from_usr_tmp){s.len} == 0 )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $avp(s:from_usr_tmp) = $fu;<br>&nbsp;&nbsp;&nbsp; } <br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Loading AVPs for from user $avp(s:from_usr_tmp) if they exist\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; #if(avp_db_load(&quot;$fu{uri.user}/username&quot;,&quot;*/usr_preferences_from&quot;))<br>&nbsp;&nbsp;&nbsp; if(avp_db_load(&quot;$avp(s:from_usr_tmp)/username&quot;,&quot;*/usr_preferences_from&quot;))<br>&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Loaded AVPs for from user $fU\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setflag(2) ; # from local user<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # is user account set to disabled or not allowed to make calls to pstn?<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( ! is_avp_set(&quot;$avp(s:allow_call_pstn)&quot;) || avp_check(&quot;$avp(s:allow_call_pstn)&quot;, &quot;re/yes/i&quot;) ) 
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; resetflag(3) ; # user IS allowed to make pstn calls<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setflag(3) ; # user IS NOT allowed to make pstn calls<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( ! is_avp_set(&quot;$avp(s:acct_status)&quot;) || ! avp_check(&quot;$avp(s:acct_status)&quot;, &quot;re/disabled/i&quot;) )
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; resetflag(4) ; # user account IS NOT disabled<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setflag(4) ; # user account IS disabled<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setflag(3) ; # user IS NOT allowed to make pstn calls
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; avp_delete(&quot;$avp(s:from_usr_tmp)&quot;);<br>}<br><br>route[10] # check for and load settings for calling domain.<br>{<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;In Route 10.\n&quot;);
<br><br>}<br>onreply_route[1]<br>{<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Reply - S=$rs D=$rr F=$fu T=$tu IP=$si ID=$ci\n&quot;);<br>&nbsp;&nbsp;&nbsp; if(! isbflagset(22) &amp;&amp; status=~&quot;(180)|(183)|2[0-9][0-9]&quot;)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( is_method(&quot;CANCEL&quot;)) 
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(7); # stop media proxy<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( is_method(&quot;INVITE&quot;)) <br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(6);<br>#&nbsp;&nbsp;&nbsp; {<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Starting Media Proxy\n&quot;);<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(use_media_proxy())
<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setbflag(22); # mark media proxy as started<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Started Media Proxy\n&quot;);<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;FAILED to start Media Proxy\n&quot;);
<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>#&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; exit;<br>&nbsp;&nbsp;&nbsp; <br>}<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>failure_route[1] {<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Failure route for PSTN entered - S=$T_reply_code M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n&quot;);
<br><br>#&nbsp;&nbsp;&nbsp; avp_pushto(&quot;$br&quot;,&quot;$avp(s:first_gw)&quot;); # new branch for this uri<br>#&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;: first_gw branching --&nbsp; $avp(s:first_gw)\n&quot;);<br>#&nbsp;&nbsp;&nbsp; avp_delete(&quot;$avp(s:first_gw)&quot;);
<br>#&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;: first_gw &#39;next-time&#39; branch to --&nbsp; $avp(s:first_gw)\n&quot;);<br>&nbsp;&nbsp;&nbsp; if (t_check_status(&quot;(403)|(Forbiden)&quot;))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Status $T_reply_code\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Rejected by this gateway group, skip to next group if it exists.\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_delete(&quot;$avp(s:first_gw)/g&quot;);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; if ( ! is_avp_set(&quot;$avp(s:first_gw)&quot;) )
<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( is_avp_set(&quot;$avp(s:second_gw)&quot;))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_copy(&quot;$avp(s:second_gw)&quot;, &quot;$avp(s:first_gw)/gd&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( is_avp_set(&quot;$avp(s:third_gw)&quot;))
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avp_copy(&quot;$avp(s:third_gw)&quot;, &quot;$avp(s:second_gw)/gd&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Out of gateways to try, dropping call.\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; drop();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; t_on_failure(&quot;1&quot;);<br>&nbsp;&nbsp;&nbsp; t_on_branch(&quot;1&quot;);<br>&nbsp;&nbsp;&nbsp; avp_pushto(&quot;$br&quot;,&quot;$avp(s:first_gw)&quot;); # new branch for this uri<br>&nbsp;&nbsp;&nbsp; avp_delete(&quot;$avp(s:first_gw)&quot;);
<br>#&nbsp;&nbsp;&nbsp; t_on_failure(&quot;2&quot;);<br>#&nbsp;&nbsp;&nbsp; t_on_branch(&quot;2&quot;);<br>#&nbsp;&nbsp;&nbsp; rewritehost(&quot;<a href="http://65.217.40.219">65.217.40.219</a>&quot;); <br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Now R-URI=$ru\n&quot;);<br>
#&nbsp;&nbsp;&nbsp; append_branch();<br>&nbsp;&nbsp;&nbsp; route(1);<br>}<br><br>branch_route[1]<br>{<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;In Branch_Route 1\n&quot;);<br>&nbsp;&nbsp;&nbsp; if(uri==myself)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Dropping local branch - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; drop();<br>&nbsp;&nbsp;&nbsp; } else {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;In Branch_Route 1, Sending to=$ru\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( is_method(&quot;INVITE&quot;))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(6); # start media proxy<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( is_method(&quot;CANCEL&quot;)) 
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(7); # stop media proxy<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>branch_route[2]<br>{<br>&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;In Br_Rt2, Failed Domain=$avp(s:FailedAddr)\n&quot;);<br>&nbsp;&nbsp;&nbsp; if(uri==myself )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;Dropping local branch - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; drop();<br>&nbsp;&nbsp;&nbsp; } else {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;In Br_Rt2, Sending to=$ru Proto=$dP\n&quot;);
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( is_method(&quot;INVITE&quot;))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(6); # start media proxy<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( is_method(&quot;CANCEL&quot;)) <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; route(7); # stop media proxy<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br><br><br>