[asterisk-commits] rmudgett: branch group/issue14068 r173242 - in /team/group/issue14068: ./ cha...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 3 16:26:39 CST 2009


Author: rmudgett
Date: Tue Feb  3 16:26:39 2009
New Revision: 173242

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=173242
Log:
*  Fixed some redirecting.from.number usage errors.
*  Fixed compilation if lippri not present.
*  Fixed handling of AST_CONTROL_CONNECTED_LINE and
AST_CONTROL_REDIRECTING if the channel is not PRI.
*  Removed unused AST_CONNECTED_LINE_UPDATE_SOURCE_DIVERSION.
*  Added new AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER_ALERTING.

Modified:
    team/group/issue14068/CHANGES
    team/group/issue14068/channels/chan_dahdi.c

Modified: team/group/issue14068/CHANGES
URL: http://svn.digium.com/svn-view/asterisk/team/group/issue14068/CHANGES?view=diff&rev=173242&r1=173241&r2=173242
==============================================================================
--- team/group/issue14068/CHANGES (original)
+++ team/group/issue14068/CHANGES Tue Feb  3 16:26:39 2009
@@ -44,6 +44,10 @@
     received number from the ISDN link if that number has the corresponding
     Type-Of-Number.
 
+libpri channel driver (chan_dahdi) changes
+-------------------------------------------
+  * The channel variable PRIREDIRECTREASON is now just a status variable.
+    Use the REDIRECTING(reason) dialplan function to alter the reason.
 
 SIP channel driver (chan_sip) changes
 -------------------------------------------

Modified: team/group/issue14068/channels/chan_dahdi.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/issue14068/channels/chan_dahdi.c?view=diff&rev=173242&r1=173241&r2=173242
==============================================================================
--- team/group/issue14068/channels/chan_dahdi.c (original)
+++ team/group/issue14068/channels/chan_dahdi.c Tue Feb  3 16:26:39 2009
@@ -2521,14 +2521,40 @@
 }
 #endif	/* defined(HAVE_SS7) */
 
+#if defined(HAVE_PRI)
+static enum AST_REDIRECTING_REASON pri_to_ast_reason(int pri_reason)
+{
+	enum AST_REDIRECTING_REASON ast_reason;
+
+	switch (pri_reason) {
+	case PRI_REDIR_FORWARD_ON_BUSY:
+		ast_reason = AST_REDIRECTING_REASON_USER_BUSY;
+		break;
+	case PRI_REDIR_FORWARD_ON_NO_REPLY:
+		ast_reason = AST_REDIRECTING_REASON_NO_ANSWER;
+		break;
+	case PRI_REDIR_DEFLECTION:
+		ast_reason = AST_REDIRECTING_REASON_DEFLECTION;
+		break;
+	case PRI_REDIR_UNCONDITIONAL:
+		ast_reason = AST_REDIRECTING_REASON_UNCONDITIONAL;
+		break;
+	case PRI_REDIR_UNKNOWN:
+	default:
+		ast_reason = AST_REDIRECTING_REASON_UNKNOWN;
+		break;
+	}	/* end switch */
+
+	return ast_reason;
+}
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 static int ast_to_pri_reason(enum AST_REDIRECTING_REASON ast_reason)
 {
 	int pri_reason;
 
 	switch (ast_reason) {
-	case AST_REDIRECTING_REASON_UNKNOWN:
-		pri_reason = PRI_REDIR_UNKNOWN;
-		break;
 	case AST_REDIRECTING_REASON_USER_BUSY:
 		pri_reason = PRI_REDIR_FORWARD_ON_BUSY;
 		break;
@@ -2541,6 +2567,7 @@
 	case AST_REDIRECTING_REASON_DEFLECTION:
 		pri_reason = PRI_REDIR_DEFLECTION;
 		break;
+	case AST_REDIRECTING_REASON_UNKNOWN:
 	default:
 		pri_reason = PRI_REDIR_UNKNOWN;
 		break;
@@ -2548,7 +2575,9 @@
 
 	return pri_reason;
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 static int pri_to_ast_presentation(int pri_presentation)
 {
 	int ast_presentation;
@@ -2588,7 +2617,9 @@
 
 	return ast_presentation;
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 static int ast_to_pri_presentation(int ast_presentation)
 {
 	int pri_presentation;
@@ -2628,24 +2659,24 @@
 
 	return pri_presentation;
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 static enum AST_CONNECTED_LINE_UPDATE_SOURCE pri_to_ast_connected_line_update_source(enum PRI_CONNECTED_LINE_UPDATE_SOURCE pri_source)
 {
 	enum AST_CONNECTED_LINE_UPDATE_SOURCE ast_source;
 
 	switch (pri_source) {
-	case PRI_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN:
-		ast_source = AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN;
-		break;
 	case PRI_CONNECTED_LINE_UPDATE_SOURCE_ANSWER:
 		ast_source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-		break;
-	case PRI_CONNECTED_LINE_UPDATE_SOURCE_DIVERSION:
-		ast_source = AST_CONNECTED_LINE_UPDATE_SOURCE_DIVERSION;
 		break;
 	case PRI_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER:
 		ast_source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
 		break;
+	case PRI_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER_ALERTING:
+		ast_source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER_ALERTING;
+		break;
+	case PRI_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN:
 	default:
 		ast_source = AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN;
 		break;
@@ -2653,24 +2684,24 @@
 
 	return ast_source;
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 static enum PRI_CONNECTED_LINE_UPDATE_SOURCE ast_to_pri_connected_line_update_source(enum AST_CONNECTED_LINE_UPDATE_SOURCE ast_source)
 {
 	enum PRI_CONNECTED_LINE_UPDATE_SOURCE pri_source;
 
 	switch (ast_source) {
-	case AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN:
-		pri_source = PRI_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN;
-		break;
 	case AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER:
 		pri_source = PRI_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-		break;
-	case AST_CONNECTED_LINE_UPDATE_SOURCE_DIVERSION:
-		pri_source = PRI_CONNECTED_LINE_UPDATE_SOURCE_DIVERSION;
 		break;
 	case AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER:
 		pri_source = PRI_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
 		break;
+	case AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER_ALERTING:
+		pri_source = PRI_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER_ALERTING;
+		break;
+	case AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN:
 	default:
 		pri_source = PRI_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN;
 		break;
@@ -2678,6 +2709,7 @@
 
 	return pri_source;
 }
+#endif	/* defined(HAVE_PRI) */
 
 static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout)
 {
@@ -2972,7 +3004,8 @@
 		ast_mutex_unlock(&p->lock);
 		return -1;
 	}
-#ifdef HAVE_SS7
+
+#if defined(HAVE_SS7)
 	if (p->ss7) {
 		char ss7_called_nai;
 		int called_nai_strip;
@@ -3109,8 +3142,9 @@
 		ast_setstate(ast, AST_STATE_DIALING);
 		ss7_rel(p->ss7);
 	}
-#endif /* HAVE_SS7 */
-#ifdef HAVE_PRI
+#endif	/* defined(HAVE_SS7) */
+
+#if defined(HAVE_PRI)
 	if (p->pri) {
 		struct pri_sr *sr;
 #ifdef SUPPORT_USERUSER
@@ -3121,8 +3155,6 @@
 		int prilocaldialplan;
 		int ldp_strip;
 		int exclusive;
-		const char *rr_str;
-		int redirect_reason;
 
 		c = strchr(dest, '/');
 		if (c) {
@@ -3351,21 +3383,9 @@
 		}
 		pri_sr_set_caller(sr, l ? (l + ldp_strip) : NULL, n, prilocaldialplan,
 			p->use_callingpres ? ast->connected.id.number_presentation : (l ? PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN : PRES_NUMBER_NOT_AVAILABLE));
-		if ((rr_str = pbx_builtin_getvar_helper(ast, "PRIREDIRECTREASON"))) {
-			if (!strcasecmp(rr_str, "UNKNOWN"))
-				redirect_reason = 0;
-			else if (!strcasecmp(rr_str, "BUSY"))
-				redirect_reason = 1;
-			else if (!strcasecmp(rr_str, "NO_REPLY"))
-				redirect_reason = 2;
-			else if (!strcasecmp(rr_str, "UNCONDITIONAL"))
-				redirect_reason = 15;
-			else
-				redirect_reason = PRI_REDIR_UNCONDITIONAL;
-		} else
-			redirect_reason = PRI_REDIR_UNCONDITIONAL;
-		pri_sr_set_redirecting(sr, ast->redirecting.from.name, ast->redirecting.from.number, ast->redirecting.from.number_type,
-		                       ast->redirecting.from.number_presentation, ast_to_pri_reason(ast->redirecting.reason));
+		pri_sr_set_redirecting(sr, ast->redirecting.from.name,
+			ast->cid.cid_rdnis, ast->redirecting.from.number_type,
+			ast->redirecting.from.number_presentation, ast_to_pri_reason(ast->redirecting.reason));
 
 #ifdef SUPPORT_USERUSER
 		/* User-user info */
@@ -3386,7 +3406,8 @@
 		ast_setstate(ast, AST_STATE_DIALING);
 		pri_rel(p->pri);
 	}
-#endif
+#endif	/* defined(HAVE_PRI) */
+
 	ast_mutex_unlock(&p->lock);
 	return 0;
 }
@@ -6401,42 +6422,13 @@
 	return 0;
 }
 
-static enum AST_REDIRECTING_REASON pri_to_ast_reason(int pri_reason)
-{
-	enum AST_REDIRECTING_REASON ast_reason;
-
-	switch (pri_reason) {
-	case PRI_REDIR_UNKNOWN:
-		ast_reason = AST_REDIRECTING_REASON_UNKNOWN;
-		break;
-	case PRI_REDIR_FORWARD_ON_BUSY:
-		ast_reason = AST_REDIRECTING_REASON_USER_BUSY;
-		break;
-	case PRI_REDIR_FORWARD_ON_NO_REPLY:
-		ast_reason = AST_REDIRECTING_REASON_NO_ANSWER;
-		break;
-	case PRI_REDIR_DEFLECTION:
-		ast_reason = AST_REDIRECTING_REASON_DEFLECTION;
-		break;
-	case PRI_REDIR_UNCONDITIONAL:
-		ast_reason = AST_REDIRECTING_REASON_UNCONDITIONAL;
-		break;
-	default:
-		ast_reason = AST_REDIRECTING_REASON_UNKNOWN;
-		break;
-	}	/* end switch */
-
-	return ast_reason;
-}
-
 static int dahdi_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen)
 {
 	struct dahdi_pvt *p = chan->tech_pvt;
 	int res=-1;
 	int idx;
 	int func = DAHDI_FLASH;
-	struct pri_party_connected_line connected;
-	struct pri_party_redirecting redirecting;
+
 	ast_mutex_lock(&p->lock);
 	idx = dahdi_get_index(chan, p, 0);
 	ast_debug(1, "Requested indication %d on channel %s\n", condition, chan->name);
@@ -6663,45 +6655,63 @@
 			res = tone_zone_play_tone(p->subs[idx].dfd, -1);
 			break;
 		case AST_CONTROL_CONNECTED_LINE:
-			ast_debug(1,"Received AST_CONTROL_CONNECTED_LINE on %s\n",chan->name);
-			if (chan->connected.id.number)
-				ast_copy_string(connected.id.number, chan->connected.id.number, sizeof(connected.id.number));
-			else
-				connected.id.number[0] = '\0';
-			if (chan->connected.id.name)
-				ast_copy_string(connected.id.name, chan->connected.id.name, sizeof(connected.id.name));
-			else
-				connected.id.name[0] = '\0';
-			connected.id.number_type = chan->connected.id.number_type;
-			connected.id.number_presentation = ast_to_pri_presentation(chan->connected.id.number_presentation);
-			connected.source = ast_to_pri_connected_line_update_source(chan->connected.source);
-			pri_connected_line_update(p->pri->pri, p->call, &connected);
+			ast_debug(1, "Received AST_CONTROL_CONNECTED_LINE on %s\n", chan->name);
+#if defined(HAVE_PRI)
+			if (p->pri) {
+				struct pri_party_connected_line connected;
+
+				if (chan->connected.id.number) {
+					ast_copy_string(connected.id.number, chan->connected.id.number, sizeof(connected.id.number));
+				} else {
+					connected.id.number[0] = '\0';
+				}
+				if (chan->connected.id.name) {
+					ast_copy_string(connected.id.name, chan->connected.id.name, sizeof(connected.id.name));
+				} else {
+					connected.id.name[0] = '\0';
+				}
+				connected.id.number_type = chan->connected.id.number_type;
+				connected.id.number_presentation = ast_to_pri_presentation(chan->connected.id.number_presentation);
+				connected.source = ast_to_pri_connected_line_update_source(chan->connected.source);
+				pri_connected_line_update(p->pri->pri, p->call, &connected);
+			}
+#endif	/* defined(HAVE_PRI) */
 			break;
 		case AST_CONTROL_REDIRECTING:
-			ast_debug(1,"Received AST_CONTROL_REDIRECTING on %s\n",chan->name);
-			if (chan->redirecting.from.number)
-				ast_copy_string(redirecting.from.number, chan->redirecting.from.number, sizeof(redirecting.from.number));
-			else
-				redirecting.from.number[0] = '\0';
-			if (chan->redirecting.from.name)
-				ast_copy_string(redirecting.from.name, chan->redirecting.from.name, sizeof(redirecting.from.name));
-			else
-				redirecting.from.name[0] = '\0';
-			redirecting.from.number_type = chan->redirecting.from.number_type;
-			redirecting.from.number_presentation = ast_to_pri_presentation(chan->redirecting.from.number_presentation);
-			if (chan->redirecting.to.number)
-				ast_copy_string(redirecting.to.number, chan->redirecting.to.number, sizeof(redirecting.to.number));
-			else
-				redirecting.to.number[0] = '\0';
-			if (chan->redirecting.to.name)
-				ast_copy_string(redirecting.to.name, chan->redirecting.to.name, sizeof(redirecting.to.name));
-			else
-				redirecting.to.name[0] = '\0';
-			redirecting.to.number_type = chan->redirecting.to.number_type;
-			redirecting.to.number_presentation = ast_to_pri_presentation(chan->redirecting.to.number_presentation);
-			redirecting.count = chan->redirecting.count;
-			redirecting.reason = ast_to_pri_reason(chan->redirecting.reason);
-			pri_redirecting_update(p->pri->pri, p->call, &redirecting);
+			ast_debug(1, "Received AST_CONTROL_REDIRECTING on %s\n", chan->name);
+#if defined(HAVE_PRI)
+			if (p->pri) {
+				struct pri_party_redirecting redirecting;
+
+				if (chan->cid.cid_rdnis) {
+					ast_copy_string(redirecting.from.number, chan->cid.cid_rdnis, sizeof(redirecting.from.number));
+				} else {
+					redirecting.from.number[0] = '\0';
+				}
+				if (chan->redirecting.from.name) {
+					ast_copy_string(redirecting.from.name, chan->redirecting.from.name, sizeof(redirecting.from.name));
+				} else {
+					redirecting.from.name[0] = '\0';
+				}
+				redirecting.from.number_type = chan->redirecting.from.number_type;
+				redirecting.from.number_presentation = ast_to_pri_presentation(chan->redirecting.from.number_presentation);
+				if (chan->redirecting.to.number) {
+					ast_copy_string(redirecting.to.number, chan->redirecting.to.number, sizeof(redirecting.to.number));
+				} else {
+					redirecting.to.number[0] = '\0';
+				}
+				if (chan->redirecting.to.name) {
+					ast_copy_string(redirecting.to.name, chan->redirecting.to.name, sizeof(redirecting.to.name));
+				} else {
+					redirecting.to.name[0] = '\0';
+				}
+				redirecting.to.number_type = chan->redirecting.to.number_type;
+				redirecting.to.number_presentation = ast_to_pri_presentation(chan->redirecting.to.number_presentation);
+				redirecting.count = chan->redirecting.count;
+				redirecting.reason = ast_to_pri_reason(chan->redirecting.reason);
+				pri_redirecting_update(p->pri->pri, p->call, &redirecting);
+			}
+#endif	/* defined(HAVE_PRI) */
 			break;
 		}
 	} else
@@ -11706,17 +11716,17 @@
 					if (chanpos > -1) {
 						ast_mutex_lock(&pri->pvts[chanpos]->lock);
 						/* queue DTMF frame if the PBX for this call was already started (we're forwarding KEYPAD_DIGITs further on */
-						if ((pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING) && pri->pvts[chanpos]->call==e->digit.call && pri->pvts[chanpos]->owner) {
+						if ((pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING)
+							&& pri->pvts[chanpos]->call == e->digit.call
+							&& pri->pvts[chanpos]->owner) {
 							/* how to do that */
 							int digitlen = strlen(e->digit.digits);
-							char digit;
 							int i;
+
 							for (i = 0; i < digitlen; i++) {
-								digit = e->digit.digits[i];
-								{
-									struct ast_frame f = { AST_FRAME_DTMF, digit, };
-									dahdi_queue_frame(pri->pvts[chanpos], &f, pri);
-								}
+								struct ast_frame f = { AST_FRAME_DTMF, e->digit.digits[i], };
+
+								dahdi_queue_frame(pri->pvts[chanpos], &f, pri);
 							}
 						}
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
@@ -11734,38 +11744,40 @@
 					if (chanpos > -1) {
 						ast_mutex_lock(&pri->pvts[chanpos]->lock);
 						/* queue DTMF frame if the PBX for this call was already started (we're forwarding INFORMATION further on */
-						if ((pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING) && pri->pvts[chanpos]->call==e->ring.call && pri->pvts[chanpos]->owner) {
+						if ((pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING)
+							&& pri->pvts[chanpos]->call == e->ring.call
+							&& pri->pvts[chanpos]->owner) {
 							/* how to do that */
 							int digitlen = strlen(e->ring.callednum);
-							char digit;
 							int i;
+
 							for (i = 0; i < digitlen; i++) {
-								digit = e->ring.callednum[i];
-								{
-									struct ast_frame f = { AST_FRAME_DTMF, digit, };
-									dahdi_queue_frame(pri->pvts[chanpos], &f, pri);
-								}
+								struct ast_frame f = { AST_FRAME_DTMF, e->ring.callednum[i], };
+
+								dahdi_queue_frame(pri->pvts[chanpos], &f, pri);
 							}
 							if (pri->pvts[chanpos]->owner) {
 								char dnid[AST_MAX_EXTENSION];
-								char rdnis[AST_MAX_EXTENSION];
-								if (pri->pvts[chanpos]->owner->exten) {
-									int pos = strlen(pri->pvts[chanpos]->owner->exten);
-									if (pos < sizeof(pri->pvts[chanpos]->owner->exten) - 2)
-										ast_copy_string(&pri->pvts[chanpos]->owner->exten[pos], e->ring.callednum, sizeof(pri->pvts[chanpos]->owner->exten) - strlen(e->ring.callednum));
+
+								/*
+								 * Append the received info digits to the end of
+								 * the exten and dnid strings
+								 */
+								strncat(pri->pvts[chanpos]->owner->exten,
+									e->ring.callednum,
+									sizeof(pri->pvts[chanpos]->owner->exten) - 1
+									- strlen(pri->pvts[chanpos]->owner->exten));
+								if (pri->pvts[chanpos]->owner->cid.cid_dnid) {
+									ast_copy_string(dnid,
+										pri->pvts[chanpos]->owner->cid.cid_dnid,
+										sizeof(dnid));
+									ast_free(pri->pvts[chanpos]->owner->cid.cid_dnid);
+								} else {
+									dnid[0] = 0;
 								}
-								if (pri->pvts[chanpos]->owner->cid.cid_dnid) {
-									ast_copy_string(dnid, pri->pvts[chanpos]->owner->cid.cid_dnid, sizeof(dnid));
-									strncat (dnid, e->ring.callednum, sizeof(dnid) - strlen(dnid) - 1);
-									ast_free(pri->pvts[chanpos]->owner->cid.cid_dnid);
-									pri->pvts[chanpos]->owner->cid.cid_dnid = ast_strdup(dnid);
-								}
-								if (pri->pvts[chanpos]->owner->cid.cid_rdnis) {
-									ast_copy_string(rdnis, pri->pvts[chanpos]->owner->cid.cid_rdnis, sizeof(rdnis));
-									strncat (rdnis, e->ring.callednum, sizeof(rdnis) - strlen(rdnis) - 1);
-									ast_free(pri->pvts[chanpos]->owner->cid.cid_rdnis);
-									pri->pvts[chanpos]->owner->cid.cid_rdnis = ast_strdup(rdnis);
-								}
+								strncat(dnid, e->ring.callednum,
+									sizeof(dnid) - 1 - strlen(dnid));
+								pri->pvts[chanpos]->owner->cid.cid_dnid = ast_strdup(dnid);
 							}
 						}
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
@@ -11921,7 +11933,9 @@
 						pri->pvts[chanpos]->callingpres = e->ring.callingpres;
 
 						/* Start PBX */
-						if (!e->ring.complete && (pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING) && ast_matchmore_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) {
+						if (!e->ring.complete
+							&& (pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING)
+							&& ast_matchmore_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) {
 							/* Release the PRI lock while we create the channel */
 							ast_mutex_unlock(&pri->lock);
 							if (crv) {
@@ -11936,8 +11950,8 @@
 
 							ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 
-							if (c  && (redirecting.from.number || redirecting.from.name)) {
-								ast_party_redirecting_copy(&c->redirecting, &redirecting);
+							if (c && (redirecting.from.number || redirecting.from.name)) {
+								ast_set_redirecting(c, &redirecting);
 							}
 							if (!ast_strlen_zero(e->ring.callingsubaddr)) {
 								pbx_builtin_setvar_helper(c, "CALLINGSUBADDR", e->ring.callingsubaddr);
@@ -11956,8 +11970,10 @@
 
 							snprintf(calledtonstr, sizeof(calledtonstr), "%d", e->ring.calledplan);
 							pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
-							if (e->ring.redirectingreason >= 0)
+							if (e->ring.redirectingreason >= 0) {
+								/* This is now just a status variable.  Use REDIRECTING() dialplan function. */
 								pbx_builtin_setvar_helper(c, "PRIREDIRECTREASON", redirectingreason2str(e->ring.redirectingreason));
+							}
 
 							ast_mutex_lock(&pri->pvts[chanpos]->lock);
 							ast_mutex_lock(&pri->lock);
@@ -11985,7 +12001,7 @@
 								ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 
 								if (redirecting.from.number || redirecting.from.name) {
-									ast_party_redirecting_copy(&c->redirecting, &redirecting);
+									ast_set_redirecting(c, &redirecting);
 								}
 								if (e->ring.ani2 >= 0) {
 									snprintf(ani2str, 5, "%d", e->ring.ani2);
@@ -11999,8 +12015,10 @@
 								}
 #endif
 
-								if (e->ring.redirectingreason >= 0)
+								if (e->ring.redirectingreason >= 0) {
+									/* This is now just a status variable.  Use REDIRECTING() dialplan function. */
 									pbx_builtin_setvar_helper(c, "PRIREDIRECTREASON", redirectingreason2str(e->ring.redirectingreason));
+								}
 
 								snprintf(calledtonstr, sizeof(calledtonstr), "%d", e->ring.calledplan);
 								pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
@@ -12196,7 +12214,7 @@
 						ast_mutex_lock(&pri->pvts[chanpos]->lock);
 						ast_copy_string(pri->pvts[chanpos]->lastcid_num, e->facname.callingnum, sizeof(pri->pvts[chanpos]->lastcid_num));
 						ast_copy_string(pri->pvts[chanpos]->lastcid_name, e->facname.callingname, sizeof(pri->pvts[chanpos]->lastcid_name));
-						pri->pvts[chanpos]->subs[SUB_REAL].needcallerid =1;
+						pri->pvts[chanpos]->subs[SUB_REAL].needcallerid = 1;
 						dahdi_enable_ec(pri->pvts[chanpos]);
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 					}
@@ -12205,70 +12223,69 @@
 			case PRI_EVENT_FACILITY:
 				chanpos = pri_find_principle(pri, e->facility.channel);
 				if (chanpos < 0) {
-					ast_log(LOG_WARNING, "Facility requested on unconfigured channel %d/%d span %d\n", 
+					ast_log(LOG_WARNING, "Facility requested on unconfigured channel %d/%d span %d\n",
 						PRI_SPAN(e->facility.channel), PRI_CHANNEL(e->facility.channel), pri->span);
 				} else {
 					chanpos = pri_fixup_principle(pri, chanpos, e->facility.call);
 					if (chanpos < 0) {
-						ast_log(LOG_WARNING, "Facility requested on channel %d/%d not in use on span %d\n", 
+						ast_log(LOG_WARNING, "Facility requested on channel %d/%d not in use on span %d\n",
 							PRI_SPAN(e->facility.channel), PRI_CHANNEL(e->facility.channel), pri->span);
 					} else {
 						int i;
 
 						ast_mutex_lock(&pri->pvts[chanpos]->lock);
 						for (i = 0; i < e->facility.subcmds.counter_subcmd; i++) {
-							subcommand *subcmd = &e->facility.subcmds.subcmd[i];
+							struct subcommand *subcmd = &e->facility.subcmds.subcmd[i];
+							struct ast_channel *owner;
 
 							switch (subcmd->cmd) {
 							case CMD_CONNECTEDLINE:
-								{
-									struct ast_channel *owner = pri->pvts[chanpos]->owner;
-									if (owner) {
-										struct ast_party_connected_line connected;
-										cmd_connectedline *cmdcl;
-
-										/* Update the connected line information on the other channel */
-										ast_party_connected_line_init(&connected);
-										cmdcl = &subcmd->connectedline;
-										connected.id.number = cmdcl->connected.id.number;
-										connected.id.name = cmdcl->connected.id.name;
-										connected.id.number_type = cmdcl->connected.id.number_type;
-										connected.id.number_presentation = pri_to_ast_presentation(cmdcl->connected.id.number_presentation);
-										connected.source = pri_to_ast_connected_line_update_source(cmdcl->connected.source);
-										ast_queue_connected_line_update(owner, &connected);
-
-										ast_copy_string(pri->pvts[chanpos]->lastcid_num, cmdcl->connected.id.number, sizeof(pri->pvts[chanpos]->lastcid_num));
-										ast_copy_string(pri->pvts[chanpos]->lastcid_name, cmdcl->connected.id.name, sizeof(pri->pvts[chanpos]->lastcid_name));
-
-										pri->pvts[chanpos]->subs[SUB_REAL].needcallerid =1;
-									}
+								owner = pri->pvts[chanpos]->owner;
+								if (owner) {
+									struct ast_party_connected_line connected;
+									struct cmd_connectedline *cmdcl;
+
+									/* Update the connected line information on the other channel */
+									ast_party_connected_line_init(&connected);
+									cmdcl = &subcmd->connectedline;
+									connected.id.number = cmdcl->connected.id.number;
+									connected.id.name = cmdcl->connected.id.name;
+									connected.id.number_type = cmdcl->connected.id.number_type;
+									connected.id.number_presentation = pri_to_ast_presentation(cmdcl->connected.id.number_presentation);
+									connected.source = pri_to_ast_connected_line_update_source(cmdcl->connected.source);
+									ast_queue_connected_line_update(owner, &connected);
+
+									ast_copy_string(pri->pvts[chanpos]->lastcid_num, cmdcl->connected.id.number, sizeof(pri->pvts[chanpos]->lastcid_num));
+									ast_copy_string(pri->pvts[chanpos]->lastcid_name, cmdcl->connected.id.name, sizeof(pri->pvts[chanpos]->lastcid_name));
+
+									pri->pvts[chanpos]->subs[SUB_REAL].needcallerid = 1;
+									//dahdi_enable_ec(pri->pvts[chanpos]);
 								}
 								break;
 							case CMD_REDIRECTING:
-								{
-									struct ast_channel *owner = pri->pvts[chanpos]->owner;
-									if (owner) {
-										struct ast_party_redirecting redirecting = {{0,},};
-										cmd_redirecting *cmdr;
-
-										cmdr = &subcmd->redirecting;
-										redirecting.from.number = cmdr->redirecting.from.number;
-										redirecting.from.name = cmdr->redirecting.from.name;
-										redirecting.from.number_type = cmdr->redirecting.from.number_type;
-										redirecting.from.number_presentation = pri_to_ast_presentation(cmdr->redirecting.from.number_presentation);
-										redirecting.to.number = cmdr->redirecting.to.number;
-										redirecting.to.name = cmdr->redirecting.to.name;
-										redirecting.to.number_type = cmdr->redirecting.to.number_type;
-										redirecting.to.number_presentation = pri_to_ast_presentation(cmdr->redirecting.to.number_presentation);
-										redirecting.count = 0;
-										redirecting.reason = pri_to_ast_reason(cmdr->redirecting.reason);
-										ast_queue_redirecting_update(owner, &redirecting);
-									}
+								owner = pri->pvts[chanpos]->owner;
+								if (owner) {
+									struct ast_party_redirecting redirecting = {{0,},};
+									struct cmd_redirecting *cmdr;
+
+									cmdr = &subcmd->redirecting;
+									redirecting.from.number = cmdr->redirecting.from.number;
+									redirecting.from.name = cmdr->redirecting.from.name;
+									redirecting.from.number_type = cmdr->redirecting.from.number_type;
+									redirecting.from.number_presentation = pri_to_ast_presentation(cmdr->redirecting.from.number_presentation);
+									redirecting.to.number = cmdr->redirecting.to.number;
+									redirecting.to.name = cmdr->redirecting.to.name;
+									redirecting.to.number_type = cmdr->redirecting.to.number_type;
+									redirecting.to.number_presentation = pri_to_ast_presentation(cmdr->redirecting.to.number_presentation);
+									redirecting.count = 0;
+									redirecting.reason = pri_to_ast_reason(cmdr->redirecting.reason);
+									ast_queue_redirecting_update(owner, &redirecting);
 								}
 								break;
 							default:
-								ast_log(LOG_WARNING, "Illegal subcommand %d in facility request on channel %d/%d not in use on span %d\n", \
-															subcmd->cmd, PRI_SPAN(e->facility.channel), PRI_CHANNEL(e->facility.channel), pri->span);
+								ast_log(LOG_WARNING,
+									"Illegal subcommand %d in facility request on channel %d/%d not in use on span %d\n",
+									subcmd->cmd, PRI_SPAN(e->facility.channel), PRI_CHANNEL(e->facility.channel), pri->span);
 								break;
 							}
 						}
@@ -12386,6 +12403,7 @@
 										break;
 									default:
 										pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+										break;
 									}
 								}
 							}




More information about the asterisk-commits mailing list