diff rvinterf/libasync/rvtrace.c @ 0:e7502631a0f9

initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 Jun 2016 00:13:35 +0000
parents
children 6a0aa8d36d06
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/libasync/rvtrace.c	Sat Jun 11 00:13:35 2016 +0000
@@ -0,0 +1,54 @@
+/*
+ * Here we detect and handle "Lost Message" packets.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include "pktmux.h"
+#include "limits.h"
+#include "localsock.h"
+
+extern u_char rvi_msg[];
+extern int rvi_msg_len;
+
+void
+safe_print_trace(src, srclen, dest)
+	u_char *src;
+	char *dest;
+{
+	int i, c;
+	char *dp;
+
+	dp = dest;
+	for (i = 0; i < srclen; i++) {
+		c = src[i];
+		if (c & 0x80) {
+			*dp++ = 'M';
+			*dp++ = '-';
+			c &= 0x7F;
+		}
+		if (c < 0x20) {
+			*dp++ = '^';
+			*dp++ = c + '@';
+		} else if (c == 0x7F) {
+			*dp++ = '^';
+			*dp++ = '?';
+		} else
+			*dp++ = c;
+	}
+	*dp = '\0';
+}
+
+void
+handle_useid_0()
+{
+	char buf[MAX_PKT_FROM_TARGET*4];
+
+	if (strncmp(rvi_msg + 7, "RVT: Lost Message", 17))
+		return;
+	safe_print_trace(rvi_msg + 7, rvi_msg_len - 7, buf);
+	async_msg_output(buf);
+}