On 11/02/2010 09:35 AM, Sergey Okhapkin wrote:
htable module should do the trick to you.
On Tuesday 02 November 2010, Bernhard Suttner wrote:
Hi,
I want something like that:
# define some router to use later in the script (global section) Mod_param(router(1), "10.10.10.1") mod_param(router(2), "10.10.10.2") mod_param(router(3), "10.10.10.3") Mod_param(router_count, "3")
within the different routes I want to loop through the routers like that:
$var(i) while($(var(i)< $var(router_count)) { if ($var(router($var(i)) == src_ip") { .. do something } }
Another option is to push the constants into AVP arrays at startup (I assume there is some sort of init route at this point, otherwise a module init event-route):
$(avp(s:routers)[0]) = "10.10.10.1"; $(avp(s:routers)[1]) = "10.10.10.2"; $(avp(s:routers)[2]) = "10.10.10.3";
You can then iterate through them, using is_avp_set() to check if something exists at the current index/array subscript:
$var(i) = 0;
while(is_avp_set("$(avp(s:routers)[$var(i)])")) { xlog("L_INFO", "Router is: $(avp(s:routers)[$var(i)])\n"; $var(i) = $var(i) + 1; }