[asterisk-commits] moy: branch moy/mfcr2 r115263 - /team/moy/mfcr2/channels/chan_zap.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 2 20:41:44 CDT 2008


Author: moy
Date: Fri May  2 20:41:43 2008
New Revision: 115263

URL: http://svn.digium.com/view/asterisk?view=rev&rev=115263
Log:
handle hangup condition properly when the line is still no UP

Modified:
    team/moy/mfcr2/channels/chan_zap.c

Modified: team/moy/mfcr2/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/moy/mfcr2/channels/chan_zap.c?view=diff&rev=115263&r1=115262&r2=115263
==============================================================================
--- team/moy/mfcr2/channels/chan_zap.c (original)
+++ team/moy/mfcr2/channels/chan_zap.c Fri May  2 20:41:43 2008
@@ -1391,16 +1391,37 @@
 	/*ast_log(LOG_DEBUG, "Read data from zap channel %d\n", openr2_chan_get_number(r2chan));*/
 }
 
-static void zt_r2_on_call_disconnected(openr2_chan_t *r2chan, openr2_call_disconnect_reason_t reason)
+static int zt_r2_cause_to_ast_cause(openr2_call_disconnect_cause_t cause)
+{
+	switch (cause) {
+	case OR2_CAUSE_BUSY_NUMBER:
+		return AST_CAUSE_BUSY;
+	case OR2_CAUSE_NETWORK_CONGESTION:
+		return AST_CAUSE_CONGESTION;
+	case OR2_CAUSE_OUT_OF_ORDER:
+		return AST_CAUSE_DESTINATION_OUT_OF_ORDER;
+	case OR2_CAUSE_UNASSIGNED_NUMBER:
+		return AST_CAUSE_UNREGISTERED;
+	case OR2_CAUSE_NO_ANSWER:
+		return AST_CAUSE_NO_ANSWER;
+	case OR2_CAUSE_NORMAL_CLEARING:
+		return AST_CAUSE_NORMAL_CLEARING;
+	case OR2_CAUSE_UNSPECIFIED:
+	default:
+		return AST_CAUSE_NOTDEFINED;
+	}	
+}
+
+static void zt_r2_on_call_disconnected(openr2_chan_t *r2chan, openr2_call_disconnect_cause_t cause)
 {
 	struct zt_pvt *p = openr2_chan_get_client_data(r2chan);
 	ast_log(LOG_NOTICE, "MFC/R2 call disconnected on chan %d\n", openr2_chan_get_number(r2chan));
 	if (p->owner) {
 		if (p->owner->_state == AST_STATE_UP) {
 			p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
-		} else {
-			/* should we have this branch at all? */
-			switch (reason) {
+		} else if (openr2_chan_get_direction(r2chan) == OR2_DIR_FORWARD) {
+			/* being the forward side we must report what happened to the call to whoever requested it */
+			switch (cause) {
 			case OR2_CAUSE_BUSY_NUMBER:
 				p->subs[SUB_REAL].needbusy = 1;
 				break;
@@ -1415,6 +1436,9 @@
 			default:
 				p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
 			}
+		} else {
+			/* being the backward side and not UP yet, we only need to request hangup */
+			ast_queue_hangup(p->owner, zt_r2_cause_to_ast_cause(cause));
 		}	
 	}
 	openr2_chan_disconnect_call(r2chan, OR2_CAUSE_NORMAL_CLEARING);




More information about the asterisk-commits mailing list