summaryrefslogtreecommitdiff
path: root/main/channel.c
diff options
context:
space:
mode:
authorMichiel van Baak <michiel@vanbaak.info>2008-04-24 22:16:48 +0000
committerMichiel van Baak <michiel@vanbaak.info>2008-04-24 22:16:48 +0000
commit08e674bce0e7ce47068f495ff437549d7e20496c (patch)
tree2c247ba7f500b9bdc0fa9867d833b6af194d7139 /main/channel.c
parenta50b48dacd3754b09aa228ba137af5c2e324e8ce (diff)
Pass the hangup cause all the way to the calling app/channel.
(closes issue #11328) Reported by: rain Patches: 20071207__pass_cause_in_hangup_control_frame.diff.txt uploaded by Corydon76 (license 14) brought up-to-date to trunk by me git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114637 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/main/channel.c b/main/channel.c
index fbb14d8ae..351d64198 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -1000,12 +1000,19 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
}
/*! \brief Queue a hangup frame for channel */
-int ast_queue_hangup(struct ast_channel *chan)
+int ast_queue_hangup(struct ast_channel *chan, int cause)
{
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
+
+ if (cause >= 0)
+ f.seqno = cause;
+
/* Yeah, let's not change a lock-critical value without locking */
if (!ast_channel_trylock(chan)) {
chan->_softhangup |= AST_SOFTHANGUP_DEV;
+ if (cause < 0)
+ f.seqno = chan->hangupcause;
+
ast_channel_unlock(chan);
}
return ast_queue_frame(chan, &f);
@@ -2307,7 +2314,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
struct ast_frame *f = NULL; /* the return value */
int blah;
int prestate;
- int count = 0;
+ int count = 0, cause = 0;
/* this function is very long so make sure there is only one return
* point at the end (there are only two exceptions to this).
@@ -2418,6 +2425,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
/* Interpret hangup and return NULL */
/* XXX why not the same for frames from the channel ? */
if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) {
+ cause = f->seqno;
ast_frfree(f);
f = NULL;
}
@@ -2687,6 +2695,8 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
} else {
/* Make sure we always return NULL in the future */
chan->_softhangup |= AST_SOFTHANGUP_DEV;
+ if (cause)
+ chan->hangupcause = cause;
if (chan->generator)
ast_deactivate_generator(chan);
/* End the CDR if appropriate */