aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-01-31 18:46:59 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-01-31 18:46:59 +0000
commit3f77bd9cb5a8c97802e11f41c0302f4f7b2fcad3 (patch)
tree6d87fec1ed01e73a30f2fb3740227e5fea9b8a6b
parent74f53cec98b443c55177a686e4832078d55b5d16 (diff)
Send busy when busy, congestion when congestion on PRI (bug #890)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2100 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xchannels/chan_zap.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index f790e28b4..ba80313bd 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -352,6 +352,8 @@ struct zt_subchannel {
short buffer[AST_FRIENDLY_OFFSET/2 + READ_SIZE];
struct ast_frame f; /* One frame for each channel. How did this ever work before? */
int needringing;
+ int needbusy;
+ int needcongestion;
int needcallerid;
int needanswer;
int linear;
@@ -1718,6 +1720,8 @@ static int zt_hangup(struct ast_channel *ast)
p->subs[index].owner = NULL;
p->subs[index].needanswer = 0;
p->subs[index].needringing = 0;
+ p->subs[index].needbusy = 0;
+ p->subs[index].needcongestion = 0;
p->subs[index].linear = 0;
p->subs[index].needcallerid = 0;
zt_setlinear(p->subs[index].zfd, 0);
@@ -3460,6 +3464,24 @@ struct ast_frame *zt_read(struct ast_channel *ast)
return &p->subs[index].f;
}
+ if (p->subs[index].needbusy) {
+ /* Send ringing frame if requested */
+ p->subs[index].needbusy = 0;
+ p->subs[index].f.frametype = AST_FRAME_CONTROL;
+ p->subs[index].f.subclass = AST_CONTROL_BUSY;
+ ast_mutex_unlock(&p->lock);
+ return &p->subs[index].f;
+ }
+
+ if (p->subs[index].needcongestion) {
+ /* Send ringing frame if requested */
+ p->subs[index].needcongestion = 0;
+ p->subs[index].f.frametype = AST_FRAME_CONTROL;
+ p->subs[index].f.subclass = AST_CONTROL_CONGESTION;
+ ast_mutex_unlock(&p->lock);
+ return &p->subs[index].f;
+ }
+
if (p->subs[index].needcallerid) {
ast_set_callerid(ast, strlen(p->lastcallerid) ? p->lastcallerid : NULL, 1);
p->subs[index].needcallerid = 0;
@@ -6450,8 +6472,24 @@ static void *pri_dchannel(void *vpri)
if (!pri->pvt[chan]->alreadyhungup) {
/* we're calling here zt_hangup so once we get there we need to clear p->call after calling pri_hangup */
pri->pvt[chan]->alreadyhungup = 1;
- if (pri->pvt[chan]->owner)
- pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ /* Queue a BUSY instead of a hangup if our cause is appropriate */
+ if (pri->pvt[chan]->owner) {
+ switch(e->hangup.cause) {
+ case PRI_CAUSE_USER_BUSY:
+ pri->pvt[chan]->subs[SUB_REAL].needbusy =1;
+ break;
+ case PRI_CAUSE_CALL_REJECTED:
+ case PRI_CAUSE_NETWORK_OUT_OF_ORDER:
+ case PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION:
+ case PRI_CAUSE_SWITCH_CONGESTION:
+ case PRI_CAUSE_DESTINATION_OUT_OF_ORDER:
+ case PRI_CAUSE_NORMAL_TEMPORARY_FAILURE:
+ pri->pvt[chan]->subs[SUB_REAL].needcongestion =1;
+ break;
+ default:
+ pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ }
+ }
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Channel %d, span %d got hangup\n", chan, pri->span);
} else {