changeset 964:373af5f74e39

rvinterf: all retired stuff gathered under old
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Fri, 06 Nov 2015 23:22:47 +0000
parents d69d1e097b18
children bd873572ef2c
files rvinterf/g23sh/Makefile rvinterf/g23sh/init.c rvinterf/g23sh/main.c rvinterf/g23sh/pktsort.c rvinterf/g23sh/sendsp.c rvinterf/g23sh/usercmd.c rvinterf/misc/Makefile rvinterf/misc/rvifsend.c rvinterf/misc/sendsp.c rvinterf/old/Makefile rvinterf/old/before-rvinterf/Makefile rvinterf/old/before-rvinterf/etmsend.c rvinterf/old/before-rvinterf/log.c rvinterf/old/before-rvinterf/openport.c rvinterf/old/before-rvinterf/packetrx.c rvinterf/old/before-rvinterf/packettx.c rvinterf/old/before-rvinterf/pktmux.h rvinterf/old/before-rvinterf/rvtdump.c rvinterf/old/before-rvinterf/rvtdump_tx.c rvinterf/old/before-rvinterf/trdump.c rvinterf/old/before-rvinterf/txpkt.h rvinterf/old/etmsend.c rvinterf/old/g23sh/Makefile rvinterf/old/g23sh/init.c rvinterf/old/g23sh/main.c rvinterf/old/g23sh/pktsort.c rvinterf/old/g23sh/sendsp.c rvinterf/old/g23sh/usercmd.c rvinterf/old/log.c rvinterf/old/openport.c rvinterf/old/packetrx.c rvinterf/old/packettx.c rvinterf/old/pktmux.h rvinterf/old/rvtdump.c rvinterf/old/rvtdump_tx.c rvinterf/old/sendsp/Makefile rvinterf/old/sendsp/rvifsend.c rvinterf/old/sendsp/sendsp.c rvinterf/old/trdump.c rvinterf/old/txpkt.h
diffstat 40 files changed, 1243 insertions(+), 1243 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/g23sh/Makefile	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-CC=	gcc
-CFLAGS=	-O2 -I../include
-PROG=	g23sh
-OBJS=	init.o main.o pktsort.o sendsp.o usercmd.o
-LIBS=	../libasync/libasync.a ../libg23/libg23.a
-INSTBIN=/usr/local/bin
-
-all:	${PROG}
-
-${PROG}: ${OBJS} ${LIBS}
-	${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS}
-
-install:	${PROG}
-	mkdir -p ${INSTBIN}
-	install -c ${PROG} ${INSTBIN}
-
-clean:
-	rm -f *.o *.out *errs ${PROG}
--- a/rvinterf/g23sh/init.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * This module contains the initialization code for g23sh.
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-#include "pktmux.h"
-#include "localsock.h"
-
-extern int sock;
-
-init()
-{
-	static u_char want_rvt_lost[9] = {CLI2RVI_WANT_RVTRACE,
-					  0xFF, 0xFF, 0xFF, 0xFF,
-					  0x00, 0x00, 0x00, 0x00};
-	static u_char want_l23_mux[2] = {CLI2RVI_WANT_MUXPROTO, RVT_L23_HEADER};
-
-	if (!sock)
-		connect_local_socket();
-	localsock_prep_for_length_rx();
-	send_init_command(want_rvt_lost, 9);
-	send_init_command(want_l23_mux, 2);
-}
--- a/rvinterf/g23sh/main.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * This module contains the main() function for g23sh.
- */
-
-#include <sys/types.h>
-#include <sys/errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-char *socket_pathname = "/tmp/rvinterf_socket";
-int ttyhacks, dflag;
-
-int sock;
-
-extern char *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
-
-main(argc, argv)
-	char **argv;
-{
-	extern int optind;
-	extern char *optarg;
-	int c;
-	fd_set fds;
-
-	while ((c = getopt(argc, argv, "B:dl:s:w:")) != EOF)
-		switch (c) {
-		case 'B':
-			rvinterf_Bopt = optarg;
-			continue;
-		case 'd':
-			dflag++;
-			continue;
-		case 'l':
-			rvinterf_lopt = optarg;
-			continue;
-		case 's':
-			socket_pathname = optarg;
-			continue;
-		case 'w':
-			rvinterf_wopt = optarg;
-			continue;
-		case '?':
-		default:
-usage:			fprintf(stderr,
-				"usage: %s [options] [ttyport]\n", argv[0]);
-			exit(1);
-		}
-	switch (argc - optind) {
-	case 0:
-		if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) {
-			fprintf(stderr,
-      "%s: -B, -l and -w options are meaningful only when launching rvinterf\n",
-				argv[0]);
-			exit(1);
-		}
-		break;
-	case 1:
-		launch_rvinterf(argv[optind]);
-		break;
-	default:
-		goto usage;
-	}
-
-	ttyhacks = isatty(0) && !dflag;
-	init();
-	tty_init();
-	for (;;) {
-		FD_ZERO(&fds);
-		FD_SET(0, &fds);
-		FD_SET(sock, &fds);
-		c = select(sock+1, &fds, 0, 0, 0);
-		if (c < 0) {
-			if (errno == EINTR)
-				continue;
-			tty_cleanup();
-			perror("select");
-			exit(1);
-		}
-		if (FD_ISSET(0, &fds))
-			handle_tty_input();
-		if (FD_ISSET(sock, &fds))
-			handle_rvinterf_input();
-		fflush(stdout);
-	}
-}
--- a/rvinterf/g23sh/pktsort.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * 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);
-	}
-}
--- a/rvinterf/g23sh/sendsp.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * g23sh system primitive sending command
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-#include "pktmux.h"
-#include "limits.h"
-
-void
-cmd_sendsp(argc, argv)
-	char **argv;
-{
-	char *stackdest, *primarg;
-	unsigned intlen;
-	u_char sendpkt[MAX_PKT_TO_TARGET+1];
-	unsigned pktlen;
-
-	stackdest = argv[1];
-	primarg = argv[2];
-	if (strlen(stackdest) > 4) {
-		printf(
-		  "error: stack destination arg may not exceed 4 characters\n");
-		return;
-	}
-	intlen = 12 + strlen(primarg);
-	pktlen = intlen + 4;
-	if (pktlen > MAX_PKT_TO_TARGET) {
-		printf("error: max pkt to target limit exceeded\n");
-		return;
-	}
-	/* fill out the packet */
-	sendpkt[0] = RVT_L23_HEADER;
-	sendpkt[1] = 0xB7;	/* system prim */
-	sendpkt[2] = intlen;
-	sendpkt[3] = intlen >> 8;
-	/* send zeros for the timestamp */
-	sendpkt[4] = 0;
-	sendpkt[5] = 0;
-	sendpkt[6] = 0;
-	sendpkt[7] = 0;
-	/* as far as TI's sw is concerned, we are PCO */
-	sendpkt[8] = 'P';
-	sendpkt[9] = 'C';
-	sendpkt[10] = 'O';
-	sendpkt[11] = ' ';
-	sprintf(sendpkt + 12, "%-4s%s", stackdest, primarg);
-	/* send it! */
-	send_pkt_to_target(sendpkt, pktlen);
-}
--- a/rvinterf/g23sh/usercmd.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
- * This module implements g23sh user command dispatch.
- */
-
-#include <sys/types.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-
-extern char usercmd[];
-
-extern void cmd_sendsp();
-
-void
-cmd_exit()
-{
-	tty_cleanup();
-	exit(0);
-}
-
-static struct cmdtab {
-	char *cmd;
-	int minargs;
-	int maxargs;
-	void (*func)();
-} cmdtab[] = {
-	{"exit", 0, 0, cmd_exit},
-	{"quit", 0, 0, cmd_exit},
-	{"sp", 2, 2, cmd_sendsp},
-	{0, 0, 0, 0}
-};
-
-void
-dispatch_user_cmd()
-{
-	char *argv[10];
-	char *cp, **ap;
-	struct cmdtab *tp;
-
-	for (cp = usercmd; isspace(*cp); cp++)
-		;
-	if (!*cp || *cp == '#')
-		return;
-	argv[0] = cp;
-	while (*cp && !isspace(*cp))
-		cp++;
-	if (*cp)
-		*cp++ = '\0';
-	for (tp = cmdtab; tp->cmd; tp++)
-		if (!strcmp(tp->cmd, argv[0]))
-			break;
-	if (!tp->func) {
-		printf("error: no such command\n");
-		return;
-	}
-	for (ap = argv + 1; ; ) {
-		while (isspace(*cp))
-			cp++;
-		if (!*cp || *cp == '#')
-			break;
-		if (ap - argv - 1 >= tp->maxargs) {
-			printf("error: too many arguments\n");
-			return;
-		}
-		if (*cp == '"') {
-			*ap++ = ++cp;
-			while (*cp && *cp != '"')
-				cp++;
-			if (*cp != '"') {
-				printf("error: unterminated quoted string\n");
-				return;
-			}
-			*cp++ = '\0';
-		} else {
-			*ap++ = cp;
-			while (*cp && !isspace(*cp))
-				cp++;
-			if (*cp)
-				*cp++ = '\0';
-		}
-	}
-	if (ap - argv - 1 < tp->minargs) {
-		printf("error: too few arguments\n");
-		return;
-	}
-	*ap = 0;
-	tp->func(ap - argv, argv);
-}
--- a/rvinterf/misc/Makefile	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-CC=	gcc
-CFLAGS=	-O2 -I../include
-PROGS=	fc-sendsp
-INSTBIN=/usr/local/bin
-
-SENDSP_OBJS=	rvifsend.o sendsp.o
-
-all:	${PROGS}
-
-fc-sendsp:	${SENDSP_OBJS}
-	${CC} ${CFLAGS} -o $@ ${SENDSP_OBJS}
-
-install:	${PROGS}
-	mkdir -p ${INSTBIN}
-	install -c ${PROGS} ${INSTBIN}
-
-clean:
-	rm -f *.o *.out *errs ${PROGS}
--- a/rvinterf/misc/rvifsend.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * This module is currently linked by fc-sendsp, and may be used by
- * other similar hack-utilities in the future.  Here we connect to
- * rvinterf, send one packet to the target, and call it done.
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "localsock.h"
-
-extern char *socket_pathname;
-
-send_pkt_to_target(pkt, pktlen)
-	u_char *pkt;
-	unsigned pktlen;
-{
-	/* local socket binding voodoo copied from osmocon */
-	struct sockaddr_un local;
-	unsigned int namelen;
-	int sock, rc;
-	u_char hdrbuf[3];
-	int len1;
-
-	sock = socket(AF_UNIX, SOCK_STREAM, 0);
-	if (sock < 0) {
-		perror("socket(AF_UNIX, SOCK_STREAM, 0)");
-		exit(1);
-	}
-
-	local.sun_family = AF_UNIX;
-	strncpy(local.sun_path, socket_pathname, sizeof(local.sun_path));
-	local.sun_path[sizeof(local.sun_path) - 1] = '\0';
-
-	/* we use the same magic that X11 uses in Xtranssock.c for
-	 * calculating the proper length of the sockaddr */
-#if defined(BSD44SOCKETS) || defined(__UNIXWARE__)
-	local.sun_len = strlen(local.sun_path);
-#endif
-#if defined(BSD44SOCKETS) || defined(SUN_LEN)
-	namelen = SUN_LEN(&local);
-#else
-	namelen = strlen(local.sun_path) +
-		  offsetof(struct sockaddr_un, sun_path) + 1;
-#endif
-
-	rc = connect(sock, (struct sockaddr *) &local, namelen);
-	if (rc != 0) {
-		perror(socket_pathname);
-		exit(1);
-	}
-
-	len1 = pktlen + 1;
-	hdrbuf[0] = len1 >> 8;
-	hdrbuf[1] = len1 & 0xFF;
-	hdrbuf[2] = CLI2RVI_PKT_TO_TARGET;
-	write(sock, hdrbuf, 3);
-	write(sock, pkt, pktlen);
-	close(sock);
-	return(0);
-}
--- a/rvinterf/misc/sendsp.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * This hack-utility sends a GPF System Primitive given on the command line
- * to a target GSM device via rvinterf.
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-#include "pktmux.h"
-#include "limits.h"
-
-char *socket_pathname = "/tmp/rvinterf_socket";
-
-main(argc, argv)
-	char **argv;
-{
-	char *stackdest, *primarg;
-	unsigned intlen;
-	u_char sendpkt[MAX_PKT_TO_TARGET];
-	unsigned pktlen;
-
-	if (argc < 3) {
-usage:		fprintf(stderr, "usage: %s [-s socket] stackdest primarg\n",
-			argv[0]);
-		exit(1);
-	}
-	if (strcmp(argv[1], "-s")) {
-		if (argc != 3)
-			goto usage;
-		stackdest = argv[1];
-		primarg = argv[2];
-	} else {
-		if (argc != 5)
-			goto usage;
-		socket_pathname = argv[2];
-		stackdest = argv[3];
-		primarg = argv[4];
-	}
-	if (strlen(stackdest) > 4) {
-		fprintf(stderr,
-		"error: stack destination arg may not exceed 4 characters\n");
-		exit(1);
-	}
-	intlen = 12 + strlen(primarg) + 1;
-	pktlen = intlen + 4;
-	if (pktlen > MAX_PKT_TO_TARGET) {
-		fprintf(stderr, "error: max pkt to target limit exceeded\n");
-		exit(1);
-	}
-	/* fill out the packet */
-	sendpkt[0] = RVT_L23_HEADER;
-	sendpkt[1] = 0xB7;	/* system prim */
-	sendpkt[2] = intlen;
-	sendpkt[3] = intlen >> 8;
-	/* send zeros for the timestamp */
-	sendpkt[4] = 0;
-	sendpkt[5] = 0;
-	sendpkt[6] = 0;
-	sendpkt[7] = 0;
-	/* as far as TI's sw is concerned, we are PCO */
-	sendpkt[8] = 'P';
-	sendpkt[9] = 'C';
-	sendpkt[10] = 'O';
-	sendpkt[11] = ' ';
-	sprintf(sendpkt + 12, "%-4s%s", stackdest, primarg);
-	/* send it! */
-	send_pkt_to_target(sendpkt, pktlen);
-	exit(0);
-}
--- a/rvinterf/old/Makefile	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-CC=	gcc
-CFLAGS=	-O2
-PROGS=	rvtdump
-XPROGS=	etmsend
-INSTBIN=/usr/local/bin
-
-RVTDUMP_OBJS=	log.o openport.o packetrx.o packettx.o rvtdump.o rvtdump_tx.o \
-		trdump.o
-
-all:	${PROGS} ${XPROGS}
-
-rvtdump:	${RVTDUMP_OBJS}
-	${CC} ${CFLAGS} -o $@ ${RVTDUMP_OBJS}
-
-etmsend:	etmsend.c
-	${CC} ${CFLAGS} -o $@ $@.c
-
-install:	${PROGS}
-	mkdir -p ${INSTBIN}
-	install -c ${PROGS} ${INSTBIN}
-
-clean:
-	rm -f *.o *.out *errs ${PROGS} ${XPROGS}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/before-rvinterf/Makefile	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,23 @@
+CC=	gcc
+CFLAGS=	-O2
+PROGS=	rvtdump
+XPROGS=	etmsend
+INSTBIN=/usr/local/bin
+
+RVTDUMP_OBJS=	log.o openport.o packetrx.o packettx.o rvtdump.o rvtdump_tx.o \
+		trdump.o
+
+all:	${PROGS} ${XPROGS}
+
+rvtdump:	${RVTDUMP_OBJS}
+	${CC} ${CFLAGS} -o $@ ${RVTDUMP_OBJS}
+
+etmsend:	etmsend.c
+	${CC} ${CFLAGS} -o $@ $@.c
+
+install:	${PROGS}
+	mkdir -p ${INSTBIN}
+	install -c ${PROGS} ${INSTBIN}
+
+clean:
+	rm -f *.o *.out *errs ${PROGS} ${XPROGS}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/before-rvinterf/etmsend.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,79 @@
+/*
+ * This program is a hack that sends a hand-crafted ETM packet
+ * to the UNIX-local dgram socket established by rvtdump with -s option.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "pktmux.h"
+#include "txpkt.h"
+
+char sockpath[] = "/tmp/rvt_send_socket";
+
+u_char packet[MAX_PKT_TO_TARGET];
+int payload_len;
+
+main(argc, argv)
+	char **argv;
+{
+	int i, c, s;
+	struct sockaddr_un local;
+	unsigned int namelen;
+
+	if (argc < 2) {
+		fprintf(stderr, "usage: %s hexbytes...\n", argv[0]);
+		exit(1);
+	}
+	payload_len = argc - 1;
+	if (payload_len > MAX_PKT_TO_TARGET-2) {
+		fprintf(stderr,
+			"%s: too many bytes (packet length limit exceeded)\n",
+			argv[0]);
+		exit(1);
+	}
+
+	packet[0] = RVT_TM_HEADER;
+	for (i = 1; i <= payload_len; i++)
+		packet[i] = strtoul(argv[i], 0, 16);
+	c = 0;
+	for (i = 1; i <= payload_len; i++)
+		c ^= packet[i];
+	packet[payload_len+1] = c;
+
+	s = socket(AF_UNIX, SOCK_DGRAM, 0);
+	if (s < 0) {
+		perror("socket(AF_UNIX, SOCK_DGRAM, 0)");
+		exit(1);
+	}
+
+	local.sun_family = AF_UNIX;
+	strncpy(local.sun_path, sockpath, sizeof(local.sun_path));
+	local.sun_path[sizeof(local.sun_path) - 1] = '\0';
+
+	/* we use the same magic that X11 uses in Xtranssock.c for
+	 * calculating the proper length of the sockaddr */
+#if defined(BSD44SOCKETS) || defined(__UNIXWARE__)
+	local.sun_len = strlen(local.sun_path);
+#endif
+#if defined(BSD44SOCKETS) || defined(SUN_LEN)
+	namelen = SUN_LEN(&local);
+#else
+	namelen = strlen(local.sun_path) +
+		  offsetof(struct sockaddr_un, sun_path);
+#endif
+
+	i = sendto(s, packet, payload_len+2, 0,
+			(struct sockaddr *) &local, namelen);
+	if (i < 0) {
+		perror("sendto");
+		exit(1);
+	}
+
+	exit(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/before-rvinterf/log.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,50 @@
+/*
+ * This module implements the logging function
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+
+extern char pr_item[];
+
+extern FILE *logF;
+extern time_t logtime;
+
+static struct tm last_tm;
+
+log_item()
+{
+	struct tm *curtm;
+
+	curtm = gmtime(&logtime);
+	if (curtm->tm_year != last_tm.tm_year ||
+	    curtm->tm_mon != last_tm.tm_mon ||
+	    curtm->tm_mday != last_tm.tm_mday)
+		fprintf(logF, "%d-%02d-%02d (gmtime):\n", curtm->tm_year + 1900,
+			curtm->tm_mon+1, curtm->tm_mday);
+	fprintf(logF, "[%02d:%02d:%02d] %s\n", curtm->tm_hour, curtm->tm_min,
+		curtm->tm_sec, pr_item);
+	bcopy(curtm, &last_tm, sizeof(struct tm));
+}
+
+log_sent_packet(pkt, pktlen)
+	u_char *pkt;
+{
+	int i;
+	char *dp;
+
+	dp = pr_item;
+	strcpy(dp, "Sent");
+	dp += 4;
+	for (i = 0; i < pktlen; i++) {
+		sprintf(dp, " %02X", pkt[i]);
+		dp += 3;
+	}
+	*dp = '\0';
+	print_item();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/before-rvinterf/openport.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,82 @@
+/*
+ * This module takes care of opening the serial port and setting the
+ * proper "raw" termios modes, including the baud rate.
+ */
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <unistd.h>
+
+int target_fd;
+char *baudrate_name = "115200";
+
+static struct baudrate {
+	char	*name;
+	speed_t	termios_code;
+} baud_rate_table[] = {
+	{"19200",	B19200},
+	{"38400",	B38400},
+	{"57600",	B57600},
+	{"115200",	B115200},
+	/* non-standard high baud rates "remapped" by CP2102 usb2serial IC */
+	{"203125",	B230400},
+	{"406250",	B460800},
+	{"812500",	B921600},
+	/* table search terminator */
+	{NULL,		B0}
+};
+
+static speed_t
+get_baud_rate()
+{
+	struct baudrate *br;
+
+	for (br = baud_rate_table; br->name; br++)
+		if (!strcmp(br->name, baudrate_name))
+			break;
+	if (!br->name) {
+		fprintf(stderr, "baud rate \"%s\" unknown/unsupported\n",
+			baudrate_name);
+		exit(1);
+	}
+	return br->termios_code;
+}
+
+open_target_serial(ttydev)
+	char *ttydev;
+{
+	struct termios target_termios;
+	speed_t br_code;
+
+	br_code = get_baud_rate();
+	target_fd = open(ttydev, O_RDWR|O_NONBLOCK);
+	if (target_fd < 0) {
+		perror(ttydev);
+		exit(1);
+	}
+	target_termios.c_iflag = IGNBRK;
+	target_termios.c_oflag = 0;
+	target_termios.c_cflag = CLOCAL|HUPCL|CREAD|CS8;
+	target_termios.c_lflag = 0;
+	target_termios.c_cc[VMIN] = 1;
+	target_termios.c_cc[VTIME] = 0;
+	cfsetispeed(&target_termios, br_code);
+	cfsetospeed(&target_termios, br_code);
+	if (tcsetattr(target_fd, TCSAFLUSH, &target_termios) < 0) {
+		perror("initial tcsetattr on target");
+		exit(1);
+	}
+	return 0;
+}
+
+set_serial_nonblock(state)
+	int state;
+{
+	ioctl(target_fd, FIONBIO, &state);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/before-rvinterf/packetrx.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,88 @@
+/*
+ * This module handles the lowest level of serial packet Rx
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "pktmux.h"
+
+extern int target_fd;
+
+#define	MAXPKT	512
+u_char rxpkt[MAXPKT];
+size_t rxpkt_len;
+
+extern char pr_item[];
+
+static int in_pkt, dle_state, toobig;
+
+static void
+process_inbyte(inb)
+{
+	if (!in_pkt) {
+		if (inb != STX || dle_state) {
+			rxpkt_len++;
+			dle_state = (inb == DLE);
+			return;
+		}
+		if (rxpkt_len) {
+			sprintf(pr_item,
+				"Warning: Rx %u byte%s outside of a packet",
+				(unsigned)rxpkt_len, rxpkt_len != 1 ? "s" : "");
+			print_item();
+			rxpkt_len = 0;
+		}
+		in_pkt = 1;
+		toobig = 0;
+		return;
+	}
+	if (dle_state) {
+		dle_state = 0;
+		if (inb != STX && inb != DLE) {
+			sprintf(pr_item,
+				"Rx framing error: %02X after DLE\n", inb);
+			print_item();
+			in_pkt = 0;
+			rxpkt_len = 0;
+			return;
+		}
+		goto data;
+	}
+	if (inb == DLE) {
+		dle_state = 1;
+		return;
+	} else if (inb == STX) {
+		if (!rxpkt_len)
+			return;
+		in_pkt = 0;
+		handle_rx_packet();
+		rxpkt_len = 0;
+		return;
+	}
+data:	if (rxpkt_len >= MAXPKT) {
+		if (!toobig) {
+			sprintf(pr_item, "Error: Rx packet too big!\n");
+			print_item();
+			toobig = 1;
+		}
+		return;
+	}
+	rxpkt[rxpkt_len++] = inb;
+}
+
+void
+process_serial_rx()
+{
+	u_char rdbuf[512];
+	int cc, i;
+
+	cc = read(target_fd, rdbuf, sizeof rdbuf);
+	if (cc <= 0) {
+		perror("Error/EOF reading from target");
+		exit(1);
+	}
+	for (i = 0; i < cc; i++)
+		process_inbyte(rdbuf[i]);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/before-rvinterf/packettx.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,32 @@
+/*
+ * This module handles the lowest level of serial packet Tx
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "pktmux.h"
+#include "txpkt.h"
+
+extern int target_fd;
+
+send_pkt_to_target(pkt, pktlen)
+	u_char *pkt;
+{
+	u_char buf[MAX_PKT_TO_TARGET*2+2];
+	u_char *cp, *dp, *endp;
+	int c;
+
+	endp = pkt + pktlen;
+	dp = buf;
+	*dp++ = STX;
+	for (cp = pkt; cp < endp; cp++) {
+		c = *cp;
+		if (c == STX || c == DLE)
+			*dp++ = DLE;
+		*dp++ = c;
+	}
+	*dp++ = STX;
+	write(target_fd, buf, dp - buf);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/before-rvinterf/pktmux.h	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,16 @@
+/*
+ * Definitions for the RVT MUX over-the-wire protocol
+ */
+
+#define	STX	0x02
+#define	DLE	0x10
+
+#define RVT_RV_HEADER        0x11
+#define RVT_L1_HEADER        0x12
+#define RVT_L23_HEADER       0x13
+#define RVT_TM_HEADER        0x14
+#define RVT_RNET_HEADER      0x15
+#define RVT_PROF_HEADER      0x16
+#define RVT_GTTBACK_HEADER   0x17
+#define RVT_OTHER_HEADER     0x18
+#define RVT_INVALID_HEADER   0xFF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/before-rvinterf/rvtdump.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,123 @@
+/*
+ * This program reads bytes from a serial port, parses them assuming
+ * TI's RVT MUX format, and prints every decoded packet.
+ */
+
+#include <sys/types.h>
+#include <sys/errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+
+extern int target_fd;
+extern char *baudrate_name;
+
+extern char pr_item[];
+extern int sendsock_fd;
+
+char *logfname;
+FILE *logF;
+time_t logtime;
+int background, sendsock_enable;
+
+main(argc, argv)
+	char **argv;
+{
+	extern char *optarg;
+	extern int optind;
+	int c, maxfd;
+	fd_set fds;
+
+	while ((c = getopt(argc, argv, "bB:d:l:s")) != EOF)
+		switch (c) {
+		case 'b':
+			background++;
+			continue;
+		case 'B':
+			baudrate_name = optarg;
+			continue;
+		case 'd':
+			target_fd = atoi(optarg);
+			continue;
+		case 'l':
+			logfname = optarg;
+			continue;
+		case 's':
+			sendsock_enable++;
+			continue;
+		case '?':
+		default:
+usage:			fprintf(stderr,
+			"usage: %s [options] ttyport\n", argv[0]);
+			exit(1);
+		}
+	if (background && !logfname) {
+		fprintf(stderr, "%s: -b is meaningless without -l\n", argv[0]);
+		exit(1);
+	}
+	if (target_fd <= 0) {
+		if (argc - optind != 1)
+			goto usage;
+		open_target_serial(argv[optind]);
+	}
+
+	set_serial_nonblock(0);
+	setlinebuf(stdout);
+	if (logfname) {
+		logF = fopen(logfname, "w");
+		if (!logF) {
+			perror(logfname);
+			exit(1);
+		}
+		fprintf(logF, "*** Log of decoded RVT output ***\n");
+		setlinebuf(logF);
+	}
+	if (sendsock_enable)
+		create_send_socket();
+	if (background) {
+		c = fork();
+		if (c < 0) {
+			perror("fork");
+			exit(1);
+		}
+		if (c) {
+			printf("rvtdump forked into background (pid %d)\n", c);
+			exit(0);
+		}
+	}
+	maxfd = target_fd;
+	if (sendsock_fd > maxfd)
+		maxfd = sendsock_fd;
+	for (;;) {
+		FD_ZERO(&fds);
+		FD_SET(target_fd, &fds);
+		if (sendsock_enable)
+			FD_SET(sendsock_fd, &fds);
+		c = select(maxfd+1, &fds, 0, 0, 0);
+		time(&logtime);
+		if (c < 0) {
+			if (errno == EINTR)
+				continue;
+			perror("select");
+			exit(1);
+		}
+		if (FD_ISSET(target_fd, &fds))
+			process_serial_rx();
+		if (FD_ISSET(sendsock_fd, &fds))
+			handle_sendsock();
+	}
+}
+
+handle_rx_packet()
+{
+	print_rx_packet();
+}
+
+print_item()
+{
+	if (!background)
+		printf("%s\n", pr_item);
+	if (logF)
+		log_item();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/before-rvinterf/rvtdump_tx.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,70 @@
+/*
+ * This module contains the implementation of the Tx extension to rvtdump
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "txpkt.h"
+
+static char sockpath[] = "/tmp/rvt_send_socket";
+
+int sendsock_fd;
+u_char sendsock_pkt[MAX_PKT_TO_TARGET];
+int sendsock_pktlen;
+
+create_send_socket()
+{
+	/* local socket binding voodoo copied from osmocon */
+	struct sockaddr_un local;
+	unsigned int namelen;
+	int rc;
+
+	sendsock_fd = socket(AF_UNIX, SOCK_DGRAM, 0);
+	if (sendsock_fd < 0) {
+		perror("socket(AF_UNIX, SOCK_DGRAM, 0)");
+		exit(1);
+	}
+
+	local.sun_family = AF_UNIX;
+	strncpy(local.sun_path, sockpath, sizeof(local.sun_path));
+	local.sun_path[sizeof(local.sun_path) - 1] = '\0';
+	unlink(local.sun_path);
+
+	/* we use the same magic that X11 uses in Xtranssock.c for
+	 * calculating the proper length of the sockaddr */
+#if defined(BSD44SOCKETS) || defined(__UNIXWARE__)
+	local.sun_len = strlen(local.sun_path);
+#endif
+#if defined(BSD44SOCKETS) || defined(SUN_LEN)
+	namelen = SUN_LEN(&local);
+#else
+	namelen = strlen(local.sun_path) +
+		  offsetof(struct sockaddr_un, sun_path);
+#endif
+
+	rc = bind(sendsock_fd, (struct sockaddr *) &local, namelen);
+	if (rc != 0) {
+		perror("bind on local dgram socket");
+		exit(1);
+	}
+
+	return(0);
+}
+
+handle_sendsock()
+{
+	sendsock_pktlen = recv(sendsock_fd, sendsock_pkt, MAX_PKT_TO_TARGET, 0);
+	if (sendsock_pktlen <= 0) {
+		fprintf(stderr, "return value from recv on socket: %d\n",
+			sendsock_pktlen);
+		exit(1);
+	}
+	send_pkt_to_target(sendsock_pkt, sendsock_pktlen);
+	log_sent_packet(sendsock_pkt, sendsock_pktlen);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/before-rvinterf/trdump.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,169 @@
+/*
+ * This module implements the basic dump of any incoming packets
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include "pktmux.h"
+
+extern u_char rxpkt[];
+extern size_t rxpkt_len;
+
+char pr_item[4096];
+
+void
+print_rv_trace()
+{
+	int i, c;
+	char *dp;
+
+	dp = pr_item;
+	strcpy(dp, "RV ");
+	dp += 3;
+	/* the SWE static ID is sent MSB first */
+	for (i = 1; i <= 4; i++) {
+		sprintf(dp, "%02X", rxpkt[i]);
+		dp += 2;
+	}
+	/* severity level */
+	sprintf(dp, " %d ", rxpkt[5]);
+	dp = index(dp, '\0');
+	for (i = 6; i < rxpkt_len; i++) {
+		c = rxpkt[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';
+	print_item();
+}
+
+void
+print_l1_trace()
+{
+	int i, c;
+	char *dp;
+
+	dp = pr_item;
+	strcpy(dp, "L1: ");
+	dp += 4;
+	for (i = 1; i < rxpkt_len; i++) {
+		if ((i+1 < rxpkt_len) &&
+		    (rxpkt[i] == '\r' && rxpkt[i+1] == '\n' ||
+		     rxpkt[i] == '\n' && rxpkt[i+1] == '\r')) {
+			*dp = '\0';
+			print_item();
+			if (i+2 == rxpkt_len)
+				return;
+			dp = pr_item;
+			*dp++ = '+';
+			*dp++ = ' ';
+			i++;
+			continue;
+		}
+		c = rxpkt[i];
+		if (c & 0x80) {
+			*dp++ = 'M';
+			*dp++ = '-';
+			c &= 0x7F;
+		}
+		if (c < 0x20) {
+			*dp++ = '^';
+			*dp++ = c + '@';
+		} else if (c == 0x7F) {
+			*dp++ = '^';
+			*dp++ = '?';
+		} else
+			*dp++ = c;
+	}
+	/* will get here only if no newline sequence at the end */
+	*dp = '\0';
+	print_item();
+}
+
+void
+print_g23_trace()
+{
+	int i;
+	char *dp;
+
+	dp = pr_item;
+	strcpy(dp, "G23:");
+	dp += 4;
+	for (i = 1; i < rxpkt_len; i++) {
+		sprintf(dp, " %02X", rxpkt[i]);
+		dp += 3;
+	}
+	*dp = '\0';
+	print_item();
+}
+
+void
+print_etm_output_raw()
+{
+	int i;
+	char *dp;
+
+	dp = pr_item;
+	strcpy(dp, "ETM:");
+	dp += 4;
+	for (i = 1; i < rxpkt_len; i++) {
+		sprintf(dp, " %02X", rxpkt[i]);
+		dp += 3;
+	}
+	*dp = '\0';
+	print_item();
+}
+
+void
+print_unknown_packet()
+{
+	int i;
+	char *dp;
+
+	dp = pr_item;
+	strcpy(dp, "UNK:");
+	dp += 4;
+	for (i = 0; i < rxpkt_len; i++) {
+		sprintf(dp, " %02X", rxpkt[i]);
+		dp += 3;
+	}
+	*dp = '\0';
+	print_item();
+}
+
+void
+print_rx_packet()
+{
+	switch (rxpkt[0]) {
+	case RVT_RV_HEADER:
+		if (rxpkt_len < 6)
+			goto unknown;
+		print_rv_trace();
+		return;
+	case RVT_L1_HEADER:
+		print_l1_trace();
+		return;
+	case RVT_L23_HEADER:
+		print_g23_trace();
+		return;
+	case RVT_TM_HEADER:
+		print_etm_output_raw();
+		return;
+	default:
+	unknown:
+		print_unknown_packet();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/before-rvinterf/txpkt.h	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,15 @@
+/*
+ * For sizing our buffers etc in rvinterf, we need a limit on the size of
+ * message packets we can send to the target.  As it happens, the packet
+ * Rx code in RVT on the target side also has a limit (quite naturally,
+ * as it needs to use a static buffer to reassemble incoming packets as
+ * they arrive at the UART in unpredictable interrupt-sized chunks), so
+ * we set our limit to match that in RVT.
+ */
+
+#define	MAX_PKT_TO_TARGET	255
+
+/*
+ * The above limit definition counts all bytes between the opening and
+ * closing STX flags, but not DLEs inserted for binary transparency.
+ */
--- a/rvinterf/old/etmsend.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * This program is a hack that sends a hand-crafted ETM packet
- * to the UNIX-local dgram socket established by rvtdump with -s option.
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "pktmux.h"
-#include "txpkt.h"
-
-char sockpath[] = "/tmp/rvt_send_socket";
-
-u_char packet[MAX_PKT_TO_TARGET];
-int payload_len;
-
-main(argc, argv)
-	char **argv;
-{
-	int i, c, s;
-	struct sockaddr_un local;
-	unsigned int namelen;
-
-	if (argc < 2) {
-		fprintf(stderr, "usage: %s hexbytes...\n", argv[0]);
-		exit(1);
-	}
-	payload_len = argc - 1;
-	if (payload_len > MAX_PKT_TO_TARGET-2) {
-		fprintf(stderr,
-			"%s: too many bytes (packet length limit exceeded)\n",
-			argv[0]);
-		exit(1);
-	}
-
-	packet[0] = RVT_TM_HEADER;
-	for (i = 1; i <= payload_len; i++)
-		packet[i] = strtoul(argv[i], 0, 16);
-	c = 0;
-	for (i = 1; i <= payload_len; i++)
-		c ^= packet[i];
-	packet[payload_len+1] = c;
-
-	s = socket(AF_UNIX, SOCK_DGRAM, 0);
-	if (s < 0) {
-		perror("socket(AF_UNIX, SOCK_DGRAM, 0)");
-		exit(1);
-	}
-
-	local.sun_family = AF_UNIX;
-	strncpy(local.sun_path, sockpath, sizeof(local.sun_path));
-	local.sun_path[sizeof(local.sun_path) - 1] = '\0';
-
-	/* we use the same magic that X11 uses in Xtranssock.c for
-	 * calculating the proper length of the sockaddr */
-#if defined(BSD44SOCKETS) || defined(__UNIXWARE__)
-	local.sun_len = strlen(local.sun_path);
-#endif
-#if defined(BSD44SOCKETS) || defined(SUN_LEN)
-	namelen = SUN_LEN(&local);
-#else
-	namelen = strlen(local.sun_path) +
-		  offsetof(struct sockaddr_un, sun_path);
-#endif
-
-	i = sendto(s, packet, payload_len+2, 0,
-			(struct sockaddr *) &local, namelen);
-	if (i < 0) {
-		perror("sendto");
-		exit(1);
-	}
-
-	exit(0);
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/g23sh/Makefile	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,18 @@
+CC=	gcc
+CFLAGS=	-O2 -I../include
+PROG=	g23sh
+OBJS=	init.o main.o pktsort.o sendsp.o usercmd.o
+LIBS=	../libasync/libasync.a ../libg23/libg23.a
+INSTBIN=/usr/local/bin
+
+all:	${PROG}
+
+${PROG}: ${OBJS} ${LIBS}
+	${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS}
+
+install:	${PROG}
+	mkdir -p ${INSTBIN}
+	install -c ${PROG} ${INSTBIN}
+
+clean:
+	rm -f *.o *.out *errs ${PROG}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/g23sh/init.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,27 @@
+/*
+ * This module contains the initialization code for g23sh.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include "pktmux.h"
+#include "localsock.h"
+
+extern int sock;
+
+init()
+{
+	static u_char want_rvt_lost[9] = {CLI2RVI_WANT_RVTRACE,
+					  0xFF, 0xFF, 0xFF, 0xFF,
+					  0x00, 0x00, 0x00, 0x00};
+	static u_char want_l23_mux[2] = {CLI2RVI_WANT_MUXPROTO, RVT_L23_HEADER};
+
+	if (!sock)
+		connect_local_socket();
+	localsock_prep_for_length_rx();
+	send_init_command(want_rvt_lost, 9);
+	send_init_command(want_l23_mux, 2);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/g23sh/main.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,86 @@
+/*
+ * This module contains the main() function for g23sh.
+ */
+
+#include <sys/types.h>
+#include <sys/errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+char *socket_pathname = "/tmp/rvinterf_socket";
+int ttyhacks, dflag;
+
+int sock;
+
+extern char *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
+
+main(argc, argv)
+	char **argv;
+{
+	extern int optind;
+	extern char *optarg;
+	int c;
+	fd_set fds;
+
+	while ((c = getopt(argc, argv, "B:dl:s:w:")) != EOF)
+		switch (c) {
+		case 'B':
+			rvinterf_Bopt = optarg;
+			continue;
+		case 'd':
+			dflag++;
+			continue;
+		case 'l':
+			rvinterf_lopt = optarg;
+			continue;
+		case 's':
+			socket_pathname = optarg;
+			continue;
+		case 'w':
+			rvinterf_wopt = optarg;
+			continue;
+		case '?':
+		default:
+usage:			fprintf(stderr,
+				"usage: %s [options] [ttyport]\n", argv[0]);
+			exit(1);
+		}
+	switch (argc - optind) {
+	case 0:
+		if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) {
+			fprintf(stderr,
+      "%s: -B, -l and -w options are meaningful only when launching rvinterf\n",
+				argv[0]);
+			exit(1);
+		}
+		break;
+	case 1:
+		launch_rvinterf(argv[optind]);
+		break;
+	default:
+		goto usage;
+	}
+
+	ttyhacks = isatty(0) && !dflag;
+	init();
+	tty_init();
+	for (;;) {
+		FD_ZERO(&fds);
+		FD_SET(0, &fds);
+		FD_SET(sock, &fds);
+		c = select(sock+1, &fds, 0, 0, 0);
+		if (c < 0) {
+			if (errno == EINTR)
+				continue;
+			tty_cleanup();
+			perror("select");
+			exit(1);
+		}
+		if (FD_ISSET(0, &fds))
+			handle_tty_input();
+		if (FD_ISSET(sock, &fds))
+			handle_rvinterf_input();
+		fflush(stdout);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/g23sh/pktsort.c	Fri Nov 06 23:22:47 2015 +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);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/g23sh/sendsp.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,53 @@
+/*
+ * g23sh system primitive sending command
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include "pktmux.h"
+#include "limits.h"
+
+void
+cmd_sendsp(argc, argv)
+	char **argv;
+{
+	char *stackdest, *primarg;
+	unsigned intlen;
+	u_char sendpkt[MAX_PKT_TO_TARGET+1];
+	unsigned pktlen;
+
+	stackdest = argv[1];
+	primarg = argv[2];
+	if (strlen(stackdest) > 4) {
+		printf(
+		  "error: stack destination arg may not exceed 4 characters\n");
+		return;
+	}
+	intlen = 12 + strlen(primarg);
+	pktlen = intlen + 4;
+	if (pktlen > MAX_PKT_TO_TARGET) {
+		printf("error: max pkt to target limit exceeded\n");
+		return;
+	}
+	/* fill out the packet */
+	sendpkt[0] = RVT_L23_HEADER;
+	sendpkt[1] = 0xB7;	/* system prim */
+	sendpkt[2] = intlen;
+	sendpkt[3] = intlen >> 8;
+	/* send zeros for the timestamp */
+	sendpkt[4] = 0;
+	sendpkt[5] = 0;
+	sendpkt[6] = 0;
+	sendpkt[7] = 0;
+	/* as far as TI's sw is concerned, we are PCO */
+	sendpkt[8] = 'P';
+	sendpkt[9] = 'C';
+	sendpkt[10] = 'O';
+	sendpkt[11] = ' ';
+	sprintf(sendpkt + 12, "%-4s%s", stackdest, primarg);
+	/* send it! */
+	send_pkt_to_target(sendpkt, pktlen);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/g23sh/usercmd.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,90 @@
+/*
+ * This module implements g23sh user command dispatch.
+ */
+
+#include <sys/types.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+
+extern char usercmd[];
+
+extern void cmd_sendsp();
+
+void
+cmd_exit()
+{
+	tty_cleanup();
+	exit(0);
+}
+
+static struct cmdtab {
+	char *cmd;
+	int minargs;
+	int maxargs;
+	void (*func)();
+} cmdtab[] = {
+	{"exit", 0, 0, cmd_exit},
+	{"quit", 0, 0, cmd_exit},
+	{"sp", 2, 2, cmd_sendsp},
+	{0, 0, 0, 0}
+};
+
+void
+dispatch_user_cmd()
+{
+	char *argv[10];
+	char *cp, **ap;
+	struct cmdtab *tp;
+
+	for (cp = usercmd; isspace(*cp); cp++)
+		;
+	if (!*cp || *cp == '#')
+		return;
+	argv[0] = cp;
+	while (*cp && !isspace(*cp))
+		cp++;
+	if (*cp)
+		*cp++ = '\0';
+	for (tp = cmdtab; tp->cmd; tp++)
+		if (!strcmp(tp->cmd, argv[0]))
+			break;
+	if (!tp->func) {
+		printf("error: no such command\n");
+		return;
+	}
+	for (ap = argv + 1; ; ) {
+		while (isspace(*cp))
+			cp++;
+		if (!*cp || *cp == '#')
+			break;
+		if (ap - argv - 1 >= tp->maxargs) {
+			printf("error: too many arguments\n");
+			return;
+		}
+		if (*cp == '"') {
+			*ap++ = ++cp;
+			while (*cp && *cp != '"')
+				cp++;
+			if (*cp != '"') {
+				printf("error: unterminated quoted string\n");
+				return;
+			}
+			*cp++ = '\0';
+		} else {
+			*ap++ = cp;
+			while (*cp && !isspace(*cp))
+				cp++;
+			if (*cp)
+				*cp++ = '\0';
+		}
+	}
+	if (ap - argv - 1 < tp->minargs) {
+		printf("error: too few arguments\n");
+		return;
+	}
+	*ap = 0;
+	tp->func(ap - argv, argv);
+}
--- a/rvinterf/old/log.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * This module implements the logging function
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <time.h>
-
-extern char pr_item[];
-
-extern FILE *logF;
-extern time_t logtime;
-
-static struct tm last_tm;
-
-log_item()
-{
-	struct tm *curtm;
-
-	curtm = gmtime(&logtime);
-	if (curtm->tm_year != last_tm.tm_year ||
-	    curtm->tm_mon != last_tm.tm_mon ||
-	    curtm->tm_mday != last_tm.tm_mday)
-		fprintf(logF, "%d-%02d-%02d (gmtime):\n", curtm->tm_year + 1900,
-			curtm->tm_mon+1, curtm->tm_mday);
-	fprintf(logF, "[%02d:%02d:%02d] %s\n", curtm->tm_hour, curtm->tm_min,
-		curtm->tm_sec, pr_item);
-	bcopy(curtm, &last_tm, sizeof(struct tm));
-}
-
-log_sent_packet(pkt, pktlen)
-	u_char *pkt;
-{
-	int i;
-	char *dp;
-
-	dp = pr_item;
-	strcpy(dp, "Sent");
-	dp += 4;
-	for (i = 0; i < pktlen; i++) {
-		sprintf(dp, " %02X", pkt[i]);
-		dp += 3;
-	}
-	*dp = '\0';
-	print_item();
-}
--- a/rvinterf/old/openport.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * This module takes care of opening the serial port and setting the
- * proper "raw" termios modes, including the baud rate.
- */
-
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <termios.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <unistd.h>
-
-int target_fd;
-char *baudrate_name = "115200";
-
-static struct baudrate {
-	char	*name;
-	speed_t	termios_code;
-} baud_rate_table[] = {
-	{"19200",	B19200},
-	{"38400",	B38400},
-	{"57600",	B57600},
-	{"115200",	B115200},
-	/* non-standard high baud rates "remapped" by CP2102 usb2serial IC */
-	{"203125",	B230400},
-	{"406250",	B460800},
-	{"812500",	B921600},
-	/* table search terminator */
-	{NULL,		B0}
-};
-
-static speed_t
-get_baud_rate()
-{
-	struct baudrate *br;
-
-	for (br = baud_rate_table; br->name; br++)
-		if (!strcmp(br->name, baudrate_name))
-			break;
-	if (!br->name) {
-		fprintf(stderr, "baud rate \"%s\" unknown/unsupported\n",
-			baudrate_name);
-		exit(1);
-	}
-	return br->termios_code;
-}
-
-open_target_serial(ttydev)
-	char *ttydev;
-{
-	struct termios target_termios;
-	speed_t br_code;
-
-	br_code = get_baud_rate();
-	target_fd = open(ttydev, O_RDWR|O_NONBLOCK);
-	if (target_fd < 0) {
-		perror(ttydev);
-		exit(1);
-	}
-	target_termios.c_iflag = IGNBRK;
-	target_termios.c_oflag = 0;
-	target_termios.c_cflag = CLOCAL|HUPCL|CREAD|CS8;
-	target_termios.c_lflag = 0;
-	target_termios.c_cc[VMIN] = 1;
-	target_termios.c_cc[VTIME] = 0;
-	cfsetispeed(&target_termios, br_code);
-	cfsetospeed(&target_termios, br_code);
-	if (tcsetattr(target_fd, TCSAFLUSH, &target_termios) < 0) {
-		perror("initial tcsetattr on target");
-		exit(1);
-	}
-	return 0;
-}
-
-set_serial_nonblock(state)
-	int state;
-{
-	ioctl(target_fd, FIONBIO, &state);
-}
--- a/rvinterf/old/packetrx.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
- * This module handles the lowest level of serial packet Rx
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "pktmux.h"
-
-extern int target_fd;
-
-#define	MAXPKT	512
-u_char rxpkt[MAXPKT];
-size_t rxpkt_len;
-
-extern char pr_item[];
-
-static int in_pkt, dle_state, toobig;
-
-static void
-process_inbyte(inb)
-{
-	if (!in_pkt) {
-		if (inb != STX || dle_state) {
-			rxpkt_len++;
-			dle_state = (inb == DLE);
-			return;
-		}
-		if (rxpkt_len) {
-			sprintf(pr_item,
-				"Warning: Rx %u byte%s outside of a packet",
-				(unsigned)rxpkt_len, rxpkt_len != 1 ? "s" : "");
-			print_item();
-			rxpkt_len = 0;
-		}
-		in_pkt = 1;
-		toobig = 0;
-		return;
-	}
-	if (dle_state) {
-		dle_state = 0;
-		if (inb != STX && inb != DLE) {
-			sprintf(pr_item,
-				"Rx framing error: %02X after DLE\n", inb);
-			print_item();
-			in_pkt = 0;
-			rxpkt_len = 0;
-			return;
-		}
-		goto data;
-	}
-	if (inb == DLE) {
-		dle_state = 1;
-		return;
-	} else if (inb == STX) {
-		if (!rxpkt_len)
-			return;
-		in_pkt = 0;
-		handle_rx_packet();
-		rxpkt_len = 0;
-		return;
-	}
-data:	if (rxpkt_len >= MAXPKT) {
-		if (!toobig) {
-			sprintf(pr_item, "Error: Rx packet too big!\n");
-			print_item();
-			toobig = 1;
-		}
-		return;
-	}
-	rxpkt[rxpkt_len++] = inb;
-}
-
-void
-process_serial_rx()
-{
-	u_char rdbuf[512];
-	int cc, i;
-
-	cc = read(target_fd, rdbuf, sizeof rdbuf);
-	if (cc <= 0) {
-		perror("Error/EOF reading from target");
-		exit(1);
-	}
-	for (i = 0; i < cc; i++)
-		process_inbyte(rdbuf[i]);
-}
--- a/rvinterf/old/packettx.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * This module handles the lowest level of serial packet Tx
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "pktmux.h"
-#include "txpkt.h"
-
-extern int target_fd;
-
-send_pkt_to_target(pkt, pktlen)
-	u_char *pkt;
-{
-	u_char buf[MAX_PKT_TO_TARGET*2+2];
-	u_char *cp, *dp, *endp;
-	int c;
-
-	endp = pkt + pktlen;
-	dp = buf;
-	*dp++ = STX;
-	for (cp = pkt; cp < endp; cp++) {
-		c = *cp;
-		if (c == STX || c == DLE)
-			*dp++ = DLE;
-		*dp++ = c;
-	}
-	*dp++ = STX;
-	write(target_fd, buf, dp - buf);
-}
--- a/rvinterf/old/pktmux.h	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-/*
- * Definitions for the RVT MUX over-the-wire protocol
- */
-
-#define	STX	0x02
-#define	DLE	0x10
-
-#define RVT_RV_HEADER        0x11
-#define RVT_L1_HEADER        0x12
-#define RVT_L23_HEADER       0x13
-#define RVT_TM_HEADER        0x14
-#define RVT_RNET_HEADER      0x15
-#define RVT_PROF_HEADER      0x16
-#define RVT_GTTBACK_HEADER   0x17
-#define RVT_OTHER_HEADER     0x18
-#define RVT_INVALID_HEADER   0xFF
--- a/rvinterf/old/rvtdump.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
- * This program reads bytes from a serial port, parses them assuming
- * TI's RVT MUX format, and prints every decoded packet.
- */
-
-#include <sys/types.h>
-#include <sys/errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <time.h>
-
-extern int target_fd;
-extern char *baudrate_name;
-
-extern char pr_item[];
-extern int sendsock_fd;
-
-char *logfname;
-FILE *logF;
-time_t logtime;
-int background, sendsock_enable;
-
-main(argc, argv)
-	char **argv;
-{
-	extern char *optarg;
-	extern int optind;
-	int c, maxfd;
-	fd_set fds;
-
-	while ((c = getopt(argc, argv, "bB:d:l:s")) != EOF)
-		switch (c) {
-		case 'b':
-			background++;
-			continue;
-		case 'B':
-			baudrate_name = optarg;
-			continue;
-		case 'd':
-			target_fd = atoi(optarg);
-			continue;
-		case 'l':
-			logfname = optarg;
-			continue;
-		case 's':
-			sendsock_enable++;
-			continue;
-		case '?':
-		default:
-usage:			fprintf(stderr,
-			"usage: %s [options] ttyport\n", argv[0]);
-			exit(1);
-		}
-	if (background && !logfname) {
-		fprintf(stderr, "%s: -b is meaningless without -l\n", argv[0]);
-		exit(1);
-	}
-	if (target_fd <= 0) {
-		if (argc - optind != 1)
-			goto usage;
-		open_target_serial(argv[optind]);
-	}
-
-	set_serial_nonblock(0);
-	setlinebuf(stdout);
-	if (logfname) {
-		logF = fopen(logfname, "w");
-		if (!logF) {
-			perror(logfname);
-			exit(1);
-		}
-		fprintf(logF, "*** Log of decoded RVT output ***\n");
-		setlinebuf(logF);
-	}
-	if (sendsock_enable)
-		create_send_socket();
-	if (background) {
-		c = fork();
-		if (c < 0) {
-			perror("fork");
-			exit(1);
-		}
-		if (c) {
-			printf("rvtdump forked into background (pid %d)\n", c);
-			exit(0);
-		}
-	}
-	maxfd = target_fd;
-	if (sendsock_fd > maxfd)
-		maxfd = sendsock_fd;
-	for (;;) {
-		FD_ZERO(&fds);
-		FD_SET(target_fd, &fds);
-		if (sendsock_enable)
-			FD_SET(sendsock_fd, &fds);
-		c = select(maxfd+1, &fds, 0, 0, 0);
-		time(&logtime);
-		if (c < 0) {
-			if (errno == EINTR)
-				continue;
-			perror("select");
-			exit(1);
-		}
-		if (FD_ISSET(target_fd, &fds))
-			process_serial_rx();
-		if (FD_ISSET(sendsock_fd, &fds))
-			handle_sendsock();
-	}
-}
-
-handle_rx_packet()
-{
-	print_rx_packet();
-}
-
-print_item()
-{
-	if (!background)
-		printf("%s\n", pr_item);
-	if (logF)
-		log_item();
-}
--- a/rvinterf/old/rvtdump_tx.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * This module contains the implementation of the Tx extension to rvtdump
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "txpkt.h"
-
-static char sockpath[] = "/tmp/rvt_send_socket";
-
-int sendsock_fd;
-u_char sendsock_pkt[MAX_PKT_TO_TARGET];
-int sendsock_pktlen;
-
-create_send_socket()
-{
-	/* local socket binding voodoo copied from osmocon */
-	struct sockaddr_un local;
-	unsigned int namelen;
-	int rc;
-
-	sendsock_fd = socket(AF_UNIX, SOCK_DGRAM, 0);
-	if (sendsock_fd < 0) {
-		perror("socket(AF_UNIX, SOCK_DGRAM, 0)");
-		exit(1);
-	}
-
-	local.sun_family = AF_UNIX;
-	strncpy(local.sun_path, sockpath, sizeof(local.sun_path));
-	local.sun_path[sizeof(local.sun_path) - 1] = '\0';
-	unlink(local.sun_path);
-
-	/* we use the same magic that X11 uses in Xtranssock.c for
-	 * calculating the proper length of the sockaddr */
-#if defined(BSD44SOCKETS) || defined(__UNIXWARE__)
-	local.sun_len = strlen(local.sun_path);
-#endif
-#if defined(BSD44SOCKETS) || defined(SUN_LEN)
-	namelen = SUN_LEN(&local);
-#else
-	namelen = strlen(local.sun_path) +
-		  offsetof(struct sockaddr_un, sun_path);
-#endif
-
-	rc = bind(sendsock_fd, (struct sockaddr *) &local, namelen);
-	if (rc != 0) {
-		perror("bind on local dgram socket");
-		exit(1);
-	}
-
-	return(0);
-}
-
-handle_sendsock()
-{
-	sendsock_pktlen = recv(sendsock_fd, sendsock_pkt, MAX_PKT_TO_TARGET, 0);
-	if (sendsock_pktlen <= 0) {
-		fprintf(stderr, "return value from recv on socket: %d\n",
-			sendsock_pktlen);
-		exit(1);
-	}
-	send_pkt_to_target(sendsock_pkt, sendsock_pktlen);
-	log_sent_packet(sendsock_pkt, sendsock_pktlen);
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/sendsp/Makefile	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,18 @@
+CC=	gcc
+CFLAGS=	-O2 -I../include
+PROGS=	fc-sendsp
+INSTBIN=/usr/local/bin
+
+SENDSP_OBJS=	rvifsend.o sendsp.o
+
+all:	${PROGS}
+
+fc-sendsp:	${SENDSP_OBJS}
+	${CC} ${CFLAGS} -o $@ ${SENDSP_OBJS}
+
+install:	${PROGS}
+	mkdir -p ${INSTBIN}
+	install -c ${PROGS} ${INSTBIN}
+
+clean:
+	rm -f *.o *.out *errs ${PROGS}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/sendsp/rvifsend.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,66 @@
+/*
+ * This module is currently linked by fc-sendsp, and may be used by
+ * other similar hack-utilities in the future.  Here we connect to
+ * rvinterf, send one packet to the target, and call it done.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "localsock.h"
+
+extern char *socket_pathname;
+
+send_pkt_to_target(pkt, pktlen)
+	u_char *pkt;
+	unsigned pktlen;
+{
+	/* local socket binding voodoo copied from osmocon */
+	struct sockaddr_un local;
+	unsigned int namelen;
+	int sock, rc;
+	u_char hdrbuf[3];
+	int len1;
+
+	sock = socket(AF_UNIX, SOCK_STREAM, 0);
+	if (sock < 0) {
+		perror("socket(AF_UNIX, SOCK_STREAM, 0)");
+		exit(1);
+	}
+
+	local.sun_family = AF_UNIX;
+	strncpy(local.sun_path, socket_pathname, sizeof(local.sun_path));
+	local.sun_path[sizeof(local.sun_path) - 1] = '\0';
+
+	/* we use the same magic that X11 uses in Xtranssock.c for
+	 * calculating the proper length of the sockaddr */
+#if defined(BSD44SOCKETS) || defined(__UNIXWARE__)
+	local.sun_len = strlen(local.sun_path);
+#endif
+#if defined(BSD44SOCKETS) || defined(SUN_LEN)
+	namelen = SUN_LEN(&local);
+#else
+	namelen = strlen(local.sun_path) +
+		  offsetof(struct sockaddr_un, sun_path) + 1;
+#endif
+
+	rc = connect(sock, (struct sockaddr *) &local, namelen);
+	if (rc != 0) {
+		perror(socket_pathname);
+		exit(1);
+	}
+
+	len1 = pktlen + 1;
+	hdrbuf[0] = len1 >> 8;
+	hdrbuf[1] = len1 & 0xFF;
+	hdrbuf[2] = CLI2RVI_PKT_TO_TARGET;
+	write(sock, hdrbuf, 3);
+	write(sock, pkt, pktlen);
+	close(sock);
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/old/sendsp/sendsp.c	Fri Nov 06 23:22:47 2015 +0000
@@ -0,0 +1,71 @@
+/*
+ * This hack-utility sends a GPF System Primitive given on the command line
+ * to a target GSM device via rvinterf.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include "pktmux.h"
+#include "limits.h"
+
+char *socket_pathname = "/tmp/rvinterf_socket";
+
+main(argc, argv)
+	char **argv;
+{
+	char *stackdest, *primarg;
+	unsigned intlen;
+	u_char sendpkt[MAX_PKT_TO_TARGET];
+	unsigned pktlen;
+
+	if (argc < 3) {
+usage:		fprintf(stderr, "usage: %s [-s socket] stackdest primarg\n",
+			argv[0]);
+		exit(1);
+	}
+	if (strcmp(argv[1], "-s")) {
+		if (argc != 3)
+			goto usage;
+		stackdest = argv[1];
+		primarg = argv[2];
+	} else {
+		if (argc != 5)
+			goto usage;
+		socket_pathname = argv[2];
+		stackdest = argv[3];
+		primarg = argv[4];
+	}
+	if (strlen(stackdest) > 4) {
+		fprintf(stderr,
+		"error: stack destination arg may not exceed 4 characters\n");
+		exit(1);
+	}
+	intlen = 12 + strlen(primarg) + 1;
+	pktlen = intlen + 4;
+	if (pktlen > MAX_PKT_TO_TARGET) {
+		fprintf(stderr, "error: max pkt to target limit exceeded\n");
+		exit(1);
+	}
+	/* fill out the packet */
+	sendpkt[0] = RVT_L23_HEADER;
+	sendpkt[1] = 0xB7;	/* system prim */
+	sendpkt[2] = intlen;
+	sendpkt[3] = intlen >> 8;
+	/* send zeros for the timestamp */
+	sendpkt[4] = 0;
+	sendpkt[5] = 0;
+	sendpkt[6] = 0;
+	sendpkt[7] = 0;
+	/* as far as TI's sw is concerned, we are PCO */
+	sendpkt[8] = 'P';
+	sendpkt[9] = 'C';
+	sendpkt[10] = 'O';
+	sendpkt[11] = ' ';
+	sprintf(sendpkt + 12, "%-4s%s", stackdest, primarg);
+	/* send it! */
+	send_pkt_to_target(sendpkt, pktlen);
+	exit(0);
+}
--- a/rvinterf/old/trdump.c	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,169 +0,0 @@
-/*
- * This module implements the basic dump of any incoming packets
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include "pktmux.h"
-
-extern u_char rxpkt[];
-extern size_t rxpkt_len;
-
-char pr_item[4096];
-
-void
-print_rv_trace()
-{
-	int i, c;
-	char *dp;
-
-	dp = pr_item;
-	strcpy(dp, "RV ");
-	dp += 3;
-	/* the SWE static ID is sent MSB first */
-	for (i = 1; i <= 4; i++) {
-		sprintf(dp, "%02X", rxpkt[i]);
-		dp += 2;
-	}
-	/* severity level */
-	sprintf(dp, " %d ", rxpkt[5]);
-	dp = index(dp, '\0');
-	for (i = 6; i < rxpkt_len; i++) {
-		c = rxpkt[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';
-	print_item();
-}
-
-void
-print_l1_trace()
-{
-	int i, c;
-	char *dp;
-
-	dp = pr_item;
-	strcpy(dp, "L1: ");
-	dp += 4;
-	for (i = 1; i < rxpkt_len; i++) {
-		if ((i+1 < rxpkt_len) &&
-		    (rxpkt[i] == '\r' && rxpkt[i+1] == '\n' ||
-		     rxpkt[i] == '\n' && rxpkt[i+1] == '\r')) {
-			*dp = '\0';
-			print_item();
-			if (i+2 == rxpkt_len)
-				return;
-			dp = pr_item;
-			*dp++ = '+';
-			*dp++ = ' ';
-			i++;
-			continue;
-		}
-		c = rxpkt[i];
-		if (c & 0x80) {
-			*dp++ = 'M';
-			*dp++ = '-';
-			c &= 0x7F;
-		}
-		if (c < 0x20) {
-			*dp++ = '^';
-			*dp++ = c + '@';
-		} else if (c == 0x7F) {
-			*dp++ = '^';
-			*dp++ = '?';
-		} else
-			*dp++ = c;
-	}
-	/* will get here only if no newline sequence at the end */
-	*dp = '\0';
-	print_item();
-}
-
-void
-print_g23_trace()
-{
-	int i;
-	char *dp;
-
-	dp = pr_item;
-	strcpy(dp, "G23:");
-	dp += 4;
-	for (i = 1; i < rxpkt_len; i++) {
-		sprintf(dp, " %02X", rxpkt[i]);
-		dp += 3;
-	}
-	*dp = '\0';
-	print_item();
-}
-
-void
-print_etm_output_raw()
-{
-	int i;
-	char *dp;
-
-	dp = pr_item;
-	strcpy(dp, "ETM:");
-	dp += 4;
-	for (i = 1; i < rxpkt_len; i++) {
-		sprintf(dp, " %02X", rxpkt[i]);
-		dp += 3;
-	}
-	*dp = '\0';
-	print_item();
-}
-
-void
-print_unknown_packet()
-{
-	int i;
-	char *dp;
-
-	dp = pr_item;
-	strcpy(dp, "UNK:");
-	dp += 4;
-	for (i = 0; i < rxpkt_len; i++) {
-		sprintf(dp, " %02X", rxpkt[i]);
-		dp += 3;
-	}
-	*dp = '\0';
-	print_item();
-}
-
-void
-print_rx_packet()
-{
-	switch (rxpkt[0]) {
-	case RVT_RV_HEADER:
-		if (rxpkt_len < 6)
-			goto unknown;
-		print_rv_trace();
-		return;
-	case RVT_L1_HEADER:
-		print_l1_trace();
-		return;
-	case RVT_L23_HEADER:
-		print_g23_trace();
-		return;
-	case RVT_TM_HEADER:
-		print_etm_output_raw();
-		return;
-	default:
-	unknown:
-		print_unknown_packet();
-	}
-}
--- a/rvinterf/old/txpkt.h	Fri Nov 06 22:52:25 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-/*
- * For sizing our buffers etc in rvinterf, we need a limit on the size of
- * message packets we can send to the target.  As it happens, the packet
- * Rx code in RVT on the target side also has a limit (quite naturally,
- * as it needs to use a static buffer to reassemble incoming packets as
- * they arrive at the UART in unpredictable interrupt-sized chunks), so
- * we set our limit to match that in RVT.
- */
-
-#define	MAX_PKT_TO_TARGET	255
-
-/*
- * The above limit definition counts all bytes between the opening and
- * closing STX flags, but not DLEs inserted for binary transparency.
- */