diff rvinterf/g23sh/pktsort.c @ 336:922efdd65dce

g23sh written, compiles
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 22 Apr 2014 07:21:04 +0000
parents rvinterf/tmsh/pktsort.c@40b8557b9d04
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/g23sh/pktsort.c	Tue Apr 22 07:21:04 2014 +0000
@@ -0,0 +1,67 @@
+/*
+ * Here we sort out incoming packets from the target relayed via rvinterf.
+ */
+
+#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"
+#include "localtypes.h"
+
+extern u_char rvi_msg[];
+extern int rvi_msg_len;
+
+static void
+process_rvt()
+{
+	u32 useid;
+
+	if (rvi_msg_len < 7) {
+		tty_cleanup();
+		fprintf(stderr, "Error: rvinterf sent us an invalid RVT msg\n");
+		exit(1);
+	}
+	useid = rvi_msg[2] << 24 | rvi_msg[3] << 16 | rvi_msg[4] << 8
+		| rvi_msg[5];
+	switch (useid) {
+	case 0:
+		handle_useid_0();
+		return;
+	default:
+		tty_cleanup();
+		fprintf(stderr, "unexpected fwd of USEID %08X from rvinterf\n",
+			useid);
+		exit(1);
+	}
+}
+
+void
+g23_packet_rx()
+{
+	char fmtbuf[MAX_PKT_FROM_TARGET*8];	/* size it generously */
+
+	format_g23_packet(rvi_msg + 1, rvi_msg_len - 1, fmtbuf);
+	async_msg_output(fmtbuf);
+}
+
+void
+process_pkt_from_target()
+{
+	switch (rvi_msg[1]) {
+	case RVT_RV_HEADER:
+		process_rvt();
+		return;
+	case RVT_L23_HEADER:
+		g23_packet_rx();
+		return;
+	default:
+		tty_cleanup();
+		fprintf(stderr, "unexpected fwd of MUX %02X from rvinterf\n",
+			rvi_msg[1]);
+		exit(1);
+	}
+}