[Kamailio-Users] (no subject)

Daniel-Constantin Mierla miconda at gmail.com
Tue Nov 18 12:18:16 CET 2008


Hello,

On 11/13/08 16:42, Ricardo Martinez wrote:
>
> Hello list.
>
> I’m having some problems trying to build a counter for my kamailio.cfg 
> file.
>
> This is what I have..
>
> Th
>
> main()
>
>>
> load avp from radius}
>
> var(i)=0;
>
> route(3);
>
>>
> route[1] {
>
> t_on_failure("1");
>
> if (!t_relay()) {
>
> sl_reply_error();
>
> };
>
> xlog("L_INFO","[$ci] $rm t_relay a $ru");
>
> exit;
>
> }
>
> route(3)
>
>>
> $var(nr)=$avp(s:caller_nr);
>
> If ( var(i) < $var(nr) );
>
> $var(i) = $var(i) + 1;
>
> route(1);
>
> else
>
> exit;
>
> failure_route[1] {
>
> xlog("L_INFO", "[$ci] $rm:$ru failure_route\n");
>
> if (t_was_cancelled()) {
>
> xlog("L_INFO", "[$ci] $rm:$ru t_was_cancelled en failure_route\n");
>
> exit;
>
> }
>
> if (!next_gw()) {
>
> xlog("L_INFO", "[$ci] No hay mas gateways para $rm:$ou\n");
>
> route(3);
>
> } else {
>
> xlog("L_INFO", "XXXXX");
>
> }
>
> t_on_failure("1");
>
> t_relay();
>
> }
>
> After I restart the service the first time a call arrives the counter 
> seems to go OK, the counter goes from 0 to 2 (if the caller_nr=3). But 
> the second time the $var(i) at the main and route(3) it’s = 0, but in 
> the failure_route it keeps the value = 3. What I’m doing wrong?
>
> Can someone help me here?
>
the $var(x) variables are per process. As you use them in failure route, 
the process can be different. You need a counter specific per SIP 
message, therefore you have to use AVPs. Use := operator so you are sure 
there is a single avp counter.
$avp(i:23) := $avp(i:23) + 1;

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
http://www.asipto.com





More information about the sr-users mailing list