decode QMUX logs using libqmi-glib
diff --git a/src/GNUmakefile b/src/GNUmakefile
index 6e45445..e1bae6e 100644
--- a/src/GNUmakefile
+++ b/src/GNUmakefile
@@ -1,8 +1,8 @@
-CPPFLAGS ?= -g -O0 -Wall
-LIBS = -losmocore
+CPPFLAGS ?= -g -O0 -Wall `pkg-config --cflags qmi-glib`
+LIBS ?= -losmocore `pkg-config --libs qmi-glib`
all: qxdm-log
-qxdm-log: framing.o serial.o qxdm-log.o config.o gprs_rlc.o gprs_mac.o diag_gsm.o protocol.o
+qxdm-log: framing.o serial.o qxdm-log.o config.o gprs_rlc.o gprs_mac.o diag_gsm.o protocol.o qmi_decode.o
$(CC) $(CPPFLAGS) -o $@ $^ $(LIBS)
clean:
diff --git a/src/qmi_decode.c b/src/qmi_decode.c
new file mode 100644
index 0000000..23af90e
--- /dev/null
+++ b/src/qmi_decode.c
@@ -0,0 +1,27 @@
+#include <stdint.h>
+#include <stdio.h>
+
+#include <libqmi-glib.h>
+
+int dump_qmi_msg(const uint8_t *data, unsigned int len)
+{
+ GByteArray *buffer;
+ GError *error = NULL;
+ QmiMessage *message;
+ gchar *printable;
+
+ buffer = g_byte_array_sized_new(len);
+ g_byte_array_append(buffer, data, len);
+
+ message = qmi_message_new_from_raw(buffer, &error);
+ if (!message) {
+ fprintf(stderr, "qmi_message_new_from_raw() returned NULL\n");
+ return -1;
+ }
+
+ printable = qmi_message_get_printable(message, "QMI ");
+ fputs(printable, stdout);
+ g_free(printable);
+
+ return 0;
+}
diff --git a/src/qmi_decode.h b/src/qmi_decode.h
new file mode 100644
index 0000000..0e4ac6a
--- /dev/null
+++ b/src/qmi_decode.h
@@ -0,0 +1,4 @@
+#pragma once
+#include <stdint.h>
+
+int dump_qmi_msg(const uint8_t *data, unsigned int len);
diff --git a/src/qxdm-log.c b/src/qxdm-log.c
index aceb2ce..05cfe59 100644
--- a/src/qxdm-log.c
+++ b/src/qxdm-log.c
@@ -21,9 +21,11 @@
#include "diag_gsm.h"
#include "log_codes_gsm.h"
#include "log_codes_wcdma.h"
+#include "log_codes_qmi.h"
#include "diag_wcdma.h"
#include "gprs_rlc.h"
#include "gprs_mac.h"
+#include "qmi_decode.h"
char *DumpBYTEs(unsigned char *p, long n, int nBytesPerRow /* = 16 */, char *szLineSep /* = "\n" */, int bRaw /* = FALSE */, const char *szIndent /* = "" */)
{
@@ -401,6 +403,13 @@
printf("LOG(0x%04x, %"PRIu64"u, %u): %s\n", lh->code, lh->ts, lh->len,
osmo_hexdump(lh->data, lh->len));
+
+ uint8_t subsys = lh->code >> 12;
+
+ if (subsys == 0x01 &&
+ ((lh->code & 0xfff) >= LOG_QMI_RESERVED_CODES_BASE_C) &&
+ ((lh->code & 0xfff) <= LOG_QMI_LAST_C))
+ dump_qmi_msg(lh->data, lh->len);
}
/*********/
@@ -542,6 +551,18 @@
transmit_msgb(fd, msg);
do_read(fd);
+
+ printf("Core\n");
+ msg = gen_log_config_set_mask(1, 1064);
+ log_config_set_mask_bit(msg, LOG_QMI_CALL_FLOW_C);
+ log_config_set_mask_bit(msg, LOG_QMI_SUPPORTED_INTERFACES_C);
+ for (int i = 0; i < 16*2; i++)
+ log_config_set_mask_bit(msg, LOG_QMI_RESERVED_CODES_BASE_C+i);
+ for (int i = LOG_QMI_RESERVED_CODES_BASE_C; i < LOG_QMI_LAST_C; i++)
+ log_config_set_mask_bit(msg, i);
+
+ transmit_msgb(fd, msg);
+ do_read(fd);
}
int main(int argc, char **argv)