Hi,
I am using force_send_socket as I have two interfaces. It works fine but at the moment I am hard coding the IP address. I want to use a variable instead, I have tried the following:
force_send_socket($sel(cfg_get.kamailio.bindip);
But kamailio doesn't start and complains about the format.
Any ideas?
Thanks, Keith
On 12/11/2013 04:31 AM, Keith wrote:
Hi,
I am using force_send_socket as I have two interfaces. It works fine but at the moment I am hard coding the IP address. I want to use a variable instead, I have tried the following:
force_send_socket($sel(cfg_get.kamailio.bindip);
But kamailio doesn't start and complains about the format.
force_send_socket() is an old core function that does not accept variables. Try write to $fs instead:
$fs = "udp:$sel(cfg_get.kamailio.bindip):5060";
-- Alex
On 11/12/13 10:35, Alex Balashov wrote:
On 12/11/2013 04:31 AM, Keith wrote:
Hi,
I am using force_send_socket as I have two interfaces. It works fine but at the moment I am hard coding the IP address. I want to use a variable instead, I have tried the following:
force_send_socket($sel(cfg_get.kamailio.bindip);
But kamailio doesn't start and complains about the format.
force_send_socket() is an old core function that does not accept variables. Try write to $fs instead:
$fs = "udp:$sel(cfg_get.kamailio.bindip):5060";
Actually, to work, the above line has to be:
$fs = "udp:" + $sel(cfg_get.kamailio.bindip) + ":5060";
or:
pv_printf($fs, "udp:$sel(cfg_get.kamailio.bindip):5060");
or with more recent versions:
$fs = $_s(udp:$sel(cfg_get.kamailio.bindip):5060);
Cheers, Daniel
On 12/11/2013 04:45 AM, Daniel-Constantin Mierla wrote:
Actually, to work, the above line has to be:
$fs = "udp:" + $sel(cfg_get.kamailio.bindip) + ":5060";
I never did understand that. Some PVs seem to be substituted inside a string literal, others are not. What's the rule?
-- Alex
On 11/12/13 10:46, Alex Balashov wrote:
On 12/11/2013 04:45 AM, Daniel-Constantin Mierla wrote:
Actually, to work, the above line has to be:
$fs = "udp:" + $sel(cfg_get.kamailio.bindip) + ":5060";
I never did understand that. Some PVs seem to be substituted inside a string literal, others are not. What's the rule?
They were never substituted in expressions/statements that have quoted string literals as standalone element. Only in parameters for functions or names for variables (e.g. $sht(...)).
Daniel
On 12/11/2013 04:48 AM, Daniel-Constantin Mierla wrote:
On 11/12/13 10:46, Alex Balashov wrote:
On 12/11/2013 04:45 AM, Daniel-Constantin Mierla wrote:
Actually, to work, the above line has to be:
$fs = "udp:" + $sel(cfg_get.kamailio.bindip) + ":5060";
I never did understand that. Some PVs seem to be substituted inside a string literal, others are not. What's the rule?
They were never substituted in expressions/statements that have quoted string literals as standalone element. Only in parameters for functions or names for variables (e.g. $sht(...)).
Oh, I see. So, this will work:
redis_cmd("srv", "SET user 1$rU", "r");
but this will not:
$fu = "sip:1$fU@$sel(cfg_get.term_gw):5060";
?
-- Alex
On 11/12/13 10:53, Alex Balashov wrote:
On 12/11/2013 04:48 AM, Daniel-Constantin Mierla wrote:
On 11/12/13 10:46, Alex Balashov wrote:
On 12/11/2013 04:45 AM, Daniel-Constantin Mierla wrote:
Actually, to work, the above line has to be:
$fs = "udp:" + $sel(cfg_get.kamailio.bindip) + ":5060";
I never did understand that. Some PVs seem to be substituted inside a string literal, others are not. What's the rule?
They were never substituted in expressions/statements that have quoted string literals as standalone element. Only in parameters for functions or names for variables (e.g. $sht(...)).
Oh, I see. So, this will work:
redis_cmd("srv", "SET user 1$rU", "r");
but this will not:
$fu = "sip:1$fU@$sel(cfg_get.term_gw):5060";
It is better said 'it will not work as you expect", because the assignment works fine, just PVs are not replaced, they simply stay with their name there.
Cheers, Daniel