separate diag_log_umts to diag_log_wcdma

Qualcomm differentiates between WCDMA (the access stratum) and UMTS (the
non access stratum).  Let's reflect that here.  As an added bonus, we
get working NAS protocol traces.
diff --git a/src/Makefile b/src/Makefile
index 525e784..cf325e6 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2,7 +2,7 @@
 LIBS ?= `pkg-config --libs libosmocore` `pkg-config --libs qmi-glib`
 all: osmo-qcdiag-log
 
-MODS_LOG = gprs_rlc.o gprs_mac.o diag_gsm.o diag_log.o diag_log_gsm.o diag_log_gprs.o diag_log_umts.o diag_log_qmi.o diag_dpl.o
+MODS_LOG = gprs_rlc.o gprs_mac.o diag_gsm.o diag_log.o diag_log_gsm.o diag_log_gprs.o diag_log_wcdma.o diag_log_umts.o diag_log_qmi.o diag_dpl.o
 
 osmo-qcdiag-log: diagchar_hdlc.o diag_io.o osmo-qcdiag-log.o diag_msg.o protocol.o diag_cmd.o $(MODS_LOG)
 	$(CC) $(CPPFLAGS) -o $@ $^ $(LIBS)
diff --git a/src/diag_log_gprs.c b/src/diag_log_gprs.c
index 3a65ac0..00c2e13 100644
--- a/src/diag_log_gprs.c
+++ b/src/diag_log_gprs.c
@@ -169,6 +169,10 @@
 	printf("RLC-%cL-RELEASE { tfi=%u, cause=%u }\n", ud, rli->tfi, rli->cause);
 }
 
+static void handle_gmm_ota_msg(struct log_hdr *lh, struct msgb *msg)
+{
+	printf("GMM-OTA-MESSAGE { FIXME }\n");
+}
 
 static const struct diag_log_dispatch_tbl log_tbl[] = {
 	{ GSM(LOG_GPRS_LLC_ME_INFO_C), handle_llc_me_info },
@@ -186,6 +190,7 @@
 	{ GSM(LOG_GPRS_MAC_UL_TBF_RELEASE_C), handle_mac_ul_tbf_rel },
 	{ GSM(LOG_GPRS_RLC_UL_STATS_C), handle_rlc_ul_stats },
 	{ GSM(LOG_GPRS_RLC_DL_STATS_C), handle_rlc_dl_stats },
+	{ GSM(LOG_GPRS_SM_GMM_OTA_MESSAGE_C), handle_gmm_ota_msg },
 };
 
 static __attribute__((constructor)) void on_dso_load_gprs(void)
diff --git a/src/diag_log_umts.c b/src/diag_log_umts.c
index 609e09d..4826548 100644
--- a/src/diag_log_umts.c
+++ b/src/diag_log_umts.c
@@ -1,25 +1,18 @@
 #include <stdio.h>
 
 #include "diag_log.h"
-#include "protocol/diag_log_gsm.h"
-#include "protocol/diag_log_wcdma.h"
+#include "protocol/diag_log_umts.h"
 
-static void handle_rrc_sig_msg(struct log_hdr *lh, struct msgb *msg)
+static void handle_nas_msg(struct log_hdr *lh, struct msgb *msg)
 {
-	struct diag_umts_rrc_msg *rrm = (struct diag_umts_rrc_msg *) msgb_data(msg);
+	struct diag_umts_nas_ota_msg *nas = (struct diag_umts_nas_ota_msg *) msgb_data(msg);
 
-	printf("RRC: %u %u %u: %s\n", rrm->chan_type, rrm->rb_id, rrm->length,
-		osmo_hexdump(msgb_data(msg), rrm->length));
-}
-
-static void handle_gmm_ota_msg(struct log_hdr *lh, struct msgb *msg)
-{
-	/* FIXME */
+	printf("NAS: %cL %u: %s\n", nas->direction ? 'U':'D', nas->msg_length,
+		osmo_hexdump(msgb_data(msg), nas->msg_length));
 }
 
 static const struct diag_log_dispatch_tbl log_tbl[] = {
-	{ UMTS(LOG_WCDMA_SIGNALING_MSG_C), handle_rrc_sig_msg },
-	{ UMTS(LOG_GPRS_SM_GMM_OTA_MESSAGE_C), handle_gmm_ota_msg },
+	{ UMTS(LOG_UMTS_NAS_OTA_MESSAGE_LOG_PACKET_C), handle_nas_msg },
 };
 
 static __attribute__((constructor)) void on_dso_load_umts(void)
diff --git a/src/diag_log_wcdma.c b/src/diag_log_wcdma.c
new file mode 100644
index 0000000..0c3b2b2
--- /dev/null
+++ b/src/diag_log_wcdma.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+#include "diag_log.h"
+#include "protocol/diag_log_gsm.h"
+#include "protocol/diag_log_wcdma.h"
+
+static void handle_rrc_sig_msg(struct log_hdr *lh, struct msgb *msg)
+{
+	struct diag_umts_rrc_msg *rrm = (struct diag_umts_rrc_msg *) msgb_data(msg);
+
+	printf("RRC: %u %u %u: %s\n", rrm->chan_type, rrm->rb_id, rrm->length,
+		osmo_hexdump(msgb_data(msg), rrm->length));
+}
+
+static const struct diag_log_dispatch_tbl log_tbl[] = {
+	{ WCDMA(LOG_WCDMA_SIGNALING_MSG_C), handle_rrc_sig_msg },
+};
+
+static __attribute__((constructor)) void on_dso_load_umts(void)
+{
+	diag_log_reg_dispatch(log_tbl, ARRAY_SIZE(log_tbl));
+}
diff --git a/src/protocol/diag_log_umts.h b/src/protocol/diag_log_umts.h
new file mode 100644
index 0000000..e66b296
--- /dev/null
+++ b/src/protocol/diag_log_umts.h
@@ -0,0 +1,29 @@
+#pragma once
+
+#include <stdint.h>
+
+#define UMTS(x)	(0x7000 + x)
+
+enum diag_log_code_umts {
+	LOG_UMTS_NAS_GMM_STATE_LOG_PACKET_C		= 0x130,
+	LOG_UMTS_NAS_MM_STATE_LOG_PACKET_C		= 0x131,
+	LOG_UMTS_NAS_REG_LOG_PACKET_C			= 0x132,
+	LOG_UMTS_CS_CALL_SETUP_INFO_LOG_PACKET_C	= 0x133,
+	LOG_UMTS_PS_CALL_INFO_LOG_PACKET_C		= 0x134,
+	LOG_UMTS_MM_INFO_LOG_PACKET_C			= 0x135,
+	LOG_UMTS_NAS_PS_CONNECTION_QOS_LOG_PACKET_C	= 0x136,
+	LOG_UMTS_NAS_CS_CONNECTION_BC_LOG_PACKET_C	= 0x137,
+	LOG_UMTS_NAS_UE_DYNAMIC_ID_LOG_PACKET_C		= 0x138,
+	LOG_UMTS_NAS_UE_STATIC_ID_LOG_PACKET_C		= 0x139,
+	LOG_UMTS_NAS_OTA_MESSAGE_LOG_PACKET_C		= 0x13a,
+	LOG_UMTS_NAS_CFA_MESSAGE_LOG_PACKET_C		= 0xa3b,
+	LOG_UMTS_NAS_ERROR_MESSAGE_LOG_PACKET_C		= 0x13c,
+	LOG_UMTS_CS_CALL_RELEASE_INFO_LOG_PACKET_C	= 0x13d,
+	LOG_UMTS_CS_CALL_CHANGE_INFO_LOG_PACKET_C	= 0x13e,
+};
+
+struct diag_umts_nas_ota_msg {
+	uint8_t		direction;
+	uint32_t	msg_length;
+	uint8_t		data[0];
+} __attribute__((packed));
diff --git a/src/protocol/diag_log_wcdma.h b/src/protocol/diag_log_wcdma.h
index 82a631a..0f7fd47 100644
--- a/src/protocol/diag_log_wcdma.h
+++ b/src/protocol/diag_log_wcdma.h
@@ -2,9 +2,9 @@
 
 #include <stdint.h>
 
-#define UMTS(x)	(0x4000 + x)
+#define WCDMA(x)	(0x4000 + x)
 
-enum diag_log_code_umts {
+enum diag_log_code_wcdma {
 	LOG_WCDMA_RRC_STATES_C				= 0x125,
 	LOG_WCDMA_RRC_PROTOCOL_ERRORS_C			= 0x126,
 	LOG_WCDMA_CELL_ID_C				= 0x127,