comparison rvinterf/tmsh/l1resp.c @ 132:5380872923a6

fc-tmsh: beginning of l1tm response handling
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 19 Feb 2017 20:53:41 +0000
parents
children 4aa1c18c7a2f
comparison
equal deleted inserted replaced
131:cae9cb333c2c 132:5380872923a6
1 /*
2 * Handling of TM3 responses from L1TM
3 */
4
5 #include <sys/types.h>
6 #include <stdio.h>
7
8 extern u_char rvi_msg[];
9 extern int rvi_msg_len;
10
11 void
12 l1tm_response_nodata(op)
13 char *op;
14 {
15 char buf[80];
16
17 if (rvi_msg_len > 5) {
18 sprintf(buf, "%s response wrong length", op);
19 print_etm_pkt_raw(buf);
20 return;
21 }
22 if (rvi_msg[3])
23 sprintf(buf, "%s error %u (0x%x)", op, rvi_msg[3], rvi_msg[3]);
24 else
25 sprintf(buf, "%s OK", op);
26 async_msg_output(buf);
27 }
28
29 void
30 l1tm_response_index(op)
31 char *op;
32 {
33 char buf[80];
34
35 if (rvi_msg[3]) {
36 if (rvi_msg_len == 5) {
37 sprintf(buf, "%s error %u (0x%02X)", op,
38 rvi_msg[3], rvi_msg[3]);
39 async_msg_output(buf);
40 } else {
41 sprintf(buf, "%s long error response", op);
42 print_etm_pkt_raw(buf);
43 }
44 return;
45 }
46 if (rvi_msg_len != 6) {
47 sprintf(buf, "%s response wrong length", op);
48 print_etm_pkt_raw(buf);
49 return;
50 }
51 sprintf(buf, "%s index %u (0x%02X) OK", op, rvi_msg[4], rvi_msg[4]);
52 async_msg_output(buf);
53 }
54
55 void
56 l1tm_response_index_val(op)
57 char *op;
58 {
59 char buf[80];
60 unsigned val;
61
62 if (rvi_msg[3]) {
63 if (rvi_msg_len == 5) {
64 sprintf(buf, "%s error %u (0x%02X)", op,
65 rvi_msg[3], rvi_msg[3]);
66 async_msg_output(buf);
67 } else {
68 sprintf(buf, "%s long error response", op);
69 print_etm_pkt_raw(buf);
70 }
71 return;
72 }
73 if (rvi_msg_len != 8) {
74 sprintf(buf, "%s response wrong length", op);
75 print_etm_pkt_raw(buf);
76 return;
77 }
78 val = rvi_msg[5] | (rvi_msg[6] << 8);
79 sprintf(buf, "%s index %u (0x%02X): %u (0x%04X)", op,
80 rvi_msg[4], rvi_msg[4], val, val);
81 async_msg_output(buf);
82 }