FreeCalypso > hg > freecalypso-sw
changeset 1026:f511bbac0efa
fc-shell: beginning of TCH code expansion
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 30 May 2016 22:45:48 +0000 |
parents | 4c80a6e6723f |
children | 1178befeda76 |
files | rvinterf/asyncshell/pktsort.c rvinterf/asyncshell/tchcmd.c |
diffstat | 2 files changed, 59 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/asyncshell/pktsort.c Tue May 03 23:46:54 2016 +0000 +++ b/rvinterf/asyncshell/pktsort.c Mon May 30 22:45:48 2016 +0000 @@ -58,24 +58,6 @@ async_msg_output(buf); } -static void -dump_tch() -{ - char buf[MAX_PKT_FROM_TARGET*3+5], *dp; - u_char *cp, *endp; - - cp = rvi_msg + 2; - endp = rvi_msg + rvi_msg_len; - strcpy(buf, "TCH:"); - dp = buf + 4; - while (cp < endp) { - sprintf(dp, " %02X", *cp++); - dp += 3; - } - *dp = '\0'; - async_msg_output(buf); -} - void process_pkt_from_target() { @@ -90,7 +72,7 @@ response_from_ati(); return; case RVT_TCH_HEADER: - dump_tch(); + tch_packet_rx(); return; default: tty_cleanup();
--- a/rvinterf/asyncshell/tchcmd.c Tue May 03 23:46:54 2016 +0000 +++ b/rvinterf/asyncshell/tchcmd.c Mon May 30 22:45:48 2016 +0000 @@ -9,8 +9,14 @@ #include <strings.h> #include <stdlib.h> #include "pktmux.h" +#include "limits.h" #include "tch_feature.h" +extern u_char rvi_msg[]; +extern int rvi_msg_len; + +static int tch_rawdump_mode; + send_tch_config_req(config) { u_char sendpkt[3]; @@ -60,3 +66,55 @@ { return cmd_tchdl_common(argc - 1, argv + 1); } + +static void +tch_rawdump() +{ + char buf[MAX_PKT_FROM_TARGET*3+5], *dp; + u_char *cp, *endp; + + cp = rvi_msg + 2; + endp = rvi_msg + rvi_msg_len; + strcpy(buf, "TCH:"); + dp = buf + 4; + while (cp < endp) { + sprintf(dp, " %02X", *cp++); + dp += 3; + } + *dp = '\0'; + async_msg_output(buf); +} + +void +tch_packet_rx() +{ + char buf[128]; + + if (tch_rawdump_mode) { + tch_rawdump(); + return; + } + if (rvi_msg_len < 3) { +inv: async_msg_output("Error: invalid TCH packet received"); + return; + } + switch (rvi_msg[2]) { + case TCH_CONFIG_CONF: + if (rvi_msg_len != 4) + goto inv; + if (rvi_msg[3] & 0xFE) + goto inv; + sprintf(buf, "TCH_CONFIG_CONF: DL forwarding is %s", + rvi_msg[3] ? "enabled" : "disabled"); + async_msg_output(buf); + return; + case TCH_ULBITS_CONF: + /* TCH UL play code will hook in here */ + return; + case TCH_DLBITS_IND: + /* TCH DL record code will hook in here */ + return; + default: + goto inv; + } +}