--- asterisk-1.4.21.2/channels/chan_sip.c 2008-06-03 16:46:24.000000000 +0200
+++ asterisk-1.4.21.2_patched/channels/chan_sip.c 2008-07-29 12:17:26.000000000 +0200
@@ -796,6 +796,7 @@
#define SIP_PAGE2_BUGGY_MWI (1 << 26) /*!< 26: Buggy CISCO MWI fix */
#define SIP_PAGE2_OUTGOING_CALL (1 << 27) /*!< 27: Is this an outgoing call? */
#define SIP_PAGE2_UDPTL_DESTINATION (1 << 28) /*!< 28: Use source IP of RTP as destination if NAT is enabled */
+#define SIP_ANSWEREDELSEWHERE (1 << 30) /*!< 30: Is set when the call is answered by another phone in a ringgroup */
#define SIP_PAGE2_FLAGS_TO_COPY \
(SIP_PAGE2_ALLOWSUBSCRIBE | SIP_PAGE2_ALLOWOVERLAP | SIP_PAGE2_VIDEOSUPPORT | \
@@ -3497,6 +3498,14 @@
return 0;
}
+ if (ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE)) {
+ if(option_debug)
+ ast_log(LOG_DEBUG, "This call was answered elsewhere\n");
+
+ append_history(p, "Cancel", "Call answered elsewhere");
+ ast_set_flag(&p->flags[1], SIP_ANSWEREDELSEWHERE);
+ }
+
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)
@@ -7858,6 +7867,10 @@
p->invitestate = INV_CONFIRMED;
reqprep(&resp, p, sipmethod, seqno, newbranch);
+
+ if (sipmethod == SIP_CANCEL && ast_test_flag(&p->flags[1], SIP_ANSWEREDELSEWHERE))
+ add_header(&resp, "Reason", "SIP;cause=200;text=\"Call completed elsewhere\"");
+
add_header_contentLength(&resp, 0);
return send_request(p, &resp, reliable, seqno ? seqno : p->ocseq);
}