[OpenSIPS-Users] dp_translate() on other headers?
Kingsley Tart
kingsley at dns99.co.uk
Fri Mar 26 16:09:02 EST 2021
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.
More information about the Users
mailing list