Hi
I'm using Kamailio v1.5.1 and, I do not know why, the avp value is disappearing. Let
me show you what is happening:
#IT DOESN'T WORK
avp_db_query("select count(1) as c from group_endpoint where
num_ip='$si'","$avp(i:105)");
log(1,"Before AVP_PRINT\n");
avp_print();
log(1,"After AVP_PRINT\n");
if( avp_check("$avp(i:105)","eq/i:0") )
#Debug
Jun 10 09:57:48 [4326] DBG:avpops:ops_dbquery_avps: query [select count(1) as c from
group_endpoint where num_ip='192.168.0.194']
Jun 10 09:57:48 [4326] DBG:core:db_new_result: allocate 28 bytes for result set at
0x8180ea8
Jun 10 09:57:48 [4326] DBG:db_mysql:db_mysql_get_columns: 1 columns returned from the
query
Jun 10 09:57:48 [4326] DBG:core:db_allocate_columns: allocate 4 bytes for result names at
0x8180ed0
Jun 10 09:57:48 [4326] DBG:core:db_allocate_columns: allocate 4 bytes for result types at
0x8180ee0
Jun 10 09:57:48 [4326] DBG:db_mysql:db_mysql_get_columns: allocate 8 bytes for
RES_NAMES[0] at 0x8180ef0
Jun 10 09:57:48 [4326] DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x8180ef0)[0]=[c]
Jun 10 09:57:48 [4326] DBG:db_mysql:db_mysql_get_columns: use DB_BIGINT result type
Jun 10 09:57:48 [4326] DBG:core:db_allocate_rows: allocate 8 bytes for rows at 0x8180f00
Jun 10 09:57:48 [4326] DBG:core:db_allocate_row: allocate 20 bytes for row values at
0x8180f10
Jun 10 09:57:48 [4326] DBG:core:db_str2val: converting BIGINT [0]
Jun 10 09:57:48 [4326] DBG:avpops:db_query_avp: rows [1]
Jun 10 09:57:48 [4326] DBG:avpops:db_query_avp: row [0]
Jun 10 09:57:48 [4326] DBG:avpops:db_close_query: close avp query
Jun 10 09:57:48 [4326] DBG:core:db_free_columns: freeing 1 columns
Jun 10 09:57:48 [4326] DBG:core:db_free_columns: freeing RES_NAMES[0] at 0x8180ef0
Jun 10 09:57:48 [4326] DBG:core:db_free_columns: freeing result names at 0x8180ed0
Jun 10 09:57:48 [4326] DBG:core:db_free_columns: freeing result types at 0x8180ee0
Jun 10 09:57:48 [4326] DBG:core:db_free_rows: freeing 1 rows
Jun 10 09:57:48 [4326] DBG:core:db_free_row: freeing row values at 0x8180f10
Jun 10 09:57:48 [4326] DBG:core:db_free_rows: freeing rows at 0x8180f00
Jun 10 09:57:48 [4326] DBG:core:db_free_result: freeing result set at 0x8180ea8
Before AVP_PRINT
After AVP_PRINT
Jun 10 09:57:48 [4326] DBG:avpops:ops_check_avp: no src avp found
No src avp found! There isn't any avp. The avp value returned by mysql server is
quickly dropped. So, to avoid this, I changed the query's result into a string.
I'm using the mysql concat function.
#IT WORKS!
avp_db_query("select concat('',count(1)) from group_endpoint where
num_ip='$si'","$avp(s:105)");
log(1,"Before AVP_PRINT\n");
avp_print();
log(1,"After AVP_PRINT\n");
if( avp_check("$avp(s:105)","eq/s:0/g") )
#Debug
Jun 10 10:01:37 [4378] DBG:avpops:ops_dbquery_avps: query [select
concat('',count(1)) from group_endpoint where num_ip='192.168.0.194']
Jun 10 10:01:37 [4378] DBG:core:db_new_result: allocate 28 bytes for result set at
0x8180ea8
Jun 10 10:01:37 [4378] DBG:db_mysql:db_mysql_get_columns: 1 columns returned from the
query
Jun 10 10:01:37 [4378] DBG:core:db_allocate_columns: allocate 4 bytes for result names at
0x8180ed0
Jun 10 10:01:37 [4378] DBG:core:db_allocate_columns: allocate 4 bytes for result types at
0x8180ee0
Jun 10 10:01:37 [4378] DBG:db_mysql:db_mysql_get_columns: allocate 8 bytes for
RES_NAMES[0] at 0x8180ef0
Jun 10 10:01:37 [4378] DBG:db_mysql:db_mysql_get_columns:
RES_NAMES(0x8180ef0)[0]=[concat('',count(1))]
Jun 10 10:01:37 [4378] DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
Jun 10 10:01:37 [4378] DBG:core:db_allocate_rows: allocate 8 bytes for rows at 0x8180f00
Jun 10 10:01:37 [4378] DBG:core:db_allocate_row: allocate 20 bytes for row values at
0x8180f10
Jun 10 10:01:37 [4378] DBG:core:db_str2val: converting STRING [0]
Jun 10 10:01:37 [4378] DBG:avpops:db_query_avp: rows [1]
Jun 10 10:01:37 [4378] DBG:avpops:db_query_avp: row [0]
Jun 10 10:01:37 [4378] DBG:avpops:db_close_query: close avp query
Jun 10 10:01:37 [4378] DBG:core:db_free_columns: freeing 1 columns
Jun 10 10:01:37 [4378] DBG:core:db_free_columns: freeing RES_NAMES[0] at 0x8180ef0
Jun 10 10:01:37 [4378] DBG:core:db_free_columns: freeing result names at 0x8180ed0
Jun 10 10:01:37 [4378] DBG:core:db_free_columns: freeing result types at 0x8180ee0
Jun 10 10:01:37 [4378] DBG:core:db_free_rows: freeing 1 rows
Jun 10 10:01:37 [4378] DBG:core:db_free_row: freeing row values at 0x8180f10
Jun 10 10:01:37 [4378] DBG:core:db_free_rows: freeing rows at 0x8180f00
Jun 10 10:01:37 [4378] DBG:core:db_free_result: freeing result set at 0x8180ea8
Before AVP_PRINT
Jun 10 10:01:37 [4378] INFO:avpops:ops_print_avp: p=0xb5d3ef08, flags=0x0003
Jun 10 10:01:37 [4378] INFO:avpops:ops_print_avp: name=<105>
Jun 10 10:01:37 [4378] INFO:avpops:ops_print_avp: val_str=<0 /
1>
After AVP_PRINT
Jun 10 10:01:37 [4378] DBG:avpops:ops_check_avp: check <0> against <0> as str
/16777217
The avp value is there now! Why is it happening? Am I doing something wrong? I think the
answer is a perfect 'yes'. Thanks for any advice.
Bruno
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com