<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
using global custom parameters is a bit complex, because they cannot
be referred by a dynamic name.<br>
<br>
Creating a loop is not possible, you will have to put all the
options one after the other, using an if condition to see if it is
set, like:<br>
<br>
if($sel(cfg_get.asterisk1.bindip)!=$null &&
$sel(cfg_get.asterisk1.bindip)!="") {<br>
$var(astip) = $sel(cfg_get.asterisk1.bindip);<br>
if($sel(cfg_get.asterisk1.bindport)!=$null &&
$sel(cfg_get.asterisk1.bindport)!="") {<br>
$var(astport) = $sel(cfg_get.asterisk1.bindport);<br>
} else {<br>
$var(astport) = 5060;<br>
}<br>
route(REGFWD);<br>
}<br>
<br>
Then do the same for asterisk2, ...<br>
<br>
The route[REGFWD] has to be updated to use $var(astip) and
$var(astport) instead of using $sel(...).<br>
<br>
Perhaps i better to use hash table (because you can get the key
dynamic) or global avps in this case.<br>
<br>
For example with a hash table named ast:<br>
<br>
$var(i) = 1;<br>
while($sht(ast=>ip$var(i))!= $null) {<br>
$var(i) = $var(i) + 1;<br>
$var(astip) = $sht(ast=>ip$var(i));<br>
if($sht(ast=>port$var(i))!=$null) {<br>
$var(astport) = $sht(ast=>port$var(i));<br>
} else {<br>
$var(astport) = 5060;<br>
}<br>
route(REGFWD);<br>
}<br>
<br>
In the hash table 'ast' you need to add pairs like: (ip1,
"1.2.3.4"), (port1, "5060"), (ip2, "2.2.3.4"), (port2, "5060"), ...<br>
<br>
More about hash tables in config in the readme of htable module.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<div class="moz-cite-prefix">On 15/08/14 11:29, ANTHONY HESNAUX
wrote:<br>
</div>
<blockquote
cite="mid:A2B1EAB7-AC33-49FB-8281-2D9F88BB9FDC@gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
hello everybody,
<div><br>
</div>
<div>I would like loop in kamailio.cfg because I want register
soft phone on all asterisk system so I have this configuration</div>
<div><br>
</div>
<div>but also if I want add another asterisk system</div>
<div><br>
</div>
<div>my Kamailio.cfg</div>
<div><br>
</div>
<div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">#!define
WITH_ASTERISK</div>
</div>
<div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">#!define
WITH_CLUST_AST</div>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
<div style="margin: 0px; min-height: 13px;"><br>
</div>
<div style="margin: 0px;">#!ifdef WITH_ASTERISK</div>
<div style="margin: 0px;">asterisk.bindip = "<a
moz-do-not-send="true" href="http://asterisk.home.fr">asterisk.home.fr</a>"
desc "Asterisk IP Address"</div>
<div style="margin: 0px;">asterisk.bindport = "5080" desc
"Asterisk Port"</div>
<div style="margin: 0px;">kamailio.bindip = « <a
moz-do-not-send="true" href="http://kamailio.home.fr">kamailio.home.fr</a>"
desc "kamailio IP Address"</div>
<div style="margin: 0px;">kamailio.bindport = "5060" desc
"Kamailio Port"</div>
<div style="margin: 0px;">#!endif</div>
<div style="margin: 0px; min-height: 13px;"><br>
</div>
<div style="margin: 0px;">#!ifdef WITH_CLUST_AST</div>
<div style="margin: 0px;">#!define HOST 2</div>
<div style="margin: 0px;">asterisk1.bindip = "192.168.0.10" desc
« Asterisk - 1 - IP Address"</div>
<div style="margin: 0px;">asterisk1.bindport = "5080" desc
"Asterisk Port"</div>
<div style="margin: 0px;">asterisk2.bindip = "192.168.0.20" desc
« Asterisk - 2 - IP Address"</div>
<div style="margin: 0px;">asterisk2.bindport = "5080" desc
"Asterisk Port"</div>
<div style="margin: 0px;">#!endif</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">#
Forward REGISTER to Asterisk</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">route[REGFWD]
{</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
if(!is_method("REGISTER"))</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
{</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
return;</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
}</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$var(rip) = $sel(cfg_get.<b>asterisk1.bindip</b>);</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(method)="REGISTER";</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(ruri)="sip:" + $var(rip) + ":" + $sel(cfg_get.<b>asterisk1.bindport</b>);</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(furi)="sip:" + $au + "@" + $var(rip);</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(turi)="sip:" + $au + "@" + $var(rip);</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(hdrs)="Contact: <sip:" + $au + "@"</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
+ $sel(cfg_get.kamailio.bindip)</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
+ ":" +
$sel(cfg_get.kamailio.bindport) + ">\r\n";</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
if($sel(contact.expires) != $null)</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " +
$sel(contact.expires) + "\r\n";</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
else</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " +
$hdr(Expires) + "\r\n";</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
uac_req_send();</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span
class="Apple-tab-span" style="white-space:pre"> </span>$var(rip)
= $sel(cfg_get.<b>asterisk2.bindip</b>);</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(method)="REGISTER";</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(ruri)="sip:" + $var(rip) + ":" + $sel(cfg_get.<b>asterisk2</b>.bindport);</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(furi)="sip:" + $au + "@" + $var(rip);</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(turi)="sip:" + $au + "@" + $var(rip);</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(hdrs)="Contact: <sip:" + $au + "@"</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
+ $sel(cfg_get.kamailio.bindip)</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
+ ":" +
$sel(cfg_get.kamailio.bindport) + ">\r\n";</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
if($sel(contact.expires) != $null)</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " +
$sel(contact.expires) + "\r\n";</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
else</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " +
$hdr(Expires) + "\r\n";</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
uac_req_send();</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">}</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">#!endif</div>
<div> </div>
<div><br>
</div>
<div>thank you for your help</div>
<div><br>
</div>
<div>anthony</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</pre>
</body>
</html>