Add HANGUPCAUSE information to callee channels
authorKinsey Moore <kmoore@digium.com>
Wed, 15 Aug 2012 17:56:04 +0000 (17:56 +0000)
committerKinsey Moore <kmoore@digium.com>
Wed, 15 Aug 2012 17:56:04 +0000 (17:56 +0000)
This adds HANGUPCAUSE information to called channels so that hangup
handlers can, in conjunction with predial dialplan execution, access
the hangupcause information when the dialed channel hangs up on a
one-to-one basis instead of a many-to-one basis as with HANGUPCAUSE
usage on the caller channel.

Review: https://reviewboard.asterisk.org/r/2069/
(closes issue ASTERISK-20198)
........

Merged revisions 371258 from http://svn.asterisk.org/svn/asterisk/branches/11

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@371259 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_dahdi.c
channels/chan_iax2.c
channels/chan_sip.c
channels/sig_analog.c
channels/sig_pri.c
channels/sig_ss7.c

index b342e0b..884ad4b 100644 (file)
@@ -4248,6 +4248,7 @@ static void dahdi_r2_on_call_disconnect(openr2_chan_t *r2chan, openr2_call_disco
        ast_copy_string(cause_code->chan_name, ast_channel_name(p->owner), AST_CHANNEL_NAME);
        ast_copy_string(cause_code->code, cause_str, datalen + 1 - sizeof(*cause_code));
        ast_queue_control_data(p->owner, AST_CONTROL_PVT_CAUSE_CODE, cause_code, datalen);
+       ast_channel_hangupcause_hash_set(p->owner, cause_code, datalen);
 
        /* when we have an owner we don't call dahdi_r2_disconnect_call here, that will
           be done in dahdi_hangup */
index 51e777c..3774962 100644 (file)
@@ -10237,7 +10237,12 @@ static int socket_process_helper(struct iax2_thread *thread)
                cause_code->ast_cause = ies.causecode;
                snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "IAX2 %s(%d)", subclass, ies.causecode);
 
-               iax2_queue_control_data(fr->callno, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
+               iax2_lock_owner(fr->callno);
+               if (iaxs[fr->callno] && iaxs[fr->callno]->owner) {
+                       ast_queue_control_data(iaxs[fr->callno]->owner, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
+                       ast_channel_hangupcause_hash_set(iaxs[fr->callno]->owner, cause_code, data_size);
+                       ast_channel_unlock(iaxs[fr->callno]->owner);
+               }
                if (!iaxs[fr->callno]) {
                        ast_variables_destroy(ies.vars);
                        ast_mutex_unlock(&iaxsl[fr->callno]);
index 252e87d..03f7a44 100644 (file)
@@ -27207,6 +27207,7 @@ static int handle_incoming(struct sip_pvt *p, struct sip_request *req, struct as
                                }
 
                                ast_queue_control_data(p->owner, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
+                               ast_channel_hangupcause_hash_set(p->owner, cause_code, data_size);
                        }
 
                        handle_response(p, respid, e + len, req, seqno);
index a7f7b2f..79e8e7c 100644 (file)
@@ -2819,6 +2819,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                cause_code->ast_cause = AST_CAUSE_NETWORK_OUT_OF_ORDER;
        case ANALOG_EVENT_ONHOOK:
                ast_queue_control_data(ast, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
+               ast_channel_hangupcause_hash_set(ast, cause_code, data_size);
                switch (p->sig) {
                case ANALOG_SIG_FXOLS:
                case ANALOG_SIG_FXOGS:
@@ -3498,6 +3499,7 @@ winkflashdone:
                                        if (p->hanguponpolarityswitch) {
                                                ast_debug(1, "HangingUp on polarity switch! channel %d\n", p->channel);
                                                ast_queue_control_data(ast, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
+                                               ast_channel_hangupcause_hash_set(ast, cause_code, data_size);
                                                ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT);
                                                p->polarity = POLARITY_IDLE;
                                        } else {
index 2840c3b..da60e7e 100644 (file)
@@ -1300,6 +1300,7 @@ static void pri_queue_pvt_cause_data(struct sig_pri_span *pri, int chanpos, cons
                ast_copy_string(cause_code->chan_name, ast_channel_name(chan), AST_CHANNEL_NAME);
                ast_copy_string(cause_code->code, cause, datalen + 1 - sizeof(*cause_code));
                ast_queue_control_data(chan, AST_CONTROL_PVT_CAUSE_CODE, cause_code, datalen);
+               ast_channel_hangupcause_hash_set(chan, cause_code, datalen);
                ast_channel_unlock(chan);
        }
 }
index e699923..0c9b8f5 100644 (file)
@@ -397,6 +397,7 @@ static void ss7_queue_pvt_cause_data(struct ast_channel *owner, const char *caus
        ast_copy_string(cause_code->chan_name, ast_channel_name(owner), AST_CHANNEL_NAME);
        ast_copy_string(cause_code->code, cause, datalen + 1 - sizeof(*cause_code));
        ast_queue_control_data(owner, AST_CONTROL_PVT_CAUSE_CODE, cause_code, datalen);
+       ast_channel_hangupcause_hash_set(owner, cause_code, datalen);
 }