]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Adding ability to toggle mod_xml_radius debug flag from a console api command rather...
authorWilliam King <william.king@quentustech.com>
Sat, 3 Nov 2012 00:06:27 +0000 (17:06 -0700)
committerWilliam King <william.king@quentustech.com>
Sat, 3 Nov 2012 00:06:27 +0000 (17:06 -0700)
src/mod/xml_int/mod_xml_radius/mod_xml_radius.c

index 0b99166f98406d8ed3f8dc0a8f84d70d345f540c..d858f4653561713d65c9defd617fb7e60ca0c3e5 100644 (file)
@@ -45,7 +45,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_radius_load);
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_radius_shutdown);
 SWITCH_MODULE_DEFINITION(mod_xml_radius, mod_xml_radius_load, mod_xml_radius_shutdown, NULL);
 
-static int GLOBAL_DEBUG = 0;
+int GLOBAL_DEBUG = 0;
 
 switch_status_t mod_xml_radius_new_handle(rc_handle **new_handle, switch_xml_t xml) {
        switch_xml_t server, param;
@@ -531,6 +531,21 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
        
 }
 
+/* static switch_status_t name (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream) */
+SWITCH_STANDARD_API(mod_xml_radius_debug_api)
+{
+       if ( !strncmp(cmd, "on", 2) ) {
+               GLOBAL_DEBUG = 1;
+       } else if ( !strncmp(cmd, "off", 3)){
+               GLOBAL_DEBUG = 0;
+       } else {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Valid options are [yes|no]\n" );
+       }
+
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "debug is %s\n", (GLOBAL_DEBUG ? "on" : "off") );
+       return SWITCH_STATUS_SUCCESS;
+}
+
 /* static switch_status_t name (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream) */
 SWITCH_STANDARD_API(mod_xml_radius_connect_test)
 {
@@ -1132,6 +1147,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_radius_load)
        }
                
        SWITCH_ADD_API(mod_xml_radius_api_interface, "xml_radius_connect_test", "mod_xml_radius connection test", mod_xml_radius_connect_test, NULL);
+       SWITCH_ADD_API(mod_xml_radius_api_interface, "xml_radius_debug", "mod_xml_radius toggle debug", mod_xml_radius_debug_api, NULL);
 
        switch_core_add_state_handler(&state_handlers);