FreeCalypso > hg > freecalypso-tools
changeset 935:d203a9c7c4e6
rvinterf TM log: beginning of TM/ETM classification
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 23 May 2023 07:51:13 +0000 |
parents | 0d6be90ae74f |
children | f4e6f6b6548e |
files | rvinterf/lowlevel/rviftmode.c |
diffstat | 1 files changed, 176 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/lowlevel/rviftmode.c Tue May 23 06:49:10 2023 +0000 +++ b/rvinterf/lowlevel/rviftmode.c Tue May 23 07:51:13 2023 +0000 @@ -9,6 +9,8 @@ #include <stdio.h> #include <string.h> #include <strings.h> +#include "../include/etm.h" +#include "../include/tm3.h" extern u_char rxpkt[]; extern size_t rxpkt_len; @@ -16,6 +18,170 @@ extern int verbose; extern FILE *logF; +static int +verify_cksum(pkt, pktlen) + u_char *pkt; + unsigned pktlen; +{ + int i, c; + + c = 0; + for (i = 1; i < pktlen; i++) + c ^= pkt[i]; + if (c == 0) + return(0); + else + return(-1); +} + +static void +etm_core_classify(pkt, pktlen, outbuf) + u_char *pkt; + unsigned pktlen; + char *outbuf; +{ + /* classification code to be filled */ + strcpy(outbuf, "ETM_CORE"); +} + +static void +tmffs2_cmd_classify(pkt, pktlen, outbuf) + u_char *pkt; + unsigned pktlen; + char *outbuf; +{ + /* classification code to be filled */ + strcpy(outbuf, "FFS2"); +} + +static void +audio_cmd_classify(pkt, pktlen, outbuf) + u_char *pkt; + unsigned pktlen; + char *outbuf; +{ + /* classification code to be filled */ + strcpy(outbuf, "ETM_AUDIO"); +} + +static void +tm_classify(pkt, pktlen, is_cmd, outbuf) + u_char *pkt; + unsigned pktlen; + char *outbuf; +{ + if (pktlen < 3) { + strcpy(outbuf, "RUNT"); + return; + } + if (verify_cksum(pkt, pktlen) < 0) { + strcpy(outbuf, "BAD CKSUM"); + return; + } + switch (pkt[1]) { + case ETM_CORE: + if (is_cmd) + etm_core_classify(pkt, pktlen, outbuf); + else + strcpy(outbuf, "ETM_CORE"); + return; + case ETM_FFS1: + strcpy(outbuf, "FFS1"); + return; + case ETM_FFS2: + if (is_cmd) + tmffs2_cmd_classify(pkt, pktlen, outbuf); + else + strcpy(outbuf, "FFS2"); + return; + case ETM_AUDIO: + if (is_cmd) + audio_cmd_classify(pkt, pktlen, outbuf); + else + strcpy(outbuf, "ETM_AUDIO"); + return; + case ETM_BSIM: + strcpy(outbuf, "BSIM"); + return; + /* TM3 */ + case MEM_READ: + strcpy(outbuf, "omr"); + return; + case MEM_WRITE: + strcpy(outbuf, "omw"); + return; + case CODEC_READ: + strcpy(outbuf, "oabbr"); + return; + case CODEC_WRITE: + strcpy(outbuf, "oabbw"); + return; + /* L1TM */ + case TM_INIT: + strcpy(outbuf, "tminit"); + return; + case TM_MODE_SET: + strcpy(outbuf, "tms"); + return; + case VERSION_GET: + strcpy(outbuf, "tm3ver"); + return; + case RF_ENABLE: + strcpy(outbuf, "rfe"); + return; + case STATS_READ: + strcpy(outbuf, "sr"); + return; + case STATS_CONFIG_WRITE: + strcpy(outbuf, "scw"); + return; + case STATS_CONFIG_READ: + strcpy(outbuf, "scr"); + return; + case RF_PARAM_WRITE: + strcpy(outbuf, "rfpw"); + return; + case RF_PARAM_READ: + strcpy(outbuf, "rfpr"); + return; + case RF_TABLE_WRITE: + strcpy(outbuf, "rftw"); + return; + case RF_TABLE_READ: + strcpy(outbuf, "rftr"); + return; + case RX_PARAM_WRITE: + strcpy(outbuf, "rxpw"); + return; + case RX_PARAM_READ: + strcpy(outbuf, "rxpr"); + return; + case TX_PARAM_WRITE: + strcpy(outbuf, "txpw"); + return; + case TX_PARAM_READ: + strcpy(outbuf, "txpr"); + return; + case TX_TEMPLATE_WRITE: + strcpy(outbuf, "ttw"); + return; + case TX_TEMPLATE_READ: + strcpy(outbuf, "ttr"); + return; + case MISC_PARAM_WRITE: + strcpy(outbuf, "mpw"); + return; + case MISC_PARAM_READ: + strcpy(outbuf, "mpr"); + return; + case MISC_ENABLE: + strcpy(outbuf, "me"); + return; + default: + sprintf(outbuf, "mid 0x%02X", pkt[1]); + } +} + static void hexdump_out(line) char *line; @@ -30,7 +196,11 @@ log_sent_tm(pkt, pktlen) u_char *pkt; { - output_line("Sent Test Mode packet"); + char summary[32], headline[80]; + + tm_classify(pkt, pktlen, 1, summary); + sprintf(headline, "Sent Test Mode cmd (%s)", summary); + output_line(headline); if (verbose >= 1) packet_hex_dump(pkt, pktlen, hexdump_out); } @@ -38,7 +208,11 @@ void print_tm_output_new() { - output_line("Rx Test Mode packet"); + char summary[32], headline[80]; + + tm_classify(rxpkt, (unsigned) rxpkt_len, 0, summary); + sprintf(headline, "Rx Test Mode resp (%s)", summary); + output_line(headline); if (verbose >= 1) packet_hex_dump(rxpkt, (unsigned) rxpkt_len, hexdump_out); }