Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 137271) +++ channels/chan_sip.c (working copy) @@ -15810,9 +15810,15 @@ sipmethod = find_sip_method(msg); owner = p->owner; - if (owner) + if (owner) { owner->hangupcause = hangup_sip2cause(resp); + /* Copy the SIP reason reported by the other end to HANGUPCAUSETEXT chan variable */ + char hangupcausetext[256]; + snprintf(hangupcausetext,256,"SIP %s",req->rlPart2); + pbx_builtin_setvar_helper(owner,"HANGUPCAUSETEXT",hangupcausetext); + } + /* Acknowledge whatever it is destined for */ if ((resp >= 100) && (resp <= 199)) __sip_semi_ack(p, seqno, 0, sipmethod); Index: apps/app_dial.c =================================================================== --- apps/app_dial.c (revision 137271) +++ apps/app_dial.c (working copy) @@ -567,6 +567,13 @@ char status[256]; }; +static void copy_variable(struct ast_channel *dst,struct ast_channel *src,char *varname) +{ + const char *sreason; + sreason = pbx_builtin_getvar_helper(src, varname); + pbx_builtin_setvar_helper(dst,"HANGUPCAUSETEXT",sreason); +} + static struct ast_channel *wait_for_answer(struct ast_channel *in, struct chanlist *outgoing, int *to, struct ast_flags64 *peerflags, struct privacy_args *pa, @@ -656,6 +663,8 @@ f = ast_read(winner); if (!f) { in->hangupcause = c->hangupcause; + + copy_variable(in,c,"HANGUPCAUSETEXT"); #ifdef HAVE_EPOLL ast_poll_channel_del(in, c); #endif @@ -692,10 +701,14 @@ /* If call has been answered, then the eventual hangup is likely to be normal hangup */ in->hangupcause = AST_CAUSE_NORMAL_CLEARING; c->hangupcause = AST_CAUSE_NORMAL_CLEARING; + break; case AST_CONTROL_BUSY: ast_verb(3, "%s is busy\n", c->name); in->hangupcause = c->hangupcause; + + copy_variable(in,c,"HANGUPCAUSETEXT"); + ast_hangup(c); c = o->chan = NULL; ast_clear_flag64(o, DIAL_STILLGOING); @@ -704,6 +717,9 @@ case AST_CONTROL_CONGESTION: ast_verb(3, "%s is circuit-busy\n", c->name); in->hangupcause = c->hangupcause; + + copy_variable(in,c,"HANGUPCAUSETEXT"); + ast_hangup(c); c = o->chan = NULL; ast_clear_flag64(o, DIAL_STILLGOING); @@ -1975,8 +1991,10 @@ ast_parseable_goto(peer, opt_args[OPT_ARG_CALLEE_GO_ON]); ast_pbx_start(peer); } else { - if (!ast_check_hangup(chan)) + if (!ast_check_hangup(chan)) { chan->hangupcause = peer->hangupcause; + copy_variable(chan,peer,"HANGUPCAUSETEXT"); + } ast_hangup(peer); } } Index: CHANGES =================================================================== --- CHANGES (revision 137271) +++ CHANGES (working copy) @@ -133,6 +133,8 @@ up video RTP ports, even on clients that don't support it. This helps with callfiles and certain transfers to ensure that if two video phones are connected, they will always share video feeds. + * Added HANGUPCAUSETEXT channel variable. This variable will save the + other end SIP Text Status Line with the exact disconnect reason. IAX Changes ----------- Index: main/pbx.c =================================================================== --- main/pbx.c (revision 137271) +++ main/pbx.c (working copy) @@ -2496,6 +2496,8 @@ } else if (!strcmp(var, "HANGUPCAUSE")) { snprintf(workspace, workspacelen, "%d", c->hangupcause); s = workspace; + } else if (!strcmp(var,"HANGUPCAUSETEXT")) { + s = pbx_builtin_getvar_helper(c, "HANGUPCAUSETEXT"); } } if (s == ¬_found) { /* look for more */