]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
(FSCORE-217) Add support for passing the cause of hangup to the uuid_kill command
authorMichael Jerris <mike@jerris.com>
Wed, 12 Nov 2008 11:46:44 +0000 (11:46 +0000)
committerMichael Jerris <mike@jerris.com>
Wed, 12 Nov 2008 11:46:44 +0000 (11:46 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10347 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_commands/mod_commands.c

index ea41d04982d40d146bec4db8b067e5c7a7b475e7..f0e4a48146659176e7e45bfe76ed25ec410f774b 100644 (file)
@@ -921,26 +921,39 @@ SWITCH_STANDARD_API(reload_xml_function)
        return SWITCH_STATUS_SUCCESS;
 }
 
-#define KILL_SYNTAX "<uuid>"
+#define KILL_SYNTAX "<uuid> [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;
 
        if (session) {
                return SWITCH_STATUS_FALSE;
        }
 
-       if (!cmd) {
+       if (switch_strlen_zero(cmd) || !(mycmd = strdup(cmd))) {
                stream->write_function(stream, "-USAGE: %s\n", KILL_SYNTAX);
-       } else if ((ksession = switch_core_session_locate(cmd))) {
+               return SWITCH_STATUS_SUCCESS;
+       }
+
+       if ((kcause = strchr(mycmd, ' '))) {
+               *kcause++ = '\0';
+       }
+
+       if (switch_strlen_zero(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);
-               switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+               if (!switch_strlen_zero(kcause)){
+                       cause = switch_channel_str2cause(kcause);
+               }  
+               switch_channel_hangup(channel, cause);
                switch_core_session_rwunlock(ksession);
                stream->write_function(stream, "+OK\n");
-       } else {
-               stream->write_function(stream, "-ERR No Such Channel!\n");
        }
 
+       switch_safe_free(mycmd);
        return SWITCH_STATUS_SUCCESS;
 }