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.
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.
El Monday 13 August 2007 18:54:57 Daniel-Constantin Mierla escribió:
Hello,
you can access the avps via index.
Sorry, I've seen nothing about AVP's and index. Could you explain me this way please?
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,
Yes, I understood (but it's quite complex). Anyway, I think I've improved a lot my algorithm and now all the complex is in a single SQL query that just return a single row and single value. :)
Thanks for all and regards.
On 08/14/07 11:14, Iñaki Baz Castillo wrote:
El Monday 13 August 2007 18:54:57 Daniel-Constantin Mierla escribió:
Hello,
you can access the avps via index.
Sorry, I've seen nothing about AVP's and index. Could you explain me this way please?
$avp(i:23[2]) returns the value of third avp with id 23. http://www.openser.org/dokuwiki/doku.php/pseudovariables:devel#avps
Daniel
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,
Yes, I understood (but it's quite complex). Anyway, I think I've improved a lot my algorithm and now all the complex is in a single SQL query that just return a single row and single value. :)
Thanks for all and regards.
El Tuesday 14 August 2007 10:16:09 Daniel-Constantin Mierla escribió:
On 08/14/07 11:14, Iñaki Baz Castillo wrote:
El Monday 13 August 2007 18:54:57 Daniel-Constantin Mierla escribió:
Hello,
you can access the avps via index.
Sorry, I've seen nothing about AVP's and index. Could you explain me this way please?
$avp(i:23[2]) returns the value of third avp with id 23. http://www.openser.org/dokuwiki/doku.php/pseudovariables:devel#avps
Nice :)
Thanks.