Index: chan_sip.c =================================================================== --- chan_sip.c (revision 280339) +++ chan_sip.c (working copy) @@ -12514,8 +12514,19 @@ } reqprep(&resp, p, sipmethod, seqno, newbranch); - if (sipmethod == SIP_CANCEL && p->answered_elsewhere) { - add_header(&resp, "Reason", "SIP;cause=200;text=\"Call completed elsewhere\""); + if (sipmethod == SIP_CANCEL) { + if (p->answered_elsewhere) { + if (ast_test_flag(&p->flags[1], SIP_PAGE2_Q850_REASON)) + add_header(&resp, "Reason", "Q.850;cause=200;text=\"Call completed elsewhere\""); + else + add_header(&resp, "Reason", "SIP;cause=200;text=\"Call completed elsewhere\""); + } + else if (ast_test_flag(&p->flags[1], SIP_PAGE2_Q850_REASON) && p->hangupcause) { + char buf[50]; + + sprintf(buf, "Q.850;cause=%i", p->hangupcause & 0x7f); + add_header(&resp, "Reason", buf); + } } return send_request(p, &resp, reliable, seqno ? seqno : p->ocseq);