[SR-Users] Negative return codes from functions

Phil Lavin phil.lavin at synety.com
Thu Feb 11 13:41:13 CET 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20160211/b1a5a0df/attachment.html>


More information about the sr-users mailing list