[libpri-commits] rmudgett: branch rmudgett/l2l3_debug r1875 - /team/rmudgett/l2l3_debug/

SVN commits to the libpri project libpri-commits at lists.digium.com
Tue Aug 10 18:08:37 CDT 2010


Author: rmudgett
Date: Tue Aug 10 18:08:32 2010
New Revision: 1875

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1875
Log:
Q.921/Q.931 message debug output improvements.

The Q.931 message decode debug output now will follow the correct Q.921
header decode if Q.921 message dumping is enabled.  Also the Q.931 message
decode will happen when the message actually goes out on the line instead
of when Q.931 passes the message to Q.921.  Q.921 may have to request a
TEI, bring the connection up, or retransmit previous frames before it can
actually send the new message.

Modified:
    team/rmudgett/l2l3_debug/q921.c
    team/rmudgett/l2l3_debug/q931.c

Modified: team/rmudgett/l2l3_debug/q921.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/l2l3_debug/q921.c?view=diff&rev=1875&r1=1874&r2=1875
==============================================================================
--- team/rmudgett/l2l3_debug/q921.c (original)
+++ team/rmudgett/l2l3_debug/q921.c Tue Aug 10 18:08:32 2010
@@ -524,6 +524,18 @@
 		q921_transmit(ctrl, (q921_h *)(&f->h), f->len);
 		Q921_INC(ctrl->v_s);
 		++frames_txd;
+
+		if (ctrl->debug & PRI_DEBUG_Q931_DUMP) {
+			/*
+			 * The transmit operation might dump the Q.921 header, so logging
+			 * the Q.931 message body after the transmit puts the sections of
+			 * the message in the right order in the log.
+			 *
+			 * Also the dump is done here so the Q.931 part is decoded only
+			 * once instead of for every retransmission.
+			 */
+			q931_dump(ctrl, ctrl->tei, (q931_h *) f->h.data, f->len - 4, 1);
+		}
 	}
 
 	if (frames_txd) {

Modified: team/rmudgett/l2l3_debug/q931.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/l2l3_debug/q931.c?view=diff&rev=1875&r1=1874&r2=1875
==============================================================================
--- team/rmudgett/l2l3_debug/q931.c (original)
+++ team/rmudgett/l2l3_debug/q931.c Tue Aug 10 18:08:32 2010
@@ -4158,34 +4158,29 @@
 }
 
 /*!
- * \brief Debug dump the given Q.931 packet.
+ * \internal
+ * \brief Dump the Q.931 message header.
  *
  * \param ctrl D channel controller.
  * \param tei TEI the packet is associated with.
  * \param h Q.931 packet contents/header.
- * \param len Received length of the Q.931 packet
- * \param txrx TRUE if packet is transmitted/outgoing
- *
- * \return Nothing
+ * \param len Received length of the Q.931 packet.
+ * \param c Message direction prefix character.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
  */
-void q931_dump(struct pri *ctrl, int tei, q931_h *h, int len, int txrx)
+static int q931_dump_header(struct pri *ctrl, int tei, q931_h *h, int len, char c)
 {
 	q931_mh *mh;
-	char c;
-	int x;
-	int r;
-	int cur_codeset;
-	int codeset;
 	int cref;
-
-	c = txrx ? '>' : '<';
 
 	pri_message(ctrl, "%c Protocol Discriminator: %s (%d)  len=%d\n", c, disc2str(h->pd), h->pd, len);
 
 	if (len < 2 || len < 2 + h->crlen) {
 		pri_message(ctrl, "%c Message too short for call reference. len=%d\n",
 			c, len);
-		return;
+		return -1;
 	}
 	cref = q931_cr(h);
 	pri_message(ctrl, "%c TEI=%d Call Ref: len=%2d (reference %d/0x%X) (%s)\n",
@@ -4198,7 +4193,7 @@
 	if (len < 3 + h->crlen) {
 		pri_message(ctrl, "%c Message too short for supported protocols. len=%d\n",
 			c, len);
-		return;
+		return -1;
 	}
 
 	/* Message header begins at the end of the call reference number */
@@ -4215,7 +4210,64 @@
 		pri_message(ctrl, "%c Message Type: %s (%d)\n", c, msg2str(mh->msg), mh->msg);
 		break;
 	}
+
+	return 0;
+}
+
+/*!
+ * \internal
+ * \brief Q.931 is passing this message to Q.921 debug indication.
+ *
+ * \param ctrl D channel controller.
+ * \param tei TEI the packet is associated with.
+ * \param h Q.931 packet contents/header.
+ * \param len Received length of the Q.931 packet
+ *
+ * \return Nothing
+ */
+static void q931_to_q921_passing_dump(struct pri *ctrl, int tei, q931_h *h, int len)
+{
+	char c;
+
+	c = '>';
+
+	pri_message(ctrl, "\n");
+	pri_message(ctrl, "%c DL-DATA request\n", c);
+	q931_dump_header(ctrl, tei, h, len, c);
+}
+
+/*!
+ * \brief Debug dump the given Q.931 packet.
+ *
+ * \param ctrl D channel controller.
+ * \param tei TEI the packet is associated with.
+ * \param h Q.931 packet contents/header.
+ * \param len Received length of the Q.931 packet
+ * \param txrx TRUE if packet is transmitted/outgoing
+ *
+ * \return Nothing
+ */
+void q931_dump(struct pri *ctrl, int tei, q931_h *h, int len, int txrx)
+{
+	q931_mh *mh;
+	char c;
+	int x;
+	int r;
+	int cur_codeset;
+	int codeset;
+
+	c = txrx ? '>' : '<';
+
+	if (!(ctrl->debug & (PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW))) {
+		/* Put out a blank line if Q.921 is not dumping. */
+		pri_message(ctrl, "\n");
+	}
+	if (q931_dump_header(ctrl, tei, h, len, c)) {
+		return;
+	}
+
 	/* Drop length of header, including call reference */
+	mh = (q931_mh *)(h->contents + h->crlen);
 	len -= (h->crlen + 3);
 	codeset = cur_codeset = 0;
 	for (x = 0; x < len; x += r) {
@@ -4337,21 +4389,30 @@
 
 static int q931_xmit(struct pri *ctrl, int tei, q931_h *h, int len, int cr, int uiframe)
 {
-	/*
-	 * Dump the Q.931 message first.  Q.921 may have to request a TEI or
-	 * bring the connection up before it can actually send the message.
-	 * Therefore, the Q.931 message may actually get sent a few seconds
-	 * later.
-	 */
-	if (ctrl->debug & PRI_DEBUG_Q931_DUMP) {
-		q931_dump(ctrl, tei, h, len, 1);
-	}
 #ifdef LIBPRI_COUNTERS
 	ctrl->q931_txcount++;
 #endif
 	if (uiframe) {
 		q921_transmit_uiframe(ctrl, h, len);
+		if (ctrl->debug & PRI_DEBUG_Q931_DUMP) {
+			/*
+			 * The transmit operation might dump the Q.921 header, so logging
+			 * the Q.931 message body after the transmit puts the sections of
+			 * the message in the right order in the log,
+			 */
+			q931_dump(ctrl, tei, h, len, 1);
+		}
 	} else {
+		/*
+		 * Indicate passing the Q.931 message to Q.921 first.  Q.921 may
+		 * have to request a TEI or bring the connection up before it can
+		 * actually send the message.  Therefore, the Q.931 message may
+		 * actually get sent a few seconds later.  Q.921 will dump the
+		 * Q.931 message as appropriate at that time.
+		 */
+		if (ctrl->debug & PRI_DEBUG_Q931_DUMP) {
+			q931_to_q921_passing_dump(ctrl, tei, h, len);
+		}
 		q921_transmit_iframe(ctrl, tei, h, len, cr);
 	}
 	return 0;




More information about the libpri-commits mailing list