Hi, yeah, that looks like a good solution. But I assume that there should be the similar way to use the shm or pseudo variables as a array. Maybe someone else does know more about this way?
Best regards, Bernhard -----Ursprüngliche Nachricht----- Von: sr-users-boun...@lists.sip-router.org [mailto:sr-users-boun...@lists.sip-router.org] Im Auftrag von Alex Balashov Gesendet: Dienstag, 2. November 2010 14:41 An: sr-users@lists.sip-router.org Betreff: Re: [SR-Users] loop through variables 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; } -- Alex Balashov - Principal Evariste Systems LLC 1170 Peachtree Street 12th Floor, Suite 1200 Atlanta, GA 30309 Tel: +1-678-954-0670 Fax: +1-404-961-1892 Web: http://www.evaristesys.com/ _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users