aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index c4af5049e..c08d84a5d 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1028,6 +1028,7 @@ static struct sip_pvt {
struct sip_pvt *next; /*!< Next dialog in chain */
struct sip_invite_param *options; /*!< Options for INVITE */
int autoframing;
+ int hangupcause; /*!< Storage of hangupcause copied from our owner before we disconnect from the AST channel (only used at hangup) */
} *iflist = NULL;
/*! Max entires in the history list for a sip_pvt */
@@ -3539,6 +3540,10 @@ static int sip_hangup(struct ast_channel *ast)
return 0;
}
+ /* 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 (option_debug && sipdebug)
@@ -3589,7 +3594,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)
@@ -3641,7 +3646,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);
@@ -7997,11 +8002,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);
}