Hi Gang
We want to allow customers to send a 301 to forward calls to mimik ISDN PARE.
The new destination is in the contact user HF.
So I guess I could handle this on the t_on_failure route to catch that error, extract the contact user HF, craft an appropriate Diversion header and send the call on.
But I wonder, is there maybe a module which handles all of this out of the box?
Hi Patrick
You can check the uac_redirect module.
Not sure it handle Diversion header but its a good starting point.
Merci! That sounds promising I'll try. The ability to add a 'reason' let's me hope it might create a Diversion header.
No the uac_redirect module does not create Diversion header.
but thats not a big issue.
we can still use branch_route to add a Diversion with diversion module before forwarding the request. ________________________________ De : Benoît Panizzon benoit.panizzon@imp.ch Envoyé : vendredi 24 juin 2022 11:11 À : Patrick Karton patrickarton@hotmail.com Cc : Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Objet : Re: [SR-Users] How to handle a 301 redirect request from a client?
Hi Patrick
You can check the uac_redirect module.
Not sure it handle Diversion header but its a good starting point.
Merci! That sounds promising I'll try. The ability to add a 'reason' let's me hope it might create a Diversion header.
-- 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 ______________________________________________________
t_on_failure("REDIRECT");
failure_route[REDIRECT] { if(!t_check_status("3[0-9][0-9]")) { exit; } if ( get_redirects("3:1") ) { t_on_branch("REDIRECT_ADD_DIVERSION"); t_relay(); }
}
branch_route[REDIRECT_ADD_DIVERSION] { add_diversion("user-busy"); add_diversion("user-busy", "$ru"); }
________________________________ De : sr-users sr-users-bounces@lists.kamailio.org de la part de Patrick Karton patrickarton@hotmail.com Envoyé : vendredi 24 juin 2022 11:21 À : Benoît Panizzon benoit.panizzon@imp.ch Cc : Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Objet : Re: [SR-Users] How to handle a 301 redirect request from a client?
No the uac_redirect module does not create Diversion header.
but thats not a big issue.
we can still use branch_route to add a Diversion with diversion module before forwarding the request. ________________________________ De : Benoît Panizzon benoit.panizzon@imp.ch Envoyé : vendredi 24 juin 2022 11:11 À : Patrick Karton patrickarton@hotmail.com Cc : Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Objet : Re: [SR-Users] How to handle a 301 redirect request from a client?
Hi Patrick
You can check the uac_redirect module.
Not sure it handle Diversion header but its a good starting point.
Merci! That sounds promising I'll try. The ability to add a 'reason' let's me hope it might create a Diversion header.
-- 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 ______________________________________________________
Hi Gang
if ( get_redirects("3:1") ) { t_on_branch("REDIRECT_ADD_DIVERSION"); t_relay();
Not working quite as expected. This seems to consider the complete URI received from the customer. I am only interested in the 'user' part containing the new target phone number not some bogus domain sent by the customer.
Is the 302 reply contact uri or user put in any PV I could access and do some manipulations before sending on (like translating from local notation to e164).
So I also attempted to extract the username from $ct only to notice, that $ct contains the value of the INVITE contact header sent to the customer, not of the 302 reply contact header.
you can do whatever manipulation you want in branch_route
just update what you want in branch_route either $rd , $rp.
no ,need to change $rU because it alreay contains the new user returned from 300.
t_on_failure("REDIRECT");
failure_route[REDIRECT] { if(!t_check_status("3[0-9][0-9]")) { exit; } if ( get_redirects("3:1") ) { t_on_branch("REDIRECT_ADD_DIVERSION"); t_relay(); }
}
branch_route[REDIRECT_ADD_DIVERSION]{ $rd = 'PUT_THE_DOMAIN_YOU_WANT_OR_THE_ONE_BEFORE_300'; # $rU = no need to change it ; it already contains the new user from 300 add_diversion("user-busy"); add_diversion("user-busy", "$ru"); }
________________________________ De : Benoît Panizzon benoit.panizzon@imp.ch Envoyé : vendredi 24 juin 2022 14:11 À : Patrick Karton patrickarton@hotmail.com Cc : Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Objet : Re: [SR-Users] How to handle a 301 redirect request from a client?
Hi Gang
if ( get_redirects("3:1") ) { t_on_branch("REDIRECT_ADD_DIVERSION"); t_relay();
Not working quite as expected. This seems to consider the complete URI received from the customer. I am only interested in the 'user' part containing the new target phone number not some bogus domain sent by the customer.
Is the 302 reply contact uri or user put in any PV I could access and do some manipulations before sending on (like translating from local notation to e164).
So I also attempted to extract the username from $ct only to notice, that $ct contains the value of the INVITE contact header sent to the customer, not of the 302 reply contact header.
-- 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 ______________________________________________________
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?
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@imp.ch Envoyé : vendredi 24 juin 2022 15:06 À : Patrick Karton patrickarton@hotmail.com Cc : Kamailio (SER) - Users Mailing List sr-users@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 ______________________________________________________
Salut Patrick
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.
So that is what I attempted...
if (t_check_status("(301)|(302)") or (t_branch_timeout() and !t_branch_replied())) { t_on_branch("TEST_BR"); route(IMP_ROUTE_TO_CORE); exit; }
branch_route[TEST_BR] { xlog("L_ERR", "$cfg(route): HERE WE ARE\n"); # To verify via logs this was triggered $fU = "+41441234567"; }
I still end up with +41441234567 being appended to the From User HF I have set previously for the invite towards the CPE which then replied with 302
For better understanding, this is the situation:
We want to use e164 on the 'core' as this is the format we have defined as 'normalized' format and which is also in use on IC to other TSP. Only to/from the customer CPE we translate numbers to from the mostly used national format.
Basically replacing +41 with '0' and + with '00' and the other way round.
So in this example From user is +41441234567 and location lookup is performed. Then From user is translated to 0441234567 to reflect the national notation and display the callerID in a usual format to the customer.
But when I get a 302 from that CPE and need to send the call back on an IC. I want to preserve the original From: username and translate it back to e164. But as I already have set $fU = "0441234567" when I do an additional $fU = "+41441234567" in branch_route, I and up with
From: "John Doe" 0441234567+41441234567@sip.example.com;user=phone
as setting $fU is APPENDING. No matter if I do this on a failure route or a branch route.
Or did I miss a trick? :-)
Would I need to also use branch_route to send the initial call towards the customer CPE and set the 'localized' $fU there? Is this message being dropped and the original one used again when triggering failure_route? Is this how it's supposed to work?
if something is still appended to From User thats means you updated $fU also before update it in branch_route.
surely you update $fU also in route[IMP_ROUTE_TO_CORE] thats why.
all updates to $fU must be done once otherwise you concatenate it.
________________________________ De : Benoît Panizzon benoit.panizzon@imp.ch Envoyé : vendredi 24 juin 2022 16:10 À : Patrick Karton patrickarton@hotmail.com Cc : Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Objet : Re: [SR-Users] How to handle a 301 redirect request from a client?
Salut Patrick
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.
So that is what I attempted...
if (t_check_status("(301)|(302)") or (t_branch_timeout() and !t_branch_replied())) { t_on_branch("TEST_BR"); route(IMP_ROUTE_TO_CORE); exit; }
branch_route[TEST_BR] { xlog("L_ERR", "$cfg(route): HERE WE ARE\n"); # To verify via logs this was triggered $fU = "+41441234567"; }
I still end up with +41441234567 being appended to the From User HF I have set previously for the invite towards the CPE which then replied with 302
For better understanding, this is the situation:
We want to use e164 on the 'core' as this is the format we have defined as 'normalized' format and which is also in use on IC to other TSP. Only to/from the customer CPE we translate numbers to from the mostly used national format.
Basically replacing +41 with '0' and + with '00' and the other way round.
So in this example From user is +41441234567 and location lookup is performed. Then From user is translated to 0441234567 to reflect the national notation and display the callerID in a usual format to the customer.
But when I get a 302 from that CPE and need to send the call back on an IC. I want to preserve the original From: username and translate it back to e164. But as I already have set $fU = "0441234567" when I do an additional $fU = "+41441234567" in branch_route, I and up with
From: "John Doe" 0441234567+41441234567@sip.example.com;user=phone
as setting $fU is APPENDING. No matter if I do this on a failure route or a branch route.
Or did I miss a trick? :-)
Would I need to also use branch_route to send the initial call towards the customer CPE and set the 'localized' $fU there? Is this message being dropped and the original one used again when triggering failure_route? Is this how it's supposed to work?
-- 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 ______________________________________________________
24 juni 2022 kl. 17:34 skrev Patrick Karton patrickarton@hotmail.com:
if something is still appended to From User thats means you updated $fU also before update it in branch_route.
surely you update $fU also in route[IMP_ROUTE_TO_CORE] thats why.
all updates to $fU must be done once otherwise you concatenate it.
Is this documented anywhere? If not, we need to add it to docs.
/O
De : Benoît Panizzon <benoit.panizzon@imp.ch mailto:benoit.panizzon@imp.ch> Envoyé : vendredi 24 juin 2022 16:10 À : Patrick Karton <patrickarton@hotmail.com mailto:patrickarton@hotmail.com> Cc : Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org mailto:sr-users@lists.kamailio.org> Objet : Re: [SR-Users] How to handle a 301 redirect request from a client?
Salut Patrick
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.
So that is what I attempted...
if (t_check_status("(301)|(302)") or (t_branch_timeout() and !t_branch_replied())) { t_on_branch("TEST_BR"); route(IMP_ROUTE_TO_CORE); exit; }
branch_route[TEST_BR] { xlog("L_ERR", "$cfg(route): HERE WE ARE\n"); # To verify via logs this was triggered $fU = "+41441234567"; }
I still end up with +41441234567 being appended to the From User HF I have set previously for the invite towards the CPE which then replied with 302
For better understanding, this is the situation:
We want to use e164 on the 'core' as this is the format we have defined as 'normalized' format and which is also in use on IC to other TSP. Only to/from the customer CPE we translate numbers to from the mostly used national format.
Basically replacing +41 with '0' and + with '00' and the other way round.
So in this example From user is +41441234567 and location lookup is performed. Then From user is translated to 0441234567 to reflect the national notation and display the callerID in a usual format to the customer.
But when I get a 302 from that CPE and need to send the call back on an IC. I want to preserve the original From: username and translate it back to e164. But as I already have set $fU = "0441234567" when I do an additional $fU = "+41441234567" in branch_route, I and up with
From: "John Doe" <0441234567+41441234567@sip.example.com mailto:0441234567+41441234567@sip.example.com>;user=phone
as setting $fU is APPENDING. No matter if I do this on a failure route or a branch route.
Or did I miss a trick? :-)
Would I need to also use branch_route to send the initial call towards the customer CPE and set the 'localized' $fU there? Is this message being dropped and the original one used again when triggering failure_route? Is this how it's supposed to work?
-- 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 http://www.imp.ch/ ______________________________________________________ __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions
- sr-users@lists.kamailio.org mailto:sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: