FreeCalypso > hg > gsm-net-reveng
comparison tfo/tfo-trace-msg.c @ 30:19039ffbe605
tfo-trace-msg: higher level of decoding for TFO_REQ
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 28 Aug 2024 03:03:46 +0000 |
parents | fec87477e60b |
children | f6bb790e186a |
comparison
equal
deleted
inserted
replaced
29:fec87477e60b | 30:19039ffbe605 |
---|---|
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
11 #include <strings.h> | 11 #include <strings.h> |
12 | |
13 #define MAX_EXT_WORDS 5 | |
12 | 14 |
13 static uint8_t is_hunt_buf[320]; | 15 static uint8_t is_hunt_buf[320]; |
14 static int is_state; | 16 static int is_state; |
15 static unsigned is_hunt_fill; | 17 static unsigned is_hunt_fill; |
16 static unsigned is_offset; | 18 static unsigned is_offset; |
17 static unsigned is_file_offset; | 19 static unsigned is_file_offset; |
18 static unsigned is_bit_count; | 20 static unsigned is_bit_count; |
19 static unsigned is_rx_word; | 21 static uint32_t is_rx_word, is_cmd, is_ext_words[MAX_EXT_WORDS]; |
22 static unsigned is_ext_count; | |
20 | 23 |
21 static const u_char hdr_pattern[20] = {0, 1, 0, 1, 0, 1, 1, 0, 1, 0, | 24 static const u_char hdr_pattern[20] = {0, 1, 0, 1, 0, 1, 1, 0, 1, 0, |
22 0, 1, 1, 0, 1, 0, 1, 0, 0, 1}; | 25 0, 1, 1, 0, 1, 0, 1, 0, 0, 1}; |
23 | 26 |
24 static void | 27 static void |
48 is_process_cmd() | 51 is_process_cmd() |
49 { | 52 { |
50 int cont; | 53 int cont; |
51 | 54 |
52 printf("0x%x: ", is_file_offset); | 55 printf("0x%x: ", is_file_offset); |
53 switch (is_rx_word) { | 56 is_cmd = is_rx_word; |
57 switch (is_cmd) { | |
54 case 0x05D: | 58 case 0x05D: |
55 printf("IS_REQ\n"); | 59 printf("IS_REQ\n"); |
56 cont = 1; | 60 cont = 1; |
57 break; | 61 break; |
58 case 0x0BA: | 62 case 0x0BA: |
74 case 0x193: | 78 case 0x193: |
75 printf("IS_SYL\n"); | 79 printf("IS_SYL\n"); |
76 cont = 0; | 80 cont = 0; |
77 break; | 81 break; |
78 default: | 82 default: |
79 printf("unknown IS_Command 0x%03X\n", is_rx_word); | 83 printf("unknown IS_Command 0x%03X\n", (unsigned) is_cmd); |
80 cont = 0; | 84 cont = 0; |
81 } | 85 } |
82 if (cont) { | 86 if (cont) { |
83 is_state = 2; | 87 is_state = 2; |
84 is_bit_count = 0; | 88 is_bit_count = 0; |
85 is_rx_word = 0; | 89 is_rx_word = 0; |
90 is_ext_count = 0; | |
86 } else | 91 } else |
87 is_state = 0; | 92 is_state = 0; |
88 } | 93 } |
89 | 94 |
90 static void | 95 static void |
96 process_tfo_req_ack(reqack) | |
97 char *reqack; | |
98 { | |
99 if (is_ext_count != 2) | |
100 return; | |
101 if (is_ext_words[0] != 0x5394B) /* GSM System ID */ | |
102 return; | |
103 printf(" TFO_%s: List_Ind=%u Sig=0x%02X CoID=0x%X CRC=%u\n", reqack, | |
104 (is_ext_words[1] >> 18) & 1, (is_ext_words[1] >> 10) & 0xFF, | |
105 (is_ext_words[1] >> 5) & 0xF, (is_ext_words[1] >> 2) & 7); | |
106 } | |
107 | |
108 static void | |
109 is_process_high_level() | |
110 { | |
111 switch (is_cmd) { | |
112 case 0x05D: | |
113 process_tfo_req_ack("REQ"); | |
114 break; | |
115 case 0x0BA: | |
116 process_tfo_req_ack("ACK"); | |
117 break; | |
118 } | |
119 } | |
120 | |
121 static void | |
91 is_process_ext() | 122 is_process_ext() |
92 { | 123 { |
93 printf(" IS_Extension: 0x%05X", is_rx_word); | 124 printf(" IS_Extension: 0x%05X", (unsigned) is_rx_word); |
94 if (is_rx_word & 0x80200) { | 125 if (is_rx_word & 0x80200) { |
95 printf(" (bad sync)\n"); | 126 printf(" (bad sync)\n"); |
96 is_state = 0; | 127 is_state = 0; |
97 return; | 128 return; |
98 } | 129 } |
130 if (is_ext_count < MAX_EXT_WORDS) | |
131 is_ext_words[is_ext_count++] = is_rx_word; | |
99 switch (is_rx_word & 3) { | 132 switch (is_rx_word & 3) { |
100 case 0: | 133 case 0: |
101 printf(" (final)\n"); | 134 printf(" (final)\n"); |
102 is_state = 0; | 135 is_state = 0; |
136 is_process_high_level(); | |
103 return; | 137 return; |
104 case 3: | 138 case 3: |
105 printf(" (continue)\n"); | 139 printf(" (continue)\n"); |
106 is_state = 2; | 140 is_state = 2; |
107 is_bit_count = 0; | 141 is_bit_count = 0; |