Answering myself: This is a "feature".
Assigning AVPs multiple times add an additional AVP with the same name.
To overwrite an existing AVP the following syntax is needed:
$(avp(pattern)[*]) = .....
regards
Klaus
On 07.07.2014 12:50, Klaus Darilion wrote:
Hi!
Kamailio 4.1.4. When using avp_check with fnmatch and AVP the result is
always TRUE if it is true for 1 time. It only happens with $avp(), but
not with $var().
Is this a bug or some special behavior of AVPs?
xlog("L_ERR", "======= with $$avp(...)================");
$avp(rpid) = "+499539110";
$avp(pattern) = "+499539[2-5]"; # NO MATCH
if (avp_check("$avp(rpid)", "fm/$avp(pattern)/g")) {
xlog("L_ERR", "$avp(rpid) matches $avp(pattern): YES");
} else {
xlog("L_ERR", "$avp(rpid) matches $avp(pattern): NO");
}
$avp(pattern) = "+499539*"; # MATCH
if (avp_check("$avp(rpid)", "fm/$avp(pattern)/g")) {
xlog("L_ERR", "$avp(rpid) matches $avp(pattern): YES");
} else {
xlog("L_ERR", "$avp(rpid) matches $avp(pattern): NO");
}
$avp(pattern) = "+499539[2-5]"; # NO MATCH
if (avp_check("$avp(rpid)", "fm/$avp(pattern)/g")) {
xlog("L_ERR", "$avp(rpid) matches $avp(pattern): YES");
} else {
xlog("L_ERR", "$avp(rpid) matches $avp(pattern): NO");
}
xlog("L_ERR", "======= with $$var(...)================");
$var(rpid) = "+499539110";
$var(pattern) = "+499539[2-5]"; # NO MATCH
if (avp_check("$var(rpid)", "fm/$var(pattern)/g")) {
xlog("L_ERR", "$var(rpid) matches $var(pattern): YES");
} else {
xlog("L_ERR", "$var(rpid) matches $var(pattern): NO");
}
$var(pattern) = "+499539*"; # MATCH
if (avp_check("$var(rpid)", "fm/$var(pattern)/g")) {
xlog("L_ERR", "$var(rpid) matches $var(pattern): YES");
} else {
xlog("L_ERR", "$var(rpid) matches $var(pattern): NO");
}
$var(pattern) = "+499539[2-5]"; # NO MATCH
if (avp_check("$var(rpid)", "fm/$var(pattern)/g")) {
xlog("L_ERR", "$var(rpid) matches $var(pattern): YES");
} else {
xlog("L_ERR", "$var(rpid) matches $var(pattern): NO");
}
--> The result is:
<script>: ======= with $avp(...)================
<script>: +499539110 matches +499539[2-5]: NO
<script>: +499539110 matches +499539*: YES
<script>: +499539110 matches +499539[2-5]: YES
<script>: ======= with $var(...)================
<script>: +499539110 matches +499539[2-5]: NO
<script>: +499539110 matches +499539*: YES
<script>: +499539110 matches +499539[2-5]: NO
Thanks
Klaus
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users(a)lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users