From dbea0d8d15d87bab55f45432dc86405cdba1626c Mon Sep 17 00:00:00 2001 From: Kaian Date: Thu, 24 Sep 2015 20:04:58 +0200 Subject: [PATCH] Remove ignore configuration directive. Ignore directive is not well coded. In order to work properly it requires message attributes to exists for checking their values. This forces payload parsing of each SIP messages with extra overload and memory usage. Not sure about the impact of removing this feature, but we must think other way to implement it. --- config/sngreprc | 13 ------------- src/option.c | 25 ------------------------- src/option.h | 25 ------------------------- src/sip.c | 22 ---------------------- src/sip.h | 9 --------- 5 files changed, 94 deletions(-) diff --git a/config/sngreprc b/config/sngreprc index b072f92..630e8fe 100644 --- a/config/sngreprc +++ b/config/sngreprc @@ -100,16 +100,3 @@ ##----------------------------------------------------------------------------- ## Uncomment to display dialogs that does not start with a request method # set sip.ignoreincomplete off - -##----------------------------------------------------------------------------- -## You can ignore some calls with any of the previous attributes with a given -## value with ignore directive. -## -## ignore {field} {value} -## -## Examples: -# ignore method OPTIONS -# ignore method REGISTER -# ignore method BYE -# ignore srchost 192.168.1.1 -# ignore transport TCP diff --git a/src/option.c b/src/option.c index 221fe3b..1e592f6 100644 --- a/src/option.c +++ b/src/option.c @@ -114,8 +114,6 @@ read_options(const char *fname) } else { set_option_value(option, value); } - } else if (!strcasecmp(type, "ignore")) { - set_ignore_value(option, value); } else if (!strcasecmp(type, "alias")) { set_alias_value(option, value); } else if (!strcasecmp(type, "bind")) { @@ -173,29 +171,6 @@ set_option_value(const char *opt, const char *value) } } -void -set_ignore_value(const char *opt, const char *value) -{ - options[optscnt].type = IGNORE; - options[optscnt].opt = strdup(opt); - options[optscnt].value = strdup(value); - optscnt++; -} - -int -is_ignored_value(const char *field, const char *fvalue) -{ - int i; - for (i = 0; i < optscnt; i++) { - if (options[i].type != IGNORE) - continue; - if (!strcasecmp(options[i].opt, field) && !strcasecmp(options[i].value, fvalue)) { - return 1; - } - } - return 0; -} - void set_alias_value(const char *address, const char *alias) { diff --git a/src/option.h b/src/option.h index 49fb0e5..d6bf4e4 100644 --- a/src/option.h +++ b/src/option.h @@ -48,7 +48,6 @@ typedef struct config_option option_opt_t; //! Option types enum option_type { COLUMN = 0, - IGNORE, ALIAS }; @@ -138,30 +137,6 @@ get_option_int_value(const char *opt); void set_option_value(const char *opt, const char *value); -/** - * @brief Sets a ignore option value - * - * Basic setter for 'ignore' directive attributes - * - * @param opt Name of configuration option - * @param value Value of configuration option - */ -void -set_ignore_value(const char *opt, const char *value); - -/** - * @brief Check if a exits an ignore directive for the given field and value - * - * Like is_option_enabled, this check if there is a match in configuration - * options that match the given field and value - * - * @param field Name of configuration option - * @param fvalue Value to check if it has an ignore directive - * @return 1 if value for field exists - */ -int -is_ignored_value(const char *field, const char *fvalue); - /** * @brief Sets an alias for a given address * diff --git a/src/sip.c b/src/sip.c index 0ce33df..09c6473 100644 --- a/src/sip.c +++ b/src/sip.c @@ -268,10 +268,6 @@ sip_load_message(capture_packet_t *packet, const char *src, u_short sport, const if (calls.ignore_incomplete && msg->reqresp > SIP_METHOD_MESSAGE) goto skip_message; - // Check if this message is ignored by configuration directive - if (sip_check_msg_ignore(msg)) - goto skip_message; - // Create the call if not found if (!(call = call_create(callid))) goto skip_message; @@ -627,24 +623,6 @@ sip_check_match_expression(const char *payload) #endif } - -int -sip_check_msg_ignore(sip_msg_t *msg) -{ - int i; - sip_attr_hdr_t *header; - char value[512]; - - // Check if an ignore option exists - for (i = 0; i < SIP_ATTR_COUNT; i++) { - header = sip_attr_get_header(i); - if (is_ignored_value(header->name, call_get_attribute(msg->call, header->id, value))) { - return 1; - } - } - return 0; -} - const char * sip_method_str(int method) { diff --git a/src/sip.h b/src/sip.h index 4c91e05..cf28aab 100644 --- a/src/sip.h +++ b/src/sip.h @@ -296,15 +296,6 @@ sip_set_match_expression(const char *expr, int insensitive, int invert); int sip_check_match_expression(const char *payload); -/** - * @brief Check if this msg is affected by filters - * - * @param call Message to check - * @return 1 if msg is filtered, 0 otherwise - */ -int -sip_check_msg_ignore(struct sip_msg *msg); - /** * @brief Get String value for a Method *