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

Helena Garcia-Nieto helena.gnieto at morodo.co.uk
Thu Feb 13 13:40:16 CET 2014


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_replace_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




More information about the sr-users mailing list