[SR-Users] Negative return codes from functions

Phil Lavin phil.lavin at synety.com
Thu Feb 11 16:34:09 CET 2016

Thanks for the info. In this case, why did (!pike_check_req()) fail to work but (pike_check_req() == -2) worked?


From: sr-users [mailto:sr-users-bounces at lists.sip-router.org] On Behalf Of Daniel-Constantin Mierla
Sent: 11 February 2016 14:39
To: Kamailio (SER) - Users Mailing List <sr-users at lists.sip-router.org>
Subject: Re: [SR-Users] Negative return codes from functions


yes, the return codes are interpreted in a special way, see:

- http://www.kamailio.org/wiki/cookbooks/devel/core#return

Same applies for the functions exported by the modules.

On 11/02/16 13:41, Phil Lavin wrote:
Hi all,

Just a sanity check, really. Does Kamailio consider negative response codes to be false? For example, should the following log execute?

if (!foo()) { # Returns -2
     x_log("Foo is false");

The reason for asking here is that I'm implementing flood protection using pike, based off the kamailio.cfg that ships with v4.3. The logic is thus:

if (!pike_check_req()) {
    # Do blocking

However pike_check_req only returns -1 or -2 in the case of failure, never 0. The blocking code is, thus, never executed. Changing to explicitly check for != 1 works correctly.

Am I missing something here or is the example kamailio.cfg incorrect?



SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list

sr-users at lists.sip-router.org<mailto:sr-users at lists.sip-router.org>



Daniel-Constantin Mierla

http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda

Book: SIP Routing With Kamailio - http://www.asipto.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20160211/caf90456/attachment.html>

More information about the sr-users mailing list