FreeCalypso > hg > gsm-net-reveng
annotate tfo/tfo-trace-msg.c @ 31:5f98c5cae4ea
new program tfo-parse-fr16
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 28 Aug 2024 06:23:21 +0000 |
parents | 19039ffbe605 |
children | f6bb790e186a |
rev | line source |
---|---|
29
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This program reads a raw binary file that contains a recording of |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * a T1/E1 timeslot on the MSC side of a TRAU, analyzes it looking for |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * TFO IS messages, and prints whatever it finds. |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdint.h> |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdlib.h> |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <string.h> |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <strings.h> |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
30
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
13 #define MAX_EXT_WORDS 5 |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
14 |
29
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 static uint8_t is_hunt_buf[320]; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 static int is_state; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 static unsigned is_hunt_fill; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 static unsigned is_offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 static unsigned is_file_offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 static unsigned is_bit_count; |
30
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
21 static uint32_t is_rx_word, is_cmd, is_ext_words[MAX_EXT_WORDS]; |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
22 static unsigned is_ext_count; |
29
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 static const u_char hdr_pattern[20] = {0, 1, 0, 1, 0, 1, 1, 0, 1, 0, |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 0, 1, 1, 0, 1, 0, 1, 0, 0, 1}; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 static void |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 is_rx_hunt(cur_file_offset) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 unsigned cur_file_offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 unsigned offset, n; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 for (offset = 0; offset < 16; offset++) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 for (n = 0; n < 20; n++) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 if ((is_hunt_buf[offset + n*16] & 1) != hdr_pattern[n]) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 break; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 if (n == 20) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 break; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 if (n != 20) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 return; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 is_offset = offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 is_file_offset = cur_file_offset - 19*16 + offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 is_state = 1; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 is_bit_count = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 is_rx_word = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 is_hunt_fill = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 static void |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 is_process_cmd() |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 int cont; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 printf("0x%x: ", is_file_offset); |
30
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
56 is_cmd = is_rx_word; |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
57 switch (is_cmd) { |
29
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 case 0x05D: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 printf("IS_REQ\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 cont = 1; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 break; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 case 0x0BA: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 printf("IS_ACK\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 cont = 1; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 break; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 case 0x0E7: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 printf("IS_IPE\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 cont = 1; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 break; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 case 0x129: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 printf("IS_FILL\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 cont = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 break; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 case 0x174: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 printf("IS_DUP\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 cont = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 break; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 case 0x193: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 printf("IS_SYL\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 cont = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 break; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 default: |
30
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
83 printf("unknown IS_Command 0x%03X\n", (unsigned) is_cmd); |
29
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 cont = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 if (cont) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 is_state = 2; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 is_bit_count = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 is_rx_word = 0; |
30
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
90 is_ext_count = 0; |
29
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 } else |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 is_state = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 static void |
30
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
96 process_tfo_req_ack(reqack) |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
97 char *reqack; |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
98 { |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
99 if (is_ext_count != 2) |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
100 return; |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
101 if (is_ext_words[0] != 0x5394B) /* GSM System ID */ |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
102 return; |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
103 printf(" TFO_%s: List_Ind=%u Sig=0x%02X CoID=0x%X CRC=%u\n", reqack, |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
104 (is_ext_words[1] >> 18) & 1, (is_ext_words[1] >> 10) & 0xFF, |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
105 (is_ext_words[1] >> 5) & 0xF, (is_ext_words[1] >> 2) & 7); |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
106 } |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
107 |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
108 static void |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
109 is_process_high_level() |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
110 { |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
111 switch (is_cmd) { |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
112 case 0x05D: |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
113 process_tfo_req_ack("REQ"); |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
114 break; |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
115 case 0x0BA: |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
116 process_tfo_req_ack("ACK"); |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
117 break; |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
118 } |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
119 } |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
120 |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
121 static void |
29
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 is_process_ext() |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 { |
30
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
124 printf(" IS_Extension: 0x%05X", (unsigned) is_rx_word); |
29
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 if (is_rx_word & 0x80200) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 printf(" (bad sync)\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 is_state = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 return; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 } |
30
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
130 if (is_ext_count < MAX_EXT_WORDS) |
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
131 is_ext_words[is_ext_count++] = is_rx_word; |
29
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 switch (is_rx_word & 3) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 case 0: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 printf(" (final)\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 is_state = 0; |
30
19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
136 is_process_high_level(); |
29
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 return; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 case 3: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 printf(" (continue)\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 is_state = 2; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 is_bit_count = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 is_rx_word = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 return; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 default: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 printf(" (bad EX)\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 is_state = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 static void |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 is_rx_process(input, cur_file_offset) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 uint8_t *input; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 unsigned cur_file_offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 unsigned new_bit; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 memmove(is_hunt_buf, is_hunt_buf + 16, 304); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 memcpy(is_hunt_buf + 304, input, 16); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 if (!is_state) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 if (is_hunt_fill < 20) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 is_hunt_fill++; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 if (is_hunt_fill == 20) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 is_rx_hunt(cur_file_offset); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 return; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 new_bit = input[is_offset] & 1; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 is_rx_word <<= 1; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 is_rx_word |= new_bit; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 is_bit_count++; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 if (is_state == 1 && is_bit_count == 10) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 is_process_cmd(); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 else if (is_state == 2 && is_bit_count == 20) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 is_process_ext(); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 main(argc, argv) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 char **argv; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 FILE *inf; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 uint8_t chunk[16]; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 unsigned file_offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 int cc; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 if (argc != 2) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 fprintf(stderr, "usage: %s pcm-capture-file\n", argv[0]); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 exit(1); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 inf = fopen(argv[1], "r"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 if (!inf) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 perror(argv[1]); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 exit(1); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 for (file_offset = 0; ; file_offset += 16) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 cc = fread(chunk, 1, 16, inf); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 if (cc == 0) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 break; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 if (cc != 16) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 fprintf(stderr, |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 "error: read of 16 bytes returned %d\n", cc); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 exit(1); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 is_rx_process(chunk, file_offset); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 exit(0); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 } |