提交 3d486a34 authored 作者: Anthony Minessale's avatar Anthony Minessale

add some more stuff to sho

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9134 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 83592d1d
...@@ -593,6 +593,8 @@ SWITCH_DECLARE(char *) switch_core_get_variable(_In_z_ const char *varname); ...@@ -593,6 +593,8 @@ SWITCH_DECLARE(char *) switch_core_get_variable(_In_z_ const char *varname);
*/ */
SWITCH_DECLARE(void) switch_core_set_variable(_In_z_ const char *varname, _In_opt_z_ const char *value); 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 \brief Hangup All Sessions
\param cause the hangup cause to apply to the hungup channels \param cause the hangup cause to apply to the hungup channels
......
...@@ -1977,7 +1977,7 @@ SWITCH_STANDARD_API(alias_function) ...@@ -1977,7 +1977,7 @@ SWITCH_STANDARD_API(alias_function)
return SWITCH_STATUS_SUCCESS; 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) SWITCH_STANDARD_API(show_function)
{ {
char sql[1024]; char sql[1024];
...@@ -2018,13 +2018,28 @@ SWITCH_STANDARD_API(show_function) ...@@ -2018,13 +2018,28 @@ SWITCH_STANDARD_API(show_function)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/* If you change the field qty or order of any of these select */ /* If you change the field qty or order of any of these select */
/* statmements, you must also change show_callback and friends to match! */ /* statmements, you must also change show_callback and friends to match! */
if (!command) { if (!command) {
stream->write_function(stream, "-USAGE: %s\n", SHOW_SYNTAX); stream->write_function(stream, "-USAGE: %s\n", SHOW_SYNTAX);
return SWITCH_STATUS_SUCCESS; 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); 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")) { } else if (!strcasecmp(command, "tasks")) {
sprintf(sql, "select * from %s", command); sprintf(sql, "select * from %s", command);
} else if (!strcasecmp(command, "application") || !strcasecmp(command, "api")) { } else if (!strcasecmp(command, "application") || !strcasecmp(command, "api")) {
...@@ -2407,13 +2422,11 @@ SWITCH_STANDARD_API(global_setvar_function) ...@@ -2407,13 +2422,11 @@ SWITCH_STANDARD_API(global_setvar_function)
SWITCH_STANDARD_API(global_getvar_function) 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))); 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; return SWITCH_STATUS_SUCCESS;
} }
......
...@@ -139,6 +139,22 @@ SWITCH_DECLARE(const switch_state_handler_table_t *) switch_core_get_state_handl ...@@ -139,6 +139,22 @@ SWITCH_DECLARE(const switch_state_handler_table_t *) switch_core_get_state_handl
return runtime.state_handlers[index]; 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) SWITCH_DECLARE(char *) switch_core_get_variable(const char *varname)
{ {
char *val; char *val;
......
...@@ -138,6 +138,11 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable ...@@ -138,6 +138,11 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Endpoint '%s'\n", ptr->interface_name); 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); 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);
}
} }
} }
} }
......
...@@ -701,13 +701,14 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int fam ...@@ -701,13 +701,14 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int fam
return status; return status;
} }
switch_copy_string(buf, "127.0.0.1", len);
switch (family) { switch (family) {
case AF_INET: case AF_INET:
switch_copy_string(buf, "127.0.0.1", len);
base = "82.45.148.209"; base = "82.45.148.209";
break; break;
case AF_INET6: case AF_INET6:
switch_copy_string(buf, "::1", len);
base = "2001:503:BA3E::2:30"; // DNS Root server A base = "2001:503:BA3E::2:30"; // DNS Root server A
break; break;
default: default:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论