aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authoroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2009-01-29 09:56:53 +0000
committeroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2009-01-29 09:56:53 +0000
commitfa3b07f3c6a8912c3ef09e04059d53784e27c454 (patch)
tree8fabaed4ebdc2f3dabf592fb200452bc79f80bd2 /channels/chan_sip.c
parent63456f0c1bf3dddca50e4007dff42ceaf203872a (diff)
Merged revisions 172173 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r172173 | oej | 2009-01-29 10:18:01 +0100 (Tor, 29 Jan 2009) | 24 lines Merged revisions 172169 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r172169 | oej | 2009-01-29 09:48:18 +0100 (Tor, 29 Jan 2009) | 16 lines Make sure that we always add the hangupcause headers. In some cases, the owner was disconnected before we checked for the cause. This patch implements a temporary storage in the pvt and use that instead. The code is based on ideas from code from Adomjan in issue #13385 (Add support for Reason: header) Thanks to Klaus Darillion for testing! (closes issue #14294) related to issue #13385 Reported by: klaus3000 and adomjan Patches: bug14294b.diff uploaded by oej (license 306) Based on 20080829_chan_sip.c-q850reason_header.patch uploaded by adomjan (license 487) Tested by: oej, klaus3000 ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@172217 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 1354c37bf..99667d317 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1309,7 +1309,8 @@ struct sip_pvt {
(A bit unsure of this, please correct if
you know more) */
struct sip_st_dlg *stimer; /*!< SIP Session-Timers */
-};
+ int hangupcause; /*!< Storage of hangupcause copied from our owner before we disconnect from the AST channel (only used at hangup) */
+};
/*! Max entires in the history list for a sip_pvt */
@@ -4844,6 +4845,10 @@ static int sip_hangup(struct ast_channel *ast)
p->answered_elsewhere = TRUE;
}
+ /* Store hangupcause locally in PVT so we still have it before disconnect */
+ if (p->owner)
+ p->hangupcause = p->owner->hangupcause;
+
if (ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
if (ast_test_flag(&p->flags[0], SIP_INC_COUNT) || ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD)) {
if (sipdebug)
@@ -4891,7 +4896,7 @@ static int sip_hangup(struct ast_channel *ast)
stop_media_flows(p); /* Immediately stop RTP, VRTP and UDPTL as applicable */
- append_history(p, needcancel ? "Cancel" : "Hangup", "Cause %s", p->owner ? ast_cause2str(p->owner->hangupcause) : "Unknown");
+ append_history(p, needcancel ? "Cancel" : "Hangup", "Cause %s", p->owner ? ast_cause2str(p->hangupcause) : "Unknown");
/* Disconnect */
if (p->vad)
@@ -4942,7 +4947,7 @@ static int sip_hangup(struct ast_channel *ast)
}
} else { /* Incoming call, not up */
const char *res;
- if (ast->hangupcause && (res = hangup_cause2sip(ast->hangupcause)))
+ if (p->hangupcause && (res = hangup_cause2sip(p->hangupcause)))
transmit_response_reliable(p, res, &p->initreq);
else
transmit_response_reliable(p, "603 Declined", &p->initreq);
@@ -9786,11 +9791,11 @@ static int transmit_request_with_auth(struct sip_pvt *p, int sipmethod, int seqn
}
/* If we are hanging up and know a cause for that, send it in clear text to make
debugging easier. */
- if (sipmethod == SIP_BYE && p->owner && p->owner->hangupcause) {
+ if (sipmethod == SIP_BYE) {
char buf[10];
- add_header(&resp, "X-Asterisk-HangupCause", ast_cause2str(p->owner->hangupcause));
- snprintf(buf, sizeof(buf), "%d", p->owner->hangupcause);
+ add_header(&resp, "X-Asterisk-HangupCause", ast_cause2str(p->hangupcause));
+ snprintf(buf, sizeof(buf), "%d", p->hangupcause);
add_header(&resp, "X-Asterisk-HangupCauseCode", buf);
}