FreeCalypso > hg > freecalypso-sw
annotate rvinterf/asyncshell/pktsort.c @ 1010:658fe6f1880f
rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 20 Mar 2016 20:35:17 +0000 |
parents | 4661b84260a0 |
children | 820d34f3f3d7 |
rev | line source |
---|---|
872
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Here we sort out incoming packets from the target relayed via rvinterf. |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <string.h> |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <strings.h> |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <stdlib.h> |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "pktmux.h" |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "limits.h" |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "localsock.h" |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "localtypes.h" |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 extern u_char rvi_msg[]; |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 extern int rvi_msg_len; |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 static void |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 process_rvt() |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 { |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 u32 useid; |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 if (rvi_msg_len < 7) { |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 tty_cleanup(); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 fprintf(stderr, "Error: rvinterf sent us an invalid RVT msg\n"); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 exit(1); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 } |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 useid = rvi_msg[2] << 24 | rvi_msg[3] << 16 | rvi_msg[4] << 8 |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 | rvi_msg[5]; |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 switch (useid) { |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 case 0: |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 handle_useid_0(); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 return; |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 default: |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 tty_cleanup(); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 fprintf(stderr, "unexpected fwd of USEID %08X from rvinterf\n", |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 useid); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 exit(1); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 } |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 } |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 void |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 gpf_packet_rx() |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 { |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 char fmtbuf[MAX_PKT_FROM_TARGET*8]; /* size it generously */ |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 format_g23_packet(rvi_msg + 1, rvi_msg_len - 1, fmtbuf); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 async_msg_output(fmtbuf); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 } |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 void |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 response_from_ati() |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 { |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 char buf[MAX_PKT_FROM_TARGET*4+2]; |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 strcpy(buf, "ATI: "); |
879
4661b84260a0
fc-shell: AT-over-RVTMUX command sending implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
872
diff
changeset
|
57 safe_print_trace(rvi_msg + 2, rvi_msg_len - 2, buf + 5); |
872
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 async_msg_output(buf); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 } |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 void |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 process_pkt_from_target() |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 { |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 switch (rvi_msg[1]) { |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 case RVT_RV_HEADER: |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 process_rvt(); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 return; |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 case RVT_L23_HEADER: |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 gpf_packet_rx(); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 return; |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 case RVT_AT_HEADER: |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 response_from_ati(); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 return; |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 default: |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 tty_cleanup(); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 fprintf(stderr, "unexpected fwd of MUX %02X from rvinterf\n", |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 rvi_msg[1]); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 exit(1); |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 } |
5e46679bdb6a
fc-shell skeleton created
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 } |