[OpenSER-Users] [avp_db_query] How to analize resulting AVP's row by row?

Daniel-Constantin Mierla daniel at voice-system.ro
Mon Aug 13 18:54:57 CEST 2007


Hello,

you can access the avps via index. Also, what you want can be achieved 
via some recursive route calling. It is a bit complex, here is the 
pseudo-algorithm:
- call the route where in first place check if $avp(s:priority) is null, 
if yes, rename back all the avps (see next) and return false
- if not, do the checking you want and rename the current set of avps to 
something else and run again the route if you need it

basically by renaming the avp you can iterate via calling routes 
recursively until no more avps with initial name are in place. hope you 
understand me, I will have in mind to add ability to provide the index 
to an avp via another PV.

Cheers,
Daniel

On 08/13/07 13:19, Iñaki Baz Castillo wrote:
> Hi, in order to implement a ACL system for incoming calls I've 
> created a table "acl" with those columns:
>
> - priority
> - from_username
> - from_domain 
> - to_username 
> - group_from 
> - group_to 
> - type | action
>
>
> In that tables I store rules, and my idea is to work as a firewall: 
> the first match is ejecuted (action=ALLOW or action=REJECT) and exit.
>
> But I can't do it since I don't know how to use all the AVP's JUST 
> for the first row, then for the second:
>
> avp_db_query("SELECT priority,from_username,from_domain,to_username,group_from,group_to,type,action FROM acl", "$avp(s:priority);$avp(s:from_username);$avp(s:from_domain);$avp(s:to_username);$avp(s:group_from);$avp(s:group_to);$avp(s:type);$avp(s:action)");
>
> This query results in many rows, but I can't analize each row, I just 
> can compare each AVP with a value, but for that AVP they are possible 
> all the values of any row.
>
> Because this I'm thinking in using the "exec" module to call a system 
> script. Is not possible to access to tjhe query result by rows?
>
>
> Thanks for any help.
>
>
>
>   




More information about the sr-users mailing list