diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index cf8b365f29..6657cfd2c2 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2604,12 +2604,17 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t goto done; } - if ((gateway_ptr = sofia_reg_find_gateway(argv[2]))) { - sofia_glue_del_gateway(gateway_ptr); - sofia_reg_release_gateway(gateway_ptr); - stream->write_function(stream, "+OK gateway marked for deletion.\n"); + if (!strcasecmp(argv[2], "_all_")) { + sofia_glue_del_every_gateway(profile); + stream->write_function(stream, "+OK every gateway marked for deletion.\n"); } else { - stream->write_function(stream, "-ERR no such gateway.\n"); + if ((gateway_ptr = sofia_reg_find_gateway(argv[2]))) { + sofia_glue_del_gateway(gateway_ptr); + sofia_reg_release_gateway(gateway_ptr); + stream->write_function(stream, "+OK gateway marked for deletion.\n"); + } else { + stream->write_function(stream, "-ERR no such gateway.\n"); + } } goto done; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index bff6087cfd..c03da5f648 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -915,6 +915,7 @@ switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int const char *sofia_glue_strip_proto(const char *uri); switch_status_t reconfig_sofia(sofia_profile_t *profile); void sofia_glue_del_gateway(sofia_gateway_t *gp); +void sofia_glue_del_every_gateway(sofia_profile_t *profile); void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent, const char *network_ip); void sofia_glue_restart_all_profiles(void); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index aeffdbfc49..782e62dd90 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -3932,6 +3932,19 @@ switch_status_t sofia_glue_add_profile(char *key, sofia_profile_t *profile) return status; } + +void sofia_glue_del_every_gateway(sofia_profile_t *profile) +{ + sofia_gateway_t *gp = NULL; + + switch_mutex_lock(mod_sofia_globals.hash_mutex); + for (gp = profile->gateways; gp; gp = gp->next) { + sofia_glue_del_gateway(gp); + } + switch_mutex_unlock(mod_sofia_globals.hash_mutex); +} + + void sofia_glue_del_gateway(sofia_gateway_t *gp) { if (!gp->deleted) {