]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Adding an anti pattern check option
authorWilliam King <william.king@quentustech.com>
Fri, 26 Oct 2012 22:45:51 +0000 (15:45 -0700)
committerWilliam King <william.king@quentustech.com>
Fri, 26 Oct 2012 22:45:59 +0000 (15:45 -0700)
src/mod/xml_int/mod_xml_radius/mod_xml_radius.c

index d80e9e7d542bfbddd39d652155ed21da82a6e4d0..0b99166f98406d8ed3f8dc0a8f84d70d345f540c 100644 (file)
@@ -838,7 +838,9 @@ switch_status_t mod_xml_radius_check_conditions(switch_channel_t *channel, switc
        switch_xml_t condition, param;
        char *channel_var = NULL;
        char *regex = NULL;
+       char *anti = NULL;
        int all_matched = 1;
+       int result = 0;
        
        if ( (condition = switch_xml_child(conditions, "condition")) == NULL) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to locate a condition under the conditions section\n");
@@ -856,14 +858,19 @@ switch_status_t mod_xml_radius_check_conditions(switch_channel_t *channel, switc
                for (; param && all_matched; param = param->next) {
                        channel_var = (char *) switch_xml_attr(param, "var");
                        regex = (char *) switch_xml_attr(param, "regex");
+                       anti = (char *) switch_xml_attr(param, "anti");
                        
                        if ( channel_var == NULL || regex == NULL ) {
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Improperly constructed mod_radius condition: %s %s\n", channel_var, regex);
                        }
                        
-                       if ( switch_regex_match( switch_channel_get_variable(channel, channel_var), regex) != SWITCH_STATUS_SUCCESS) {
+                       result = ( switch_regex_match( switch_channel_get_variable(channel, channel_var), regex) != SWITCH_STATUS_SUCCESS);
+                       if (( anti == NULL && result ) || ( anti != NULL && !result ) ){
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Didn't match: %s == %s \n", switch_channel_get_variable(channel, channel_var), regex);
                                all_matched = 0;
+                       } else {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Result of %s match: %s == %s \n", 
+                                                                 anti, switch_channel_get_variable(channel, channel_var), regex);
                        }
                }