[Asterisk-cvs] libpri pri_q921.h,1.5,1.6 q921.c,1.9,1.10 q931.c,1.48,1.49

markster at lists.digium.com markster at lists.digium.com
Sat Apr 10 21:25:35 CDT 2004


Update of /usr/cvsroot/libpri
In directory mongoose.digium.com:/tmp/cvs-serv24510

Modified Files:
	pri_q921.h q921.c q931.c 
Log Message:
Debug improvements (bug #1329)


Index: pri_q921.h
===================================================================
RCS file: /usr/cvsroot/libpri/pri_q921.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- pri_q921.h	29 Mar 2004 08:09:01 -0000	1.5
+++ pri_q921.h	11 Apr 2004 01:27:11 -0000	1.6
@@ -148,7 +148,7 @@
 } q921_state;
 
 /* Dumps a *known good* Q.921 packet */
-extern void q921_dump(q921_h *h, int len, int showraw, int txrx);
+extern void q921_dump(struct pri *pri, q921_h *h, int len, int showraw, int txrx);
 
 /* Bring up the D-channel */
 extern void q921_start(struct pri *pri, int now);

Index: q921.c
===================================================================
RCS file: /usr/cvsroot/libpri/q921.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- q921.c	5 Apr 2004 08:22:14 -0000	1.9
+++ q921.c	11 Apr 2004 01:27:11 -0000	1.10
@@ -78,7 +78,7 @@
 #endif
 	/* Just send it raw */
 	if (pri->debug & PRI_DEBUG_Q921_DUMP)
-		q921_dump(h, len, pri->debug & PRI_DEBUG_Q921_RAW, 1);
+		q921_dump(pri, h, len, pri->debug & PRI_DEBUG_Q921_RAW, 1);
 	/* Write an extra two bytes for the FCS */
 	res = write(pri->fd, h, len + 2);
 	if (res != (len + 2)) {
@@ -486,13 +486,27 @@
 	return NULL;
 }
 
-void q921_dump(q921_h *h, int len, int showraw, int txrx)
+void q921_dump(struct pri *pri, q921_h *h, int len, int showraw, int txrx)
 {
 	int x;
         char *type;
 	char direction_tag;
+	char *cmd_rsp;
 	
 	direction_tag = txrx ? '>' : '<';
+        /* If we are PRI_CPE: Use "Command" if we are transmitting and C/R bit is 0.
+         *                    Use "Response" if we are transmitting and C/R bit is 1.
+         *                    Use "Command" if we are receiving and C/R bit is 1.
+         *                    Use "Response" if we are receiving and C/R bit is 0.
+         *
+         * If we are PRI_NETWORK: Use "Command" if we are transmitting and C/R bit is 1.
+         *                        Use "Response" if we are transmitting and C/R bit is 0.
+         *                        Use "Command" if we are receiving and C/R bit is 0.
+         *                        Use "Response" if we are receiving and C/R bit is 1.
+         */
+        cmd_rsp = (((pri->localtype == PRI_CPE)?0:1) ^ txrx ^ h->h.c_r) ? "Command" : "Response";
+
+
 	if (showraw) {
 		char *buf = malloc(len * 3 + 1);
 		int buflen = 0;
@@ -518,12 +532,13 @@
 	}
 	
 	pri_message(
-"%c SAPI: %02d  C/R: %d EA: %d\n"
+"%c SAPI: %02d  C/R: %d EA: %d [%s]\n"
 "%c  TEI: %03d        EA: %d\n", 
     	direction_tag,
 	h->h.sapi, 
 	h->h.c_r,
 	h->h.ea1,
+	cmd_rsp,
     	direction_tag,
 	h->h.tei,
 	h->h.ea2);
@@ -686,7 +701,7 @@
 	len -= 2;
 	
 	if (pri->debug & PRI_DEBUG_Q921_DUMP)
-		q921_dump(h, len, pri->debug & PRI_DEBUG_Q921_RAW, 0);
+		q921_dump(pri, h, len, pri->debug & PRI_DEBUG_Q921_RAW, 0);
 
 	/* Check some reject conditions -- Start by rejecting improper ea's */
 	if (h->h.ea1 || !(h->h.ea2))

Index: q931.c
===================================================================
RCS file: /usr/cvsroot/libpri/q931.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- q931.c	6 Apr 2004 14:50:19 -0000	1.48
+++ q931.c	11 Apr 2004 01:27:11 -0000	1.49
@@ -1149,7 +1149,7 @@
 
 static void dump_sending_complete(q931_ie *ie, int len, char prefix)
 {
-	pri_message("%c Sending Complete (len=%2d)\n", prefix, ie->len);
+	pri_message("%c Sending Complete.\n", prefix);
 }
 
 static int receive_sending_complete(struct pri *pri, q931_call *call, int msgtype, q931_ie *ie, int len)
@@ -1410,7 +1410,8 @@
 	int x=0, r;
 	c = txrx ? '>' : '<';
 	pri_message("%c Protocol Discriminator: %s (%d)  len=%d\n", c, disc2str(h->pd), h->pd, len);
-	pri_message("%c Call Ref: len=%2d (reference %d/0x%X) (%s)\n", c, h->crlen, q931_cr(h), q931_cr(h), (h->crv[0] & 0x80) ? "Terminator" : "Originator");
+	pri_message("%c Call Ref: len=%2d (reference %d/0x%X) (%s)\n",
+		c, h->crlen, q931_cr(h) & 0x7fff, q931_cr(h) & 0x7fff, (q931_cr(h) & 0x8000) ? "Terminator" : "Originator");
 	/* Message header begins at the end of the call reference number */
 	mh = (q931_mh *)(h->contents + h->crlen);
 	pri_message("%c Message type: %s (%d)\n", c, msg2str(mh->msg), mh->msg);




More information about the svn-commits mailing list