Author: anthm Date: Tue Jul 22 13:19:26 2008 New Revision: 9134 Modified: freeswitch/trunk/src/include/switch_core.h freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c freeswitch/trunk/src/switch_core.c freeswitch/trunk/src/switch_loadable_module.c freeswitch/trunk/src/switch_utils.c Log: add some more stuff to sho Modified: freeswitch/trunk/src/include/switch_core.h ============================================================================== --- freeswitch/trunk/src/include/switch_core.h (original) +++ freeswitch/trunk/src/include/switch_core.h Tue Jul 22 13:19:26 2008 @@ -593,6 +593,8 @@ */ SWITCH_DECLARE(void) switch_core_set_variable(_In_z_ const char *varname, _In_opt_z_ const char *value); +SWITCH_DECLARE(void) switch_core_dump_variables(_In_ switch_stream_handle_t *stream); + /*! \brief Hangup All Sessions \param cause the hangup cause to apply to the hungup channels Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original) +++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Tue Jul 22 13:19:26 2008 @@ -1977,7 +1977,7 @@ return SWITCH_STATUS_SUCCESS; } -#define SHOW_SYNTAX "codec|application|api|dialplan|file|timer|calls [count]|channels [count]|aliases|complete" +#define SHOW_SYNTAX "codec|application|api|dialplan|file|timer|calls [count]|channels [count]|aliases|complete|chat|endpoint|management|say|interfaces|interface_types" SWITCH_STANDARD_API(show_function) { char sql[1024]; @@ -2018,13 +2018,28 @@ return SWITCH_STATUS_SUCCESS; } + /* If you change the field qty or order of any of these select */ /* statmements, you must also change show_callback and friends to match! */ if (!command) { stream->write_function(stream, "-USAGE: %s\n", SHOW_SYNTAX); return SWITCH_STATUS_SUCCESS; - } else if (!strcasecmp(command, "codec") || !strcasecmp(command, "dialplan") || !strcasecmp(command, "file") || !strcasecmp(command, "timer")) { + } else if (!strncasecmp(command, "codec", 5) || + !strncasecmp(command, "dialplan", 8) || + !strncasecmp(command, "file", 4) || + !strncasecmp(command, "timer", 5) || + !strncasecmp(command, "chat", 4) || + !strncasecmp(command, "say", 3) || + !strncasecmp(command, "management", 10) || + !strncasecmp(command, "endpoint", 8)) { + if (end_of(command) == 's') { + end_of(command) = '\0'; + } sprintf(sql, "select type, name from interfaces where type = '%s' order by type,name", command); + } else if (!strcasecmp(command, "interfaces")) { + sprintf(sql, "select type, name from interfaces order by type,name"); + } else if (!strcasecmp(command, "interface_types")) { + sprintf(sql, "select type,count(type) as total from interfaces group by type order by type"); } else if (!strcasecmp(command, "tasks")) { sprintf(sql, "select * from %s", command); } else if (!strcasecmp(command, "application") || !strcasecmp(command, "api")) { @@ -2407,13 +2422,11 @@ SWITCH_STANDARD_API(global_getvar_function) { - if (!switch_strlen_zero(cmd)) { + if (switch_strlen_zero(cmd)) { + switch_core_dump_variables(stream); + } else { stream->write_function(stream, "%s", switch_str_nil(switch_core_get_variable(cmd))); - goto done; } - - stream->write_function(stream, "-USAGE: %s\n", GLOBAL_GETVAR_SYNTAX); - done: return SWITCH_STATUS_SUCCESS; } Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Tue Jul 22 13:19:26 2008 @@ -139,6 +139,22 @@ return runtime.state_handlers[index]; } +SWITCH_DECLARE(void) switch_core_dump_variables(switch_stream_handle_t *stream) +{ + switch_hash_index_t *hi; + const void *var; + void *val; + switch_mutex_lock(runtime.global_mutex); + for (hi = switch_hash_first(NULL, runtime.global_vars); hi; hi = switch_hash_next(hi)) { + char *vvar, *vval; + switch_hash_this(hi, &var, NULL, &val); + vvar = (char *) var; + vval = (char *) val; + stream->write_function(stream, "%s=%s\n", vvar, vval); + } + switch_mutex_unlock(runtime.global_mutex); +} + SWITCH_DECLARE(char *) switch_core_get_variable(const char *varname) { char *val; Modified: freeswitch/trunk/src/switch_loadable_module.c ============================================================================== --- freeswitch/trunk/src/switch_loadable_module.c (original) +++ freeswitch/trunk/src/switch_loadable_module.c Tue Jul 22 13:19:26 2008 @@ -138,6 +138,11 @@ } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Endpoint '%s'\n", ptr->interface_name); switch_core_hash_insert(loadable_modules.endpoint_hash, ptr->interface_name, (const void *) ptr); + if (switch_event_create(&event, SWITCH_EVENT_MODULE_LOAD) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "type", "%s", "endpoint"); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "name", "%s", ptr->interface_name); + switch_event_fire(&event); + } } } } Modified: freeswitch/trunk/src/switch_utils.c ============================================================================== --- freeswitch/trunk/src/switch_utils.c (original) +++ freeswitch/trunk/src/switch_utils.c Tue Jul 22 13:19:26 2008 @@ -701,13 +701,14 @@ return status; } - switch_copy_string(buf, "127.0.0.1", len); - + switch (family) { case AF_INET: + switch_copy_string(buf, "127.0.0.1", len); base = "82.45.148.209"; break; case AF_INET6: + switch_copy_string(buf, "::1", len); base = "2001:503:BA3E::2:30"; // DNS Root server A break; default: