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(); }
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@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users