diff -Naur asterisk-1.0.7-clean/channels/chan_zap.c asterisk-1.0.7-clean-patched/channels/chan_zap.c --- asterisk-1.0.7-clean/channels/chan_zap.c 2005-02-25 19:11:41.000000000 +0100 +++ asterisk-1.0.7-clean-patched/channels/chan_zap.c 2005-06-15 11:46:57.000000000 +0200 @@ -237,6 +237,7 @@ static int cur_debounce = -1; static int priindication_oob = 0; +static int handleprogresscause = 0; #ifdef ZAPATA_PRI static int minunused = 2; @@ -516,6 +517,7 @@ int busycount; int callprogress; int priindication_oob; + int handleprogresscause; struct timeval flashtime; /* Last flash-hook time */ struct ast_dsp *dsp; int cref; /* Call reference number */ @@ -6474,6 +6476,7 @@ tmp->restrictcid = restrictcid; tmp->use_callingpres = use_callingpres; tmp->priindication_oob = priindication_oob; + tmp->handleprogresscause = handleprogresscause; if (tmp->usedistinctiveringdetection) { if (!tmp->use_callerid) { ast_log(LOG_NOTICE, "Distinctive Ring detect requires 'usecallerid' be on\n"); @@ -7743,11 +7746,25 @@ if (chanpos > -1) { if (pri->overlapdial && !pri->pvts[chanpos]->proceeding) { struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, }; - + + /* handle cause code 'user busy' (17) in q.931 PROGRESS messages*/ + if (e->proceeding.cause > -1) { + if (option_verbose > 2) + ast_verbose(VERBOSE_PREFIX_3 "PROGRESS with cause code %d receiveded!\n",e->proceeding.cause); + if ( handleprogresscause && (e->proceeding.cause == AST_CAUSE_USER_BUSY)) { + if (pri->pvts[chanpos]->owner) { + if (option_verbose > 2) + ast_verbose(VERBOSE_PREFIX_3 "PROGRESS with 'user busy' received, signaling AST_CONTROL_BUSY instead of AST_CONTROL_PROGRESS\n"); + pri->pvts[chanpos]->owner->hangupcause = e->proceeding.cause; + f.subclass = AST_CONTROL_BUSY; + } + } + } + ast_mutex_lock(&pri->pvts[chanpos]->lock); ast_log(LOG_DEBUG, "Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d\n", pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span); - zap_queue_frame(pri->pvts[chanpos], &f, pri); + zap_queue_frame(pri->pvts[chanpos], &f, pri); ast_mutex_unlock(&pri->pvts[chanpos]->lock); } } @@ -9511,6 +9528,13 @@ else ast_log(LOG_WARNING, "'%s' is not a valid pri indication value, should be 'inband' or 'outofband' at line %d\n", v->value, v->lineno); + } else if (!strcasecmp(v->name, "handleprogresscause")) { + if (!strcasecmp(v->value, "yes")) + handleprogresscause = 1; + else if (!strcasecmp(v->value, "no")) + handleprogresscause = 0; + else + ast_log(LOG_WARNING, "'%s' is not a valid value for 'handleprogresscause', should be 'yes' or 'no' at line %d\n",v->value, v->lineno); } else if (!strcasecmp(v->name, "minunused")) { minunused = atoi(v->value); } else if (!strcasecmp(v->name, "idleext")) { diff -Naur asterisk-1.0.7-clean/configs/zapata.conf.sample asterisk-1.0.7-clean-patched/configs/zapata.conf.sample --- asterisk-1.0.7-clean/configs/zapata.conf.sample 2004-12-30 21:36:57.000000000 +0100 +++ asterisk-1.0.7-clean-patched/configs/zapata.conf.sample 2005-06-14 17:19:12.000000000 +0200 @@ -90,6 +90,13 @@ ; ; priindication = outofband ; +; Handle cause code in PROGRESS message +; Some Telco send PROGRESS messages with a cause code to signal +; certain line conditions, e.g. user busy. +; Turn this option to enable busy detection in PROGRESS messages. +; Default = no +; +;handleprogresscause=yes ; ; Signalling method (default is fxs). Valid values: ; em: E & M