Hello,
We are running Kamailio 1.5.
I'm trying to use the forward() function with a variable like this: forward($shv(voip1-edge1));
That fails to parse. I then tried this, which I thought would fail: forward("$shv(voip1-edge1)");
That parsed correctly, but it then failed to resolve the domain '$shv(voip1-edge1)' as expected. Why can this function not use variables?
I tried to make a workaround by doing this: $du=$ru; $dd=$shv(voip1-edge1); forward();
That also failed. Why is $du writable but $dd is not?
I then made a fourth attempt, which seems to work: $du="sip:" + $shv(voip1-edge1); forward();
With kind regards, Pan
On 12/2/10 4:57 PM, Pan B. Christensen wrote:
Hello, We are running Kamailio 1.5. I'm trying to use the forward() function with a variable like this: forward($shv(voip1-edge1)); That fails to parse. I then tried this, which I thought would fail: forward("$shv(voip1-edge1)"); That parsed correctly, but it then failed to resolve the domain '$shv(voip1-edge1)' as expected. Why can this function not use variables? I tried to make a workaround by doing this: $du=$ru; $dd=$shv(voip1-edge1); forward(); That also failed. Why is $du writable but $dd is not? I then made a fourth attempt, which seems to work: $du="sip:" + $shv(voip1-edge1); forward();
indeed, the last version is the one that works.
forward() does not take dynamic parameters, only static string values. $dd is not writable because is just part of $du which you can set like you did. $du refers to outbound proxy address (destination uri) and there matters only host, port and transport, all the other attributes in $du have no relevance.
Cheers, Daniel
Thanks for your swift reply, Daniel. I would also like to thank you again for the great training last week.
My main question was: Why does forward() not take dynamic parameters? Should it not do so (in the future) to be in line with other functions? It was not difficult to work around, but I think it would be more logical if the function could use dynamic parameters like all the other functions I've used can do.
With kind regards, Pan ----- Original Message ----- From: Daniel-Constantin Mierla To: Pan B. Christensen Cc: kamailio Sent: Friday, December 03, 2010 11:14 AM Subject: Re: [SR-Users] using forward() with variables
On 12/2/10 4:57 PM, Pan wrote: Hello,
We are running Kamailio 1.5.
I'm trying to use the forward() function with a variable like this: forward($shv(voip1-edge1));
That fails to parse. I then tried this, which I thought would fail: forward("$shv(voip1-edge1)");
That parsed correctly, but it then failed to resolve the domain '$shv(voip1-edge1)' as expected. Why can this function not use variables?
I tried to make a workaround by doing this: $du=$ru; $dd=$shv(voip1-edge1); forward();
That also failed. Why is $du writable but $dd is not?
I then made a fourth attempt, which seems to work: $du="sip:" + $shv(voip1-edge1); forward();
indeed, the last version is the one that works.
forward() does not take dynamic parameters, only static string values. $dd is not writable because is just part of $du which you can set like you did. $du refers to outbound proxy address (destination uri) and there matters only host, port and transport, all the other attributes in $du have no relevance.
Cheers, Daniel
On 12/3/10 11:28 AM, Pan B. Christensen wrote:
[...] My main question was: Why does forward() not take dynamic parameters? Should it not do so (in the future) to be in line with other functions? It was not difficult to work around, but I think it would be more logical if the function could use dynamic parameters like all the other functions I've used can do.
forward() is a function exported by core and they were developed long time ago without support for cfg variables. In the future that may be changed, but having an existing alternative has set very low priority on it.
Cheers, Daniel