view rvinterf/tmsh/l1resp.c @ 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
children 4aa1c18c7a2f
line wrap: on
line source

/*
 * 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);
}