changeset 976:ca65f5adf1af

rvinterf: print old ASCII GPF traces emitted by 20020917 firmware on D-Sample
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sun, 29 Nov 2015 05:22:41 +0000
parents 0d7cc054ef72
children ce0ded19a769
files rvinterf/libg23/fmtdispatch.c
diffstat 1 files changed, 42 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/libg23/fmtdispatch.c	Sun Nov 15 04:26:10 2015 +0000
+++ b/rvinterf/libg23/fmtdispatch.c	Sun Nov 29 05:22:41 2015 +0000
@@ -54,7 +54,7 @@
 }
 
 static void
-print_malformed(rxpkt, rxpkt_len, outbuf)
+print_unknown_bin(rxpkt, rxpkt_len, outbuf)
 	u_char *rxpkt;
 	char *outbuf;
 {
@@ -71,6 +71,47 @@
 	*dp = '\0';
 }
 
+static void
+print_old_ascii(rxpkt, rxpkt_len, outbuf)
+	u_char *rxpkt;
+	char *outbuf;
+{
+	char *dp;
+	int txtlen = rxpkt_len - 1;
+
+	dp = outbuf;
+	strcpy(dp, "GPF ASC: ");
+	dp += 9;
+	bcopy(rxpkt + 1, dp, txtlen);
+	dp += txtlen;
+	*dp = '\0';
+}
+
+static int
+is_old_ascii(rxpkt, rxpkt_len)
+	u_char *rxpkt;
+{
+	int i, c;
+
+	for (i = 1; i < rxpkt_len; i++) {
+		c = rxpkt[i];
+		if (c < ' ' || c > '~')
+			return(0);
+	}
+	return(1);
+}
+
+static void
+print_malformed(rxpkt, rxpkt_len, outbuf)
+	u_char *rxpkt;
+	char *outbuf;
+{
+	if (is_old_ascii(rxpkt, rxpkt_len))
+		print_old_ascii(rxpkt, rxpkt_len, outbuf);
+	else
+		print_unknown_bin(rxpkt, rxpkt_len, outbuf);
+}
+
 void
 format_g23_packet(rxpkt, rxpkt_len, outbuf)
 	u_char *rxpkt;