<!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> </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> </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> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=937564919-16032011>Here is the
failure_route I am using. Any input would be
appreciated.</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=937564919-16032011></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Courier><SPAN
class=937564919-16032011>failure_route[ECRC] {<BR> if (t_is_canceled())
{<BR> xlog("L_INFO", "Call has been canceled in
'ECRC'.");<BR> exit;<BR> }<BR> <BR> xlog("L_INFO",
"SIP Response Code: $T_reply_code");<BR> <BR> # We should fail over if
we received one of these response codes.<BR> if
(!t_check_status("[45][0-9][0-9]")) {<BR> xlog("L_INFO", "Not a
failover error.");<BR> exit;<BR> }<BR> <BR> #
Translate the dialed number into the ECRC DID.<BR> dp_translate("1",
"$rU/$rU");<BR> <BR> # Load the gateways for normal
dialing.<BR> xlog("L_INFO", "Trying to find LCR route for
$rU");<BR> if (! load_gws("1", "$rU")) {<BR> xlog("Unable to
load routing");<BR> t_reply("503", "Unable to load
routing");<BR> exit;<BR> }<BR> <BR> xlog("L_INFO",
"Trying gateway '$avp(i:709)'");<BR> if (!next_gw())
{<BR> xlog("L_INFO", "No LCR route for
$rU");<BR> t_reply("404", "No available
gateways");<BR> exit;<BR> }<BR> <BR> $rd=$dd;<BR> $rp=$dp;<BR> $du=$ru;<BR> xlog("L_INFO",
"ru: $ru");<BR> xlog("L_INFO", "du: $du");</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Courier><SPAN class=937564919-16032011> #at this
point $ru and $du contain the correct
uri.<BR> append_branch();<BR><BR> # Send out the
request.<BR> xlog("L_INFO", "Now we're sending the request
out.");<BR> if (!t_relay()) {<BR> xlog("L_INFO" "Relay
failed!");<BR> t_reply("502", "Bad
Gateway");<BR> exit;<BR> }<BR>}</SPAN></FONT></DIV>
<DIV><FONT face=Courier></FONT> </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> INVITE
sip:11235550000@xxx.xxx.xxx.xxx
SIP/2.0<BR> Record-Route:
<sip:xxx.xxx.xxx.xxx;lr=on><BR>
Via: SIP/2.0/UDP
xxx.xxx.xxx.xxx;branch=z9hG4bK2e2f.4145be65.2<BR>
Via: SIP/2.0/UDP
xxx.xxx.xxx.xxx:5060;branch=z9hG4bK28aa7440;rport=5060<BR>
Max-Forwards: 69<BR> From: "Steven
Wheeler"
<sip:6124243265@xxx.xxx.xxx.xxx>;tag=as30b3d6f5<BR>
To: <sip:11235551234@xxx.xxx.xxx.xxx:5060></SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=937564919-16032011>
...<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> INVITE
sip:11235551234@xxx.xxx.xxx.xxx
SIP/2.0<BR> Record-Route:
<sip:xxx.xxx.xxx.xxx;lr=on><BR>
Via: SIP/2.0/UDP
xxx.xxx.xxx.xxx;branch=z9hG4bK2e2f.4145be65.3<BR>
Via: SIP/2.0/UDP
xxx.xxx.xxx.xxx:5060;branch=z9hG4bK28aa7440;rport=5060<BR>
Max-Forwards: 69<BR> From: "Steven
Wheeler"
<sip:6124243265@xxx.xxx.xxx.xxx>;tag=as30b3d6f5<BR>
To: <sip:11235551234@xxx.xxx.xxx.xxx:5060></SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=937564919-16032011>
...<BR></DIV></SPAN></FONT>
<DIV> </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> </DIV></DIV></BODY></HTML>