[libpri-commits] rmudgett: branch rmudgett/q921_review r1876 - /team/rmudgett/q921_review/q921.c

SVN commits to the libpri project libpri-commits at lists.digium.com
Thu Aug 12 12:03:23 CDT 2010


Author: rmudgett
Date: Thu Aug 12 12:03:18 2010
New Revision: 1876

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1876
Log:
Move MDL-ERROR messages to be displayed when the event is detected.

* Suppress MDL-ERROR messages C, D, F, G, H, and I unless Q.921 state
debug messages are enabled.  Messages C and D will always display if in
point-to-point mode.

* Negate the removed TEI value so debug messages will display a negated
TEI when it is actually unassigned.

Modified:
    team/rmudgett/q921_review/q921.c

Modified: team/rmudgett/q921_review/q921.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/q921_review/q921.c?view=diff&rev=1876&r1=1875&r2=1876
==============================================================================
--- team/rmudgett/q921_review/q921.c (original)
+++ team/rmudgett/q921_review/q921.c Thu Aug 12 12:03:18 2010
@@ -1361,6 +1361,9 @@
 {
 	int mdl_free_me;
 
+	if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
+		pri_message(ctrl, "MDL-REMOVE: Removing TEI %d\n", ctrl->tei);
+	}
 	if (BRI_NT_PTMP(ctrl)) {
 		if (ctrl == PRI_MASTER(ctrl)) {
 			pri_error(ctrl, "Bad bad bad!  Cannot MDL-REMOVE master\n");
@@ -1410,6 +1413,12 @@
 			ctrl->q921_state, q921_state2str(ctrl->q921_state));
 		return;
 	}
+
+	/*
+	 * Negate the TEI value so debug messages will display a
+	 * negated TEI when it is actually unassigned.
+	 */
+	ctrl->tei = -ctrl->tei;
 
 	ctrl->mdl_free_me = mdl_free_me;
 }
@@ -1508,39 +1517,82 @@
 
 static void q921_mdl_handle_error(struct pri *ctrl, char error, int errored_state)
 {
-	int handled = 0;
 	if (PTP_MODE(ctrl)) {
-		handled = q921_mdl_handle_ptp_error(ctrl, error);
+		q921_mdl_handle_ptp_error(ctrl, error);
 	} else {
 		if (ctrl->localtype == PRI_NETWORK) {
-			handled = q921_mdl_handle_network_error(ctrl, error);
+			q921_mdl_handle_network_error(ctrl, error);
 		} else {
-			handled = q921_mdl_handle_cpe_error(ctrl, error);
-		}
-	}
-
-	if (handled)
-		return;
-
-	/* Just log the protocol error */
+			q921_mdl_handle_cpe_error(ctrl, error);
+		}
+	}
+}
+
+static void q921_mdl_handle_error_callback(void *vpri)
+{
+	struct pri *ctrl = vpri;
+
+	q921_mdl_handle_error(ctrl, ctrl->mdl_error, ctrl->mdl_error_state);
+
+	ctrl->mdl_error = 0;
+	ctrl->mdl_timer = 0;
+
+	if (ctrl->mdl_free_me) {
+		struct pri *master = PRI_MASTER(ctrl);
+		struct pri *freep = NULL, *prev, *cur;
+		prev = master;
+		cur = master->subchannel;
+
+		while (cur) {
+			if (cur == ctrl) {
+				prev->subchannel = cur->subchannel;
+				freep = cur;
+				break;
+			}
+			prev = cur;
+			cur = cur->subchannel;
+		}
+
+		if (freep == NULL) {
+			pri_error(ctrl, "Huh!? no match found in list for TEI %d\n", -ctrl->tei);
+			return;
+		}
+
+		if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
+			pri_message(ctrl, "Freeing TEI of %d\n", -freep->tei);
+		}
+
+		__pri_free_tei(freep);
+	}
+
+	return;
+}
+
+static void q921_mdl_error(struct pri *ctrl, char error)
+{
+	int is_debug_q921_state;
+
+	/* Log the MDL-ERROR event when detected. */
+	is_debug_q921_state = (ctrl->debug & PRI_DEBUG_Q921_STATE);
 	switch (error) {
-	case 'C':
-	case 'D':
-		pri_message(ctrl, "TEI=%d MDL-ERROR (%c): UA in state %d(%s)\n",
-			ctrl->tei, error, errored_state, q921_state2str(errored_state));
-		break;
 	case 'A':
 		pri_message(ctrl,
 			"TEI=%d MDL-ERROR (A): Got supervisory frame with F=1 in state %d(%s)\n",
-			ctrl->tei, errored_state, q921_state2str(errored_state));
-		break;
-	case 'G':
-	case 'H':
-	case 'I':
-		/* We could not get a response from the peer. */
-		pri_message(ctrl,
-			"TEI=%d MDL-ERROR (%c): T200 expired N200 times in state %d(%s)\n",
-			ctrl->tei, error, errored_state, q921_state2str(errored_state));
+			ctrl->tei, ctrl->q921_state, q921_state2str(ctrl->q921_state));
+		break;
+	case 'B':
+	case 'E':
+		pri_message(ctrl, "TEI=%d MDL-ERROR (%c): DM (F=%c) in state %d(%s)\n",
+			ctrl->tei, error, (error == 'B') ? '1' : '0',
+			ctrl->q921_state, q921_state2str(ctrl->q921_state));
+		break;
+	case 'C':
+	case 'D':
+		if (is_debug_q921_state || PTP_MODE(ctrl)) {
+			pri_message(ctrl, "TEI=%d MDL-ERROR (%c): UA (F=%c) in state %d(%s)\n",
+				ctrl->tei, error, (error == 'C') ? '1' : '0',
+				ctrl->q921_state, q921_state2str(ctrl->q921_state));
+		}
 		break;
 	case 'F':
 		/*
@@ -1552,18 +1604,43 @@
 		 * their T200 timer expired N200 times.
 		 * 4) They got an MDL-ERROR (J).
 		 */
-		pri_message(ctrl, "TEI=%d MDL-ERROR (F): SABME in state %d(%s)\n",
-			ctrl->tei, errored_state, q921_state2str(errored_state));
-		break;
-	case 'B':
-	case 'E':
-		pri_message(ctrl, "TEI=%d MDL-ERROR (%c): DM in state %d(%s)\n",
-			ctrl->tei, error, errored_state, q921_state2str(errored_state));
+		if (is_debug_q921_state) {
+			/*
+			 * This message is rather annoying and is normal for
+			 * reasons 1-3 above.
+			 */
+			pri_message(ctrl, "TEI=%d MDL-ERROR (F): SABME in state %d(%s)\n",
+				ctrl->tei, ctrl->q921_state, q921_state2str(ctrl->q921_state));
+		}
+		break;
+	case 'G':
+		/* We could not get a response from the peer. */
+		if (is_debug_q921_state) {
+			pri_message(ctrl,
+				"TEI=%d MDL-ERROR (G): T200 expired N200 times sending SABME in state %d(%s)\n",
+				ctrl->tei, ctrl->q921_state, q921_state2str(ctrl->q921_state));
+		}
+		break;
+	case 'H':
+		/* We could not get a response from the peer. */
+		if (is_debug_q921_state) {
+			pri_message(ctrl,
+				"TEI=%d MDL-ERROR (H): T200 expired N200 times sending DISC in state %d(%s)\n",
+				ctrl->tei, ctrl->q921_state, q921_state2str(ctrl->q921_state));
+		}
+		break;
+	case 'I':
+		/* We could not get a response from the peer. */
+		if (is_debug_q921_state) {
+			pri_message(ctrl,
+				"TEI=%d MDL-ERROR (I): T200 expired N200 times sending RR/RNR in state %d(%s)\n",
+				ctrl->tei, ctrl->q921_state, q921_state2str(ctrl->q921_state));
+		}
 		break;
 	case 'J':
 		/* N(R) not within ack window. */
 		pri_error(ctrl, "TEI=%d MDL-ERROR (J): N(R) error in state %d(%s)\n",
-			ctrl->tei, errored_state, q921_state2str(errored_state));
+			ctrl->tei, ctrl->q921_state, q921_state2str(ctrl->q921_state));
 		break;
 	case 'K':
 		/*
@@ -1571,59 +1648,19 @@
 		 * The other end does not like what we are doing at all for some reason.
 		 */
 		pri_error(ctrl, "TEI=%d MDL-ERROR (K): FRMR in state %d(%s)\n",
-			ctrl->tei, errored_state, q921_state2str(errored_state));
+			ctrl->tei, ctrl->q921_state, q921_state2str(ctrl->q921_state));
 		break;
 	default:
 		pri_message(ctrl, "TEI=%d MDL-ERROR (%c): in state %d(%s)\n",
-			ctrl->tei, error, errored_state, q921_state2str(errored_state));
-		break;
-	}
-}
-
-static void q921_mdl_handle_error_callback(void *vpri)
-{
-	struct pri *ctrl = vpri;
-
-	q921_mdl_handle_error(ctrl, ctrl->mdl_error, ctrl->mdl_error_state);
-
-	ctrl->mdl_error = 0;
-	ctrl->mdl_timer = 0;
-
-	if (ctrl->mdl_free_me) {
-		struct pri *master = PRI_MASTER(ctrl);
-		struct pri *freep = NULL, *prev, *cur;
-		prev = master;
-		cur = master->subchannel;
-
-		while (cur) {
-			if (cur == ctrl) {
-				prev->subchannel = cur->subchannel;
-				freep = cur;
-				break;
-			}
-			prev = cur;
-			cur = cur->subchannel;
-		}
-
-		if (freep == NULL) {
-			pri_error(ctrl, "Huh!? no match found in list for TEI %d\n", ctrl->tei);
-			return;
-		}
-
-		if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
-			pri_message(ctrl, "Freeing TEI of %d\n", freep->tei);
-		}
-
-		__pri_free_tei(freep);
-	}
-
-	return;
-}
-
-static void q921_mdl_error(struct pri *ctrl, char error)
-{
+			ctrl->tei, error, ctrl->q921_state, q921_state2str(ctrl->q921_state));
+		break;
+	}
+
 	if (ctrl->mdl_error) {
-		pri_error(ctrl, "Trying to queue an MDL error when one is already scheduled\n");
+		/* This should not happen. */
+		pri_error(ctrl,
+			"Trying to queue MDL-ERROR (%c) when MDL-ERROR (%c) is already scheduled\n",
+			error, ctrl->mdl_error);
 		return;
 	}
 	ctrl->mdl_error = error;




More information about the libpri-commits mailing list