<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18702"></HEAD>
<BODY>
<DIV>
<DIV><FONT size=2 face=Arial><SPAN class=937564919-16032011>I am attempting to 
put together code which will allow us to redirect a call to a different tn if 
the route failed.</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN 
class=937564919-16032011></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial><SPAN 
class=937564919-16032011>Example:</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN class=937564919-16032011>User dials 
11235551234</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN class=937564919-16032011>Kamailio uses LCR to 
route to 192.168.0.100 (404 error)</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN class=937564919-16032011>Change $rU to 
11235550000 in failure_route</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN 
class=937564919-16032011></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial><SPAN class=937564919-16032011>The only way I can 
get $rU to show up in the SIP message is to call append_branch() which is not a 
solution because I now end up with two SIP messages one that is correct and one 
that is incorrect.</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN 
class=937564919-16032011></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial><SPAN class=937564919-16032011>Here is the 
failure_route I am using.&nbsp; Any input would be 
appreciated.</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN 
class=937564919-16032011></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Courier><SPAN 
class=937564919-16032011>failure_route[ECRC] {<BR>&nbsp;if (t_is_canceled()) 
{<BR>&nbsp;&nbsp;xlog("L_INFO", "Call has been canceled in 
'ECRC'.");<BR>&nbsp;&nbsp;exit;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;xlog("L_INFO", 
"SIP Response Code: $T_reply_code");<BR>&nbsp;<BR>&nbsp;# We should fail over if 
we received one of these response codes.<BR>&nbsp;if 
(!t_check_status("[45][0-9][0-9]")) {<BR>&nbsp;&nbsp;xlog("L_INFO", "Not a 
failover error.");<BR>&nbsp;&nbsp;exit;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;# 
Translate the dialed number into the ECRC DID.<BR>&nbsp;dp_translate("1", 
"$rU/$rU");<BR>&nbsp;<BR>&nbsp;# Load the gateways for normal 
dialing.<BR>&nbsp;xlog("L_INFO", "Trying to find LCR route for 
$rU");<BR>&nbsp;if (! load_gws("1", "$rU")) {<BR>&nbsp;&nbsp;xlog("Unable to 
load routing");<BR>&nbsp;&nbsp;t_reply("503", "Unable to load 
routing");<BR>&nbsp;&nbsp;exit;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;xlog("L_INFO", 
"Trying gateway '$avp(i:709)'");<BR>&nbsp;if (!next_gw()) 
{<BR>&nbsp;&nbsp;xlog("L_INFO", "No LCR route for 
$rU");<BR>&nbsp;&nbsp;t_reply("404", "No available 
gateways");<BR>&nbsp;&nbsp;exit;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;$rd=$dd;<BR>&nbsp;$rp=$dp;<BR>&nbsp;$du=$ru;<BR>&nbsp;xlog("L_INFO", 
"ru: $ru");<BR>&nbsp;xlog("L_INFO", "du: $du");</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Courier><SPAN class=937564919-16032011>&nbsp;#at this 
point $ru and $du&nbsp;contain the correct 
uri.<BR>&nbsp;append_branch();<BR><BR>&nbsp;# Send out the 
request.<BR>&nbsp;xlog("L_INFO", "Now we're sending the request 
out.");<BR>&nbsp;if (!t_relay()) {<BR>&nbsp;&nbsp;xlog("L_INFO" "Relay 
failed!");<BR>&nbsp;&nbsp;t_reply("502", "Bad 
Gateway");<BR>&nbsp;&nbsp;exit;<BR>&nbsp;}<BR>}</SPAN></FONT></DIV>
<DIV><FONT face=Courier></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial><SPAN class=937564919-16032011>Now I have two SIP 
messages one containing the correct phone number:</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN 
class=937564919-16032011>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INVITE 
sip:11235550000@xxx.xxx.xxx.xxx 
SIP/2.0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Record-Route: 
&lt;sip:xxx.xxx.xxx.xxx;lr=on&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Via: SIP/2.0/UDP 
xxx.xxx.xxx.xxx;branch=z9hG4bK2e2f.4145be65.2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Via: SIP/2.0/UDP 
xxx.xxx.xxx.xxx:5060;branch=z9hG4bK28aa7440;rport=5060<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Max-Forwards: 69<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; From: "Steven 
Wheeler" 
&lt;sip:6124243265@xxx.xxx.xxx.xxx&gt;;tag=as30b3d6f5<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
To: &lt;sip:11235551234@xxx.xxx.xxx.xxx:5060&gt;</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN 
class=937564919-16032011>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
...<BR></DIV></SPAN></FONT>
<DIV><FONT size=2 face=Arial><SPAN class=937564919-16032011>And one containing 
the wrong phone number:</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN 
class=937564919-16032011>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INVITE 
sip:11235551234@xxx.xxx.xxx.xxx 
SIP/2.0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Record-Route: 
&lt;sip:xxx.xxx.xxx.xxx;lr=on&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Via: SIP/2.0/UDP 
xxx.xxx.xxx.xxx;branch=z9hG4bK2e2f.4145be65.3<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Via: SIP/2.0/UDP 
xxx.xxx.xxx.xxx:5060;branch=z9hG4bK28aa7440;rport=5060<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Max-Forwards: 69<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; From: "Steven 
Wheeler" 
&lt;sip:6124243265@xxx.xxx.xxx.xxx&gt;;tag=as30b3d6f5<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
To: &lt;sip:11235551234@xxx.xxx.xxx.xxx:5060&gt;</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN 
class=937564919-16032011>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
...<BR></DIV></SPAN></FONT>
<DIV>&nbsp;</DIV>
<DIV align=left><FONT size=2 face=Arial>Steven Wheeler</FONT></DIV>
<DIV align=left><FONT size=2 face=Arial><A 
title=blocked::mailto:swheeler@usinternet.com 
href="mailto:swheeler@usinternet.com">swheeler@usinternet.com</A></FONT></DIV>
<DIV align=left><FONT size=2 face=Arial>952-253-3252</FONT></DIV>
<DIV>&nbsp;</DIV></DIV></BODY></HTML>