[SR-Users] modify To header, prefix + ip, using dispacher module.

Helena Garcia-Nieto helena.gnieto at morodo.co.uk
Fri Feb 14 14:23:42 CET 2014


Hi Carsten

Thanks for the info, but I cannot use a branch route, because it is a
failure route, and I need to execute the dispatcher funcitonst to set the
destination to proving and to select the next destination.

Does anyone know how to set the TO header to use always the same username
and domain than the RURI, even on failures?

Thanks in advanced

Helena

-----Original Message-----
From: sr-users-bounces at lists.sip-router.org
[mailto:sr-users-bounces at lists.sip-router.org] On Behalf Of Carsten Bock
Sent: jueves, 13 de febrero de 2014 14:43
To: Kamailio (SER) - Users Mailing List
Subject: Re: [SR-Users] modify To header, prefix + ip, using dispacher
module.

Hi Helena,

we do it the following way:

In the main route:
t_on_branch("some_route");

branch_route[some_route] {
 uac_replace_to(....);
}

This way, the uac_* functions get executed for each branch individually.

Kind regards,
Carsten

2014-02-13 13:40 GMT+01:00 Helena Garcia-Nieto <helena.gnieto at morodo.co.uk>:
> Hi,
>
> Thanks for the tip, but  I cannot manage it to work...
>
> I hadn't uac module loaded, I loaded it and added
>
> #MORODO TEST TO MODIFICATION
> loadmodule "uac.so"
> modparam("uac","restore_mode","none")
>
> The uac function cannot be used on the failure rutine (it gives an 
> error when restarting) so I chaged the order:
>
> That is the default routing
> route[FROMPHONE] {
> [...]
>         if(!ds_select_domain("1", "8"))
>         {
>                 send_reply("404", "No destination");
>                 exit;
>         }
>         t_on_failure("RTF_DISPATCH");
>
>        #MORODO Add profix to ISKRATEL: 0199
>                 subst_uri('/^sip:(.*)/sip:0199\1/i'); # add prefix to URI
>         uac_replace_to("","sip:0199$rU@$rd");
>
>         route(RELAY);
>         exit;
>
> }
>
> That is the failure function
>
> failure_route[RTF_DISPATCH] {
>         if (t_is_canceled()) {
>                 exit;
>         }
>
>         #marking the gw as failed and set state proving, to send options
>         ds_mark_dst("p");
>
>         # next DST - only for 500 or local timeout
>         if (t_check_status("500") or (t_branch_timeout() and
> !t_branch_replied()))
>         {
>                 if(ds_next_domain())
>                 {
>                         t_on_failure("RTF_DISPATCH"); #in case of fail 
> again it would try the next option
>
>                 #MORODO, update IP on TO header
>
>                 subst_hf("To", "/(.*)@(.*)$/\1@$rd>/", "a");
>                         route(RELAY);
>                         exit;
>                 }
>         }
> }
>
> But the result TO header is the same strange thing... mix of what it 
> was on normal routine + what I wanted after the failure...
>
> To: <sip:0199XXXXX10 at 10.X.X.39>sip:0199XXXXX10 at 10.X.X.38
>
> It is like once the TO is modified, It does not modify it ok anymore...
>
> Would you do it any other way that could be better?
>
> Helena
>
>
> -----Original Message-----
> From: sr-users-bounces at lists.sip-router.org
> [mailto:sr-users-bounces at lists.sip-router.org] On Behalf Of Daniel 
> Tryba
> Sent: miércoles, 12 de febrero de 2014 18:30
> To: sr-users at lists.sip-router.org
> Subject: Re: [SR-Users] modify To header, prefix + ip, using dispacher 
> module.
>
> On Wednesday 12 February 2014 17:37:46 Helena Garcia-Nieto wrote:
>> I tried modifying again the TO header with:
>> subst_hf("To", "/(.*)@(.*)$/\1@$rd>/", "a")
>>
>> before the route(relay) on the failure routine, but it does not work 
>> properly, I am getting strange TO header like:
>>
>> To: <sip:0199XXXX at 10.X.X.39> <sip:XXXXXX at 10.X.X.38>
>>
>> It looks like it is not parsing the to header it has before but 
>> adding a parsed version of the original header at the end of the other
one....
>> I tried with subst as well but the result is more or less the same.
>>
>> Probably there is a better way to set the prefix and the correct IP 
>> on
>  the to header... I'll appreciate any help with this issue.
>
> How about just using uac_replace_to()?
>
> http://kamailio.org/docs/modules/stable/modules/uac.html#uac.f.uac_rep
> lace_t
> o%28display,uri%29
>
> 4.4.  uac_replace_to(display,uri)
>
> Replace in TO header the display name and the URI part.
>
> display and URI parameters can include pseudo-variables.
>
> This function can be used from REQUEST_ROUTE and from BRANCH_ROUTE.
>
> --
>
> POCOS B.V. - Croy 9c - 5653 LC Eindhoven
> Telefoon: 040 293 8661 - Fax: 040 293 8658
> http://www.pocos.nl/   - http://www.sipo.nl/
> K.v.K. Eindhoven 17097024
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing 
> list sr-users at lists.sip-router.org 
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing 
> list sr-users at lists.sip-router.org 
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



--
Carsten Bock
CEO (Geschäftsführer)

ng-voice GmbH
Schomburgstr. 80
D-22767 Hamburg / Germany

http://www.ng-voice.com
mailto:carsten at ng-voice.com

Office +49 40 34927219
Fax +49 40 34927220

Sitz der Gesellschaft: Hamburg
Registergericht: Amtsgericht Hamburg, HRB 120189
Geschäftsführer: Carsten Bock
Ust-ID: DE279344284

Hier finden Sie unsere handelsrechtlichen Pflichtangaben:
http://www.ng-voice.com/imprint/

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users at lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users




More information about the sr-users mailing list