[Asterisk-cvs] asterisk/channels chan_zap.c,1.466,1.467

mattf at lists.digium.com mattf at lists.digium.com
Wed Jun 29 17:47:53 CDT 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv13126/channels

Modified Files:
	chan_zap.c 
Log Message:
Fix for bug 4347.  Also breaking redirectingreason interpretation routine into function


Index: chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.466
retrieving revision 1.467
diff -u -d -r1.466 -r1.467
--- chan_zap.c	24 Jun 2005 19:15:51 -0000	1.466
+++ chan_zap.c	29 Jun 2005 21:47:44 -0000	1.467
@@ -31,7 +31,7 @@
 #include <ctype.h>
 #ifdef ZAPATA_PRI
 #include <libpri.h>
-#ifndef PRI_FACILITY_ENABLE
+#ifndef PRI_PROGRESS_CAUSE
 #error "You need newer libpri"
 #endif
 #endif
@@ -7631,6 +7631,21 @@
 	ast_mutex_lock(&pri->lock);
 	return 0;
 }
+char * redirectingreason2str(int redirectingreason)
+{
+	switch (redirectingreason) {
+	case 0:
+		return "UNKNOWN";
+	case 1:
+		return "BUSY";
+	case 2:
+		return "NO_REPLY";
+	case 0xF:
+		return "UNCONDITIONAL";
+	default:
+		return "NOREDIRECT";
+	}
+}
 
 static void *pri_dchannel(void *vpri)
 {
@@ -8174,27 +8189,8 @@
 							}
 							snprintf(calledtonstr, sizeof(calledtonstr)-1, "%d", e->ring.calledplan);
 							pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
-							if (e->ring.redirectingreason >= 0) {
-								char redirstr[20] = "";
-								switch (e->ring.redirectingreason) {
-								case 0:
-									snprintf(redirstr, sizeof(redirstr), "UNKNOWN");
-									break;
-								case 1:
-									snprintf(redirstr, sizeof(redirstr), "BUSY");
-									break;
-								case 2:
-									snprintf(redirstr, sizeof(redirstr), "NO_REPLY");
-									break;
-								case 0xF:
-									snprintf(redirstr, sizeof(redirstr), "UNCONDITIONAL"); /* Other reason */
-									break;
-								default:
-									snprintf(redirstr, sizeof(redirstr), "NOREDIRECT");
-									break;
-								}
-								pbx_builtin_setvar_helper(c, "PRIREDIRECTCAUSE", redirstr);
-							}
+							if (e->ring.redirectingreason >= 0)
+								pbx_builtin_setvar_helper(c, "PRIREDIRECTCAUSE", redirectingreason2str(e->ring.redirectingreason));
 							
 							ast_mutex_lock(&pri->lock);
 							if (c && !ast_pthread_create(&threadid, &attr, ss_thread, c)) {
@@ -8226,6 +8222,9 @@
 								if (!ast_strlen_zero(e->ring.useruserinfo)) {
 									pbx_builtin_setvar_helper(c, "USERUSERINFO", e->ring.useruserinfo);
 								}
+								if (e->ring.redirectingreason >= 0)
+									pbx_builtin_setvar_helper(c, "PRIREDIRECTCAUSE", redirectingreason2str(e->ring.redirectingreason));
+							
 								snprintf(calledtonstr, sizeof(calledtonstr)-1, "%d", e->ring.calledplan);
 								pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
 								if (option_verbose > 2)
@@ -8301,6 +8300,22 @@
 					if ((pri->overlapdial && !pri->pvts[chanpos]->proceeding) || (e->proceeding.progress == 8)) {
 #endif
 						struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, };
+
+						if (e->proceeding.cause > -1) {
+							if (option_verbose > 2)
+								ast_verbose(VERBOSE_PREFIX_3 "PROGRESS with cause code %d received\n", e->proceeding.cause);
+
+							/* Work around broken, out of spec USER_BUSY cause in a progress message */
+							if (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",




More information about the svn-commits mailing list