changeset 132:5380872923a6

fc-tmsh: beginning of l1tm response handling
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 19 Feb 2017 20:53:41 +0000
parents cae9cb333c2c
children 4aa1c18c7a2f
files rvinterf/tmsh/Makefile rvinterf/tmsh/etmbasic.c rvinterf/tmsh/l1resp.c
diffstat 3 files changed, 176 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/tmsh/Makefile	Sun Feb 19 17:19:34 2017 +0000
+++ b/rvinterf/tmsh/Makefile	Sun Feb 19 20:53:41 2017 +0000
@@ -1,9 +1,9 @@
 CC=	gcc
 CFLAGS=	-O2 -I../include
 PROG=	fc-tmsh
-OBJS=	abb.o audiocmd.o etmbasic.o ffs2.o ffs2resp.o init.o l1cmd.o main.o \
-	misc.o omr.o oneshot.o pktsort.o rftablechk.o rftablerd.o tmcore.o \
-	usercmd.o
+OBJS=	abb.o audiocmd.o etmbasic.o ffs2.o ffs2resp.o init.o l1cmd.o l1resp.o \
+	main.o misc.o omr.o oneshot.o pktsort.o rftablechk.o rftablerd.o \
+	tmcore.o usercmd.o
 LIBS=	../libasync/libasync.a
 INSTBIN=/opt/freecalypso/bin
 
--- a/rvinterf/tmsh/etmbasic.c	Sun Feb 19 17:19:34 2017 +0000
+++ b/rvinterf/tmsh/etmbasic.c	Sun Feb 19 20:53:41 2017 +0000
@@ -68,6 +68,97 @@
 			goto runt;
 		handle_omr_response();
 		return;
+	/* L1TM */
+	case TM_INIT:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_nodata("tminit");
+		return;
+	case TM_MODE_SET:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_nodata("tms");
+		return;
+	case VERSION_GET:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_index_val("tm3ver");
+		return;
+	case RF_ENABLE:
+		print_etm_pkt_raw("RF_ENABLE response");
+		return;
+	case STATS_READ:
+		print_etm_pkt_raw("STATS_READ response");
+		return;
+	case STATS_CONFIG_WRITE:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_index("scw");
+		return;
+	case STATS_CONFIG_READ:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_index_val("scr");
+		return;
+	case RF_PARAM_WRITE:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_index("rfpw");
+		return;
+	case RF_PARAM_READ:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_index_val("rfpr");
+		return;
+	case RF_TABLE_WRITE:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_index("rftw");
+		return;
+	case RF_TABLE_READ:
+		print_etm_pkt_raw("RF_TABLE_READ response");
+		return;
+	case RX_PARAM_WRITE:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_index("rxpw");
+		return;
+	case RX_PARAM_READ:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_index_val("rxpr");
+		return;
+	case TX_PARAM_WRITE:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_index("txpw");
+		return;
+	case TX_PARAM_READ:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_index_val("txpr");
+		return;
+	case TX_TEMPLATE_WRITE:
+		print_etm_pkt_raw("TX_TEMPLATE_WRITE response");
+		return;
+	case TX_TEMPLATE_READ:
+		print_etm_pkt_raw("TX_TEMPLATE_READ response");
+		return;
+	case MISC_PARAM_WRITE:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_index("mpw");
+		return;
+	case MISC_PARAM_READ:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_index_val("mpr");
+		return;
+	case MISC_ENABLE:
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_response_index("me");
+		return;
 	default:
 		print_etm_pkt_raw("TM unknown");
 	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/tmsh/l1resp.c	Sun Feb 19 20:53:41 2017 +0000
@@ -0,0 +1,82 @@
+/*
+ * Handling of TM3 responses from L1TM
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+
+extern u_char rvi_msg[];
+extern int rvi_msg_len;
+
+void
+l1tm_response_nodata(op)
+	char *op;
+{
+	char buf[80];
+
+	if (rvi_msg_len > 5) {
+		sprintf(buf, "%s response wrong length", op);
+		print_etm_pkt_raw(buf);
+		return;
+	}
+	if (rvi_msg[3])
+		sprintf(buf, "%s error %u (0x%x)", op, rvi_msg[3], rvi_msg[3]);
+	else
+		sprintf(buf, "%s OK", op);
+	async_msg_output(buf);
+}
+
+void
+l1tm_response_index(op)
+	char *op;
+{
+	char buf[80];
+
+	if (rvi_msg[3]) {
+		if (rvi_msg_len == 5) {
+			sprintf(buf, "%s error %u (0x%02X)", op,
+				rvi_msg[3], rvi_msg[3]);
+			async_msg_output(buf);
+		} else {
+			sprintf(buf, "%s long error response", op);
+			print_etm_pkt_raw(buf);
+		}
+		return;
+	}
+	if (rvi_msg_len != 6) {
+		sprintf(buf, "%s response wrong length", op);
+		print_etm_pkt_raw(buf);
+		return;
+	}
+	sprintf(buf, "%s index %u (0x%02X) OK", op, rvi_msg[4], rvi_msg[4]);
+	async_msg_output(buf);
+}
+
+void
+l1tm_response_index_val(op)
+	char *op;
+{
+	char buf[80];
+	unsigned val;
+
+	if (rvi_msg[3]) {
+		if (rvi_msg_len == 5) {
+			sprintf(buf, "%s error %u (0x%02X)", op,
+				rvi_msg[3], rvi_msg[3]);
+			async_msg_output(buf);
+		} else {
+			sprintf(buf, "%s long error response", op);
+			print_etm_pkt_raw(buf);
+		}
+		return;
+	}
+	if (rvi_msg_len != 8) {
+		sprintf(buf, "%s response wrong length", op);
+		print_etm_pkt_raw(buf);
+		return;
+	}
+	val = rvi_msg[5] | (rvi_msg[6] << 8);
+	sprintf(buf, "%s index %u (0x%02X): %u (0x%04X)", op,
+		rvi_msg[4], rvi_msg[4], val, val);
+	async_msg_output(buf);
+}