Hello,

I checked the code and this behaviour is practically due to special meaning of return codes from functions exported to config file, ie,:
- <0 is false
- >0 is true

route(x) call is returning the code from route block itself, but then the interpreter converts the codes < 0 to 0 (so the condition is false in C) and the codes > 0 to 1 (so the condition is C is true).

Thus, no matter what code you return from a subroute, you have to compare against 0 (for negative return code) or 1 (for positive return code).

Solutions/alternatives:

 1)
$var(r) = route(x);

.. and then compare $var(r)

2)
route(x);
$var(r) = $rc;

.. and then compare $var(r)

3)
doing it in the if:

if(($var(r) = route(x)) && ($var(r) == -1)) {
  ...
}

The assignment which is done first in the IF expression will return true if the assignment operation is successful.

Cheers,
Daniel


just replace -1 with the return code you want to test against
On 12/12/11 11:29 AM, Daniel-Constantin Mierla wrote:
Hello,

On 12/12/11 10:45 AM, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:

cannot test it for now personally, but what you get if you do:

route(TEST_ROUTE_MINUS_ONE);

$var(r) = $rc;

xlog("returned code by route minus one is: $var(r)\n");

Maybe this will give some leads I can follow in the code...
daniel,

i correctly get:

Dec 12 11:42:37 sip /usr/sbin/sip-proxy[1308]: ERROR: returned code by route minus one is: -1

so it is only the test

if (route(TEST_ROUTE_MINUS_ONE) == -1) ...

that fails.
ok, so looks like IF with a mod function returning negative needs investigation. I will look over it soon.

Cheers,
Daniel




--
Daniel-Constantin Mierla -- http://www.asipto.com
http://linkedin.com/in/miconda -- http://twitter.com/miconda


_______________________________________________
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

Reply via email to