[SR-Users] How to handle a 301 redirect request from a client?

Patrick Karton patrickarton at hotmail.com
Fri Jun 24 16:32:47 CEST 2022


its not a good idea to make manipulations in failure_route like you do.

in failure_route you are working on the initial request.

since you want to apply manipulation on the new user received from 300 response you need to use branch_route for this. thats one of his purpose.

________________________________
De : Benoît Panizzon <benoit.panizzon at imp.ch>
Envoyé : vendredi 24 juin 2022 15:06
À : Patrick Karton <patrickarton at hotmail.com>
Cc : Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org>
Objet : Re: [SR-Users] How to handle a 301 redirect request from a client?

Salut Patrick

Thank you for your help.

I ended up with this:

        if (t_check_status("(301)|(302)") or (t_branch_timeout() and !t_branch_replied())) {
                $avp(destination) = $(T_rpl($ct){tobody.user});
                xlog("L_ERR", "$cfg(route): Got: $avp(rstatus) $avp(rtext) towards $T_rpl($ct) => $avp(destination)");
                append_hf("IMP-cust-profile-code: $var(cust_profile_code)\r\n");
                $var(newai) = "<sip:" + $rU + "@" + $(ai{uri.host}) + ">";
                append_hf("P-Asserted-Identity: $var(newai)\r\n");
                $var(newdi) = "<sip:" + $rU + "@" + $(fu{uri.host}) + ">;reason=unknown";
                append_hf("IMP-screening: no\r\n" );
                append_hf("Diversion: $var(newdi)\r\n");
                route(IMP_TRANSLATE_INBOUND);
                route(IMP_ROUTE_TO_CORE);
                exit;
        }

It sort of starts working, but I'm not there yet :-)

The next issue I am right now bumping into is that I translated some
'write is append' header towards the CPE ($tU and $fU) and now I am
translating them again (as if they were sent from the CPE) and writing
to them again so I end up with the original destination and new
destination concatenated.

Is there a way to 'reset' the $tU and $fU after setting them once, so
that they can be set again?

--
Mit freundlichen Grüssen

-Benoît Panizzon- @ HomeOffice und normal erreichbar
--
I m p r o W a r e   A G    -    Leiter Commerce Kunden
______________________________________________________

Zurlindenstrasse 29             Tel  +41 61 826 93 00
CH-4133 Pratteln                Fax  +41 61 826 93 01
Schweiz                         Web  http://www.imp.ch
______________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20220624/331b68ee/attachment.htm>


More information about the sr-users mailing list