aboutsummaryrefslogtreecommitdiffstats
path: root/pbx.c
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-25 20:51:27 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-25 20:51:27 +0000
commit08fc2908d3a3edc75807a73189c78761a8bae7d7 (patch)
tree5ac581e56a5a8e0205acf238973b2f80852a4ee1 /pbx.c
parent2aa960bb03bb82858b18123a180a9524880bea39 (diff)
Merge in branch which gives you the ability to set the hangup causecode using the Hangup application. (issue #7160 reported by kmilitzer branch by jcollie)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@30390 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx.c')
-rw-r--r--pbx.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/pbx.c b/pbx.c
index 7c44e77b5..a971cf193 100644
--- a/pbx.c
+++ b/pbx.c
@@ -343,7 +343,9 @@ static struct pbx_builtin {
{ "Hangup", pbx_builtin_hangup,
"Hang up the calling channel",
- " Hangup(): This application will hang up the calling channel.\n"
+ " Hangup([causecode]): This application will hang up the calling channel.\n"
+ "If a causecode is given the channel's hangup cause will be set to the given\n"
+ "value.\n"
},
{ "NoOp", pbx_builtin_noop,
@@ -5018,9 +5020,28 @@ static int pbx_builtin_setamaflags(struct ast_channel *chan, void *data)
*/
static int pbx_builtin_hangup(struct ast_channel *chan, void *data)
{
- /* Just return non-zero and it will hang up */
- if (!chan->hangupcause)
+ if (!ast_strlen_zero(data)) {
+ int cause;
+ char *endptr;
+
+ if ((cause = ast_str2cause(data)) > -1) {
+ chan->hangupcause = cause;
+ return -1;
+ }
+
+ cause = strtol((const char *) data, &endptr, 10);
+ if (cause != 0 || (data != endptr)) {
+ chan->hangupcause = cause;
+ return -1;
+ }
+
+ ast_log(LOG_NOTICE, "Invalid cause given to Hangup(): \"%s\"\n", (char *) data);
+ }
+
+ if (!chan->hangupcause) {
chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+ }
+
return -1;
}