Module: sip-router
Branch: master
Commit: 39a8108c62a2beafba18417613b9660a8abef86a
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=39a8108…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Oct 29 16:50:42 2010 +0200
sanity: parameter to control dropping of broken messages
- new modparam autodrop to be able to return to config even when the
message is broken
- default value is 1 - drop (return 0) - for backward compatibility
- set it to 0 to get return -1 to config - take care in config to exit
execution. This mode is good for logging purposes
- autodrop=0 helps to get similar functionality for error_route in
1.5.x, where such cases could be recorded to xlog
- reported by Sergey Okhapkin
---
modules/sanity/mod_sanity.c | 63 ++++++++++++++++++++++++------------------
1 files changed, 36 insertions(+), 27 deletions(-)
diff --git a/modules/sanity/mod_sanity.c b/modules/sanity/mod_sanity.c
index 3e748d9..ffe888f 100644
--- a/modules/sanity/mod_sanity.c
+++ b/modules/sanity/mod_sanity.c
@@ -42,6 +42,8 @@ str pr_str = STR_STATIC_INIT(PROXY_REQUIRE_DEF);
int default_checks = SANITY_DEFAULT_CHECKS;
int uri_checks = SANITY_DEFAULT_URI_CHECKS;
+int _sanity_drop = 1;
+
strl* proxyrequire_list = NULL;
sl_api_t slb;
@@ -67,9 +69,10 @@ static cmd_export_t cmds[] = {
* Exported parameters
*/
static param_export_t params[] = {
- {"default_checks", PARAM_INT, &default_checks},
- {"uri_checks", PARAM_INT, &uri_checks },
- {"proxy_require", PARAM_STR, &pr_str },
+ {"default_checks", PARAM_INT, &default_checks },
+ {"uri_checks", PARAM_INT, &uri_checks },
+ {"proxy_require", PARAM_STR, &pr_str },
+ {"autodrop", PARAM_INT, &_sanity_drop },
{0, 0, 0}
};
@@ -164,56 +167,62 @@ static int sanity_check(struct sip_msg* _msg, char* _number, char*
_arg) {
arg = (int)(long)_arg;
}
+ ret = 1;
if (SANITY_RURI_SIP_VERSION & check &&
- (ret = check_ruri_sip_version(_msg)) != SANITY_CHECK_PASSED) {
- return ret;
+ (ret = check_ruri_sip_version(_msg)) != SANITY_CHECK_PASSED) {
+ goto done;
}
if (SANITY_RURI_SCHEME & check &&
- (ret = check_ruri_scheme(_msg)) != SANITY_CHECK_PASSED) {
- return ret;
+ (ret = check_ruri_scheme(_msg)) != SANITY_CHECK_PASSED) {
+ goto done;
}
if (SANITY_REQUIRED_HEADERS & check &&
- (ret = check_required_headers(_msg)) != SANITY_CHECK_PASSED) {
- return ret;
+ (ret = check_required_headers(_msg)) != SANITY_CHECK_PASSED) {
+ goto done;
}
if (SANITY_VIA_SIP_VERSION & check &&
- (ret = check_via_sip_version(_msg)) != SANITY_CHECK_PASSED) {
- return ret;
+ (ret = check_via_sip_version(_msg)) != SANITY_CHECK_PASSED) {
+ goto done;
}
if (SANITY_VIA_PROTOCOL & check &&
- (ret = check_via_protocol(_msg)) != SANITY_CHECK_PASSED) {
- return ret;
+ (ret = check_via_protocol(_msg)) != SANITY_CHECK_PASSED) {
+ goto done;
}
if (SANITY_CSEQ_METHOD & check &&
- (ret = check_cseq_method(_msg)) != SANITY_CHECK_PASSED) {
- return ret;
+ (ret = check_cseq_method(_msg)) != SANITY_CHECK_PASSED) {
+ goto done;
}
if (SANITY_CSEQ_VALUE & check &&
- (ret = check_cseq_value(_msg)) != SANITY_CHECK_PASSED) {
- return ret;
+ (ret = check_cseq_value(_msg)) != SANITY_CHECK_PASSED) {
+ goto done;
}
if (SANITY_CL & check &&
- (ret = check_cl(_msg)) != SANITY_CHECK_PASSED) {
- return ret;
+ (ret = check_cl(_msg)) != SANITY_CHECK_PASSED) {
+ goto done;
}
if (SANITY_EXPIRES_VALUE & check &&
- (ret = check_expires_value(_msg)) != SANITY_CHECK_PASSED) {
- return ret;
+ (ret = check_expires_value(_msg)) != SANITY_CHECK_PASSED) {
+ goto done;
}
if (SANITY_PROXY_REQUIRE & check &&
- (ret = check_proxy_require(_msg)) != SANITY_CHECK_PASSED) {
- return ret;
+ (ret = check_proxy_require(_msg)) != SANITY_CHECK_PASSED) {
+ goto done;
}
if (SANITY_PARSE_URIS & check &&
- (ret = check_parse_uris(_msg, arg)) != SANITY_CHECK_PASSED) {
- return ret;
+ (ret = check_parse_uris(_msg, arg)) != SANITY_CHECK_PASSED) {
+ goto done;
}
if (SANITY_CHECK_DIGEST & check &&
- (ret = check_digest(_msg, arg)) != SANITY_CHECK_PASSED) {
- return ret;
+ (ret = check_digest(_msg, arg)) != SANITY_CHECK_PASSED) {
+ goto done;
}
+done:
+ if(_sanity_drop!=0)
+ return ret;
+ return (ret==SANITY_CHECK_FAILED)?-1:ret;
+
DBG("all sanity checks passed\n");
/* nobody complained so everything is fine */
return 1;