From ba0e7ae9ca27babbdc56e2e3da9d9b18881b3df0 Mon Sep 17 00:00:00 2001 From: William King Date: Fri, 2 Nov 2012 17:06:27 -0700 Subject: [PATCH] Adding ability to toggle mod_xml_radius debug flag from a console api command rather than having to rebuild and reload the module. --- .../xml_int/mod_xml_radius/mod_xml_radius.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mod/xml_int/mod_xml_radius/mod_xml_radius.c b/src/mod/xml_int/mod_xml_radius/mod_xml_radius.c index 0b99166f98..d858f46535 100644 --- a/src/mod/xml_int/mod_xml_radius/mod_xml_radius.c +++ b/src/mod/xml_int/mod_xml_radius/mod_xml_radius.c @@ -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);