diff options
author | mvanbaak <mvanbaak@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-24 22:16:48 +0000 |
---|---|---|
committer | mvanbaak <mvanbaak@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-24 22:16:48 +0000 |
commit | 94979a8bde5da5087e67261a4ff435aaff6188e4 (patch) | |
tree | 2c247ba7f500b9bdc0fa9867d833b6af194d7139 /channels | |
parent | e8d5948d534e44d389e8ceab04c6e1b007b8fd6d (diff) |
Pass the hangup cause all the way to the calling app/channel.
(closes issue #11328)
Reported by: rain
Patches:
20071207__pass_cause_in_hangup_control_frame.diff.txt uploaded by Corydon76 (license 14)
brought up-to-date to trunk by me
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@114637 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_alsa.c | 2 | ||||
-rw-r--r-- | channels/chan_gtalk.c | 4 | ||||
-rw-r--r-- | channels/chan_h323.c | 6 | ||||
-rw-r--r-- | channels/chan_iax2.c | 8 | ||||
-rw-r--r-- | channels/chan_jingle.c | 2 | ||||
-rw-r--r-- | channels/chan_local.c | 2 | ||||
-rw-r--r-- | channels/chan_mgcp.c | 2 | ||||
-rw-r--r-- | channels/chan_misdn.c | 6 | ||||
-rw-r--r-- | channels/chan_oss.c | 2 | ||||
-rw-r--r-- | channels/chan_sip.c | 20 | ||||
-rw-r--r-- | channels/chan_skinny.c | 8 | ||||
-rw-r--r-- | channels/chan_unistim.c | 10 | ||||
-rw-r--r-- | channels/chan_zap.c | 4 |
13 files changed, 37 insertions, 39 deletions
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index 3e9199fce..1d26ef297 100644 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -766,7 +766,7 @@ static char *console_hangup(struct ast_cli_entry *e, int cmd, struct ast_cli_arg hookstate = 0; grab_owner(); if (alsa.owner) { - ast_queue_hangup(alsa.owner); + ast_queue_hangup(alsa.owner, AST_CAUSE_NORMAL_CLEARING); ast_channel_unlock(alsa.owner); } } diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c index 04ea60865..ad7034644 100644 --- a/channels/chan_gtalk.c +++ b/channels/chan_gtalk.c @@ -620,7 +620,7 @@ static int gtalk_is_answered(struct gtalk *client, ikspak *pak) ast_getformatname_multiple(s2, BUFSIZ, tmp->peercapability), ast_getformatname_multiple(s3, BUFSIZ, tmp->jointcapability)); /* close session if capabilities don't match */ - ast_queue_hangup(tmp->owner); + ast_queue_hangup(tmp->owner, -1); return -1; @@ -749,7 +749,7 @@ static int gtalk_hangup_farend(struct gtalk *client, ikspak *pak) if (tmp) { tmp->alreadygone = 1; if (tmp->owner) - ast_queue_hangup(tmp->owner); + ast_queue_hangup(tmp->owner, -1); } else ast_log(LOG_NOTICE, "Whoa, didn't find call!\n"); gtalk_response(client, from, pak, NULL, NULL); diff --git a/channels/chan_h323.c b/channels/chan_h323.c index a3f6ee6f3..dec9aa021 100644 --- a/channels/chan_h323.c +++ b/channels/chan_h323.c @@ -342,7 +342,7 @@ static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt) ast_debug(1, "Process pending hangup for %s\n", c->name); c->_softhangup |= AST_SOFTHANGUP_DEV; c->hangupcause = pvt->hangupcause; - ast_queue_hangup(c); + ast_queue_hangup(c, pvt->hangupcause); pvt->needhangup = 0; pvt->newstate = pvt->newcontrol = pvt->newdigit = pvt->DTMFsched = -1; } @@ -2379,7 +2379,7 @@ static void cleanup_connection(unsigned call_reference, const char *call_token) /* Send hangup */ if (pvt->owner) { pvt->owner->_softhangup |= AST_SOFTHANGUP_DEV; - ast_queue_hangup(pvt->owner); + ast_queue_hangup(pvt->owner, -1); ast_channel_unlock(pvt->owner); } ast_mutex_unlock(&pvt->lock); @@ -2404,7 +2404,7 @@ static void hangup_connection(unsigned int call_reference, const char *token, in if (pvt->owner && !ast_channel_trylock(pvt->owner)) { pvt->owner->_softhangup |= AST_SOFTHANGUP_DEV; pvt->owner->hangupcause = pvt->hangupcause = cause; - ast_queue_hangup(pvt->owner); + ast_queue_hangup(pvt->owner, cause); ast_channel_unlock(pvt->owner); } else { diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index ab13d2611..2d5320537 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -1662,7 +1662,7 @@ static int iax2_queue_hangup(int callno) usleep(1); ast_mutex_lock(&iaxsl[callno]); } else { - ast_queue_hangup(iaxs[callno]->owner); + ast_queue_hangup(iaxs[callno]->owner, -1); ast_channel_unlock(iaxs[callno]->owner); break; } @@ -2146,7 +2146,7 @@ retry: /* If there's an owner, prod it to give up */ /* It is ok to use ast_queue_hangup() here instead of iax2_queue_hangup() * because we already hold the owner channel lock. */ - ast_queue_hangup(owner); + ast_queue_hangup(owner, -1); } AST_LIST_LOCK(&frame_queue); @@ -2220,10 +2220,8 @@ static void __attempt_transmit(const void *data) ast_log(LOG_WARNING, "Max retries exceeded to host %s on %s (type = %d, subclass = %d, ts=%d, seqno=%d)\n", ast_inet_ntoa(iaxs[f->callno]->addr.sin_addr),iaxs[f->callno]->owner->name , f->af.frametype, f->af.subclass, f->ts, f->oseqno); iaxs[callno]->error = ETIMEDOUT; if (iaxs[callno]->owner) { - struct ast_frame fr = { 0, }; + struct ast_frame fr = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP, .seqno = AST_CAUSE_DESTINATION_OUT_OF_ORDER }; /* Hangup the fd */ - fr.frametype = AST_FRAME_CONTROL; - fr.subclass = AST_CONTROL_HANGUP; iax2_queue_frame(callno, &fr); /* XXX */ /* Remember, owner could disappear */ if (iaxs[callno] && iaxs[callno]->owner) diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c index 728554916..39aa46c0c 100644 --- a/channels/chan_jingle.c +++ b/channels/chan_jingle.c @@ -573,7 +573,7 @@ static int jingle_hangup_farend(struct jingle *client, ikspak *pak) if (tmp) { tmp->alreadygone = 1; if (tmp->owner) - ast_queue_hangup(tmp->owner); + ast_queue_hangup(tmp->owner, -1); } else ast_log(LOG_NOTICE, "Whoa, didn't find call!\n"); jingle_response(client, pak, NULL, NULL); diff --git a/channels/chan_local.c b/channels/chan_local.c index 636dad7c2..176bc7356 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -534,7 +534,7 @@ static int local_hangup(struct ast_channel *ast) { struct local_pvt *p = ast->tech_pvt; int isoutbound; - struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP }; + struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP, .seqno = ast->hangupcause }; struct ast_channel *ochan = NULL; int glaredetect = 0, res = 0; diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 021999abd..592301e8c 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -610,7 +610,7 @@ static void mgcp_queue_hangup(struct mgcp_subchannel *sub) for(;;) { if (sub->owner) { if (!ast_channel_trylock(sub->owner)) { - ast_queue_hangup(sub->owner); + ast_queue_hangup(sub->owner, -1); ast_channel_unlock(sub->owner); break; } else { diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index ea005d5f7..cdbe3b49c 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -2320,13 +2320,13 @@ static int misdn_answer(struct ast_channel *ast) if (!p) { ast_log(LOG_WARNING, " --> Channel not connected ??\n"); - ast_queue_hangup(ast); + ast_queue_hangup(ast, AST_CAUSE_NETWORK_OUT_OF_ORDER); } if (!p->bc) { chan_misdn_log(1, 0, " --> Got Answer, but theres no bc obj ??\n"); - ast_queue_hangup(ast); + ast_queue_hangup(ast, AST_CAUSE_PROTOCOL_ERROR); } tmp = pbx_builtin_getvar_helper(p->ast, "CRYPT_KEY"); @@ -3665,7 +3665,7 @@ static void hangup_chan(struct chan_list *ch) send_cause2ast(ch->ast, ch->bc, ch); if (ch->ast) - ast_queue_hangup(ch->ast); + ast_queue_hangup(ch->ast, ch->bc->cause); cb_log(2, port, " --> queue_hangup\n"); } else { cb_log(1, port, "Cannot hangup chan, no ast\n"); diff --git a/channels/chan_oss.c b/channels/chan_oss.c index 9d1c4569c..6edbbb88c 100644 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -1040,7 +1040,7 @@ static char *console_hangup(struct ast_cli_entry *e, int cmd, struct ast_cli_arg } o->hookstate = 0; if (o->owner) - ast_queue_hangup(o->owner); + ast_queue_hangup(o->owner, AST_CAUSE_NORMAL_CLEARING); setformat(o, O_CLOSE); return CLI_SUCCESS; } diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 02d2e966a..7a27168d4 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2970,7 +2970,7 @@ static int retrans_pkt(const void *data) if (pkt->owner->owner) { sip_alreadygone(pkt->owner); ast_log(LOG_WARNING, "Hanging up call %s - no reply to our critical packet.\n", pkt->owner->callid); - ast_queue_hangup(pkt->owner->owner); + ast_queue_hangup(pkt->owner->owner, AST_CAUSE_PROTOCOL_ERROR); ast_channel_unlock(pkt->owner->owner); } else { /* If no channel owner, destroy now */ @@ -3112,7 +3112,7 @@ static int __sip_autodestruct(const void *data) if (p->owner) { ast_log(LOG_WARNING, "Autodestruct on dialog '%s' with owner in place (Method: %s)\n", p->callid, sip_methods[p->method].text); - ast_queue_hangup(p->owner); + ast_queue_hangup(p->owner, AST_CAUSE_PROTOCOL_ERROR); } else if (p->refer) { ast_debug(3, "Finally hanging up channel after transfer: %s\n", p->callid); transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1); @@ -15695,7 +15695,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, stru */ xmitres = transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE); if (p->owner && !req->ignore) { - ast_queue_hangup(p->owner); + ast_queue_hangup(p->owner, AST_CAUSE_NORMAL_CLEARING); append_history(p, "Hangup", "Got 487 on CANCEL request from us. Queued AST hangup request"); } else if (!req->ignore) { update_call_counter(p, DEC_CALL_LIMIT); @@ -15776,7 +15776,7 @@ static void handle_response_notify(struct sip_pvt *p, int resp, char *rest, stru if (p->owner) { if (!p->refer) { ast_log(LOG_WARNING, "Notify answer on an owned channel? - %s\n", p->owner->name); - ast_queue_hangup(p->owner); + ast_queue_hangup(p->owner, AST_CAUSE_NORMAL_UNSPECIFIED); } else { ast_debug(4, "Got OK on REFER Notify message\n"); } @@ -16338,7 +16338,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_ default: /* Send hangup */ if (owner && sipmethod != SIP_MESSAGE && sipmethod != SIP_INFO && sipmethod != SIP_BYE) - ast_queue_hangup(p->owner); + ast_queue_hangup(p->owner, AST_CAUSE_PROTOCOL_ERROR); break; } /* ACK on invite */ @@ -16392,7 +16392,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_ ast_debug(1, "Got 200 OK on NOTIFY for transfer\n"); } else ast_log(LOG_WARNING, "Notify answer on an owned channel?\n"); - /* ast_queue_hangup(p->owner); Disabled */ + /* ast_queue_hangup(p->owner, -1); Disabled */ } else { if (!p->subscribed && !p->refer) p->needdestroy = 1; @@ -18242,7 +18242,7 @@ static int handle_request_cancel(struct sip_pvt *p, struct sip_request *req) stop_media_flows(p); /* Immediately stop RTP, VRTP and UDPTL as applicable */ if (p->owner) - ast_queue_hangup(p->owner); + ast_queue_hangup(p->owner, -1); else sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT); if (p->initreq.len > 0) { @@ -18401,15 +18401,15 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req) ast_queue_control(c, AST_CONTROL_UNHOLD); ast_async_goto(bridged_to, p->context, p->refer->refer_to, 1); } else - ast_queue_hangup(p->owner); + ast_queue_hangup(p->owner, -1); } } else { ast_log(LOG_WARNING, "Invalid transfer information from '%s'\n", ast_inet_ntoa(p->recv.sin_addr)); if (p->owner) - ast_queue_hangup(p->owner); + ast_queue_hangup(p->owner, AST_CAUSE_PROTOCOL_ERROR); } } else if (p->owner) { - ast_queue_hangup(p->owner); + ast_queue_hangup(p->owner, -1); ast_debug(3, "Received bye, issuing owner hangup\n"); } else { sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT); diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index c4458ba04..b60952709 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -4513,7 +4513,7 @@ static int handle_onhook_message(struct skinny_req *req, struct skinnysession *s if ((res = attempt_transfer(p)) < 0) { if (sub->next && sub->next->owner) { sub->next->alreadygone = 1; - ast_queue_hangup(sub->next->owner,1); + ast_queue_hangup(sub->next->owner, -1); } } else if (res) { ast_log(LOG_WARNING, "Transfer attempt failed\n"); @@ -4525,7 +4525,7 @@ static int handle_onhook_message(struct skinny_req *req, struct skinnysession *s /* If there is another active call, skinny_hangup will ring the phone with the other call */ if (sub->owner) { sub->alreadygone = 1; - ast_queue_hangup(sub->owner); + ast_queue_hangup(sub->owner, -1); } else { ast_log(LOG_WARNING, "Skinny(%s@%s-%d) channel already destroyed\n", l->name, d->name, sub->callid); @@ -5222,7 +5222,7 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse if ((res = attempt_transfer(p)) < 0) { if (sub->next && sub->next->owner) { sub->next->alreadygone = 1; - ast_queue_hangup(sub->next->owner, 1); + ast_queue_hangup(sub->next->owner, -1); } } else if (res) { ast_log(LOG_WARNING, "Transfer attempt failed\n"); @@ -5234,7 +5234,7 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse /* If there is another active call, skinny_hangup will ring the phone with the other call */ if (sub->owner) { sub->alreadygone = 1; - ast_queue_hangup(sub->owner); + ast_queue_hangup(sub->owner, -1); } else { ast_log(LOG_WARNING, "Skinny(%s@%s-%d) channel already destroyed\n", l->name, d->name, sub->callid); diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c index 7318e7353..dca01ad31 100644 --- a/channels/chan_unistim.c +++ b/channels/chan_unistim.c @@ -1125,7 +1125,7 @@ static void close_client(struct unistimsession *s) if (sub->owner) { /* Call in progress ? */ if (unistimdebug) ast_verb(0, "Aborting call\n"); - ast_queue_hangup(sub->owner); + ast_queue_hangup(sub->owner, AST_CAUSE_NETWORK_OUT_OF_ORDER); } } else ast_log(LOG_WARNING, "Freeing a client with no subchannel !\n"); @@ -1974,11 +1974,11 @@ static void close_call(struct unistimsession *pte) if (attempt_transfer(sub, l->subs[SUB_THREEWAY]) < 0) ast_verb(0, "attempt_transfer failed.\n"); } else - ast_queue_hangup(sub->owner); + ast_queue_hangup(sub->owner, -1); } else { if (l->subs[SUB_THREEWAY]) { if (l->subs[SUB_THREEWAY]->owner) - ast_queue_hangup(l->subs[SUB_THREEWAY]->owner); + ast_queue_hangup(l->subs[SUB_THREEWAY]->owner, AST_CAUSE_NORMAL_CLEARING); else ast_log(LOG_WARNING, "threeway sub without owner\n"); } else @@ -2312,7 +2312,7 @@ static void TransferCallStep1(struct unistimsession *pte) if (unistimdebug) ast_verb(0, "Transfer canceled, hangup our threeway channel\n"); if (p->subs[SUB_THREEWAY]->owner) - ast_queue_hangup(p->subs[SUB_THREEWAY]->owner); + ast_queue_hangup(p->subs[SUB_THREEWAY]->owner, AST_CAUSE_NORMAL_CLEARING); else ast_log(LOG_WARNING, "Canceling a threeway channel without owner\n"); return; @@ -2368,7 +2368,7 @@ static void HandleCallOutgoing(struct unistimsession *s) /* start switch */ if (ast_pthread_create(&t, NULL, unistim_ss, c)) { display_last_error("Unable to create switch thread"); - ast_queue_hangup(c); + ast_queue_hangup(c, AST_CAUSE_SWITCH_CONGESTION); } } else ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", diff --git a/channels/chan_zap.c b/channels/chan_zap.c index 927275d8b..9063bb8c8 100644 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -4522,7 +4522,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast) /* It hasn't been long enough since the last flashook. This is probably a bounce on hanging up. Hangup both channels now */ if (p->subs[SUB_THREEWAY].owner) - ast_queue_hangup(p->subs[SUB_THREEWAY].owner); + ast_queue_hangup(p->subs[SUB_THREEWAY].owner, AST_CAUSE_NO_ANSWER); p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; ast_debug(1, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel); ast_channel_unlock(p->subs[SUB_THREEWAY].owner); @@ -10096,7 +10096,7 @@ static int pri_hangup_all(struct zt_pvt *p, struct zt_pri *pri) ast_mutex_lock(&p->lock); } if (p->subs[x].owner) { - ast_queue_hangup(p->subs[x].owner); + ast_queue_hangup(p->subs[x].owner, AST_CAUSE_PRE_EMPTED); ast_channel_unlock(p->subs[x].owner); } } |