Just tried this again and it does actually work as expected. No idea what I was doing incorrectly before.

 

 

Cheers

 

From: sr-users [mailto:sr-users-bounces@lists.sip-router.org] On Behalf Of Phil Lavin
Sent: 11 February 2016 15:34
To: miconda@gmail.com; Kamailio (SER) - Users Mailing List <sr-users@lists.sip-router.org>
Subject: Re: [SR-Users] Negative return codes from functions

 

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

 

 

Cheers

 

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

 

Hello,

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.

Cheers,
Daniel

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?

 

 

Cheers



_______________________________________________
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

 

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Book: SIP Routing With Kamailio - http://www.asipto.com
http://miconda.eu