[OpenSIPS-Users] dp_translate() on other headers?

Răzvan Crainea razvan at opensips.org
Mon Mar 29 07:22:02 EST 2021


Hi, Kingsley!

The only way to do this is to remove the header and add a new one using 
remove_hf/append_hf functions.

Best regards,

Răzvan Crainea
OpenSIPS Core Developer
http://www.opensips-solutions.com

On 3/26/21 6:09 PM, Kingsley Tart wrote:
> Hi,
> 
> I'm using OpenSIPS 3.1.
> 
> I've set up some dialplan rule sets to normalise numbers depending on
> the carrier, eg:
> 
> +-------------------+---------------------+----------+
>> match_exp         | subst_exp           | repl_exp |
> 
> +-------------------+---------------------+----------+
>> ^\+44[1-9][0-9]+$ | ^\+44([1-9][0-9]+)$ | 0\1      |
>> ^\+[1-9][0-9]+$   | ^\+([1-9][0-9]+)$   | 00\1     |
>> ^\+44\*[0-9]+$    | ^\+44\*([0-9]+)$    | \1       |
> 
> +-------------------+---------------------+----------+
> 
> but I also need to do this with other headers that may be present and
> contain numbers, eg
> 
> P-Asserted-Identity
> P-Preferred-Identity
> Remote-Party-ID
> 
> I know I can extract the number from the header eg like this:
> 
> if (is_present_hf(P-Asserted-Identity)) {
>    if (dp_translate(1, $(hdr(P-Asserted-
> Identity){nameaddr.uri}{uri.user}), $var(newnum))) {
>      xlog("New value is $var(newnum)");
>    }
> }
> 
> but is there an equally neat way of putting the new value back inside
> the header string? I can't use $(hdr(P-Asserted-
> Identity){nameaddr.uri}{uri.user}) as an lvalue.
> 
> Otherwise I presume I'm going to have to make my dialplan regex matches
> try to home in on the number part by having "sip:" instead of my "^"
> anchor and "@" instead of my "$" anchor in the match rule and hope that
> doesn't happen to match anything else in the header (unlikely I know,
> but not impossible).
> 
> Forgive me if I've missed something obvious - I'm new to OpenSIPS.
> 
> Cheers,
> Kingsley.
> 
> 
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> 



More information about the Users mailing list