[Kamailio-Devel] new feature: generic shared container in config language

Elena-Ramona Modroiu ramona at asipto.com
Wed Sep 24 13:03:11 CEST 2008


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

-- 
Elena-Ramona Modroiu
Web: http://www.asipto.com




More information about the Devel mailing list