[asterisk-commits] rmudgett: branch rmudgett/misdn_facility r166221 - /team/rmudgett/misdn_facil...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 19 20:04:02 CST 2008


Author: rmudgett
Date: Fri Dec 19 20:04:02 2008
New Revision: 166221

URL: http://svn.digium.com/view/asterisk?view=rev&rev=166221
Log:
Merged from:
https://origsvn.digium.com/svn/asterisk/be/branches/C.2...

..........
r166220 | rmudgett | 2008-12-19 19:57:51 -0600 (Fri, 19 Dec 2008) | 7 lines

*  Fixed point-to-point cc-request to wait for a response before continuing
since the request could fail.
*  Made always check if we have an outstanding call-completion message
when we receive an error or reject facility message.
*  Made cc-deactivate close the call-completion signaling link with more
direct tests.

Modified:
    team/rmudgett/misdn_facility/channels/chan_misdn.c

Modified: team/rmudgett/misdn_facility/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/channels/chan_misdn.c?view=diff&rev=166221&r1=166220&r2=166221
==============================================================================
--- team/rmudgett/misdn_facility/channels/chan_misdn.c (original)
+++ team/rmudgett/misdn_facility/channels/chan_misdn.c Fri Dec 19 20:04:02 2008
@@ -29,7 +29,8 @@
  * \ingroup channel_drivers
  */
 
-/*
+/*!
+ * \note
  * To use the CCBS/CCNR supplementary service feature and other
  * supplementary services using FACILITY messages requires a
  * modified version of mISDN v1.1.8 from:
@@ -7165,15 +7166,15 @@
 			}
 			break;
 		default:
-			ast_mutex_lock(&misdn_cc_record_lock);
-			cc_record = misdn_cc_find_by_invoke(bc->port, bc->fac_in.u.ERROR.invokeId);
-			if (cc_record) {
-				cc_record->outstanding_message = 0;
-				cc_record->error_code = bc->fac_in.u.ERROR.errorValue;
-			}
-			ast_mutex_unlock(&misdn_cc_record_lock);
 			break;
 		}	/* end switch */
+		ast_mutex_lock(&misdn_cc_record_lock);
+		cc_record = misdn_cc_find_by_invoke(bc->port, bc->fac_in.u.ERROR.invokeId);
+		if (cc_record) {
+			cc_record->outstanding_message = 0;
+			cc_record->error_code = bc->fac_in.u.ERROR.errorValue;
+		}
+		ast_mutex_unlock(&misdn_cc_record_lock);
 		break;
 	case Fac_REJECT:
 		diagnostic_msg = misdn_to_str_reject_code(bc->fac_in.u.REJECT.Code);
@@ -7188,17 +7189,17 @@
 			}
 			break;
 		default:
-			if (bc->fac_in.u.REJECT.InvokeIDPresent) {
-				ast_mutex_lock(&misdn_cc_record_lock);
-				cc_record = misdn_cc_find_by_invoke(bc->port, bc->fac_in.u.REJECT.InvokeID);
-				if (cc_record) {
-					cc_record->outstanding_message = 0;
-					cc_record->reject_code = bc->fac_in.u.REJECT.Code;
-				}
-				ast_mutex_unlock(&misdn_cc_record_lock);
+			break;
+		}	/* end switch */
+		if (bc->fac_in.u.REJECT.InvokeIDPresent) {
+			ast_mutex_lock(&misdn_cc_record_lock);
+			cc_record = misdn_cc_find_by_invoke(bc->port, bc->fac_in.u.REJECT.InvokeID);
+			if (cc_record) {
+				cc_record->outstanding_message = 0;
+				cc_record->reject_code = bc->fac_in.u.REJECT.Code;
 			}
-			break;
-		}	/* end switch */
+			ast_mutex_unlock(&misdn_cc_record_lock);
+		}
 		break;
 	case Fac_RESULT:
 		ast_mutex_lock(&misdn_cc_record_lock);
@@ -7384,12 +7385,27 @@
 			break;
 		}	/* end switch */
 		break;
-#if 0	/* We don't handle this yet */
 	case Fac_CCBS_T_Request:
 	case Fac_CCNR_T_Request:
-		/* We cannot be User-B in ptp mode. */
-		break;
-#endif	/* We don't handle this yet */
+		switch (bc->fac_in.u.CCBS_T_Request.ComponentType) {
+		case FacComponent_Result:
+			ast_mutex_lock(&misdn_cc_record_lock);
+			cc_record = misdn_cc_find_by_invoke(bc->port, bc->fac_in.u.CCBS_T_Request.InvokeID);
+			if (cc_record && cc_record->ptp) {
+				cc_record->outstanding_message = 0;
+				cc_record->activated = 1;
+			}
+			ast_mutex_unlock(&misdn_cc_record_lock);
+			break;
+
+		case FacComponent_Invoke:
+			/* We cannot be User-B in ptp mode. */
+		default:
+			chan_misdn_log(0, bc->port, " --> not yet handled: facility type:0x%04X\n",
+				bc->fac_in.Function);
+			break;
+		}	/* end switch */
+		break;
 
 #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
 	case Fac_None:
@@ -8766,33 +8782,32 @@
 
 	ast_mutex_lock(&misdn_cc_record_lock);
 	cc_record = misdn_cc_find_by_id(record_id);
-	if (cc_record) {
-		if (0 <= cc_record->port && cc_record->activated) {
-			if (cc_record->ptp) {
-				/* Send message */
-				bc = cc_record->mode.ptp.bc;/* bc != NULL here because activated is TRUE */
+	if (cc_record && 0 <= cc_record->port) {
+		if (cc_record->ptp) {
+			if (cc_record->mode.ptp.bc) {
+				/* Close the call-completion signaling link */
+				bc = cc_record->mode.ptp.bc;
 				bc->fac_out.Function = Fac_None;
 				bc->out_cause = AST_CAUSE_NORMAL_CLEARING;
 				misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE);
-
-				misdn_cc_delete(cc_record);
-			} else {
-				cc_record->error_code = FacError_None;
-				cc_record->reject_code = FacReject_None;
-				cc_record->invoke_id = ++misdn_invoke_id;
-				cc_record->outstanding_message = 1;
-	
-				/* Build message */
-				misdn_make_dummy(&dummy, cc_record->port, 0, misdn_lib_port_is_nt(cc_record->port), 0);
-				dummy.fac_out.Function = Fac_CCBSDeactivate;
-				dummy.fac_out.u.CCBSDeactivate.InvokeID = cc_record->invoke_id;
-				dummy.fac_out.u.CCBSDeactivate.ComponentType = FacComponent_Invoke;
-				dummy.fac_out.u.CCBSDeactivate.Component.Invoke.CCBSReference = cc_record->mode.ptmp.reference_id;
-	
-				/* Send message */
-				print_facility(&dummy.fac_out, &dummy);
-				misdn_lib_send_event(&dummy, EVENT_FACILITY);
 			}
+			misdn_cc_delete(cc_record);
+		} else if (cc_record->activated) {
+			cc_record->error_code = FacError_None;
+			cc_record->reject_code = FacReject_None;
+			cc_record->invoke_id = ++misdn_invoke_id;
+			cc_record->outstanding_message = 1;
+
+			/* Build message */
+			misdn_make_dummy(&dummy, cc_record->port, 0, misdn_lib_port_is_nt(cc_record->port), 0);
+			dummy.fac_out.Function = Fac_CCBSDeactivate;
+			dummy.fac_out.u.CCBSDeactivate.InvokeID = cc_record->invoke_id;
+			dummy.fac_out.u.CCBSDeactivate.ComponentType = FacComponent_Invoke;
+			dummy.fac_out.u.CCBSDeactivate.Component.Invoke.CCBSReference = cc_record->mode.ptmp.reference_id;
+
+			/* Send message */
+			print_facility(&dummy.fac_out, &dummy);
+			misdn_lib_send_event(&dummy, EVENT_FACILITY);
 		}
 	}
 	ast_mutex_unlock(&misdn_cc_record_lock);
@@ -8803,7 +8818,10 @@
 	ast_mutex_lock(&misdn_cc_record_lock);
 	cc_record = misdn_cc_find_by_id(record_id);
 	if (cc_record) {
-		if (cc_record->outstanding_message) {
+		if (cc_record->port < 0) {
+			/* The network did not tell us that call completion was available. */
+			error_str = NULL;
+		} else if (cc_record->outstanding_message) {
 			cc_record->outstanding_message = 0;
 			error_str = misdn_no_response_from_network;
 		} else if (cc_record->reject_code != FacReject_None) {
@@ -8890,16 +8908,15 @@
 		if (cc_record->ptp && cc_record->mode.ptp.bc) {
 			cc_record->error_code = FacError_None;
 			cc_record->reject_code = FacReject_None;
-			cc_record->invoke_id = ++misdn_invoke_id;
 
 			/* Build message */
 			bc = cc_record->mode.ptp.bc;
 			if (cc_record->party_a_free) {
 				bc->fac_out.Function = Fac_CCBS_T_Resume;
-				bc->fac_out.u.CCBS_T_Resume.InvokeID = cc_record->invoke_id;
+				bc->fac_out.u.CCBS_T_Resume.InvokeID = ++misdn_invoke_id;
 			} else {
 				bc->fac_out.Function = Fac_CCBS_T_Suspend;
-				bc->fac_out.u.CCBS_T_Suspend.InvokeID = cc_record->invoke_id;
+				bc->fac_out.u.CCBS_T_Suspend.InvokeID = ++misdn_invoke_id;
 			}
 
 			/* Send message */
@@ -9073,17 +9090,16 @@
 		cc_record->remote_user_free.priority = priority;
 
 		if (0 <= cc_record->port) {
-			cc_record->error_code = FacError_None;
-			cc_record->reject_code = FacReject_None;
-			cc_record->invoke_id = ++misdn_invoke_id;
-			cc_record->activation_requested = 1;
-
 			if (cc_record->ptp) {
 				if (!cc_record->mode.ptp.bc) {
 					bc = misdn_lib_get_register_bc(cc_record->port);
 					if (bc) {
 						cc_record->mode.ptp.bc = bc;
-						cc_record->activated = 1;
+						cc_record->error_code = FacError_None;
+						cc_record->reject_code = FacReject_None;
+						cc_record->invoke_id = ++misdn_invoke_id;
+						cc_record->outstanding_message = 1;
+						cc_record->activation_requested = 1;
 
 						/* Build message */
 						bc->fac_out.Function = request->ptp;
@@ -9113,8 +9129,12 @@
 					}
 				}
 			} else {
+				cc_record->error_code = FacError_None;
+				cc_record->reject_code = FacReject_None;
+				cc_record->invoke_id = ++misdn_invoke_id;
 				cc_record->outstanding_message = 1;
-	
+				cc_record->activation_requested = 1;
+
 				/* Build message */
 				misdn_make_dummy(&dummy, cc_record->port, 0,
 					misdn_lib_port_is_nt(cc_record->port), 0);
@@ -9139,24 +9159,35 @@
 	cc_record = misdn_cc_find_by_id(record_id);
 	if (cc_record) {
 		if (!cc_record->activated) {
-			if (cc_record->outstanding_message) {
+			if (cc_record->port < 0) {
+				/* The network did not tell us that call completion was available. */
+				error_str = "No port number";
+			} else if (cc_record->outstanding_message) {
 				cc_record->outstanding_message = 0;
 				error_str = misdn_no_response_from_network;
 			} else if (cc_record->reject_code != FacReject_None) {
 				error_str = misdn_to_str_reject_code(cc_record->reject_code);
 			} else if (cc_record->error_code != FacError_None) {
 				error_str = misdn_to_str_error_code(cc_record->error_code);
-			} else if (cc_record->port < 0) {
-				/* The network did not tell us that call completion was available. */
-				error_str = "No port number";
-			} else if (cc_record->ptp && !cc_record->mode.ptp.bc) {
-				error_str = "Could not allocate call-completion signaling link";
+			} else if (cc_record->ptp) {
+				if (cc_record->mode.ptp.bc) {
+					error_str = "Call-completion already requested";
+				} else {
+					error_str = "Could not allocate call-completion signaling link";
+				}
 			} else {
 				/* Should never happen. */
 				error_str = "Unexpected error";
 			}
 
 			/* No need to keep the call completion record. */
+			if (cc_record->ptp && cc_record->mode.ptp.bc) {
+				/* Close the call-completion signaling link */
+				bc = cc_record->mode.ptp.bc;
+				bc->fac_out.Function = Fac_None;
+				bc->out_cause = AST_CAUSE_NORMAL_CLEARING;
+				misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE);
+			}
 			misdn_cc_delete(cc_record);
 		} else {
 			error_str = NULL;




More information about the asterisk-commits mailing list