Daniel,
Ok so if i'm correct i can prefix the callid with for example 1234 to
avoid matching the eq. In other words eq will only match the regex
code if the callid string starts with it?
And by mathing on equal you mean: $shtcn(ht_test=>==$var(htid)) ?
Thanks,
Jan
Daniel-Constantin Mierla schreef op 2018-10-16 10:16:
Just to add that regexp matching when using keys
from the sip message
such as call-id is exposed further to some issues -- for example, it is
common to have . (dot) in call-id, which for a regexp is matching any
char, so a call id having 123.456 is matching 123x456. So depending on
what you want to count, might be better to match by equal or prefix
rules.
Cheers,
Daniel
On 16.10.18 10:03, jenus(a)cyberchaos.nl wrote:
> Daniel,
>
> Thanks for the quick response, that indeed solves my problem.
>
>
> Jan
>
> Daniel-Constantin Mierla schreef op 2018-10-16 09:55:
>> Hello,
>>
>> the expression in the $shtcn(table=>exp) can have some operators at
>> the
>> beginning, see:
>>
>> -
>>
https://www.kamailio.org/wiki/cookbooks/devel/pseudovariables#shtcn_htable_…
>>
>>
>>
>> So, eq is one of them, the safest is to explicitly set the operator if
>> you cannot predict what is the key, like in this case. If the operator
>> is missing, then the exp is matched as regular expression, so you can
>> do:
>>
>> $shtcn(ht_test=>~~$var(htid))
>>
>> Cheers,
>> Daniel
>>
>>
>> On 16.10.18 09:47, jenus(a)cyberchaos.nl wrote:
>>> Hello,
>>>
>>> I'm running kamailio 5.1.4 and running into a issue with htable. I
>>> use
>>> it to store some dialog data so i can use it in a http route. When i
>>> use the callid as a key it creates a issue for callid's starting with
>>> eq. Here some example code that i use to reproduce the issue:
>>>
>>>
>>> modparam("htable", "htable",
"ht_test=>size=16;autoexpire=10")
>>>
>>> $var(htable-val) = $_s($dlg(h_entry)) + "::" + $_s($dlg(h_id)) +
"::"
>>> + $Ts;
>>> xlog("L_WARN", "HT_TEST: Adding $var(htable-val) to ht_test
with key
>>> eq1234");
>>> $var(htid) = "eq1234";
>>> $sht(ht_test=>$var(htid)) = $var(htable-val);
>>> $var(htable-val) = $null;
>>>
>>> if ($shtcn(ht_test=>$var(htid)) > 0)
>>> {
>>> xlog("L_WARN", "HT_TEST: Key eq1234 found!");
>>> } else {
>>> xlog("L_WARN", "HT_TEST: Key eq1234 NOT found!");
>>> }
>>> $var(htid) = $null;
>>>
>>> Results in :
>>>
>>> Oct 16 09:36:31 sip03 /usr/sbin/kamailio[22344]: WARNING: <script>:
>>> HT_TEST: Adding 531::926::1539675391 to ht_test with key eq1234
>>> Oct 16 09:36:31 sip03 /usr/sbin/kamailio[22344]: WARNING: <script>:
>>> HT_TEST: Key eq1234 NOT found!
>>>
>>>
>>> When i prefix eq with a 1 it works fine:
>>>
>>> modparam("htable", "htable",
"ht_test=>size=16;autoexpire=10")
>>>
>>> $var(htable-val) = $_s($dlg(h_entry)) + "::" + $_s($dlg(h_id)) +
"::"
>>> + $Ts;
>>> xlog("L_WARN", "HT_TEST: Adding $var(htable-val) to ht_test
with key
>>> eq1234");
>>> $var(htid) = "1eq1234";
>>> $sht(ht_test=>$var(htid)) = $var(htable-val);
>>> $var(htable-val) = $null;
>>>
>>> if ($shtcn(ht_test=>$var(htid)) > 0)
>>> {
>>> xlog("L_WARN", "HT_TEST: Key eq1234 found!");
>>> } else {
>>> xlog("L_WARN", "HT_TEST: Key eq1234 NOT found!");
>>> }
>>> $var(htid) = $null;
>>>
>>> Results in:
>>>
>>> Oct 16 09:37:25 sip03 /usr/sbin/kamailio[22555]: WARNING: <script>:
>>> HT_TEST: Adding 3050::1098::1539675445 to ht_test with key eq1234
>>> Oct 16 09:37:25 sip03 /usr/sbin/kamailio[22555]: WARNING: <script>:
>>> HT_TEST: Key eq1234 found!
>>>
>>>
>>> Am i running into a bug? Or are there some restrictions on the
>>> key's i
>>> can use? I'm still going trough the logs to check if there are more
>>> callid's that have a issue with matching.
>>>
>>>
>>> Thanks,
>>>
>>> Jan Hazenberg
>>>
>>> _______________________________________________
>>> Kamailio (SER) - Users Mailing List
>>> sr-users(a)lists.kamailio.org
>>>
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>