<!--Colorize the Console -->
<param name="colorize-console" value="true"/>
+ <!--
+ Set the Switch Name for HA environments.
+ When setting the switch name, it will override the system hostname for all DB and CURL requests
+ allowing cluster environments such as RHCS to have identical FreeSWITCH configurations but run
+ as different hostnames.
+ -->
+ <!-- <param name="switchname" value="freeswitch"/>-->
+
<!-- maximum number of simo db handles open -->
<param name="max-db-handles" value="50"/>
<!-- maximum number of seconds to wait for a new db handle before failing -->
int max_sql_buffer_len;
switch_dbtype_t odbc_dbtype;
char hostname[256];
+ char *switchname;
int multiple_registrations;
uint32_t max_db_handles;
uint32_t db_handle_timeout;
SWITCH_DECLARE(char *) switch_core_get_variable_dup(_In_z_ const char *varname);
SWITCH_DECLARE(char *) switch_core_get_variable_pdup(_In_z_ const char *varname, switch_memory_pool_t *pool);
SWITCH_DECLARE(const char *) switch_core_get_hostname(void);
+SWITCH_DECLARE(const char *) switch_core_get_switchname(void);
/*!
\brief Add a global variable to the core
switch_time_t time_diff = 0;
CURL *curl_handle = NULL;
long httpRes = 0;
- char hostname[256] = "";
struct http_data http_data;
http_data.max_bytes = 10240;
SWITCH_STANDARD_STREAM(http_data.stream);
- gethostname(hostname, sizeof(hostname));
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "url: %s\n", query);
curl_handle = curl_easy_init();
SWITCH_STANDARD_API(hostname_api_function)
{
- char hostname[256] = "";
- gethostname(hostname, sizeof(hostname));
- stream->write_function(stream, "%s", hostname);
+ stream->write_function(stream, "%s", switch_core_get_hostname());
+ return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_STANDARD_API(switchname_api_function)
+{
+ stream->write_function(stream, "%s", switch_core_get_switchname());
return SWITCH_STATUS_SUCCESS;
}
char *command = NULL, *as = NULL;
switch_core_flag_t cflags = switch_core_flags();
switch_status_t status = SWITCH_STATUS_SUCCESS;
- char hostname[256] = "";
- gethostname(hostname, sizeof(hostname));
-
+ const char *hostname = switch_core_get_switchname();
if (!(cflags & SCF_USE_SQL)) {
stream->write_function(stream, "-ERR SQL DISABLED NO DATA AVAILABLE!\n");
SWITCH_ADD_API(commands_api_interface, "help", "Show help for all the api commands", help_function, "");
SWITCH_ADD_API(commands_api_interface, "host_lookup", "host_lookup", host_lookup_function, "<hostname>");
SWITCH_ADD_API(commands_api_interface, "hostname", "Returns the system hostname", hostname_api_function, "");
+ SWITCH_ADD_API(commands_api_interface, "switchname", "Returns the switch name", switchname_api_function, "");
SWITCH_ADD_API(commands_api_interface, "hupall", "hupall", hupall_api_function, "<cause> [<var> <value>]");
SWITCH_ADD_API(commands_api_interface, "in_group", "determine if a user is in a group", in_group_function, "<user>[@<domain>] <group_name>");
SWITCH_ADD_API(commands_api_interface, "is_lan_addr", "see if an ip is a lan addr", lan_addr_function, "<ip>");
CURL *curl_handle = NULL;
long httpRes = 0;
- char hostname[256] = "";
http_data_t *http_data = NULL;
http_data->max_bytes = 64000;
SWITCH_STANDARD_STREAM(http_data->stream);
- gethostname(hostname, sizeof(hostname));
-
if (!method) {
method = "get";
}
switch_limit_interface_t *limit_interface;
memset(&globals, 0, sizeof(&globals));
- gethostname(globals.hostname, sizeof(globals.hostname));
+ strncpy(globals.hostname, switch_core_get_switchname(), sizeof(globals.hostname));
globals.pool = pool;
static struct {
switch_hash_t *profile_hash;
- char hostname[256];
+ const char *hostname;
int integer;
int debug;
char *dbname;
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- gethostname(globals.hostname, sizeof(globals.hostname));
+ globals.hostname = switch_core_get_switchname();
globals.dbname = switch_core_sprintf(pool, "directory");
switch_cache_db_handle_t *dbh = NULL;
fifo_node_t *node;
- gethostname(globals.hostname, sizeof(globals.hostname));
+ strncpy(globals.hostname, switch_core_get_switchname(), sizeof(globals.hostname));
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
}
/* Get the keys for redis server */
- uuid_rediskey = switch_core_session_sprintf(session,"%s_%s_%s", switch_core_get_hostname(), realm, resource);
+ uuid_rediskey = switch_core_session_sprintf(session,"%s_%s_%s", switch_core_get_switchname(), realm, resource);
rediskey = switch_core_session_sprintf(session, "%s_%s", realm, resource);
if ((pvt = switch_channel_get_private(channel, "limit_redis"))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", (char *)p_key);
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
- p_uuid_key = switch_core_session_sprintf(session, "%s_%s", switch_core_get_hostname(), (char *)p_key);
+ p_uuid_key = switch_core_session_sprintf(session, "%s_%s", switch_core_get_switchname(), (char *)p_key);
if (credis_decr(redis,p_uuid_key,&uuid_val) != 0) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", p_uuid_key);
switch_goto_status(SWITCH_STATUS_FALSE, end);
} else {
rediskey = switch_core_session_sprintf(session, "%s_%s", realm, resource);
- uuid_rediskey = switch_core_session_sprintf(session, "%s_%s_%s", switch_core_get_hostname(), realm, resource);
+ uuid_rediskey = switch_core_session_sprintf(session, "%s_%s_%s", switch_core_get_switchname(), realm, resource);
switch_core_hash_delete(pvt->hash, (const char *) rediskey);
if (credis_decr(redis, rediskey, &val) != 0) {
{
REDIS redis;
if (redis_factory(&redis) == SWITCH_STATUS_SUCCESS) {
- char *rediskey = switch_mprintf("%s_*", switch_core_get_hostname());
+ char *rediskey = switch_mprintf("%s_*", switch_core_get_switchname());
int dec = 0, val = 0, keyc;
char *uuids[2000];
if ((keyc = credis_keys(redis, rediskey, uuids, switch_arraylen(uuids))) > 0) {
int i = 0;
- int hostnamelen = strlen(switch_core_get_hostname())+1;
+ int hostnamelen = strlen(switch_core_get_switchname())+1;
for (i = 0; i < keyc && uuids[i]; i++){
const char *key = uuids[i] + hostnamelen;
switch_find_local_ip(mod_sofia_globals.guess_ip, sizeof(mod_sofia_globals.guess_ip), &mod_sofia_globals.guess_mask, AF_INET);
in.s_addr = mod_sofia_globals.guess_mask;
switch_set_string(mod_sofia_globals.guess_mask_str, inet_ntoa(in));
- gethostname(mod_sofia_globals.hostname, sizeof(mod_sofia_globals.hostname));
+
+ strcpy(mod_sofia_globals.hostname, switch_core_get_switchname());
switch_core_hash_init(&mod_sofia_globals.profile_hash, mod_sofia_globals.pool);
char *address;
char *bindings;
uint32_t key_count;
- char hostname[80];
switch_port_t port;
switch_sockaddr_t *addr;
switch_socket_t *udp_socket;
case SWITCH_EVENT_LOG:
return;
default:
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Multicast-Sender", globals.hostname);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Multicast-Sender", switch_core_get_switchname());
if (switch_event_serialize(event, &packet, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
size_t len;
char *buf;
switch_core_hash_init(&globals.event_hash, module_pool);
switch_core_hash_init(&globals.peer_hash, module_pool);
- gethostname(globals.hostname, sizeof(globals.hostname));
globals.key_count = 0;
if (load_config() != SWITCH_STATUS_SUCCESS) {
idx = 1;
- sprintf(sql, "SELECT * FROM channels WHERE hostname='%s' ORDER BY created_epoch", switch_core_get_hostname());
+ sprintf(sql, "SELECT * FROM channels WHERE hostname='%s' ORDER BY created_epoch", switch_core_get_switchname());
switch_cache_db_execute_sql_callback(dbh, sql, channelList_callback, NULL, NULL);
switch_cache_db_release_db_handle(&dbh);
case SS_CURRENT_CALLS:
{
switch_cache_db_handle_t *dbh;
- char sql[1024] = "", hostname[256] = "";
+ char sql[1024] = "";
if (switch_core_db_handle(&dbh) != SWITCH_STATUS_SUCCESS) {
return SNMP_ERR_GENERR;
}
- gethostname(hostname, sizeof(hostname));
- sprintf(sql, "SELECT COUNT(*) FROM calls WHERE hostname='%s'", hostname);
+ sprintf(sql, "SELECT COUNT(*) FROM calls WHERE hostname='%s'", switch_core_get_switchname());
switch_cache_db_execute_sql_callback(dbh, sql, sql_count_callback, &int_val, NULL);
snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val);
switch_cache_db_release_db_handle(&dbh);
char *uri = NULL;
char *dynamic_url = NULL;
- gethostname(hostname, sizeof(hostname));
+ strncpy(hostname, switch_core_get_switchname(), sizeof(hostname));
if (!binding) {
return NULL;
fflush(handle);
}
-static char hostname[256] = "";
static int32_t running = 1;
-
-
struct helper {
int len;
int hits;
if (!zstr(cursor)) {
sql = switch_mprintf("select distinct uuid from channels where uuid like '%q%%' and hostname='%q' order by uuid",
- cursor, switch_core_get_hostname());
+ cursor, switch_core_get_switchname());
} else {
- sql = switch_mprintf("select distinct uuid from channels where hostname='%q' order by uuid", switch_core_get_hostname());
+ sql = switch_mprintf("select distinct uuid from channels where hostname='%q' order by uuid", switch_core_get_switchname());
}
switch_cache_db_execute_sql_callback(db, sql, uuid_callback, &h, &errmsg);
if (h.words == 0) {
sql = switch_mprintf("select distinct name from interfaces where type='api' and name like '%q%%' and hostname='%q' order by name",
- buf, switch_core_get_hostname());
+ buf, switch_core_get_switchname());
}
if (sql) {
if (h.words == 0) {
stream.write_function(&stream, "select distinct a1 from complete where " "a1 not in (select name from interfaces where hostname='%s') %s ",
- switch_core_get_hostname(), argc ? "and" : "");
+ switch_core_get_switchname(), argc ? "and" : "");
} else {
if (switch_cache_db_get_type(db) == SCDB_TYPE_CORE_DB) {
stream.write_function(&stream, "select distinct a%d,'%q','%q' from complete where ", h.words + 1, switch_str_nil(dup), switch_str_nil(lp));
}
}
- stream.write_function(&stream, " and hostname='%s' order by a%d", switch_core_get_hostname(), h.words + 1);
+ stream.write_function(&stream, " and hostname='%s' order by a%d", switch_core_get_switchname(), h.words + 1);
switch_cache_db_execute_sql_callback(db, stream.data, comp_callback, &h, &errmsg);
char *prompt(EditLine * e)
{
if (*prompt_str == '\0') {
- switch_snprintf(prompt_str, sizeof(prompt_str), "freeswitch@%s> ", hostname);
+ switch_snprintf(prompt_str, sizeof(prompt_str), "freeswitch@%s> ", switch_core_get_switchname());
}
return prompt_str;
switch_threadattr_t *thd_attr = NULL;
switch_memory_pool_t *pool;
- gethostname(hostname, sizeof(hostname));
-
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
return;
/* Load/Init the config first */
console_xml_config();
- gethostname(hostname, sizeof(hostname));
+
#ifdef _MSC_VER
- sprintf(cmd, "\nfreeswitch@%s> ", hostname);
+ sprintf(cmd, "\nfreeswitch@%s> ", switch_core_get_switchname());
console_bufferInput(0, 0, cmd, PROMPT_OP);
memset(cmd, 0, sizeof(cmd));
#endif
}
if (activity) {
- switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "\nfreeswitch@%s> ", hostname);
+ switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "\nfreeswitch@%s> ", switch_core_get_switchname());
}
#ifdef _MSC_VER
activity = 0;
}
}
}
- mystream.write_function(&mystream, " '%s')", switch_core_get_hostname());
+ mystream.write_function(&mystream, " '%s')", switch_core_get_switchname());
switch_cache_db_persistant_execute(db, mystream.data, 5);
status = SWITCH_STATUS_SUCCESS;
} else if (!strcasecmp(argv[0], "add")) {
}
}
}
- mystream.write_function(&mystream, " '%s')", switch_core_get_hostname());
+ mystream.write_function(&mystream, " '%s')", switch_core_get_switchname());
switch_cache_db_persistant_execute(db, mystream.data, 5);
status = SWITCH_STATUS_SUCCESS;
mystream.write_function(&mystream, "a%d = '%w'%w", x + 1, switch_str_nil(argv[x + 1]), x == argc - 2 ? "" : " and ");
}
}
- mystream.write_function(&mystream, " and hostname='%s'", switch_core_get_hostname());
+ mystream.write_function(&mystream, " and hostname='%s'", switch_core_get_switchname());
switch_cache_db_persistant_execute(db, mystream.data, 1);
}
status = SWITCH_STATUS_SUCCESS;
}
if (!strcasecmp(argv[0], "stickyadd") && argc == 3) {
- sql = switch_mprintf("delete from aliases where alias='%q' and hostname='%q'", argv[1], switch_core_get_hostname());
+ sql = switch_mprintf("delete from aliases where alias='%q' and hostname='%q'", argv[1], switch_core_get_switchname());
switch_cache_db_persistant_execute(db, sql, 5);
switch_safe_free(sql);
if (switch_cache_db_get_type(db) == SCDB_TYPE_CORE_DB) {
sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (1, '%q','%q','%q')",
- argv[1], argv[2], switch_core_get_hostname());
+ argv[1], argv[2], switch_core_get_switchname());
} else {
sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (1, '%w','%w','%w')",
- argv[1], argv[2], switch_core_get_hostname());
+ argv[1], argv[2], switch_core_get_switchname());
}
switch_cache_db_persistant_execute(db, sql, 5);
status = SWITCH_STATUS_SUCCESS;
} else if (!strcasecmp(argv[0], "add") && argc == 3) {
- sql = switch_mprintf("delete from aliases where alias='%q' and hostname='%q'", argv[1], switch_core_get_hostname());
+ sql = switch_mprintf("delete from aliases where alias='%q' and hostname='%q'", argv[1], switch_core_get_switchname());
switch_cache_db_persistant_execute(db, sql, 5);
switch_safe_free(sql);
if (switch_cache_db_get_type(db) == SCDB_TYPE_CORE_DB) {
sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (0, '%q','%q','%q')",
- argv[1], argv[2], switch_core_get_hostname());
+ argv[1], argv[2], switch_core_get_switchname());
} else {
sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (0, '%w','%w','%w')",
- argv[1], argv[2], switch_core_get_hostname());
+ argv[1], argv[2], switch_core_get_switchname());
}
switch_cache_db_persistant_execute(db, sql, 5);
status = SWITCH_STATUS_SUCCESS;
} else if (!strcasecmp(argv[0], "del") && argc == 2) {
char *what = argv[1];
if (!strcasecmp(what, "*")) {
- sql = switch_mprintf("delete from aliases where hostname='%q'", switch_core_get_hostname());
+ sql = switch_mprintf("delete from aliases where hostname='%q'", switch_core_get_switchname());
switch_cache_db_persistant_execute(db, sql, 1);
} else {
- sql = switch_mprintf("delete from aliases where alias='%q' and hostname='%q'", argv[1], switch_core_get_hostname());
+ sql = switch_mprintf("delete from aliases where alias='%q' and hostname='%q'", argv[1], switch_core_get_switchname());
switch_cache_db_persistant_execute(db, sql, 5);
}
status = SWITCH_STATUS_SUCCESS;
return runtime.hostname;
}
+SWITCH_DECLARE(const char *) switch_core_get_switchname(void)
+{
+ if (!zstr(runtime.switchname)) return runtime.switchname;
+ return runtime.hostname;
+}
+
+
SWITCH_DECLARE(char *) switch_core_get_variable(const char *varname)
{
char *val;
} else if (!strcasecmp(var, "rtp-enable-zrtp")) {
switch_core_set_variable("zrtp_enabled", val);
#endif
+ } else if (!strcasecmp(var, "switchname") && !zstr(val)) {
+ runtime.switchname = switch_core_strdup(runtime.memory_pool, val);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Set switchname to %s\n", runtime.switchname);
}
}
}
new_sql() = switch_mprintf("insert into tasks values(%q,'%q','%q',%q, '%q')",
id,
switch_event_get_header_nil(event, "task-desc"),
- switch_event_get_header_nil(event, "task-group"), manager ? manager : "0", switch_core_get_hostname()
+ switch_event_get_header_nil(event, "task-group"), manager ? manager : "0", switch_core_get_switchname()
);
}
}
case SWITCH_EVENT_DEL_SCHEDULE:
case SWITCH_EVENT_EXE_SCHEDULE:
new_sql() = switch_mprintf("delete from tasks where task_id=%q and hostname='%q'",
- switch_event_get_header_nil(event, "task-id"), switch_core_get_hostname());
+ switch_event_get_header_nil(event, "task-id"), switch_core_get_switchname());
break;
case SWITCH_EVENT_RE_SCHEDULE:
{
new_sql() = switch_mprintf("update tasks set task_desc='%q',task_group='%q', task_sql_manager=%q where task_id=%q and hostname='%q'",
switch_event_get_header_nil(event, "task-desc"),
switch_event_get_header_nil(event, "task-group"), manager ? manager : "0", id,
- switch_core_get_hostname());
+ switch_core_get_switchname());
}
}
break;
if (uuid) {
new_sql() = switch_mprintf("delete from channels where uuid='%q' and hostname='%q'",
- uuid, switch_core_get_hostname());
+ uuid, switch_core_get_switchname());
new_sql() = switch_mprintf("delete from calls where (caller_uuid='%q' or callee_uuid='%q') and hostname='%q'",
- uuid, uuid, switch_core_get_hostname());
+ uuid, uuid, switch_core_get_switchname());
}
}
"update calls set callee_uuid='%q' where callee_uuid='%q' and hostname='%q'",
switch_event_get_header_nil(event, "unique-id"),
switch_event_get_header_nil(event, "old-unique-id"),
- switch_core_get_hostname(),
+ switch_core_get_switchname(),
switch_event_get_header_nil(event, "unique-id"),
switch_event_get_header_nil(event, "old-unique-id"),
- switch_core_get_hostname(),
+ switch_core_get_switchname(),
switch_event_get_header_nil(event, "unique-id"),
- switch_event_get_header_nil(event, "old-unique-id"), switch_core_get_hostname()
+ switch_event_get_header_nil(event, "old-unique-id"), switch_core_get_switchname()
);
break;
}
switch_event_get_header_nil(event, "channel-state"),
switch_event_get_header_nil(event, "channel-call-state"),
switch_event_get_header_nil(event, "caller-dialplan"),
- switch_event_get_header_nil(event, "caller-context"), switch_core_get_hostname()
+ switch_event_get_header_nil(event, "caller-context"), switch_core_get_switchname()
);
break;
case SWITCH_EVENT_CODEC:
switch_event_get_header_nil(event, "channel-write-codec-name"),
switch_event_get_header_nil(event, "channel-write-codec-rate"),
switch_event_get_header_nil(event, "channel-write-codec-bit-rate"),
- switch_event_get_header_nil(event, "unique-id"), switch_core_get_hostname());
+ switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
break;
case SWITCH_EVENT_CHANNEL_HOLD:
case SWITCH_EVENT_CHANNEL_UNHOLD:
switch_event_get_header_nil(event, "application-data"),
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
- switch_event_get_header_nil(event, "unique-id"), switch_core_get_hostname()
+ switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname()
);
}
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "channel-call-uuid"),
extra_cols,
- switch_event_get_header_nil(event, "unique-id"), switch_core_get_hostname());
+ switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
free(extra_cols);
} else {
new_sql() = switch_mprintf("update channels set "
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "channel-call-uuid"),
- switch_event_get_header_nil(event, "unique-id"), switch_core_get_hostname());
+ switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
}
}
switch_str_nil(name),
switch_str_nil(number),
switch_event_get_header_nil(event, "direction"),
- switch_event_get_header_nil(event, "unique-id"), switch_core_get_hostname());
+ switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
name = switch_event_get_header(event, "callee-name");
number = switch_event_get_header(event, "callee-number");
{
new_sql() = switch_mprintf("update channels set callstate='%q' where uuid='%q' and hostname='%q'",
switch_event_get_header_nil(event, "channel-call-state"),
- switch_event_get_header_nil(event, "unique-id"), switch_core_get_hostname());
+ switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
}
break;
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
extra_cols,
- switch_event_get_header_nil(event, "unique-id"), switch_core_get_hostname());
+ switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
free(extra_cols);
} else {
new_sql() = switch_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',"
switch_event_get_header_nil(event, "caller-context"),
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
- switch_event_get_header_nil(event, "unique-id"), switch_core_get_hostname());
+ switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
}
break;
default:
new_sql() = switch_mprintf("update channels set state='%s' where uuid='%s' and hostname='%q'",
switch_event_get_header_nil(event, "channel-state"),
- switch_event_get_header_nil(event, "unique-id"), switch_core_get_hostname());
+ switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
break;
}
new_sql() = switch_mprintf("update channels set call_uuid='%q' where uuid='%s' and hostname='%q'",
switch_event_get_header_nil(event, "channel-call-uuid"),
- switch_event_get_header_nil(event, "unique-id"), switch_core_get_hostname());
+ switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
if (runtime.odbc_dbtype == DBTYPE_DEFAULT) {
func_name = "function";
callee_cid_num,
switch_event_get_header_nil(event, "Other-Leg-destination-number"),
switch_event_get_header_nil(event, "Other-Leg-channel-name"),
- switch_event_get_header_nil(event, "Other-Leg-unique-id"), switch_core_get_hostname()
+ switch_event_get_header_nil(event, "Other-Leg-unique-id"), switch_core_get_switchname()
);
}
break;
char *uuid = switch_event_get_header_nil(event, "caller-unique-id");
new_sql() = switch_mprintf("delete from calls where (caller_uuid='%q' or callee_uuid='%q') and hostname='%q'",
- uuid, uuid, switch_core_get_hostname());
+ uuid, uuid, switch_core_get_switchname());
break;
}
case SWITCH_EVENT_SHUTDOWN:
new_sql() = switch_mprintf("delete from channels where hostname='%q';"
"delete from interfaces where hostname='%q';"
"delete from calls where hostname='%q'",
- switch_core_get_hostname(), switch_core_get_hostname(), switch_core_get_hostname()
+ switch_core_get_switchname(), switch_core_get_switchname(), switch_core_get_switchname()
);
break;
case SWITCH_EVENT_LOG:
switch_mprintf
("insert into interfaces (type,name,description,syntax,ikey,filename,hostname) values('%q','%q','%q','%q','%q','%q','%q')", type, name,
switch_str_nil(description), switch_str_nil(syntax), switch_str_nil(key), switch_str_nil(filename),
- switch_core_get_hostname()
+ switch_core_get_switchname()
);
}
break;
const char *name = switch_event_get_header_nil(event, "name");
if (!zstr(type) && !zstr(name)) {
new_sql() = switch_mprintf("delete from interfaces where type='%q' and name='%q' and hostname='%q'", type, name,
- switch_core_get_hostname());
+ switch_core_get_switchname());
}
break;
}
break;
}
new_sql() = switch_mprintf("update channels set secure='%s' where uuid='%s' and hostname='%q'",
- type, switch_event_get_header_nil(event, "caller-unique-id"), switch_core_get_hostname()
+ type, switch_event_get_header_nil(event, "caller-unique-id"), switch_core_get_switchname()
);
break;
}
if (!strcmp("add", op)) {
new_sql() = switch_mprintf("insert into nat (port, proto, sticky, hostname) values (%s, %s, %d,'%q')",
switch_event_get_header_nil(event, "port"),
- switch_event_get_header_nil(event, "proto"), sticky, switch_core_get_hostname()
+ switch_event_get_header_nil(event, "proto"), sticky, switch_core_get_switchname()
);
} else if (!strcmp("del", op)) {
new_sql() = switch_mprintf("delete from nat where port=%s and proto=%s and hostname='%q'",
switch_event_get_header_nil(event, "port"),
- switch_event_get_header_nil(event, "proto"), switch_core_get_hostname());
+ switch_event_get_header_nil(event, "proto"), switch_core_get_switchname());
} else if (!strcmp("status", op)) {
/* call show nat api */
} else if (!strcmp("status_response", op)) {
if (runtime.multiple_registrations) {
sql = switch_mprintf("delete from registrations where hostname='%q' and (url='%q' or token='%q')",
- switch_core_get_hostname(), url, switch_str_nil(token));
+ switch_core_get_switchname(), url, switch_str_nil(token));
} else {
sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'",
- user, realm, switch_core_get_hostname());
+ user, realm, switch_core_get_switchname());
}
switch_queue_push(sql_manager.sql_queue[0], sql);
switch_str_nil(network_ip),
switch_str_nil(network_port),
switch_str_nil(network_proto),
- switch_core_get_hostname()
+ switch_core_get_switchname()
);
}
if (!zstr(token) && runtime.multiple_registrations) {
- sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q' and token='%q'", user, realm, switch_core_get_hostname(), token);
+ sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q' and token='%q'", user, realm, switch_core_get_switchname(), token);
} else {
- sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'", user, realm, switch_core_get_hostname());
+ sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'", user, realm, switch_core_get_switchname());
}
switch_queue_push(sql_manager.sql_queue[0], sql);
now = switch_epoch_time_now(NULL);
if (force) {
- sql = switch_mprintf("delete from registrations where hostname='%q'", switch_core_get_hostname());
+ sql = switch_mprintf("delete from registrations where hostname='%q'", switch_core_get_switchname());
} else {
- sql = switch_mprintf("delete from registrations where expires > 0 and expires <= %ld and hostname='%q'", now, switch_core_get_hostname());
+ sql = switch_mprintf("delete from registrations where expires > 0 and expires <= %ld and hostname='%q'", now, switch_core_get_switchname());
}
switch_queue_push(sql_manager.sql_queue[0], sql);
char sql[512] = "";
char *tables[] = { "channels", "calls", "interfaces", "tasks", NULL };
int i;
- const char *hostname = switch_core_get_hostname();
+ const char *hostname = switch_core_get_switchname();
for (i = 0; tables[i]; i++) {
switch_snprintf(sql, sizeof(sql), "delete from %s where hostname='%s'", tables[i], hostname);
#define MAX_DISPATCH_VAL 20
static unsigned int MAX_DISPATCH = MAX_DISPATCH_VAL;
static unsigned int SOFT_MAX_DISPATCH = 0;
-static char hostname[128] = "";
static char guess_ip_v4[80] = "";
static char guess_ip_v6[80] = "";
static switch_event_node_t *EVENT_NODES[SWITCH_EVENT_ALL + 1] = { NULL };
switch_mutex_unlock(EVENT_QUEUE_MUTEX);
switch_threadattr_create(&thd_attr, pool);
- gethostname(hostname, sizeof(hostname));
switch_find_local_ip(guess_ip_v4, sizeof(guess_ip_v4), NULL, AF_INET);
switch_find_local_ip(guess_ip_v6, sizeof(guess_ip_v6), NULL, AF_INET6);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Event-Name", switch_event_name(event->event_id));
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Core-UUID", switch_core_get_uuid());
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FreeSWITCH-Hostname", hostname);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FreeSWITCH-Hostname", switch_core_get_hostname());
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FreeSWITCH-Switchname", switch_core_get_switchname());
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FreeSWITCH-IPv4", guess_ip_v4);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FreeSWITCH-IPv6", guess_ip_v6);