[asterisk-commits] rmudgett: branch group/issue14292 r213083 - in /team/group/issue14292: ./ cha...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 19 12:43:30 CDT 2009


Author: rmudgett
Date: Wed Aug 19 12:43:27 2009
New Revision: 213083

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=213083
Log:
Rebase branch automerge to team/rmudgett/bkp_issue14068 and bring up to date.

Modified:
    team/group/issue14292/   (props changed)
    team/group/issue14292/CHANGES
    team/group/issue14292/channels/chan_dahdi.c

Propchange: team/group/issue14292/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/group/issue14292/
------------------------------------------------------------------------------
--- issue14292-integrated (original)
+++ issue14292-integrated Wed Aug 19 12:43:27 2009
@@ -1,1 +1,1 @@
-/team/group/issue14068:1-209551
+/team/rmudgett/bkp_issue14068:1-213004

Modified: team/group/issue14292/CHANGES
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/issue14292/CHANGES?view=diff&rev=213083&r1=213082&r2=213083
==============================================================================
--- team/group/issue14292/CHANGES (original)
+++ team/group/issue14292/CHANGES Wed Aug 19 12:43:27 2009
@@ -143,8 +143,9 @@
 
 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.
+  * The channel variable PRIREDIRECTREASON is now just a status variable
+    and it is also deprecated.  Use the REDIRECTING(reason) dialplan function
+    to read and alter the reason.
   * For Q.SIG and ETSI PRI/BRI-PTP, you should manually send the COLR of the
     redirected-to party for an incomming redirected call if the incoming call
     could experience further redirects.  Just set the

Modified: team/group/issue14292/channels/chan_dahdi.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/issue14292/channels/chan_dahdi.c?view=diff&rev=213083&r1=213082&r2=213083
==============================================================================
--- team/group/issue14292/channels/chan_dahdi.c (original)
+++ team/group/issue14292/channels/chan_dahdi.c Wed Aug 19 12:43:27 2009
@@ -4714,6 +4714,15 @@
 #endif	/* defined(HAVE_SS7) */
 
 #if defined(HAVE_PRI)
+/*!
+ * \internal
+ * \brief Convert PRI redirecting reason to asterisk version.
+ * \since 1.6.3
+ *
+ * \param pri_reason PRI redirecting reason.
+ *
+ * \return Equivalent asterisk redirecting reason value.
+ */
 static enum AST_REDIRECTING_REASON pri_to_ast_reason(int pri_reason)
 {
 	enum AST_REDIRECTING_REASON ast_reason;
@@ -4742,6 +4751,15 @@
 #endif	/* defined(HAVE_PRI) */
 
 #if defined(HAVE_PRI)
+/*!
+ * \internal
+ * \brief Convert asterisk redirecting reason to PRI version.
+ * \since 1.6.3
+ *
+ * \param ast_reason Asterisk redirecting reason.
+ *
+ * \return Equivalent PRI redirecting reason value.
+ */
 static int ast_to_pri_reason(enum AST_REDIRECTING_REASON ast_reason)
 {
 	int pri_reason;
@@ -4770,6 +4788,15 @@
 #endif	/* defined(HAVE_PRI) */
 
 #if defined(HAVE_PRI)
+/*!
+ * \internal
+ * \brief Convert PRI number presentation to asterisk version.
+ * \since 1.6.3
+ *
+ * \param pri_presentation PRI number presentation.
+ *
+ * \return Equivalent asterisk number presentation value.
+ */
 static int pri_to_ast_presentation(int pri_presentation)
 {
 	int ast_presentation;
@@ -4812,6 +4839,15 @@
 #endif	/* defined(HAVE_PRI) */
 
 #if defined(HAVE_PRI)
+/*!
+ * \internal
+ * \brief Convert asterisk number presentation to PRI version.
+ * \since 1.6.3
+ *
+ * \param ast_presentation Asterisk number presentation.
+ *
+ * \return Equivalent PRI number presentation value.
+ */
 static int ast_to_pri_presentation(int ast_presentation)
 {
 	int pri_presentation;
@@ -10124,38 +10160,6 @@
 	return res;
 }
 
-/*!
- * \internal
- * \brief Start a PBX on the given channel in a new thread.
- * \since 1.6.3
- *
- * \param pvt DAHDI private structure.
- * \param chan Asterisk channel to start the PBX.
- *
- * \retval AST_PBX_SUCCESS on success.
- * \retval Other on error.
- */
-static enum ast_pbx_result dahdi_pbx_start(struct dahdi_pvt *pvt, struct ast_channel *chan)
-{
-	enum ast_pbx_result result;
-
-#if defined(HAVE_OPENR2)
-	if (pvt->mfcr2call) {
-		pbx_builtin_setvar_helper(chan, "MFCR2_CATEGORY",
-			openr2_proto_get_category_string(pvt->mfcr2_recvd_category));
-	}
-#endif	/* defined(HAVE_OPENR2) */
-
-	result = ast_pbx_start(chan);
-	if (result != AST_PBX_SUCCESS) {
-		ast_log(LOG_WARNING, "Unable to start PBX on %s\n", chan->name);
-		ast_hangup(chan);
-		pvt->owner = NULL;
-	}
-
-	return result;
-}
-
 static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, int transfercapability)
 {
 	struct ast_channel *tmp;
@@ -10336,8 +10340,18 @@
 	for (v = i->vars ; v ; v = v->next)
 		pbx_builtin_setvar_helper(tmp, v->name, v->value);
 
-	if (startpbx && dahdi_pbx_start(i, tmp) != AST_PBX_SUCCESS) {
-		return NULL;
+	if (startpbx) {
+#ifdef HAVE_OPENR2
+		if (i->mfcr2call) {
+			pbx_builtin_setvar_helper(tmp, "MFCR2_CATEGORY", openr2_proto_get_category_string(i->mfcr2_recvd_category));
+		}
+#endif
+		if (ast_pbx_start(tmp)) {
+			ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
+			ast_hangup(tmp);
+			i->owner = NULL;
+			return NULL;
+		}
 	}
 
 	ast_module_ref(ast_module_info->self);
@@ -10485,6 +10499,11 @@
 			ast_verb(3, "Going to extension s|1 because of empty extension received on overlap call\n");
 			exten[0] = 's';
 			exten[1] = '\0';
+		} else {
+			if (chan->cid.cid_dnid) {
+				ast_free(chan->cid.cid_dnid);
+			}
+			chan->cid.cid_dnid = ast_strdup(exten);
 		}
 		tone_zone_play_tone(p->subs[idx].dfd, -1);
 		if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num)) {
@@ -15585,8 +15604,8 @@
 	struct dahdi_pvt *crv;
 	pthread_t threadid;
 	char ani2str[6];
-	char plancallingnum[256];
-	char plancallingani[256];
+	char plancallingnum[AST_MAX_EXTENSION];
+	char plancallingani[AST_MAX_EXTENSION];
 	char calledtonstr[10];
 
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
@@ -15873,7 +15892,7 @@
 						if (!skipit) {
 #endif
 							ast_verb(3, "B-channel %d/%d restarted on span %d\n",
-									PRI_SPAN(e->restart.channel), PRI_CHANNEL(e->restart.channel), pri->span);
+								PRI_SPAN(e->restart.channel), PRI_CHANNEL(e->restart.channel), pri->span);
 							ast_mutex_lock(&pri->pvts[chanpos]->lock);
 							if (pri->pvts[chanpos]->call) {
 								pri_destroycall(pri->pri, pri->pvts[chanpos]->call);
@@ -15952,7 +15971,6 @@
 							&& pri->pvts[chanpos]->call == e->ring.call
 							&& pri->pvts[chanpos]->owner) {
 							/* how to do that */
-							struct ast_channel *owner;
 							int digitlen = strlen(e->ring.callednum);
 							int i;
 
@@ -15960,29 +15978,6 @@
 								struct ast_frame f = { AST_FRAME_DTMF, e->ring.callednum[i], };
 
 								dahdi_queue_frame(pri->pvts[chanpos], &f, pri);
-							}
-							dahdi_pri_lock_owner(pri, chanpos);
-							owner = pri->pvts[chanpos]->owner;
-							if (owner) {
-								char dnid[AST_MAX_EXTENSION];
-
-								/*
-								 * Append the received info digits to the end of
-								 * the exten and dnid strings
-								 */
-								strncat(owner->exten, e->ring.callednum,
-									(sizeof(owner->exten) - 1) - strlen(owner->exten));
-								if (owner->cid.cid_dnid) {
-									ast_copy_string(dnid, owner->cid.cid_dnid,
-										sizeof(dnid));
-									ast_free(owner->cid.cid_dnid);
-								} else {
-									dnid[0] = 0;
-								}
-								strncat(dnid, e->ring.callednum,
-									(sizeof(dnid) - 1) - strlen(dnid));
-								owner->cid.cid_dnid = ast_strdup(dnid);
-								ast_channel_unlock(owner);
 							}
 						}
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
@@ -16099,7 +16094,13 @@
 						}
 					}
 					pri->pvts[chanpos]->call = e->ring.call;
+
+					apply_plan_to_number(pri->pvts[chanpos]->rdnis, sizeof(pri->pvts[chanpos]->rdnis), pri,
+						e->ring.redirectingnum, e->ring.callingplanrdnis);
+
+					/* Setup caller-id info */
 					apply_plan_to_number(plancallingnum, sizeof(plancallingnum), pri, e->ring.callingnum, e->ring.callingplan);
+					pri->pvts[chanpos]->cid_ani2 = 0;
 					if (pri->pvts[chanpos]->use_callerid) {
 						ast_shrink_phone_number(plancallingnum);
 						ast_copy_string(pri->pvts[chanpos]->cid_num, plancallingnum, sizeof(pri->pvts[chanpos]->cid_num));
@@ -16114,14 +16115,21 @@
 #endif
 						ast_copy_string(pri->pvts[chanpos]->cid_name, e->ring.callingname, sizeof(pri->pvts[chanpos]->cid_name));
 						pri->pvts[chanpos]->cid_ton = e->ring.callingplan; /* this is the callingplan (TON/NPI), e->ring.callingplan>>4 would be the TON */
+						pri->pvts[chanpos]->callingpres = e->ring.callingpres;
+						if (e->ring.ani2 >= 0) {
+							pri->pvts[chanpos]->cid_ani2 = e->ring.ani2;
+						}
 					} else {
 						pri->pvts[chanpos]->cid_num[0] = '\0';
 						pri->pvts[chanpos]->cid_ani[0] = '\0';
 						pri->pvts[chanpos]->cid_name[0] = '\0';
 						pri->pvts[chanpos]->cid_ton = 0;
+						pri->pvts[chanpos]->callingpres = 0;
 					}
-					apply_plan_to_number(pri->pvts[chanpos]->rdnis, sizeof(pri->pvts[chanpos]->rdnis), pri,
-						e->ring.redirectingnum, e->ring.callingplanrdnis);
+
+					/* Set DNID on all incoming calls -- even immediate */
+					ast_copy_string(pri->pvts[chanpos]->dnid, e->ring.callednum, sizeof(pri->pvts[chanpos]->dnid));
+
 					/* If immediate=yes go to s|1 */
 					if (pri->pvts[chanpos]->immediate) {
 						ast_verb(3, "Going to extension s|1 because of immediate=yes\n");
@@ -16138,14 +16146,13 @@
 						pri->pvts[chanpos]->exten[0] = 's';
 						pri->pvts[chanpos]->exten[1] = '\0';
 					}
-					/* Set DNID on all incoming calls -- even immediate */
-					ast_copy_string(pri->pvts[chanpos]->dnid, e->ring.callednum, sizeof(pri->pvts[chanpos]->dnid));
 					/* No number yet, but received "sending complete"? */
 					if (e->ring.complete && (ast_strlen_zero(e->ring.callednum))) {
 						ast_verb(3, "Going to extension s|1 because of Complete received\n");
 						pri->pvts[chanpos]->exten[0] = 's';
 						pri->pvts[chanpos]->exten[1] = '\0';
 					}
+
 					/* Make sure extension exists (or in overlap dial mode, can exist) */
 					if (((pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING) && ast_canmatch_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) ||
 						ast_exists_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) {
@@ -16177,8 +16184,6 @@
 							else
 								pri_answer(pri->pri, e->ring.call, PVT_TO_CHANNEL(pri->pvts[chanpos]), 1);
 						}
-						/* Get the use_callingpres state */
-						pri->pvts[chanpos]->callingpres = e->ring.callingpres;
 
 						/* Start PBX */
 						if (!e->ring.complete
@@ -16206,15 +16211,14 @@
 								if (e->ring.ani2 >= 0) {
 									snprintf(ani2str, sizeof(ani2str), "%d", e->ring.ani2);
 									pbx_builtin_setvar_helper(c, "ANI2", ani2str);
-									pri->pvts[chanpos]->cid_ani2 = e->ring.ani2;
 								}
-	
+
 #ifdef SUPPORT_USERUSER
 								if (!ast_strlen_zero(e->ring.useruserinfo)) {
 									pbx_builtin_setvar_helper(c, "USERUSERINFO", e->ring.useruserinfo);
 								}
 #endif
-	
+
 								snprintf(calledtonstr, sizeof(calledtonstr), "%d", e->ring.calledplan);
 								pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
 								if (e->ring.redirectingreason >= 0) {
@@ -16227,8 +16231,8 @@
 							}
 							if (c && !ast_pthread_create_detached(&threadid, NULL, analog_ss_thread, c)) {
 								ast_verb(3, "Accepting overlap call from '%s' to '%s' on channel %d/%d, span %d\n",
-										plancallingnum, S_OR(pri->pvts[chanpos]->exten, "<unspecified>"),
-										pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
+									plancallingnum, S_OR(pri->pvts[chanpos]->exten, "<unspecified>"),
+									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
 							} else {
 								ast_log(LOG_WARNING, "Unable to start PBX on channel %d/%d, span %d\n",
 									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
@@ -16254,9 +16258,7 @@
 								 * structures are locked.  The PBX has not been
 								 * started yet and it is unlikely that any other task
 								 * will do anything with the channel we have just
-								 * created.  To fix the locking so there is no
-								 * possibility of a deadlock would require some
-								 * redesign of this channel driver.
+								 * created.
 								 */
 								if (!ast_strlen_zero(e->ring.callingsubaddr)) {
 									pbx_builtin_setvar_helper(c, "CALLINGSUBADDR", e->ring.callingsubaddr);
@@ -16264,7 +16266,6 @@
 								if (e->ring.ani2 >= 0) {
 									snprintf(ani2str, sizeof(ani2str), "%d", e->ring.ani2);
 									pbx_builtin_setvar_helper(c, "ANI2", ani2str);
-									pri->pvts[chanpos]->cid_ani2 = e->ring.ani2;
 								}
 
 #ifdef SUPPORT_USERUSER
@@ -16284,23 +16285,27 @@
 								dahdi_pri_handle_subcmds(pri, chanpos, e->e, e->ring.channel,
 									e->ring.subcmds);
 							}
-							if (c && !dahdi_pbx_start(pri->pvts[chanpos], c)) {
+							if (c && !ast_pbx_start(c)) {
 								ast_verb(3, "Accepting call from '%s' to '%s' on channel %d/%d, span %d\n",
-										plancallingnum, pri->pvts[chanpos]->exten,
-										pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
+									plancallingnum, pri->pvts[chanpos]->exten,
+									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
 
 								dahdi_enable_ec(pri->pvts[chanpos]);
 							} else {
 								ast_log(LOG_WARNING, "Unable to start PBX on channel %d/%d, span %d\n",
 									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
-								pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION);
-								pri->pvts[chanpos]->call = NULL;
+								if (c) {
+									ast_hangup(c);
+								} else {
+									pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION);
+									pri->pvts[chanpos]->call = NULL;
+								}
 							}
 						}
 					} else {
 						ast_verb(3, "Extension '%s' in context '%s' from '%s' does not exist.  Rejecting call on channel %d/%d, span %d\n",
-								pri->pvts[chanpos]->exten, pri->pvts[chanpos]->context, pri->pvts[chanpos]->cid_num, pri->pvts[chanpos]->logicalspan,
-									pri->pvts[chanpos]->prioffset, pri->span);
+							pri->pvts[chanpos]->exten, pri->pvts[chanpos]->context, pri->pvts[chanpos]->cid_num, pri->pvts[chanpos]->logicalspan,
+							pri->pvts[chanpos]->prioffset, pri->span);
 						pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_UNALLOCATED);
 						pri->pvts[chanpos]->call = NULL;
 						pri->pvts[chanpos]->exten[0] = '\0';
@@ -16857,7 +16862,7 @@
 							}
 							pri->pvts[chanpos]->resetting = 0;
 							ast_verb(3, "B-channel %d/%d successfully restarted on span %d\n", pri->pvts[chanpos]->logicalspan,
-									pri->pvts[chanpos]->prioffset, pri->span);
+								pri->pvts[chanpos]->prioffset, pri->span);
 							ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 							if (pri->resetting)
 								pri_check_restart(pri);
@@ -16881,7 +16886,7 @@
 						pri->pvts[chanpos]->resetting = 0;
 						pri->pvts[chanpos]->inservice = 1;
 						ast_verb(3, "B-channel %d/%d successfully restarted on span %d\n", pri->pvts[chanpos]->logicalspan,
-									pri->pvts[chanpos]->prioffset, pri->span);
+							pri->pvts[chanpos]->prioffset, pri->span);
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 						if (pri->resetting)
 							pri_check_restart(pri);




More information about the asterisk-commits mailing list