[OpenSER-Users] uac_replace_from

CSB kjcsb at xnet.co.nz
Wed Jan 9 18:36:52 CET 2008


> > I wish to replace the from address in the following manner
> >
> > Received From: "05551233" sip:05551233 at 203.89.001.001
> >
> > Replaced From: "5551233" sip:18585551233 at 203.89.001.001
> >
> >
> >
> > In other words I want to do what the strip and prefix commands do but
> on a
> > from header. Could anyone advise how this can be achieved in OpenSER
> 1.1?
>
> Use the "uac" module and "uac_replace_from()" function:
>   http://www.openser.org/docs/modules/1.1.x/uac.html#AEN160
>
The following code worked:
                avp_write("$fu","$avp(s:replaced_fu)");
                avp_copy("$avp(s:replaced_fu)", "$avp(s:original_fu)");
                avp_subst("$avp(s:replaced_fu)",
"/(sip:)(0)([0-9]+)/99\3/");
                uac_replace_from("sip:$avp(s:replaced_fu)");

Curiously I didn't need to add the $fd so the code worked differently to
what I expected:
original "sip:05551233 at 203.89.001.001"
regex (sip:)(0)([0-9]+)
This matches sip:05551233 with the third group of the match being 5551233.
We then add the prefix 99 to get 995551233
We then do the uac_replace_from prefixing with sip:. I would have expected
to add @ and the domain at the end but I don't need to; if I do so I get a
bogus URI with 2 domains i.e. sip:995551233 at domain@domain.

Cameron






More information about the Users mailing list