[SR-Users] can you define an array and loop in kamailio.cfg
Daniel-Constantin Mierla
miconda at gmail.com
Fri Aug 15 15:34:55 CEST 2014
Hello,
you can use avp (or xavp) to simulate array:
$avp(x) = 1;
$avp(x) = 2;
$var(i) = 0;
while($(avp(x)[$var(i)])!=$null) {
...
$var(i) = $var(i) + 1;
}
Important to know:
- avps work as a stack, so the last added is first in the list/array and
the first added is going to be the last
Also, note that when you provide an index, you have to enclose
everything in a pair of parenthesis starting after $.
More details at:
- http://www.kamailio.org/wiki/cookbooks/4.1.x/pseudovariables#avp_id_-_avps
Cheers,
Daniel
On 15/08/14 14:19, ANTHONY HESNAUX wrote:
> hello all,
>
> Can you define an array and a loop in kamailio.cfg
>
> not work !!!!
>
> $var(i) = 0;
>
> tab[0]="192.168.0.2";
> tab[1]="192.168.0.3 »;
>
> while($var(i)<2)
> {
> $var(rip) = $tab[$var(i)];
> $uac_req(method)="REGISTER »;
> $uac_req(ruri)="sip:" + $var(rip) + ":" + $sel(cfg_get.asterisk.bindport);
> $uac_req(furi)="sip:" + $au + "@" + $var(rip);
> $uac_req(turi)="sip:" + $au + "@" + $var(rip);
> $uac_req(hdrs)="Contact: <sip:" + $au + "@"
> + $sel(cfg_get.kamailio.bindip)
> + ":" +
> $sel(cfg_get.kamailio.bindport) + ">\r\n";
> if($sel(contact.expires) != $null)
> $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " +
> $sel(contact.expires) + "\r\n";
> else
> $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " +
> $hdr(Expires) + "\r\n »;
> uac_req_send();
> }
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany ::: Oct 15-17, San Francisco, USA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20140815/f0b0a2df/attachment.html>
More information about the sr-users
mailing list