FreeCalypso > hg > freecalypso-tools
comparison rvinterf/asyncshell/pktsort.c @ 0:e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sat, 11 Jun 2016 00:13:35 +0000 |
| parents | |
| children | d43d82cbfb85 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:e7502631a0f9 |
|---|---|
| 1 /* | |
| 2 * Here we sort out incoming packets from the target relayed via rvinterf. | |
| 3 */ | |
| 4 | |
| 5 #include <sys/types.h> | |
| 6 #include <stdio.h> | |
| 7 #include <string.h> | |
| 8 #include <strings.h> | |
| 9 #include <stdlib.h> | |
| 10 #include "pktmux.h" | |
| 11 #include "limits.h" | |
| 12 #include "localsock.h" | |
| 13 #include "localtypes.h" | |
| 14 | |
| 15 extern u_char rvi_msg[]; | |
| 16 extern int rvi_msg_len; | |
| 17 | |
| 18 static void | |
| 19 process_rvt() | |
| 20 { | |
| 21 u32 useid; | |
| 22 | |
| 23 if (rvi_msg_len < 7) { | |
| 24 tty_cleanup(); | |
| 25 fprintf(stderr, "Error: rvinterf sent us an invalid RVT msg\n"); | |
| 26 exit(1); | |
| 27 } | |
| 28 useid = rvi_msg[2] << 24 | rvi_msg[3] << 16 | rvi_msg[4] << 8 | |
| 29 | rvi_msg[5]; | |
| 30 switch (useid) { | |
| 31 case 0: | |
| 32 handle_useid_0(); | |
| 33 return; | |
| 34 default: | |
| 35 tty_cleanup(); | |
| 36 fprintf(stderr, "unexpected fwd of USEID %08X from rvinterf\n", | |
| 37 useid); | |
| 38 exit(1); | |
| 39 } | |
| 40 } | |
| 41 | |
| 42 static void | |
| 43 gpf_packet_rx() | |
| 44 { | |
| 45 char fmtbuf[MAX_PKT_FROM_TARGET*8]; /* size it generously */ | |
| 46 | |
| 47 format_g23_packet(rvi_msg + 1, rvi_msg_len - 1, fmtbuf); | |
| 48 async_msg_output(fmtbuf); | |
| 49 } | |
| 50 | |
| 51 static void | |
| 52 response_from_ati() | |
| 53 { | |
| 54 char buf[MAX_PKT_FROM_TARGET*4+2]; | |
| 55 | |
| 56 strcpy(buf, "ATI: "); | |
| 57 safe_print_trace(rvi_msg + 2, rvi_msg_len - 2, buf + 5); | |
| 58 async_msg_output(buf); | |
| 59 } | |
| 60 | |
| 61 void | |
| 62 process_pkt_from_target() | |
| 63 { | |
| 64 switch (rvi_msg[1]) { | |
| 65 case RVT_RV_HEADER: | |
| 66 process_rvt(); | |
| 67 return; | |
| 68 case RVT_L23_HEADER: | |
| 69 gpf_packet_rx(); | |
| 70 return; | |
| 71 case RVT_AT_HEADER: | |
| 72 response_from_ati(); | |
| 73 return; | |
| 74 case RVT_TCH_HEADER: | |
| 75 tch_packet_rx(); | |
| 76 return; | |
| 77 default: | |
| 78 tty_cleanup(); | |
| 79 fprintf(stderr, "unexpected fwd of MUX %02X from rvinterf\n", | |
| 80 rvi_msg[1]); | |
| 81 exit(1); | |
| 82 } | |
| 83 } |
