annotate rvinterf/g23sh/pktsort.c @ 951:eb27543ce18e

c139explore: elementary operation commands lcdcmd and lcdpix added
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Wed, 04 Nov 2015 03:03:38 +0000
parents 922efdd65dce
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
183
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * Here we sort out incoming packets from the target relayed via rvinterf.
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <string.h>
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <strings.h>
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <stdlib.h>
260
c146f38d2b5f rvinterf subdir structure made a little more sensible
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
10 #include "pktmux.h"
c146f38d2b5f rvinterf subdir structure made a little more sensible
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
11 #include "limits.h"
c146f38d2b5f rvinterf subdir structure made a little more sensible
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
12 #include "localsock.h"
183
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "localtypes.h"
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 extern u_char rvi_msg[];
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 extern int rvi_msg_len;
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 static void
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 process_rvt()
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 {
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 u32 useid;
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 if (rvi_msg_len < 7) {
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 tty_cleanup();
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 fprintf(stderr, "Error: rvinterf sent us an invalid RVT msg\n");
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 exit(1);
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 }
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 useid = rvi_msg[2] << 24 | rvi_msg[3] << 16 | rvi_msg[4] << 8
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 | rvi_msg[5];
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 switch (useid) {
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 case 0:
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 handle_useid_0();
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 return;
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 default:
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 tty_cleanup();
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 fprintf(stderr, "unexpected fwd of USEID %08X from rvinterf\n",
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 useid);
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 exit(1);
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 }
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 }
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 void
336
922efdd65dce g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 335
diff changeset
43 g23_packet_rx()
922efdd65dce g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 335
diff changeset
44 {
922efdd65dce g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 335
diff changeset
45 char fmtbuf[MAX_PKT_FROM_TARGET*8]; /* size it generously */
922efdd65dce g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 335
diff changeset
46
922efdd65dce g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 335
diff changeset
47 format_g23_packet(rvi_msg + 1, rvi_msg_len - 1, fmtbuf);
922efdd65dce g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 335
diff changeset
48 async_msg_output(fmtbuf);
922efdd65dce g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 335
diff changeset
49 }
922efdd65dce g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 335
diff changeset
50
922efdd65dce g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 335
diff changeset
51 void
183
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 process_pkt_from_target()
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 {
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 switch (rvi_msg[1]) {
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 case RVT_RV_HEADER:
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 process_rvt();
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 return;
336
922efdd65dce g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 335
diff changeset
58 case RVT_L23_HEADER:
922efdd65dce g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 335
diff changeset
59 g23_packet_rx();
183
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 return;
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 default:
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 tty_cleanup();
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 fprintf(stderr, "unexpected fwd of MUX %02X from rvinterf\n",
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 rvi_msg[1]);
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 exit(1);
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 }
85222710dc92 rvinterf/etm: implemented everything except the packet sending command
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 }