[svn-commits] rmudgett: branch 1.4 r1414 - in /branches/1.4: q921.c q931.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jan 15 12:28:58 CST 2010


Author: rmudgett
Date: Fri Jan 15 12:28:54 2010
New Revision: 1414

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1414
Log:
Make some debugging messages conditional and some minor reformating changes.

Modified:
    branches/1.4/q921.c
    branches/1.4/q931.c

Modified: branches/1.4/q921.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/q921.c?view=diff&rev=1414&r1=1413&r2=1414
==============================================================================
--- branches/1.4/q921.c (original)
+++ branches/1.4/q921.c Fri Jan 15 12:28:54 2010
@@ -67,8 +67,11 @@
 
 static void q921_setstate(struct pri *pri, int newstate)
 {
-	if ((pri->q921_state != newstate) && (newstate != 7) && (newstate != 8))
-		pri_error(pri, "Changing from state %d to %d\n", pri->q921_state, newstate);
+	if (pri->debug & PRI_DEBUG_Q921_STATE) {
+		if ((pri->q921_state != newstate) && (newstate != 7) && (newstate != 8)) {
+			pri_message(pri, "Changing from state %d to %d\n", pri->q921_state, newstate);
+		}
+	}
 	pri->q921_state = newstate;
 }
 
@@ -678,7 +681,7 @@
 void q921_dump(struct pri *pri, q921_h *h, int len, int showraw, int txrx)
 {
 	int x;
-        char *type;
+	char *type;
 	char direction_tag;
 	
 	q921_dump_pri_by_h(pri, h);
@@ -711,33 +714,30 @@
 	}
 	
 	pri_message(pri, "%c SAPI: %02d  C/R: %d EA: %d\n",
-    	direction_tag,
-	h->h.sapi, 
-	h->h.c_r,
-	h->h.ea1);
+		direction_tag,
+		h->h.sapi, 
+		h->h.c_r,
+		h->h.ea1);
 	pri_message(pri, "%c  TEI: %03d        EA: %d\n", 
-    	direction_tag,
-	h->h.tei,
-	h->h.ea2);
+		direction_tag,
+		h->h.tei,
+		h->h.ea2);
 
 	switch (h->h.data[0] & Q921_FRAMETYPE_MASK) {
 	case 0:
 	case 2:
 		/* Informational frame */
-		pri_message(pri, 
-"%c N(S): %03d   0: %d\n",
-    	direction_tag,
-	h->i.n_s,
-	h->i.ft);
-		pri_message(pri, 
-"%c N(R): %03d   P: %d\n",
-    	direction_tag,
-	h->i.n_r,
-	h->i.p_f);
-		pri_message(pri, 
-"%c %d bytes of data\n",
-    	direction_tag,
-	len - 4);
+		pri_message(pri, "%c N(S): %03d   0: %d\n",
+			direction_tag,
+			h->i.n_s,
+			h->i.ft);
+		pri_message(pri, "%c N(R): %03d   P: %d\n",
+			direction_tag,
+			h->i.n_r,
+			h->i.p_f);
+		pri_message(pri, "%c %d bytes of data\n",
+			direction_tag,
+			len - 4);
 		break;
 	case 1:
 		/* Supervisory frame */
@@ -753,22 +753,19 @@
 			type = "REJ (reject)";
 			break;
 		}
-		pri_message(pri, 
-"%c Zero: %d     S: %d 01: %d  [ %s ]\n",
-    	direction_tag,
-	h->s.x0,
-	h->s.ss,
-	h->s.ft,
-	type);
-		pri_message(pri, 
-"%c N(R): %03d P/F: %d\n",
-	direction_tag,
-	h->s.n_r,
-	h->s.p_f);
-		pri_message(pri, 
-"%c %d bytes of data\n",
-	direction_tag,
-	len - 4);
+		pri_message(pri, "%c Zero: %d     S: %d 01: %d  [ %s ]\n",
+			direction_tag,
+			h->s.x0,
+			h->s.ss,
+			h->s.ft,
+			type);
+		pri_message(pri, "%c N(R): %03d P/F: %d\n",
+			direction_tag,
+			h->s.n_r,
+			h->s.p_f);
+		pri_message(pri, "%c %d bytes of data\n",
+			direction_tag,
+			len - 4);
 		break;
 	case 3:		
 		/* Unnumbered frame */
@@ -801,18 +798,16 @@
 				break;
 			}
 		}
-		pri_message(pri, 
-"%c   M3: %d   P/F: %d M2: %d 11: %d  [ %s ]\n",
-	direction_tag,
-	h->u.m3,
-	h->u.p_f,
-	h->u.m2,
-	h->u.ft,
-	type);
-		pri_message(pri, 
-"%c %d bytes of data\n",
-	direction_tag,
-	len - 3);
+		pri_message(pri, "%c   M3: %d   P/F: %d M2: %d 11: %d  [ %s ]\n",
+			direction_tag,
+			h->u.m3,
+			h->u.p_f,
+			h->u.m2,
+			h->u.ft,
+			type);
+		pri_message(pri, "%c %d bytes of data\n",
+			direction_tag,
+			len - 3);
 		break;
 	};
 
@@ -933,7 +928,9 @@
 			return NULL;
 		}
 		q921_setstate(sub->subchannel, Q921_TEI_ASSIGNED);
-		pri_error(pri, "Allocating new TEI %d\n", tei);
+		if (pri->debug & PRI_DEBUG_Q921_STATE) {
+			pri_message(pri, "Allocating new TEI %d\n", tei);
+		}
 		q921_send_tei(pri, Q921_TEI_IDENTITY_ASSIGNED, ri, tei, 1);
 		break;
 	case Q921_TEI_IDENTITY_ASSIGNED:
@@ -1298,7 +1295,9 @@
 			return;
 		}
 
-		pri_error(pri, "Freeing TEI of %d\n", freep->tei);
+		if (pri->debug & PRI_DEBUG_Q921_STATE) {
+			pri_message(pri, "Freeing TEI of %d\n", freep->tei);
+		}
 
 		free(freep);
 	}
@@ -1422,9 +1421,9 @@
 	if (idealcnt != realcnt) {
 		pri_error(pri, "Ideally should have ack'd %d frames, but actually ack'd %d.  This is not good.\n", idealcnt, realcnt);
 		q921_dump_iqueue_info(pri, 1);
-	}
-
-	q921_dump_iqueue_info(pri, 0);
+	} else {
+		q921_dump_iqueue_info(pri, 0);
+	}
 
 	pri->v_a = n_r;
 }
@@ -1571,7 +1570,9 @@
 {
 	pri_event * res = NULL;
 
-	pri_message(pri, "!! Got reject for frame %d in state %d\n", h->s.n_r, pri->q921_state);
+	if (pri->debug & PRI_DEBUG_Q921_STATE) {
+		pri_message(pri, "!! Got reject for frame %d in state %d\n", h->s.n_r, pri->q921_state);
+	}
 
 	switch (pri->q921_state) {
 	case Q921_TIMER_RECOVERY:

Modified: branches/1.4/q931.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/q931.c?view=diff&rev=1414&r1=1413&r2=1414
==============================================================================
--- branches/1.4/q931.c (original)
+++ branches/1.4/q931.c Fri Jan 15 12:28:54 2010
@@ -7439,20 +7439,29 @@
 
 	switch (event) {
 	case PRI_EVENT_DCHAN_DOWN:
-		pri_message(ctrl, DBGHEAD "link is DOWN\n", DBGINFO);
+		if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
+			pri_message(ctrl, DBGHEAD "link is DOWN\n", DBGINFO);
+		}
 		cur = *ctrl->callpool;
 		while(cur) {
 			if (cur->ourcallstate == Q931_CALL_STATE_ACTIVE) {
 				/* For a call in Active state, activate T309 only if there is no timer already running. */
 				if (!cur->retranstimer) {
-					pri_message(ctrl, DBGHEAD "activate T309 for call %d on channel %d\n", DBGINFO, cur->cr, cur->channelno);
+					if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
+						pri_message(ctrl,
+							DBGHEAD "activate T309 for call %d on channel %d\n", DBGINFO,
+							cur->cr, cur->channelno);
+					}
 					cur->retranstimer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T309], pri_dl_down_timeout, cur);
 				}
 			} else if (cur->ourcallstate != Q931_CALL_STATE_NULL) {
 				/* For a call that is not in Active state, schedule internal clearing of the call 'ASAP' (delay 0). */
-				pri_message(ctrl, DBGHEAD "cancel call %d on channel %d in state %d (%s)\n", DBGINFO,
-					cur->cr, cur->channelno, cur->ourcallstate,
-					q931_call_state_str(cur->ourcallstate));
+				if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
+					pri_message(ctrl,
+						DBGHEAD "cancel call %d on channel %d in state %d (%s)\n", DBGINFO,
+						cur->cr, cur->channelno, cur->ourcallstate,
+						q931_call_state_str(cur->ourcallstate));
+				}
 				pri_schedule_del(ctrl, cur->retranstimer);
 				cur->retranstimer = pri_schedule_event(ctrl, 0, pri_dl_down_cancelcall, cur);
 			}
@@ -7460,11 +7469,17 @@
 		}
 		break;
 	case PRI_EVENT_DCHAN_UP:
-		pri_message(ctrl, DBGHEAD "link is UP\n", DBGINFO);
+		if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
+			pri_message(ctrl, DBGHEAD "link is UP\n", DBGINFO);
+		}
 		cur = *ctrl->callpool;
 		while(cur) {
 			if (cur->ourcallstate == Q931_CALL_STATE_ACTIVE && cur->retranstimer) {
-				pri_message(ctrl, DBGHEAD "cancel T309 for call %d on channel %d\n", DBGINFO, cur->cr, cur->channelno);
+				if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
+					pri_message(ctrl,
+						DBGHEAD "cancel T309 for call %d on channel %d\n", DBGINFO,
+						cur->cr, cur->channelno);
+				}
 				pri_schedule_del(ctrl, cur->retranstimer);
 				cur->retranstimer = 0;
 				q931_status(ctrl, cur, PRI_CAUSE_NORMAL_UNSPECIFIED);




More information about the svn-commits mailing list