FreeCalypso > hg > gsm-net-reveng
annotate tfo/tfo-trace-msg.c @ 29:fec87477e60b
new program tfo-trace-msg
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 28 Aug 2024 02:28:37 +0000 |
parents | |
children | 19039ffbe605 |
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 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 static uint8_t is_hunt_buf[320]; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 static int is_state; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 static unsigned is_hunt_fill; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 static unsigned is_offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 static unsigned is_file_offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 static unsigned is_bit_count; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 static unsigned is_rx_word; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 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
|
22 0, 1, 1, 0, 1, 0, 1, 0, 0, 1}; |
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 void |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 is_rx_hunt(cur_file_offset) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 unsigned cur_file_offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 unsigned offset, n; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 for (offset = 0; offset < 16; offset++) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 for (n = 0; n < 20; n++) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 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
|
33 break; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if (n == 20) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 break; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 } |
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 return; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 is_offset = offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 is_file_offset = cur_file_offset - 19*16 + offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 is_state = 1; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 is_bit_count = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 is_rx_word = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 is_hunt_fill = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 static void |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 is_process_cmd() |
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 int cont; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 printf("0x%x: ", is_file_offset); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 switch (is_rx_word) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 case 0x05D: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 printf("IS_REQ\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 cont = 1; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 break; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 case 0x0BA: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 printf("IS_ACK\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 0x0E7: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 printf("IS_IPE\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 0x129: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 printf("IS_FILL\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 cont = 0; |
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 0x174: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 printf("IS_DUP\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 0x193: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 printf("IS_SYL\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 default: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 printf("unknown IS_Command 0x%03X\n", is_rx_word); |
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 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 if (cont) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 is_state = 2; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 is_bit_count = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 is_rx_word = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 } else |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 is_state = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 static void |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 is_process_ext() |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 printf(" IS_Extension: 0x%05X", is_rx_word); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 if (is_rx_word & 0x80200) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 printf(" (bad sync)\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 is_state = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 return; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 switch (is_rx_word & 3) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 case 0: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 printf(" (final)\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 is_state = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 return; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 case 3: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 printf(" (continue)\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 is_state = 2; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 is_bit_count = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 is_rx_word = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 return; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 default: |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 printf(" (bad EX)\n"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 is_state = 0; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 static void |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 is_rx_process(input, cur_file_offset) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 uint8_t *input; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 unsigned cur_file_offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 unsigned new_bit; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 memmove(is_hunt_buf, is_hunt_buf + 16, 304); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 memcpy(is_hunt_buf + 304, input, 16); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 if (!is_state) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 if (is_hunt_fill < 20) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 is_hunt_fill++; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 if (is_hunt_fill == 20) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 is_rx_hunt(cur_file_offset); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 return; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 new_bit = input[is_offset] & 1; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 is_rx_word <<= 1; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 is_rx_word |= new_bit; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 is_bit_count++; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 if (is_state == 1 && is_bit_count == 10) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 is_process_cmd(); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 else if (is_state == 2 && is_bit_count == 20) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 is_process_ext(); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 main(argc, argv) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 char **argv; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 FILE *inf; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 uint8_t chunk[16]; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 unsigned file_offset; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 int cc; |
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 if (argc != 2) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 fprintf(stderr, "usage: %s pcm-capture-file\n", argv[0]); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 exit(1); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 inf = fopen(argv[1], "r"); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 if (!inf) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 perror(argv[1]); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 exit(1); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 for (file_offset = 0; ; file_offset += 16) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 cc = fread(chunk, 1, 16, inf); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 if (cc == 0) |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 break; |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 if (cc != 16) { |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 fprintf(stderr, |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 "error: read of 16 bytes returned %d\n", cc); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 exit(1); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 is_rx_process(chunk, file_offset); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 } |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 exit(0); |
fec87477e60b
new program tfo-trace-msg
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 } |