<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
its not a good idea to make manipulations in failure_route like you do.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
in <b>failure_route </b>you are working on the <b>initial request.</b></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b><br>
</b></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
since you want to apply manipulation <b>on the new user received from 300 response</b> you need to use
<b>branch_route</b> for this. thats one of his purpose.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>De :</b> Benoît Panizzon <benoit.panizzon@imp.ch><br>
<b>Envoyé :</b> vendredi 24 juin 2022 15:06<br>
<b>À :</b> Patrick Karton <patrickarton@hotmail.com><br>
<b>Cc :</b> Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org><br>
<b>Objet :</b> Re: [SR-Users] How to handle a 301 redirect request from a client?</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Salut Patrick<br>
<br>
Thank you for your help.<br>
<br>
I ended up with this:<br>
<br>
        if (t_check_status("(301)|(302)") or (t_branch_timeout() and !t_branch_replied())) {<br>
                $avp(destination) = $(T_rpl($ct){tobody.user});<br>
                xlog("L_ERR", "$cfg(route): Got: $avp(rstatus) $avp(rtext) towards $T_rpl($ct) => $avp(destination)");<br>
                append_hf("IMP-cust-profile-code: $var(cust_profile_code)\r\n");<br>
                $var(newai) = "<sip:" + $rU + "@" + $(ai{uri.host}) + ">";<br>
                append_hf("P-Asserted-Identity: $var(newai)\r\n");<br>
                $var(newdi) = "<sip:" + $rU + "@" + $(fu{uri.host}) + ">;reason=unknown";<br>
                append_hf("IMP-screening: no\r\n" );<br>
                append_hf("Diversion: $var(newdi)\r\n");<br>
                route(IMP_TRANSLATE_INBOUND);<br>
                route(IMP_ROUTE_TO_CORE);<br>
                exit;<br>
        }<br>
<br>
It sort of starts working, but I'm not there yet :-)<br>
<br>
The next issue I am right now bumping into is that I translated some<br>
'write is append' header towards the CPE ($tU and $fU) and now I am<br>
translating them again (as if they were sent from the CPE) and writing<br>
to them again so I end up with the original destination and new<br>
destination concatenated.<br>
<br>
Is there a way to 'reset' the $tU and $fU after setting them once, so<br>
that they can be set again?<br>
<br>
-- <br>
Mit freundlichen Grüssen<br>
<br>
-Benoît Panizzon- @ HomeOffice und normal erreichbar<br>
-- <br>
I m p r o W a r e   A G    -    Leiter Commerce Kunden<br>
______________________________________________________<br>
<br>
Zurlindenstrasse 29             Tel  +41 61 826 93 00<br>
CH-4133 Pratteln                Fax  +41 61 826 93 01<br>
Schweiz                         Web  <a href="http://www.imp.ch">http://www.imp.ch</a><br>
______________________________________________________<br>
</div>
</span></font></div>
</body>
</html>