[svn-commits] kmoore: branch 1.4 r2282 - in /branches/1.4: pri_q921.h pridump.c q921.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Feb 3 17:13:01 CST 2012


Author: kmoore
Date: Fri Feb  3 17:12:57 2012
New Revision: 2282

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=2282
Log:
Make PRI_DEBUG_Q921_RAW work independantly of PRI_DEBUG_Q921_DUMP

Ensure that the DUMP and RAW flags work independently in q921_dump().

Closes mantis issue: 18528
Patch-by: wimpy

Modified:
    branches/1.4/pri_q921.h
    branches/1.4/pridump.c
    branches/1.4/q921.c

Modified: branches/1.4/pri_q921.h
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri_q921.h?view=diff&rev=2282&r1=2281&r2=2282
==============================================================================
--- branches/1.4/pri_q921.h (original)
+++ branches/1.4/pri_q921.h Fri Feb  3 17:12:57 2012
@@ -273,7 +273,7 @@
 }
 
 /* Dumps a *known good* Q.921 packet */
-extern void q921_dump(struct pri *pri, q921_h *h, int len, int showraw, int txrx);
+extern void q921_dump(struct pri *pri, q921_h *h, int len, int debugflags, int txrx);
 
 /* Bring up the D-channel */
 void q921_start(struct q921_link *link);

Modified: branches/1.4/pridump.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pridump.c?view=diff&rev=2282&r1=2281&r2=2282
==============================================================================
--- branches/1.4/pridump.c (original)
+++ branches/1.4/pridump.c Fri Feb  3 17:12:57 2012
@@ -71,7 +71,7 @@
 static void dump_packet(struct pri *pri, char *buf, int len, int txrx)
 {
 	q921_h *h = (q921_h *)buf;
-	q921_dump(pri, h, len, 1, txrx);
+	q921_dump(pri, h, len, PRI_DEBUG_ALL, txrx);
 	if (!((h->h.data[0] & Q921_FRAMETYPE_MASK) & 0x3)) {
 		q931_dump(pri, h->h.tei, (q931_h *)(h->i.data), len - 4 - 2 /* FCS */, txrx);
 	}

Modified: branches/1.4/q921.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/q921.c?view=diff&rev=2282&r1=2281&r2=2282
==============================================================================
--- branches/1.4/q921.c (original)
+++ branches/1.4/q921.c Fri Feb  3 17:12:57 2012
@@ -186,7 +186,7 @@
 	ctrl->q921_txcount++;
 	/* Just send it raw */
 	if (ctrl->debug & (PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW))
-		q921_dump(ctrl, h, len, ctrl->debug & PRI_DEBUG_Q921_RAW, 1);
+		q921_dump(ctrl, h, len, ctrl->debug, 1);
 	/* Write an extra two bytes for the FCS */
 	res = ctrl->write_func ? ctrl->write_func(ctrl, h, len + 2) : 0;
 	if (res != (len + 2)) {
@@ -1187,7 +1187,7 @@
 
 static void q921_dump_pri_by_h(struct pri *ctrl, char direction_tag, q921_h *h);
 
-void q921_dump(struct pri *ctrl, q921_h *h, int len, int showraw, int txrx)
+void q921_dump(struct pri *ctrl, q921_h *h, int len, int debugflags, int txrx)
 {
 	int x;
 	const char *type;
@@ -1196,9 +1196,11 @@
 	direction_tag = txrx ? '>' : '<';
 
 	pri_message(ctrl, "\n");
-	q921_dump_pri_by_h(ctrl, direction_tag, h);
-
-	if (showraw) {
+	if (debugflags & PRI_DEBUG_Q921_DUMP) {
+		q921_dump_pri_by_h(ctrl, direction_tag, h);
+	}
+
+	if (debugflags & PRI_DEBUG_Q921_RAW) {
 		char *buf = malloc(len * 3 + 1);
 		int buflen = 0;
 		if (buf) {
@@ -1209,132 +1211,134 @@
 		}
 	}
 
-	switch (h->h.data[0] & Q921_FRAMETYPE_MASK) {
-	case 0:
-	case 2:
-		pri_message(ctrl, "%c Informational frame:\n", direction_tag);
-		break;
-	case 1:
-		pri_message(ctrl, "%c Supervisory frame:\n", direction_tag);
-		break;
-	case 3:
-		pri_message(ctrl, "%c Unnumbered frame:\n", direction_tag);
-		break;
-	}
+	if (debugflags & PRI_DEBUG_Q921_DUMP) {
+		switch (h->h.data[0] & Q921_FRAMETYPE_MASK) {
+		case 0:
+		case 2:
+			pri_message(ctrl, "%c Informational frame:\n", direction_tag);
+			break;
+		case 1:
+			pri_message(ctrl, "%c Supervisory frame:\n", direction_tag);
+			break;
+		case 3:
+			pri_message(ctrl, "%c Unnumbered frame:\n", direction_tag);
+			break;
+		}
+		
+		pri_message(ctrl, "%c SAPI: %02d  C/R: %d EA: %d\n",
+			direction_tag,
+			h->h.sapi, 
+			h->h.c_r,
+			h->h.ea1);
+		pri_message(ctrl, "%c  TEI: %03d        EA: %d\n", 
+			direction_tag,
+			h->h.tei,
+			h->h.ea2);
 	
-	pri_message(ctrl, "%c SAPI: %02d  C/R: %d EA: %d\n",
-		direction_tag,
-		h->h.sapi, 
-		h->h.c_r,
-		h->h.ea1);
-	pri_message(ctrl, "%c  TEI: %03d        EA: %d\n", 
-		direction_tag,
-		h->h.tei,
-		h->h.ea2);
-
-	switch (h->h.data[0] & Q921_FRAMETYPE_MASK) {
-	case 0:
-	case 2:
-		/* Informational frame */
-		pri_message(ctrl, "%c N(S): %03d   0: %d\n",
-			direction_tag,
-			h->i.n_s,
-			h->i.ft);
-		pri_message(ctrl, "%c N(R): %03d   P: %d\n",
-			direction_tag,
-			h->i.n_r,
-			h->i.p_f);
-		pri_message(ctrl, "%c %d bytes of data\n",
-			direction_tag,
-			len - 4);
-		break;
-	case 1:
-		/* Supervisory frame */
-		type = "???";
-		switch (h->s.ss) {
+		switch (h->h.data[0] & Q921_FRAMETYPE_MASK) {
 		case 0:
-			type = "RR (receive ready)";
+		case 2:
+			/* Informational frame */
+			pri_message(ctrl, "%c N(S): %03d   0: %d\n",
+				direction_tag,
+				h->i.n_s,
+				h->i.ft);
+			pri_message(ctrl, "%c N(R): %03d   P: %d\n",
+				direction_tag,
+				h->i.n_r,
+				h->i.p_f);
+			pri_message(ctrl, "%c %d bytes of data\n",
+				direction_tag,
+				len - 4);
 			break;
 		case 1:
-			type = "RNR (receive not ready)";
-			break;
-		case 2:
-			type = "REJ (reject)";
-			break;
-		}
-		pri_message(ctrl, "%c Zero: %d     S: %d 01: %d  [ %s ]\n",
-			direction_tag,
-			h->s.x0,
-			h->s.ss,
-			h->s.ft,
-			type);
-		pri_message(ctrl, "%c N(R): %03d P/F: %d\n",
-			direction_tag,
-			h->s.n_r,
-			h->s.p_f);
-		pri_message(ctrl, "%c %d bytes of data\n",
-			direction_tag,
-			len - 4);
-		break;
-	case 3:		
-		/* Unnumbered frame */
-		type = "???";
-		if (h->u.ft == 3) {
-			switch (h->u.m3) {
+			/* Supervisory frame */
+			type = "???";
+			switch (h->s.ss) {
 			case 0:
-				if (h->u.m2 == 3)
-					type = "DM (disconnect mode)";
-				else if (h->u.m2 == 0)
-					type = "UI (unnumbered information)";
+				type = "RR (receive ready)";
+				break;
+			case 1:
+				type = "RNR (receive not ready)";
 				break;
 			case 2:
-				if (h->u.m2 == 0)
-					type = "DISC (disconnect)";
+				type = "REJ (reject)";
 				break;
-			case 3:
-				if (h->u.m2 == 3)
-					type = "SABME (set asynchronous balanced mode extended)";
-				else if (h->u.m2 == 0)
-					type = "UA (unnumbered acknowledgement)";
-				break;
-			case 4:
-				if (h->u.m2 == 1)
-					type = "FRMR (frame reject)";
-				break;
-			case 5:
-				if (h->u.m2 == 3)
-					type = "XID (exchange identification note)";
-				break;
-			default:
-				break;
-			}
-		}
-		pri_message(ctrl, "%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(ctrl, "%c %d bytes of data\n",
-			direction_tag,
-			len - 3);
-		break;
-	}
-
-	if ((h->u.ft == 3) && (h->u.m3 == 0) && (h->u.m2 == 0) && (h->u.data[0] == 0x0f)) {
-		int ri;
-		u_int8_t *action;
-
-		/* TEI management related */
-		type = q921_tei_mgmt2str(h->u.data[3]);
-		pri_message(ctrl, "%c MDL Message: %d(%s)\n", direction_tag, h->u.data[3], type);
-		ri = (h->u.data[1] << 8) | h->u.data[2];
-		pri_message(ctrl, "%c Ri: %d\n", direction_tag, ri);
-		action = &h->u.data[4];
-		for (x = len - (action - (u_int8_t *) h); 0 < x; --x, ++action) {
-			pri_message(ctrl, "%c Ai: %d E:%d\n",
-				direction_tag, (*action >> 1) & 0x7f, *action & 0x01);
+			}
+			pri_message(ctrl, "%c Zero: %d     S: %d 01: %d  [ %s ]\n",
+				direction_tag,
+				h->s.x0,
+				h->s.ss,
+				h->s.ft,
+				type);
+			pri_message(ctrl, "%c N(R): %03d P/F: %d\n",
+				direction_tag,
+				h->s.n_r,
+				h->s.p_f);
+			pri_message(ctrl, "%c %d bytes of data\n",
+				direction_tag,
+				len - 4);
+			break;
+		case 3:		
+			/* Unnumbered frame */
+			type = "???";
+			if (h->u.ft == 3) {
+				switch (h->u.m3) {
+				case 0:
+					if (h->u.m2 == 3)
+						type = "DM (disconnect mode)";
+					else if (h->u.m2 == 0)
+						type = "UI (unnumbered information)";
+					break;
+				case 2:
+					if (h->u.m2 == 0)
+						type = "DISC (disconnect)";
+					break;
+				case 3:
+					if (h->u.m2 == 3)
+						type = "SABME (set asynchronous balanced mode extended)";
+					else if (h->u.m2 == 0)
+						type = "UA (unnumbered acknowledgement)";
+					break;
+				case 4:
+					if (h->u.m2 == 1)
+						type = "FRMR (frame reject)";
+					break;
+				case 5:
+					if (h->u.m2 == 3)
+						type = "XID (exchange identification note)";
+					break;
+				default:
+					break;
+				}
+			}
+			pri_message(ctrl, "%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(ctrl, "%c %d bytes of data\n",
+				direction_tag,
+				len - 3);
+			break;
+		}
+	
+		if ((h->u.ft == 3) && (h->u.m3 == 0) && (h->u.m2 == 0) && (h->u.data[0] == 0x0f)) {
+			int ri;
+			u_int8_t *action;
+	
+			/* TEI management related */
+			type = q921_tei_mgmt2str(h->u.data[3]);
+			pri_message(ctrl, "%c MDL Message: %d(%s)\n", direction_tag, h->u.data[3], type);
+			ri = (h->u.data[1] << 8) | h->u.data[2];
+			pri_message(ctrl, "%c Ri: %d\n", direction_tag, ri);
+			action = &h->u.data[4];
+			for (x = len - (action - (u_int8_t *) h); 0 < x; --x, ++action) {
+				pri_message(ctrl, "%c Ai: %d E:%d\n",
+					direction_tag, (*action >> 1) & 0x7f, *action & 0x01);
+			}
 		}
 	}
 }
@@ -3006,7 +3010,7 @@
 	len -= 2;
 	
 	if (ctrl->debug & (PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW)) {
-		q921_dump(ctrl, h, len, ctrl->debug & PRI_DEBUG_Q921_RAW, 0);
+		q921_dump(ctrl, h, len, ctrl->debug, 0);
 	}
 
 	/* Check some reject conditions -- Start by rejecting improper ea's */




More information about the svn-commits mailing list