comparison rvinterf/asyncshell/pktsort.c @ 872:5e46679bdb6a

fc-shell skeleton created
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sat, 30 May 2015 06:42:32 +0000
parents
children 4661b84260a0
comparison
equal deleted inserted replaced
871:a5c8f48003cd 872:5e46679bdb6a
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 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 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);
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 default:
75 tty_cleanup();
76 fprintf(stderr, "unexpected fwd of MUX %02X from rvinterf\n",
77 rvi_msg[1]);
78 exit(1);
79 }
80 }