Given this code in .cfg:
if (!perl_exec("verify", "route_LOCATION")) { xlog("L_INFO", "Invite verify failed for ruri: $ru\n"); sl_send_reply("403", "Not Allowed"); exit; }
if the perl function returns 1 everything proceeds nicely (skipping the if block as as expected).
But should the perl function return 0 (which seemed like the right choice for failure) the call fails to progress; the if block does not run, and nothing else does either. The INVITing sip client retries and times out.
I had to return a negative value to get the if block to run.
Expected? Or bug?
(Running deb's sid build on amd64.)
-JimC -- James Cloos cloos@jhcloos.com OpenPGP: 0x997A9F17ED7DAEA6
The return codes have a special interpretation in the config file:
* >0 - is true * <0 - is false * =0 - exit config file execution
http://www.asipto.com/pub/kamailio-devel-guide/#c16return_values
I guess perl_exec() returns what is returned from the perl script.
Cheers, Daniel
On 02/05/14 02:01, James Cloos wrote:
Given this code in .cfg:
if (!perl_exec("verify", "route_LOCATION")) { xlog("L_INFO", "Invite verify failed for ruri: $ru\n"); sl_send_reply("403", "Not Allowed"); exit; }
if the perl function returns 1 everything proceeds nicely (skipping the if block as as expected).
But should the perl function return 0 (which seemed like the right choice for failure) the call fails to progress; the if block does not run, and nothing else does either. The INVITing sip client retries and times out.
I had to return a negative value to get the if block to run.
Expected? Or bug?
(Running deb's sid build on amd64.)
-JimC
James Cloos cloos@jhcloos.com OpenPGP: 0x997A9F17ED7DAEA6
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
"DM" == Daniel-Constantin Mierla miconda@gmail.com writes:
DM> The return codes have a special interpretation in the config file:
DM> * >0 - is true DM> * <0 - is false DM> * =0 - exit config file execution
Ah. I didn't find that.
DM> http://www.asipto.com/pub/kamailio-devel-guide/#c16return_values
Thanks for that pointer; most interesting!
DM> I guess perl_exec() returns what is returned from the perl script.
Yes.
The -/0/+ distinctiong nicely makes things easier for what I want to do.
Thanks,
-JimC -- James Cloos cloos@jhcloos.com OpenPGP: 0x997A9F17ED7DAEA6
On 02/05/14 13:52, James Cloos wrote:
"DM" == Daniel-Constantin Mierla miconda@gmail.com writes:
DM> The return codes have a special interpretation in the config file:
DM> * >0 - is true DM> * <0 - is false DM> * =0 - exit config file execution
Ah. I didn't find that.
DM> http://www.asipto.com/pub/kamailio-devel-guide/#c16return_values
Thanks for that pointer; most interesting!
DM> I guess perl_exec() returns what is returned from the perl script.
Yes.
The -/0/+ distinctiong nicely makes things easier for what I want to do.
This evaluation is from the beginning of ser back in 2001, some notes were in cookbook:
http://www.kamailio.org/wiki/cookbooks/4.1.x/core?&#return
I added an entry in the faq to be easier to find:
http://www.kamailio.org/wiki/tutorials/faq/main#how_is_the_function_return_c...
Cheers, Daniel
"DM" == Daniel-Constantin Mierla miconda@gmail.com writes:
DM> This evaluation is from the beginning of ser back in 2001, some notes DM> were in cookbook:
About a decade ago I'd have known/remembered that. But I've mostly been doing development (on other code bases) since then and am only now getting re-familiarized while implementing a new distriuted cluster.
DM> I added an entry in the faq to be easier to find:
Good idea.
-JimC -- James Cloos cloos@jhcloos.com OpenPGP: 0x997A9F17ED7DAEA6