Elena,
That is an EXTREMELY useful module! :-) Thanks!! I have been thinking
that a facility like this within the configuration script is needed
pretty much since I started using OpenSER.
-- Alex
Elena-Ramona Modroiu wrote:
Hi,
I just committed a new module: htable
http://www.kamailio.org/docs/modules/devel/htable.html
It adds a generic hash table container for usage in configuration file.
The hash table is in shared memory, therefore the values are global over
all kamailio processes.
The items in hash table can be accessed via $sht(name). The name can
include pseudo-variables that will be evaluated at runtime. In this way,
the hash table can be used to store data per user and can offer
functionality of dealing with array of values.
An example of how to protect against dictionary attacks is in the README
(link to online version above).
As another example, loading values in hash tables from AVPs and building
an array:
$var(i) = 0;
while($(avp(s:tmp)[$var(i)]) != NULL)
{
$sht(tmp[$var(i)]) = $(avp(s:tmp)[$var(i)]);
$var(i) = $var(i)+1;
}
As a roadmap for the new module, planned for addition:
- MI commands to get/set items in HT
- ability to save/load in/from database
- ability to init items at startup
- auto-expire time for items
This completes global variables space along with shared variables
($shv(name)) which are single value and allow only static name, but they
are faster to access (see cfgutils readme file for more details on
$shv(name)).
Regards,
Ramona
--
Alex Balashov
Evariste Systems
Web :
http://www.evaristesys.com/
Tel : (+1) (678) 954-0670
Direct : (+1) (678) 954-0671
Mobile : (+1) (706) 338-8599