i have this piece of config code:
modparam("dialplan", "attrs_pvar", "$var(plan)") ... xlog("L_INFO", "Translating <$var(calling_number)> based on dpid 4\n");
if (dp_translate("4", "$var(calling_number)")) { xlog("L_INFO", "Found attrs <$var(plan)>\n"); ...
dpid 4 has three entries:
109 4 10 1 ^+1 0 na 107 4 10 1 ^+358 0 fi 108 4 10 1 ^+46 0 se
thus in each entry attrs field has some two letter value.
when the above piece of code is executed, i get to syslog
Aug 31 19:06:51 wheezy2 /usr/sbin/sip-proxy[7162]: INFO: Translating <+35892345670> based on dpid 4 Aug 31 19:06:51 wheezy2 /usr/sbin/sip-proxy[7162]: INFO: Found attrs <0>
if i restart the proxy, attrs value may change to some other bogus value.
any ideas?
-- juha
Hello,
What version are you using? Is it happening to get the right value from time to time?
If you set higher debug mode, is it printing the message that a rule was matched?
Cheers, Daniel
-- Daniel-Constantin Mierla http://www.asipto.com
On 31 Aug 2012, at 18:15, Juha Heinanen jh@tutpro.com wrote:
i have this piece of config code:
modparam("dialplan", "attrs_pvar", "$var(plan)") ... xlog("L_INFO", "Translating <$var(calling_number)> based on dpid 4\n");
if (dp_translate("4", "$var(calling_number)")) { xlog("L_INFO", "Found attrs <$var(plan)>\n"); ...
dpid 4 has three entries:
109 4 10 1 ^+1 0 na 107 4 10 1 ^+358 0 fi 108 4 10 1 ^+46 0 se
thus in each entry attrs field has some two letter value.
when the above piece of code is executed, i get to syslog
Aug 31 19:06:51 wheezy2 /usr/sbin/sip-proxy[7162]: INFO: Translating <+35892345670> based on dpid 4 Aug 31 19:06:51 wheezy2 /usr/sbin/sip-proxy[7162]: INFO: Found attrs <0>
if i restart the proxy, attrs value may change to some other bogus value.
any ideas?
-- juha
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
Daniel-Constantin Mierla writes:
What version are you using? Is it happening to get the right value from time to time?
this is with a few days old trunk:
version: sip-proxy 3.4.0-dev3 (x86_64/linux)
i have seen it sometimes to set attrs pvar correctly, but most times not.
If you set higher debug mode, is it printing the message that a rule was matched?
see below.
-- juha
Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: INFO: Translating <+35892345670> based on dpid 4 Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dialplan.c:240]: integer value Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dialplan.c:261]: searching 15 Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dialplan.c:348]: input is +35892345670 Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:341]: regex operator testing Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:341]: regex operator testing Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:341]: regex operator testing Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:386]: found a matching rule 0x7f7d72275fa8: pr 10, match_exp ^+358 Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:393]: the rule's attrs are fi Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:404]: the copied attributes are: fi Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:151]: null replacement Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dialplan.c:357]: input +35892345670 with dpid 4 => output Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: INFO: Found attrs <<null>>
I checked the commit log and there was no change in the module. Failure to set the attrs variable is printing a error message, so looks like the variable is set.
Can you set $var(plan) to a static string value before dp_translate() just to see if the value is updated in the function?
Cheers, Daniel
On 8/31/12 7:25 PM, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
What version are you using? Is it happening to get the right value from time to time?
this is with a few days old trunk:
version: sip-proxy 3.4.0-dev3 (x86_64/linux)
i have seen it sometimes to set attrs pvar correctly, but most times not.
If you set higher debug mode, is it printing the message that a rule was matched?
see below.
-- juha
Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: INFO: Translating <+35892345670> based on dpid 4 Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dialplan.c:240]: integer value Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dialplan.c:261]: searching 15 Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dialplan.c:348]: input is +35892345670 Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:341]: regex operator testing Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:341]: regex operator testing Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:341]: regex operator testing Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:386]: found a matching rule 0x7f7d72275fa8: pr 10, match_exp ^+358 Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:393]: the rule's attrs are fi Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:404]: the copied attributes are: fi Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dp_repl.c:151]: null replacement Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: DEBUG: dialplan [dialplan.c:357]: input +35892345670 with dpid 4 => output Aug 31 20:21:56 wheezy2 /usr/sbin/sip-proxy[7560]: INFO: Found attrs <<null>>
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
Daniel-Constantin Mierla writes:
Can you set $var(plan) to a static string value before dp_translate() just to see if the value is updated in the function?
i now have:
xlog("L_INFO", "Translating <$var(calling_number)> based on dpid 4\n"); $var(plan) = "something"; if (dp_translate("4", "$var(calling_number)")) { xlog("L_INFO", "Found attrs <$var(plan)>\n");
and get:
Aug 31 21:57:21 wheezy2 /usr/sbin/sip-proxy[9733]: INFO: Translating <+35892345670> based on dpid 4 Aug 31 21:57:21 wheezy2 /usr/sbin/sip-proxy[9733]: INFO: Found attrs <598400320>
so looks like something happens to the pvar, but not the right thing.
-- juha
Aug 31 21:57:21 wheezy2 /usr/sbin/sip-proxy[9733]: INFO: Translating <+35892345670> based on dpid 4 Aug 31 21:57:21 wheezy2 /usr/sbin/sip-proxy[9733]: INFO: Found attrs <598400320>
the result in attrs is pretty much random. sometimes i get the right result and sometimes not. it does not seem to matter if i set $var(plan) to 0, "", or some other string value. i have got correct and incorrect results with all combinations.
-- juha
other weird thing is that when i tried to add more debug output to dialplan module and compiled dialplan module separately on another host (the same one where the debian package installed on this test host has been built) and then copied it to the host (virtual machine) where these tests are done, i cannot start the proxy with the separately compiled dialplan.so. i get to syslog:
0(11244) ERROR: <core> [sr_module.c:572]: ERROR: load_module: could not open module </usr/lib/sip-proxy/modules/dialplan.so>: libkmi.so.1: cannot open shared object file: No such file or directory
when the file definitely exists:
/usr/lib/sip-proxy/modules# ls -ls dialplan.so 148 -rwxr-xr-x 1 jh jh 151353 Aug 31 22:10 dialplan.so
may be all this hassle is somehow related to trying to run my sip proxy on a Virtualbox virtual machine?
-- juha
On 8/31/12 9:20 PM, Juha Heinanen wrote:
other weird thing is that when i tried to add more debug output to dialplan module and compiled dialplan module separately on another host (the same one where the debian package installed on this test host has been built) and then copied it to the host (virtual machine) where these tests are done, i cannot start the proxy with the separately compiled dialplan.so. i get to syslog:
0(11244) ERROR: <core> [sr_module.c:572]: ERROR: load_module: could not open module </usr/lib/sip-proxy/modules/dialplan.so>: libkmi.so.1: cannot open shared object file: No such file or directory
when the file definitely exists:
/usr/lib/sip-proxy/modules# ls -ls dialplan.so 148 -rwxr-xr-x 1 jh jh 151353 Aug 31 22:10 dialplan.so
The complain seems to be regarding missing of libkmi, can you check that is installed as well?
may be all this hassle is somehow related to trying to run my sip proxy on a Virtualbox virtual machine?
Do you have any possibility to test it where it compiles? You can even run from source tree, without a need to install, connecting to the database server where dialplan table is located -- just to avoid hunting ghost issues in the code.
Cheers, Daniel
Daniel-Constantin Mierla writes:
0(11244) ERROR: <core> [sr_module.c:572]: ERROR: load_module: could not open module </usr/lib/sip-proxy/modules/dialplan.so>: libkmi.so.1: cannot open shared object file: No such file or directory
when the file definitely exists:
/usr/lib/sip-proxy/modules# ls -ls dialplan.so 148 -rwxr-xr-x 1 jh jh 151353 Aug 31 22:10 dialplan.so
The complain seems to be regarding missing of libkmi, can you check that is installed as well?
yes, it is installed in libdir:
# ls -ls /usr/lib/sip-proxy/ ... 0 lrwxrwxrwx 1 root root 13 Aug 31 21:30 libkmi.so -> libkmi.so.1.0 0 lrwxrwxrwx 1 root root 13 Aug 31 21:30 libkmi.so.1 -> libkmi.so.1.0 52 -rw-r--r-- 1 root root 51673 Aug 31 21:30 libkmi.so.1.0
Do you have any possibility to test it where it compiles? You can even run from source tree, without a need to install, connecting to the database server where dialplan table is located -- just to avoid hunting ghost issues in the code.
the same problem appears also when i run proxy on the same real host where i built the debian package.
now i was able to put some LM_INFO statements in dp_update function of dialplan.c:
set_attr_pvar:
LM_INFO("trying to set pvar\n");
if(!attr_pvar) { LM_INFO("attr_pvar is null\n"); return 0; }
val.rs = *attrs; LM_INFO("setting pvar from attrs <%.*s>\n", val.rs.len, val.rs.s); if(attr_pvar->setf(msg, &attr_pvar->pvp, (int)EQ_T, &val)<0) { LM_ERR("setting attr pseudo-variable failed\n"); return -1; } if(attr_pvar->getf(msg, &attr_pvar->pvp, &res)<0) { LM_ERR("getting attr pseudo-variable failed\n"); return -1; } LM_INFO("got <%.*s>\n", res.rs.len, res.rs.s); this is what i get to syslog:
Sep 1 08:38:23 siika /usr/sbin/sip-proxy[15787]: INFO: Translating <+35892345670> based on dpid 4 Sep 1 08:38:23 siika /usr/sbin/sip-proxy[15787]: INFO: dialplan [dialplan.c:280]: entering dp_update Sep 1 08:38:23 siika /usr/sbin/sip-proxy[15787]: INFO: dialplan [dialplan.c:307]: trying to set pvar Sep 1 08:38:23 siika /usr/sbin/sip-proxy[15787]: INFO: dialplan [dialplan.c:315]: setting pvar from attrs <fi> Sep 1 08:38:23 siika /usr/sbin/sip-proxy[15787]: INFO: dialplan [dialplan.c:326]: got <-630238520>
i.e. the value i get from the pv is not the one i put there.
my next guess is that this has something to do with amd64 architecture of the host. perhaps the sizes of ints/pointers/etc are not what the code somewhere expects?
-- juha
Juha Heinanen writes:
my next guess is that this has something to do with amd64 architecture of the host. perhaps the sizes of ints/pointers/etc are not what the code somewhere expects?
i added check on length of int and pointer:
LM_INFO("got <%.*s>\n", res.rs.len, res.rs.s); LM_INFO("len is %lu bytes and s is %lu bytes\n", sizeof(res.rs.len), sizeof(res.rs.s));
Sep 1 08:58:09 siika /usr/sbin/sip-proxy[16919]: INFO: dialplan [dialplan.c:315]: setting pvar from attrs <fi> Sep 1 08:58:09 siika /usr/sbin/sip-proxy[16919]: INFO: dialplan [dialplan.c:326]: got <0> Sep 1 08:58:09 siika /usr/sbin/sip-proxy[16919]: INFO: dialplan [dialplan.c:328]: len is 4 bytes and s is 8 bytes
perhaps the code somewhere (e.g. int_str handling) assumes that int and pointer are of same length?
-- juha
i think i found the bug that causes incorrect setting of dp_translate attrs pvar value.
current code in dp_update function has this:
no_change = (dest->type == PVT_NONE) || (!repl->s) || (!repl->len);
if (no_change) goto set_attr_pvar;
memset(&val, 0, sizeof(pv_value_t)); val.flags = PV_VAL_STR; val.rs = *repl;
and then
set_attr_pvar:
if(!attr_pvar) return 0;
val.rs = *attrs;
if there is no change (like is the case in my failing test), val is not initialized and its type can be anything.
i'll commit fix to trunk. let me know if it looks ok, i'll pick it also to 3.3.
-- juha