Hello again,
Just to reply to my own email.
I was able to make it work including the regex capturing group as part
of the AVP.
So the following config works:
modparam("dialplan", "match_dynamic", 1)
$avp(s:PSTNAC) = "^0(.*)";
Dialplan entry:
dpid = 1
match_op = 1
match_exp = $(avp(s:PSTNAC)[*])
match_len = 0
subst_exp = $(avp(s:PSTNAC)[*])
repl_exp = 9\1
Now as the next step I'm trying to use it with the AVP having multiple values.
From what I understood reading
https://github.com/kamailio/kamailio/issues/5#issue-51480460 the
dialplan entry having an avp with index all([*]) will be checked with
the avp values one by one.
This is the config being used:
modparam("dialplan", "match_dynamic", 1)
$avp(s:PSTNAC) = "^0(.*)";
$avp(s:PSTNAC) = "^3(.*)";
Dialplan entry:
dpid = 1
match_op = 1
match_exp = $(avp(s:PSTNAC)[*])
match_len = 0
subst_exp = $(avp(s:PSTNAC)[*])
repl_exp = 9\1
This is now causing any error message but the dialplan line is not
matching either.
This is what I see in the logs:
DEBUG: dialplan [dp_repl.c:232]: dpl_dynamic_pcre_list(): parsed pcre
expression: $(avp(s:PSTNAC)[*])
DEBUG: dialplan [dp_repl.c:201]: dpl_dyn_pcre_comp(): compiled dynamic
pcre expression: $(avp(s:PSTNAC)[*]) (^3(.*), ^0(.*)) 2
DEBUG: <core> [core/mem/q_malloc.c:366]: qm_malloc():
qm_malloc(0x75692244c020, 40) called from dialplan: dp_repl.c:
dpl_dynamic_pcre_list(271)
DEBUG: dialplan [dp_repl.c:620]: dp_translate_helper(): match check:
[$(avp(s:PSTNAC)[*])] -1
Ah I forgot to mention early this is with kamailio 5.2.5
Any ideas?
Thanks.
Em ter., 21 de jul. de 2020 às 19:31, João Vitor Arruda
<joao.arruda(a)gmail.com> escreveu:
Hello,
I'm trying to use the dialplan with $avp("key") on match_exp and
subst_exp but i'm getting an error message when there is a regex
capturing group on subst_exp to be used on repl_exp
This is the config used:
modparam("dialplan", "match_dynamic", 1)
$avp(s:PSTNAC) = "0";
Dialplan entry:
dpid = 1
match_op = 1
match_exp = ^$avp(s:PSTNAC)
match_len = 0
subst_exp = ^$avp(s:PSTNAC)(.*)
repl_exp = 9\1
After executing dp_translate while the dialplan is properly matched
the following error message occurs and the repl_exp didn't work as
expected:
ERROR: dialplan [dp_repl.c:422]: rule_translate(): illegal access to
1-th subexpr of subst expr (max 0)
I've tried some other dialplan entries like:
dpid = 1
match_op = 1
match_exp = ^$(avp(s:PSTNAC)[*])
match_len = 0
subst_exp = ^$(avp(s:PSTNAC)[*])(.*)
repl_exp = 9\1
But that resulted in the same error message and no replacement either.
Any suggestion on what I'm doing wrong here?
Thanks,
Joao Arruda