<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
you can use avp (or xavp) to simulate array:<br>
<br>
$avp(x) = 1;<br>
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
$avp(x) = 2;<br>
$var(i) = 0;<br>
<br>
while($(avp(x)[$var(i)])!=$null) {<br>
...<br>
$var(i) = $var(i) + 1;<br>
}<br>
<br>
Important to know:<br>
- 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<br>
<br>
Also, note that when you provide an index, you have to enclose
everything in a pair of parenthesis starting after $.<br>
<br>
More details at:<br>
<br>
-
<a class="moz-txt-link-freetext" href="http://www.kamailio.org/wiki/cookbooks/4.1.x/pseudovariables#avp_id_-_avps">http://www.kamailio.org/wiki/cookbooks/4.1.x/pseudovariables#avp_id_-_avps</a><br>
<br>
Cheers,<br>
Daniel<br>
<br>
<div class="moz-cite-prefix">On 15/08/14 14:19, ANTHONY HESNAUX
wrote:<br>
</div>
<blockquote
cite="mid:D680B797-AA91-4EFF-972A-A972E4DC0688@gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
hello all,
<div><br>
</div>
<div>Can you define an array and a loop in kamailio.cfg</div>
<div><br>
</div>
<div>not work !!!!</div>
<div><br>
</div>
<div>
<div>$var(i) = 0;</div>
</div>
<div><br>
</div>
<div>tab[0]="192.168.0.2";</div>
<div>tab[1]="192.168.0.3 »;</div>
<div><br>
</div>
<div>
<div>while($var(i)<2) </div>
<div>{ </div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>$var(rip)
= $tab[$var(i)<span style="font-family: Menlo; font-size:
11px;">];</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span><font
face="Menlo"><span style="font-size: 11px;">$uac_req(method)="REGISTER »;</span></font></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span><span
style="font-family: Menlo; font-size: 11px;">$uac_req(ruri)="sip:"
+ $var(rip) + ":" + $sel(cfg_get.asterisk.bindport);</span></div>
<div><span style="font-family: Menlo; font-size: 11px;">
$uac_req(furi)="sip:" + $au + "@" + $var(rip);</span></div>
<div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
<div style="margin: 0px;"> $uac_req(turi)="sip:" + $au +
"@" + $var(rip);</div>
<div style="margin: 0px;"> $uac_req(hdrs)="Contact:
<sip:" + $au + "@"</div>
<div style="margin: 0px;"> +
$sel(cfg_get.kamailio.bindip)</div>
<div style="margin: 0px;"> +
":" + $sel(cfg_get.kamailio.bindport) + ">\r\n";</div>
<div style="margin: 0px;"> if($sel(contact.expires) !=
$null)</div>
<div style="margin: 0px;"> $uac_req(hdrs)=
$uac_req(hdrs) + "Expires: " + $sel(contact.expires) +
"\r\n";</div>
<div style="margin: 0px;"> else</div>
<div style="margin: 0px;"> $uac_req(hdrs)=
$uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n »;</div>
<div style="margin: 0px;"> uac_req_send();</div>
</div>
</div>
<div> }</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Next Kamailio Advanced Trainings 2014 - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
Sep 22-25, Berlin, Germany ::: Oct 15-17, San Francisco, USA</pre>
</body>
</html>