[Users] The usrloc table, Oracle, and Asterisk

Juan Carlos Castro y Castro jcastro at instant.com.br
Fri Dec 15 17:29:36 CET 2006


Jerome Martin escreveu:
> On Fri, 2006-12-15 at 12:07 -0200, Juan Carlos Castro y Castro wrote:
>   
>> OK, now I'm trying to do something along the lines of:
>>
>> if ("$hdr(expires)" > 3600) {
>>         avp_db_query("UPDATE sip_conf SET ipaddr='$si', port='$sp', 
>> regseconds=$Ts+$hdr(expires), useragent='$ua' WHERE name='$au'");
>> } else {
>>         avp_db_query("UPDATE sip_conf SET ipaddr='$si', port='$sp', 
>> regseconds=$Ts+3600, useragent='$ua' WHERE name='$au'");
>> };
>>
>> But I get a syntax error at the "if". How can I do such a comparison?
>>     
>
> Take a look at avpcheck() :
>
> http://www.openser.org/docs/modules/1.1.x/avpops.html#AEN38

OK, now I'm doing the following, but the "if" always yields false 
regardless of the passed Expires value. At first I thought the problem 
was interpreting values as strings, but in that case it would yield true 
for an Expires of zero. It doesn't. Could it be some flags problem? 
Using "/g" at the end does no good.

if (avp_check("$hdr(expires)","lt/3600")) {
        avp_db_query("UPDATE sip_conf SET ipaddr='$si', port='$sp', 
regseconds=$Ts+$hdr(expires), useragent='$ua' WHERE name='$au'");
} else {
        avp_db_query("UPDATE sip_conf SET ipaddr='$si', port='$sp', 
regseconds=$Ts+3600, useragent='$ua' WHERE name='$au'");
};

I also tried writing the value to an AVP beforehand. Still always false:

avp_write("$hdr(expires)","$avp(i:777)");
if (avp_check("$avp(i:777)","lt/3600/g")) {
        avp_db_query("UPDATE sip_conf SET ipaddr='$si', port='$sp', 
regseconds=$Ts+$hdr(expires), useragent='$ua' WHERE name='$au'");
} else {
        avp_db_query("UPDATE sip_conf SET ipaddr='$si', port='$sp', 
regseconds=$Ts+3600, useragent='$ua' WHERE name='$au'");
};





More information about the sr-users mailing list