Hi
I am trying to make a kamailio script which gets a uri from the database
and then directs the call to that uri. Setting the uri with a string (not
derived from the database) works just fine:
append_branch();
seturi("sip:user@domain");
But I can not seem to pass anything to seturi other than a string. Here are
some examples:
$var(branch_uri) = $dbr(ra=>[0,0]);
append_branch();
seturi($var(branch_uri));
# kamailio won't even start when I try to pass the uri from a variable
$var(branch_uri) = $dbr(ra=>[0,0]);
append_branch();
seturi("$var(branch_uri)");
# treats the "$var(branch_uri)" as a literal string -- does not evaluate to
the the value of the variable
$var(branch_uri) = $dbr(ra=>[0,0]);
append_branch();
seturi((str)$var(branch_uri));
# kamailio won't start with this syntax inplace
The errors that kamailio gives on start up when I have a variable in passed
into seturi are as follows
0(16145) : <core> [cfg.y:3567]: yyerror_at(): parse error in config file
/usr/local/kamailio-4.0/etc/kamailio/kamailio.cfg, line 647, column 12-27:
syntax error
0(16145) : <core> [cfg.y:3570]: yyerror_at(): parse error in config file
/usr/local/kamailio-4.0/etc/kamailio/kamailio.cfg, line 647, column 28: bad
argument, string expected
0(16145) DEBUG: <core> [sr_module.c:674]: find_mod_export_record():
find_export_record: found <sl_reply_error> in module sl
[/usr/local/kamailio-4.0/lib64/kamailio/modules/sl.so]
0(16145) DEBUG: <core> [sr_module.c:674]: find_mod_export_record():
find_export_record: found <sl_reply_error> in module sl
[/usr/local/kamailio-4.0/lib64/kamailio/modules/sl.so]
0(16145) DEBUG: <core> [sr_module.c:674]: find_mod_export_record():
find_export_record: found <sl_reply_error> in module sl
[/usr/local/kamailio-4.0/lib64/kamailio/modules/sl.so]
ERROR: bad config file (2 errors)
I also tried to accomplish this
append_branch($var(branch_uri), "0.0");
t_load_contacts();
t_next_contacts();
# No errors but didn't work
I found a way around the problem by making a perl script to allow me set
the uri:
Perl script:
sub rewrite_uri {
my $m = shift;
my $uri = shift;
$m->rewrite_ruri($uri);
return -1;
}
Then I call it like this:
$var(branch_uri) = $dbr(ra=>[0,0]);
append_branch();
perl_exec("rewrite_uri", $var(branch_uri));
# this works
So I have a viable work around but it seems like there is probably
something simple I am missing which should let me accomplish this with out
having to do a call into perl.
Any advice any one can give me would be greatly appreciated.
Best regards
Will Ferrer