FreeCalypso > hg > freecalypso-sw
view rvinterf/asyncshell/pktsort.c @ 1022:24440bc7cee8
gsm-fw/configs: gtamodem-gsmtch-{ext,int} configurations added
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Tue, 03 May 2016 13:43:31 +0000 |
parents | 820d34f3f3d7 |
children | f511bbac0efa |
line wrap: on
line source
/* * 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); } } static void gpf_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); } static void response_from_ati() { char buf[MAX_PKT_FROM_TARGET*4+2]; strcpy(buf, "ATI: "); safe_print_trace(rvi_msg + 2, rvi_msg_len - 2, buf + 5); 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() { switch (rvi_msg[1]) { case RVT_RV_HEADER: process_rvt(); return; case RVT_L23_HEADER: gpf_packet_rx(); return; case RVT_AT_HEADER: response_from_ati(); return; case RVT_TCH_HEADER: dump_tch(); return; default: tty_cleanup(); fprintf(stderr, "unexpected fwd of MUX %02X from rvinterf\n", rvi_msg[1]); exit(1); } }