[asterisk-commits] mmichelson: trunk r185704 - in /trunk: CHANGES main/manager.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Mar 31 19:39:06 CDT 2009
Author: mmichelson
Date: Tue Mar 31 19:39:01 2009
New Revision: 185704
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=185704
Log:
Allow the AMI Hangup command to accept a Cause header.
(closes issue #14695)
Reported by: mneuhauser
Patches:
cause-for-hangup-manager-action.patch uploaded by mneuhauser (license 425)
Modified:
trunk/CHANGES
trunk/main/manager.c
Modified: trunk/CHANGES
URL: http://svn.digium.com/svn-view/asterisk/trunk/CHANGES?view=diff&rev=185704&r1=185703&r2=185704
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Tue Mar 31 19:39:01 2009
@@ -26,6 +26,11 @@
Functions
---------
* The CHANNEL() function now supports the "name" option.
+
+Asterisk Manager Interface
+--------------------------
+ * The Hangup action now accepts a Cause header which may be used to
+ set the channel's hangup cause.
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 1.6.1 to Asterisk 1.6.2 -------------
Modified: trunk/main/manager.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/main/manager.c?view=diff&rev=185704&r1=185703&r2=185704
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Tue Mar 31 19:39:01 2009
@@ -1759,20 +1759,39 @@
static char mandescr_hangup[] =
"Description: Hangup a channel\n"
"Variables: \n"
-" Channel: The channel name to be hungup\n";
+" Channel: The channel name to be hungup\n"
+" Cause: numeric hangup cause\n";
static int action_hangup(struct mansession *s, const struct message *m)
{
struct ast_channel *c = NULL;
+ int causecode = 0; /* all values <= 0 mean 'do not set hangupcause in channel' */
const char *name = astman_get_header(m, "Channel");
+ const char *cause = astman_get_header(m, "Cause");
if (ast_strlen_zero(name)) {
astman_send_error(s, m, "No channel specified");
return 0;
+ }
+ if (!ast_strlen_zero(cause)) {
+ char *endptr;
+ causecode = strtol(cause, &endptr, 10);
+ if (causecode < 0 || causecode > 127 || *endptr != '\0') {
+ ast_log(LOG_NOTICE, "Invalid 'Cause: %s' in manager action Hangup\n", cause);
+ /* keep going, better to hangup without cause than to not hang up at all */
+ causecode = 0; /* do not set channel's hangupcause */
+ }
}
c = ast_get_channel_by_name_locked(name);
if (!c) {
astman_send_error(s, m, "No such channel");
return 0;
+ }
+ if (causecode > 0) {
+ if (option_debug >= 1) {
+ ast_log(LOG_DEBUG, "Setting hangupcause of channel %s to %d (is %d now)\n",
+ c->name, causecode, c->hangupcause);
+ }
+ c->hangupcause = causecode;
}
ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
ast_channel_unlock(c);
More information about the asterisk-commits
mailing list