[OpenSIPS-Users] variable/avp value check

Alexey slackway2me at gmail.com
Wed Feb 7 10:31:58 UTC 2024


Hi list,

what is the best way in 3.2 to push multiple values from DB query to an avp
and then check if other variable or other avp value is among one of
those values ?

There is some simple table, like

1234    customer1
5678    customer2
... etc

I'd like to fetch some integer from From: header of INVITE (not a problem),
and check if this integer is in that table.
And implement some caching, not to do SQL query for each INVITE.

Maybe one of solutions is to use avp_db_query [1] and then store
all results which were obtained from the table into some single AVP
with multiple values?
(if it can be unlimited? I need several dozens, no more, but the total
count may be dynamic)

If so, what is the best way to check if some variable's value is one
from all values of a single AVP?


An example to make my question more clear:

    INVITE sip:995322807050 at 1.2.3.4:5060 SIP/2.0
    ...
    From: "customer-1234  995322807050" <sip:995591930xxx at x.x.y.z>;

... some script magic to fetch "1234" and assign it to some variable/AVP ...
And now I'd like to check if "1234" is in some table (or is not).

GROUP [2] module seems to be appropriate, but strict membership checking
needs an SQL query each time (no caching support), and regular expression
based checking uses cache but is not able to be reloaded without
OpenSIPS restart.
And we need both caching and reloading.


[1] https://opensips.org/docs/modules/3.2.x/avpops.html#func_avp_db_query
[2] https://opensips.org/docs/modules/3.2.x/group.html

-- 
best regards, Alexey
https://alexeyka.zantsev.com/



More information about the Users mailing list