mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 08:05:37 +00:00
add ability for multiple profiles to share the same gateway names via profile::gwname syntax for normT
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16698 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
6107493160
commit
625b477c95
@ -1712,7 +1712,6 @@ SWITCH_STANDARD_API(reload_function)
|
||||
stream->write_function(stream, "+OK module unloaded\n");
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR unloading module [%s]\n", err);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) cmd, SWITCH_TRUE, &err) == SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -2282,7 +2282,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
stream->write_function(stream, "%25s\t%s\t %32s\t%s\n", "Name", " Type", "Data", "State");
|
||||
stream->write_function(stream, "%25s\t%s\t %40s\t%s\n", "Name", " Type", "Data", "State");
|
||||
stream->write_function(stream, "%s\n", line);
|
||||
switch_mutex_lock(mod_sofia_globals.hash_mutex);
|
||||
for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
|
||||
@ -2292,21 +2292,27 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
|
||||
|
||||
if (strcmp(vvar, profile->name)) {
|
||||
ac++;
|
||||
stream->write_function(stream, "%25s\t%s\t %32s\t%s\n", vvar, " alias", profile->name, "ALIASED");
|
||||
stream->write_function(stream, "%25s\t%s\t %40s\t%s\n", vvar, " alias", profile->name, "ALIASED");
|
||||
} else {
|
||||
stream->write_function(stream, "%25s\t%s\t %32s\t%s (%u)\n", profile->name, "profile", profile->url,
|
||||
stream->write_function(stream, "%25s\t%s\t %40s\t%s (%u)\n", profile->name, "profile", profile->url,
|
||||
sofia_test_pflag(profile, PFLAG_RUNNING) ? "RUNNING" : "DOWN", profile->inuse);
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_TLS)) {
|
||||
stream->write_function(stream, "%25s\t%s\t %32s\t%s (%u) (TLS)\n", profile->name, "profile", profile->tls_url,
|
||||
stream->write_function(stream, "%25s\t%s\t %40s\t%s (%u) (TLS)\n", profile->name, "profile", profile->tls_url,
|
||||
sofia_test_pflag(profile, PFLAG_RUNNING) ? "RUNNING" : "DOWN", profile->inuse);
|
||||
}
|
||||
|
||||
c++;
|
||||
|
||||
for (gp = profile->gateways; gp; gp = gp->next) {
|
||||
char *pkey = switch_mprintf("%s::%s", profile->name, gp->name);
|
||||
|
||||
switch_assert(gp->state < REG_STATE_LAST);
|
||||
stream->write_function(stream, "%25s\t%s\t %32s\t%s", gp->name, "gateway", gp->register_to, sofia_state_names[gp->state]);
|
||||
|
||||
stream->write_function(stream, "%25s\t%s\t %40s\t%s",
|
||||
pkey, "gateway", gp->register_to, sofia_state_names[gp->state]);
|
||||
free(pkey);
|
||||
|
||||
if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) {
|
||||
time_t now = switch_epoch_time_now(NULL);
|
||||
if (gp->retry > now) {
|
||||
|
@ -842,7 +842,7 @@ sofia_profile_t *sofia_glue_find_profile__(const char *file, const char *func, i
|
||||
#define sofia_glue_profile_rdlock(x) sofia_glue_profile_rdlock__(__FILE__, __SWITCH_FUNC__, __LINE__, x)
|
||||
switch_status_t sofia_glue_profile_rdlock__(const char *file, const char *func, int line, sofia_profile_t *profile);
|
||||
|
||||
switch_status_t sofia_reg_add_gateway(char *key, sofia_gateway_t *gateway);
|
||||
switch_status_t sofia_reg_add_gateway(const char *profile_name, const char *key, sofia_gateway_t *gateway);
|
||||
sofia_gateway_t *sofia_reg_find_gateway__(const char *file, const char *func, int line, const char *key);
|
||||
#define sofia_reg_find_gateway(x) sofia_reg_find_gateway__(__FILE__, __SWITCH_FUNC__, __LINE__, x)
|
||||
|
||||
|
@ -1702,17 +1702,20 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
|
||||
for (gateway_tag = switch_xml_child(gateways_tag, "gateway"); gateway_tag; gateway_tag = gateway_tag->next) {
|
||||
char *name = (char *) switch_xml_attr_soft(gateway_tag, "name");
|
||||
sofia_gateway_t *gateway;
|
||||
char *pkey = switch_mprintf("%s-%s", profile->name, name);
|
||||
|
||||
if (zstr(name)) {
|
||||
name = "anonymous";
|
||||
}
|
||||
|
||||
switch_mutex_lock(mod_sofia_globals.hash_mutex);
|
||||
if ((gp = switch_core_hash_find(mod_sofia_globals.gateway_hash, name))) {
|
||||
if ((gp = switch_core_hash_find(mod_sofia_globals.gateway_hash, name)) && (gp = switch_core_hash_find(mod_sofia_globals.gateway_hash, pkey))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate gateway '%s'\n", name);
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
free(pkey);
|
||||
goto skip;
|
||||
}
|
||||
free(pkey);
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
|
||||
if ((gateway = switch_core_alloc(profile->pool, sizeof(*gateway)))) {
|
||||
@ -2009,7 +2012,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
|
||||
|
||||
gateway->next = profile->gateways;
|
||||
profile->gateways = gateway;
|
||||
sofia_reg_add_gateway(gateway->name, gateway);
|
||||
sofia_reg_add_gateway(profile->name, gateway->name, gateway);
|
||||
}
|
||||
|
||||
skip:
|
||||
|
@ -223,6 +223,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
||||
{
|
||||
sofia_gateway_t *gateway_ptr, *last = NULL;
|
||||
switch_event_t *event;
|
||||
char *pkey;
|
||||
|
||||
for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
|
||||
if (gateway_ptr->deleted && gateway_ptr->state == REG_STATE_NOREG) {
|
||||
@ -231,10 +232,15 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
||||
} else {
|
||||
profile->gateways = gateway_ptr->next;
|
||||
}
|
||||
|
||||
pkey = switch_mprintf("%s::%s", profile->name, gateway_ptr->name);
|
||||
|
||||
switch_snprintf(pkey, sizeof(pkey), "%s::%s", profile->name, gateway_ptr->name);
|
||||
switch_core_hash_delete(mod_sofia_globals.gateway_hash, pkey);
|
||||
switch_core_hash_delete(mod_sofia_globals.gateway_hash, gateway_ptr->name);
|
||||
switch_core_hash_delete(mod_sofia_globals.gateway_hash, gateway_ptr->register_from);
|
||||
switch_core_hash_delete(mod_sofia_globals.gateway_hash, gateway_ptr->register_contact);
|
||||
|
||||
free(pkey);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deleted gateway %s\n", gateway_ptr->name);
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_GATEWAY_DEL) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile-name", gateway_ptr->profile->name);
|
||||
@ -2414,16 +2420,22 @@ void sofia_reg_release_gateway__(const char *file, const char *func, int line, s
|
||||
#endif
|
||||
}
|
||||
|
||||
switch_status_t sofia_reg_add_gateway(char *key, sofia_gateway_t *gateway)
|
||||
switch_status_t sofia_reg_add_gateway(const char *profile_name, const char *key, sofia_gateway_t *gateway)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
char *pkey = switch_mprintf("%s::%s", profile_name, key);
|
||||
|
||||
switch_mutex_lock(mod_sofia_globals.hash_mutex);
|
||||
if (!switch_core_hash_find(mod_sofia_globals.gateway_hash, key)) {
|
||||
status = switch_core_hash_insert(mod_sofia_globals.gateway_hash, key, gateway);
|
||||
}
|
||||
if (!switch_core_hash_find(mod_sofia_globals.gateway_hash, pkey)) {
|
||||
status = switch_core_hash_insert(mod_sofia_globals.gateway_hash, pkey, gateway);
|
||||
}
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
|
||||
free(pkey);
|
||||
|
||||
if (status == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_t *s_event;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Added gateway '%s' to profile '%s'\n", gateway->name, gateway->profile->name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user