diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 6df083bca6..03bbc2d753 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -934,6 +934,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_insert_file(switch_core_session_t *se SWITCH_DECLARE(switch_status_t) switch_ivr_create_message_reply(switch_event_t **reply, switch_event_t *message, const char *new_proto); SWITCH_DECLARE(char *) switch_ivr_check_presence_mapping(const char *exten_name, const char *domain_name); +SWITCH_DECLARE(switch_status_t) switch_ivr_kill_uuid(const char *uuid, switch_call_cause_t cause); /** @} */ diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 988893a39f..d01adc658a 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -2128,7 +2128,6 @@ SWITCH_STANDARD_API(reload_xml_function) #define KILL_SYNTAX " [cause]" SWITCH_STANDARD_API(kill_function) { - switch_core_session_t *ksession = NULL; char *mycmd = NULL, *kcause = NULL; switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING; @@ -2139,17 +2138,14 @@ SWITCH_STANDARD_API(kill_function) if ((kcause = strchr(mycmd, ' '))) { *kcause++ = '\0'; - } - - if (zstr(mycmd) || !(ksession = switch_core_session_locate(mycmd))) { - stream->write_function(stream, "-ERR No Such Channel!\n"); - } else { - switch_channel_t *channel = switch_core_session_get_channel(ksession); if (!zstr(kcause)) { cause = switch_channel_str2cause(kcause); - } - switch_channel_hangup(channel, cause); - switch_core_session_rwunlock(ksession); + } + } + + if (switch_ivr_kill_uuid(mycmd, cause) != SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "-ERR No Such Channel!\n"); + } else { stream->write_function(stream, "+OK\n"); } diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 608e34d191..0721639bb9 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -3201,6 +3201,20 @@ SWITCH_DECLARE(char *) switch_ivr_check_presence_mapping(const char *exten_name, } +SWITCH_DECLARE(switch_status_t) switch_ivr_kill_uuid(const char *uuid, switch_call_cause_t cause) +{ + switch_core_session_t *session; + + if (zstr(uuid) || !(session = switch_core_session_locate(uuid))) { + return SWITCH_STATUS_FALSE; + } else { + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_channel_hangup(channel, cause); + switch_core_session_rwunlock(session); + return SWITCH_STATUS_SUCCESS; + } +} + /* For Emacs: * Local Variables: