changeset 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 5f98c5cae4ea
files tfo/tfo-trace-msg.c
diffstat 1 files changed, 38 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tfo/tfo-trace-msg.c	Wed Aug 28 02:28:37 2024 +0000
+++ b/tfo/tfo-trace-msg.c	Wed Aug 28 03:03:46 2024 +0000
@@ -10,13 +10,16 @@
 #include <string.h>
 #include <strings.h>
 
+#define	MAX_EXT_WORDS	5
+
 static uint8_t is_hunt_buf[320];
 static int is_state;
 static unsigned is_hunt_fill;
 static unsigned is_offset;
 static unsigned is_file_offset;
 static unsigned is_bit_count;
-static unsigned is_rx_word;
+static uint32_t is_rx_word, is_cmd, is_ext_words[MAX_EXT_WORDS];
+static unsigned is_ext_count;
 
 static const u_char hdr_pattern[20] =	{0, 1, 0, 1, 0, 1, 1, 0, 1, 0,
 					 0, 1, 1, 0, 1, 0, 1, 0, 0, 1};
@@ -50,7 +53,8 @@
 	int cont;
 
 	printf("0x%x: ", is_file_offset);
-	switch (is_rx_word) {
+	is_cmd = is_rx_word;
+	switch (is_cmd) {
 	case 0x05D:
 		printf("IS_REQ\n");
 		cont = 1;
@@ -76,30 +80,60 @@
 		cont = 0;
 		break;
 	default:
-		printf("unknown IS_Command 0x%03X\n", is_rx_word);
+		printf("unknown IS_Command 0x%03X\n", (unsigned) is_cmd);
 		cont = 0;
 	}
 	if (cont) {
 		is_state = 2;
 		is_bit_count = 0;
 		is_rx_word = 0;
+		is_ext_count = 0;
 	} else
 		is_state = 0;
 }
 
 static void
+process_tfo_req_ack(reqack)
+	char *reqack;
+{
+	if (is_ext_count != 2)
+		return;
+	if (is_ext_words[0] != 0x5394B)		/* GSM System ID */
+		return;
+	printf("  TFO_%s: List_Ind=%u Sig=0x%02X CoID=0x%X CRC=%u\n", reqack,
+		(is_ext_words[1] >> 18) & 1, (is_ext_words[1] >> 10) & 0xFF,
+		(is_ext_words[1] >> 5) & 0xF, (is_ext_words[1] >> 2) & 7);
+}
+
+static void
+is_process_high_level()
+{
+	switch (is_cmd) {
+	case 0x05D:
+		process_tfo_req_ack("REQ");
+		break;
+	case 0x0BA:
+		process_tfo_req_ack("ACK");
+		break;
+	}
+}
+
+static void
 is_process_ext()
 {
-	printf("  IS_Extension: 0x%05X", is_rx_word);
+	printf("  IS_Extension: 0x%05X", (unsigned) is_rx_word);
 	if (is_rx_word & 0x80200) {
 		printf(" (bad sync)\n");
 		is_state = 0;
 		return;
 	}
+	if (is_ext_count < MAX_EXT_WORDS)
+		is_ext_words[is_ext_count++] = is_rx_word;
 	switch (is_rx_word & 3) {
 	case 0:
 		printf(" (final)\n");
 		is_state = 0;
+		is_process_high_level();
 		return;
 	case 3:
 		printf(" (continue)\n");