[OpenSIPS-Users] syntax error in cfg file

Vlad Paiu vladpaiu at opensips.org
Sun Apr 28 19:17:55 CEST 2013


Hello,

It seems the OpenSIPS parser does not tolerate well constructs like
     if ( ($var(t2) - $avp(diff) ) <= 0 )

with expressions in the if conditions.

While we fix this, a quick work-around would be to use an auxiliary 
variable, like :
     $var(my_aux) = $var(t2) - $avp(diff);
     if ($var(my_aux) <= 0)
         ....

Also, I see that in your script you are using division operations. I 
hope that you are aware that OpenSIPS has only integer support, so you 
result vars will be truncated to int.
If you want to use float operations, see 
http://www.opensips.org/html/docs/modules/devel/mathops , but please 
note that it is only available in the current OpenSIPS trunk.

Best Regards,
Vlad

Pe 4/28/2013 3:10 PM, Pinky harish chandran a scris:
>
> branch_route[2] {
>       xlog("new branch at $ru\n");
>
>         # values used for t1 and t2 and the constants c1 and c2 and 
> the threshold value
>
>         $var(t1)=1;
>         $var(t2)=60;
>         $var(c1)=1;
>         $var(c2)=3;
>         $var(ts)=500;
>
>
>         avp_db_query("select time from acc where caller_id=$fu and 
> max(time)","$avp(t)");
>
>         avp_db_query("select ps,pl,pt,sh from acc where caller_id=$fu" 
> ,"$avp(val)");
>
>         avp_db_query("delete ps,pl,pt,sh from acc where caller_id=$fu");
>
> $avp(diff)=$avp(t)-$(avp(val)[2]);
>
>         # calculation of long term gray level
>
>         if ( ($var(t2) - $avp(diff) ) > 0 )
>            $avp(l)= $(avp(val)[1]) + 
> $var(c2)*($(avp(val)[0])+1)*($var(t2)-$avp(diff))/$var(t2);
>
>         if ( ($var(t2) - $avp(diff) ) <= 0 )
>            $avp(l)= $(avp(val)[1]) + 
> $var(c2)*(1-$(avp(val)[0]))/($(avp(val)[0])+1))*($var(t2)-$avp(diff))/$var(t2);
>
>         if ( $avp(l) < 0 )
>            $avp(l) = 0;
>
>         # calculation of short term gray level #
>
>
>         if($avp(diff) > 1)
>          {$avp(d)=$avp(diff);}
>         else
>          {$avp(d)=1;})
>
>         if($avp(d)<$var(t1))
>          {$avp(r)=$avp(d);}
>         else
>        {$avp(r)=$var(t1);}
>
>         if ($avp(l) < $var(ts))
>            $avp(s)= 
> $(avp(val)[3])+$var(c1)*($var(t1)-$avp(diff))/($avp(r));
>
>         if ($avp(s) < 0)
>            $avp(s) = 0;
>
>         if ($avp(s) >= $var(ts))
>          {
>            $avp(l)= $avp(s);
>            $avp(s)= 0 ;
>          }
>
>          # updating spam history
>
>         if ((($(avp(val)[0])+$(avp(val)[1])) < $var(ts) )&& 
> (($avp(s)+$avp(l)) > $var(ts)))
>            $(avp(val)[3])= $(avp(val)[3])+1;
>
>         # blocking the call
>
>         $avp(sum) =$avp(l) + $avp(s);
>         if ($avp(sum) > $avp(ts) )
>            drop();
>
>        #updating database
>
>        avp_db_query(" insert into  acc (ps,pl,pt,sh) values 
> ($avp(s),$avp(l),$avp(t),$(avp(val)[3]))");
>
> }
>
>
>
> I am getting syntax error in this code...can anyone help me out here 
> ??please...
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20130428/7e01c452/attachment.htm>


More information about the Users mailing list