comparison rvinterf/g23sh/pktsort.c @ 336:922efdd65dce

g23sh written, compiles
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 22 Apr 2014 07:21:04 +0000
parents rvinterf/tmsh/pktsort.c@40b8557b9d04
children
comparison
equal deleted inserted replaced
335:40b8557b9d04 336:922efdd65dce
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 g23_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 process_pkt_from_target()
53 {
54 switch (rvi_msg[1]) {
55 case RVT_RV_HEADER:
56 process_rvt();
57 return;
58 case RVT_L23_HEADER:
59 g23_packet_rx();
60 return;
61 default:
62 tty_cleanup();
63 fprintf(stderr, "unexpected fwd of MUX %02X from rvinterf\n",
64 rvi_msg[1]);
65 exit(1);
66 }
67 }