header file restructuring

Move all protocol definitions to protocol/*.h and keep only
definitions related to our implementation as *.h in the top directory.

Also, remove some header files to reduce header file proliferation.
diff --git a/src/diag_gsm.c b/src/diag_gsm.c
index d74dc5d..a2d0ea4 100644
--- a/src/diag_gsm.c
+++ b/src/diag_gsm.c
@@ -1,9 +1,9 @@
 #include <osmocom/core/utils.h>
 #include <osmocom/core/msgb.h>
 
-#include "diagcmd.h"
-#include "diag_gsm.h"
-#include "protocol.h"
+#include "protocol/diagcmd.h"
+#include "protocol/diag_log_gsm.h"
+#include "protocol/protocol.h"
 
 const struct value_string diag_gsm_rr_st_vals[] = {
 	{ DIAG_RR_ST_INACTIVE,		"INACTIVE" },
diff --git a/src/diag_gsm.h b/src/diag_gsm.h
deleted file mode 100644
index 8e0afa0..0000000
--- a/src/diag_gsm.h
+++ /dev/null
@@ -1,118 +0,0 @@
-#pragma once
-
-#include <stdint.h>
-
-enum diag_gsm_cmd {
-	GSM_DIAG_VERNO_F		= 0,
-	GSM_STATUS_F			= 1,
-	GSM_TMC_STATE_RETRIEVAL_F	= 2,
-	GSM_DIAG_CALL_ORIG_F		= 3,
-	GSM_DIAG_CALL_END_F		= 4,
-	GSM_GPRS_LOG_PACKET_REQ_F	= 5,
-	DIAG_GSM_MAX_F			= 6,
-};
-
-/* LOG_GSM_RR_SIGNALING_MESSAGE_C */
-struct diag_gsm_rr_msg {
-	uint8_t chan_type;
-	uint8_t msg_type;
-	uint8_t length;
-	uint8_t data[0];
-} __attribute__((packed));
-
-enum diag_gsm_rr_st {
-	DIAG_RR_ST_INACTIVE		= 0,
-	DIAG_RR_ST_GOING_ACTIVE		= 1,
-	DIAG_RR_ST_GOING_INACTIVE	= 2,
-	DIAG_RR_ST_CELL_SELECTION	= 3,
-	DIAG_RR_ST_PLMN_LIST_CONSTRUCTION = 4,
-	DIAG_RR_ST_IDLE			= 5,
-	DIAG_RR_ST_CELL_RESELECTION	= 6,
-	DIAG_RR_ST_CONNECTION_PENDING	= 7,
-	DIAG_RR_ST_CHOOSE_CELL		= 8,
-	DIAG_RR_ST_DATA_TRANSFER	= 9,
-	DIAG_RR_ST_NO_CHANNELS		= 10,
-	DIAG_RR_ST_CONNECTION_RELEASE	= 11,
-	DIAG_RR_ST_EARLY_CAMPED_WAIT_FOR_SI= 12,
-	DIAG_RR_ST_W2G_INTERRAT_HO_PROGRESS= 13,
-	DIAG_RR_ST_W2G_INTERRAT_RESELECTION_PROGRESS = 14,
-	DIAG_RR_ST_W2G_INTERRAT_CC_ORDER_PROGRESS = 15,
-	DIAG_RR_ST_G2W_INTERRAT_RESELECTION_PROGRESS = 16,
-	DIAG_RR_ST_WAIT_FOR_EARLY_PSCAN	= 17,
-	DIAG_RR_ST_GRR			= 18,
-	DIAG_RR_ST_G2W_INTERRAT_HO_PROGRESS = 20,
-	DIAG_RR_ST_BACKGROUND_PLMN_SEARCH = 21,
-	DIAG_RR_ST_W2G_SERVICE_REDIR_IN_PROGRESS = 22,
-	DIAG_RR_ST_RESET		= 23,
-	DIAG_RR_ST_W2G_BACKGROUND_PLN_SEARCH = 24,
-};
-extern const struct value_string diag_gsm_rr_st_vals[25];
-
-/* LOG_GSM_RR_STATE_C */
-struct diag_gsm_rr_state {
-	uint8_t state;
-	uint8_t substate;
-	uint8_t status;
-	uint8_t mode;
-} __attribute__((packed));
-
-enum diag_gprs_grr_st {
-	DIAG_GRR_ST_NULL	= 0,
-	DIAG_GRR_ST_ACQUIRE	= 1,
-	DIAG_GRR_ST_CAMPED	= 2,
-	DIAG_GRR_ST_CONN_PEND	= 3,
-	DIAG_GRR_ST_CELL_RESEL	= 4,
-	DIAG_GRR_ST_CELL_RESEL_G2W	= 6,
-	DIAG_GRR_ST_BG_PLMN_SEARCH	= 7,
-	DIAG_GRR_ST_PCCO	= 8,
-};
-extern const struct value_string diag_gprs_grr_st_vals[9];
-
-/* LOG_GPRS_GRR_STATE_C */
-struct diag_gprs_grr_state {
-	uint8_t	active_state;
-	uint8_t grr_state;
-} __attribute__((packed));
-
-
-enum diag_gprs_llme_state {
-	DIAG_GPRS_LLMES_TLLI_UNASS	= 0,
-	DIAG_GPRS_LLMES_TLLI_ASS	= 1,
-	DIAG_GPRS_LLMES_TEST_MODE	= 2,
-};
-const struct value_string diag_gprs_llme_st_vals[4];
-
-/* LOG_GPRS_LLC_ME_INFO_C */
-struct diag_gprs_llme_info {
-	uint8_t state;
-	uint8_t xid_version;
-	uint32_t tlli_new;
-	uint32_t tlli_old;
-	uint8_t enc_alg;
-	uint8_t enc_key[8];
-	uint32_t input_offset_iov_ui;
-} __attribute__((packed));
-
-/* LOG_GPRS_LLC_PDU_STATS_C */
-struct diag_gprs_llc_stats {
-	uint8_t	sapi;
-	uint32_t ack_l3pdu_tx;
-	uint32_t ack_octet_tx;
-	uint32_t ack_l3pdu_retrans;
-	uint32_t ack_octet_retrans;
-	uint32_t ack_l3pdu_rx;
-	uint32_t ack_octet_rx;
-	uint32_t unack_l3pdu_tx;
-	uint32_t unack_octet_tx;
-	uint32_t unack_l3pdu_rx;
-	uint32_t unack_octet_rx;
-	uint32_t llpdu_tx;
-	uint32_t llpdu_rx;
-	uint32_t llpdu_fcs_err;
-	uint32_t llpdu_frm_rej;
-	uint32_t llpdu_tlli_err;
-	uint32_t llpdu_addr_err;
-	uint32_t llpdu_short_err;
-} __attribute__((packed));
-
-struct msgb *diag_gsm_make_log_pack_req(uint16_t log_code, uint8_t zero_stats, uint8_t addl_info);
diff --git a/src/diag_io.c b/src/diag_io.c
index b8dd18b..f9abd87 100644
--- a/src/diag_io.c
+++ b/src/diag_io.c
@@ -5,7 +5,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "protocol.h"
+#include "protocol/protocol.h"
 #include "diag_io.h"
 #include "diagchar_hdlc.h"
 
diff --git a/src/diag_log.c b/src/diag_log.c
index 1bb3a72..2f0bc79 100644
--- a/src/diag_log.c
+++ b/src/diag_log.c
@@ -4,8 +4,8 @@
 #include <osmocom/core/msgb.h>
 
 #include "diag_log.h"
-#include "protocol.h"
-#include "diagcmd.h"
+#include "protocol/protocol.h"
+#include "protocol/diagcmd.h"
 
 /***********************************************************************
  * LOG Configuration / Protocol
diff --git a/src/diag_log.h b/src/diag_log.h
index 785549e..5c442b8 100644
--- a/src/diag_log.h
+++ b/src/diag_log.h
@@ -1,7 +1,7 @@
 #pragma once
 
 #include "diag_io.h"
-#include "protocol.h"
+#include "protocol/protocol.h"
 
 typedef void diag_log_handler(struct log_hdr *lh, struct msgb *msg);
 
diff --git a/src/diag_log_gprs.c b/src/diag_log_gprs.c
index f267600..3225d6a 100644
--- a/src/diag_log_gprs.c
+++ b/src/diag_log_gprs.c
@@ -1,10 +1,9 @@
 #include <stdio.h>
 
 #include "diag_log.h"
-#include "diag_gsm.h"
-#include "gprs_rlc.h"
-#include "gprs_mac.h"
-#include "log_codes_gsm.h"
+#include "protocol/diag_log_gsm.h"
+#include "protocol/diag_log_gprs_rlc.h"
+#include "protocol/diag_log_gprs_mac.h"
 
 
 static void handle_grr_state_msg(struct log_hdr *lh, struct msgb *msg)
diff --git a/src/diag_log_gsm.c b/src/diag_log_gsm.c
index 791d6c6..cfc96a4 100644
--- a/src/diag_log_gsm.c
+++ b/src/diag_log_gsm.c
@@ -1,8 +1,7 @@
 #include <stdio.h>
 
 #include "diag_log.h"
-#include "diag_gsm.h"
-#include "log_codes_gsm.h"
+#include "protocol/diag_log_gsm.h"
 
 
 static void handle_rr_sig_msg(struct log_hdr *lh, struct msgb *msg)
diff --git a/src/diag_log_qmi.c b/src/diag_log_qmi.c
index b6f7eb5..cc9f0a8 100644
--- a/src/diag_log_qmi.c
+++ b/src/diag_log_qmi.c
@@ -4,7 +4,7 @@
 #include <libqmi-glib.h>
 
 #include "diag_log.h"
-#include "log_codes_qmi.h"
+#include "protocol/diag_log_qmi.h"
 
 /* A small wrapper around libqmi-glib to give us a human-readable string
  * representation of QMI messages that we receive from DIAG */
diff --git a/src/diag_log_umts.c b/src/diag_log_umts.c
index c0303b4..1d69648 100644
--- a/src/diag_log_umts.c
+++ b/src/diag_log_umts.c
@@ -1,8 +1,7 @@
 #include <stdio.h>
 
 #include "diag_log.h"
-#include "diag_wcdma.h"
-#include "log_codes_wcdma.h"
+#include "protocol/diag_log_wcdma.h"
 
 static void handle_rrc_sig_msg(struct log_hdr *lh, struct msgb *msg)
 {
@@ -12,9 +11,6 @@
 		osmo_hexdump(msgb_data(msg), rrm->length));
 }
 
-#define UMTS(x)	(0x4000 + x)
-
-
 static const struct diag_log_dispatch_tbl log_tbl[] = {
 	{ UMTS(LOG_WCDMA_SIGNALING_MSG_C), handle_rrc_sig_msg },
 };
diff --git a/src/diag_msg.c b/src/diag_msg.c
index 646663e..b17106d 100644
--- a/src/diag_msg.c
+++ b/src/diag_msg.c
@@ -7,9 +7,9 @@
 #include <osmocom/core/bit16gen.h>
 #include <osmocom/core/bit32gen.h>
 
-#include "protocol.h"
+#include "protocol/protocol.h"
 #include "diag_msg.h"
-#include "diagcmd.h"
+#include "protocol/diagcmd.h"
 
 struct diag_set_rt_mask_req {
 	uint8_t cmd_code;
diff --git a/src/gprs_mac.c b/src/gprs_mac.c
index b2073be..79341f6 100644
--- a/src/gprs_mac.c
+++ b/src/gprs_mac.c
@@ -1,6 +1,6 @@
 #include <osmocom/core/utils.h>
 
-#include "gprs_mac.h"
+#include "protocol/diag_log_gprs_mac.h"
 
 struct value_string gprs_mac_mode_vals[] = {
 	{ NULL_MODE,	"NULL" },
diff --git a/src/gprs_rlc.c b/src/gprs_rlc.c
index 7ea5437..9e3bed0 100644
--- a/src/gprs_rlc.c
+++ b/src/gprs_rlc.c
@@ -1,6 +1,6 @@
 #include <osmocom/core/utils.h>
 
-#include "gprs_rlc.h"
+#include "protocol/diag_log_gprs_rlc.h"
 
 struct value_string gprs_rlc_ul_state_vals[8] = {
 	{ US_NULL,		"US_NULL" },
diff --git a/src/log_codes_gsm.h b/src/log_codes_gsm.h
deleted file mode 100644
index aba64ab..0000000
--- a/src/log_codes_gsm.h
+++ /dev/null
@@ -1,94 +0,0 @@
-#pragma once
-
-#define GSM(x)	(0x5000 + x)
-
-enum diag_log_code_gsm {
-	LOG_GSM_POWER_SCAN_C				= 0x64,
-	LOG_GSM_FCCH_DECODE_C				= 0x65,
-	LOG_GSM_NCELL_ACQ_C				= 0x75,
-	LOG_GSM_AFC_ADJUST_C				= 0x7c,
-	LOG_GSM_MON_BURST_C				= 0x82,
-	LOG_GSM_BCCH_BURST_METRICS_C			= 0x85,
-	LOG_GSM_GL1_HW_CMD_C				= 0x8d,
-	LOG_GSM_RR_STATE_C				= 0x12c,
-	LOG_GSM_RR_SIGNALING_MESSAGE_C			= 0x12f,
-
-
-	LOG_GSM_RR_CONTROL_CHANNEL_PARAMS_C		= 306,
-
-	LOG_GPRS_INDICATORS_C				= 500,
-	LOG_GPRS_GENERAL_PARAMS_C			= 501,
-	LOG_GPRS_CELL_OPTIONS_C				= 502,
-	LOG_GPRS_POWER_CONTROL_PARAMS_C			= 503,
-	LOG_GPRS_MOBILE_ALLOCATION_C			= 504,
-	LOG_GPRS_PBCCH_DESCRIPTION_C			= 505,
-	LOG_GPRS_GRR_STATE_C				= 506,
-	LOG_GPRS_RR_CELL_RESELECTION_PARAMS_C		= 507,
-	LOG_GPRS_RR_CELL_RESELECTION_MEASMNTS_C		= 508,
-	LOG_GPRS_RR_PSI1_C				= 509,
-	LOG_GPRS_RR_PSI2_C				= 510,
-	LOG_GPRS_RR_PSI3_C				= 511,
-	LOG_GPRS_RLC_UL_ABNRML_RLS_COUNTS_C		= 512,
-	LOG_GPRS_RLC_UL_EVENT_COUNTS_C			= 513,
-	LOG_GPRS_RLC_UL_STATS_C				= 514,
-	LOG_EGPRS_RLC_UL_HEADER_C			= 517,
-	LOG_EGPRS_RLC_DL_HEADER_C			= 518,
-	LOG_EGPRS_RLC_UL_STATS_C			= 519,
-	LOG_EGPRS_RLC_DL_STATS_C			= 520,
-	LOG_EGPRS_RLC_EPUAN_C				= 521,
-	LOG_GPRS_RLC_DL_STATS_C				= 522,
-	LOG_GPRS_RLC_UL_ACKNACK_PARAMS_C		= 523,
-	LOG_GPRS_RLC_DL_ACKNACK_PARAMS_C		= 524,
-	LOG_GPRS_RLC_UL_RELEASE_IND_C			= 525,
-	LOG_GPRS_RLC_DL_RELEASE_IND_C			= 526,
-	LOG_GPRS_RLC_UL_ACKNACK_PARAMS_VER2_C		= 527,
-	LOG_GPRS_RLC_DL_ACKNACK_PARAMS_VER2_C		= 528,
-	LOG_EGPRS_RLC_EPDAN_C				= 529,
-	LOG_GPRS_LLC_ME_INFO_C				= 530,
-	LOG_GPRS_LLC_SAPI_STATES_C			= 531,
-	LOG_GPRS_LLC_XID_INFO_C				= 532,
-	LOG_GPRS_LLC_PDU_STATS_C			= 533,
-	LOG_GPRS_LLC_PERIODIC_STATS_C			= 534,
-	LOG_GPRS_LLC_READY_TIMER_STATUS_C		= 535,
-	LOG_GPRS_LLC_SEND_UI_FRAME_C			= 536,
-	LOG_GPRS_LLC_RECV_UI_FRAME_C			= 537,
-	LOG_GPRS_LLC_READY_TIMER_STATUS_VER2_C		= 538,
-	LOG_GPRS_SNDCP_ACTIVE_PDP_CONTEXTS_C		= 540,
-	LOG_GPRS_SNDCP_PDP_CONTEXT_INFO_C		= 541,
-	LOG_GPRS_SNDCP_STATES_C				= 542,
-	LOG_GPRS_SNDCP_PDU_STATS_C			= 543,
-	LOG_GPRS_SNDCP_UL_TCP_HDR_C			= 544,
-	LOG_GPRS_SNDCP_DL_TCP_HDR_C			= 545,
-	LOG_GPRS_MAC_SIGNALLING_MESSAGE_C		= 550,
-	LOG_GPRS_MAC_STATE_C				= 551,
-	LOG_GPRS_MAC_UL_TBF_ESTABLISH_C			= 552,
-	LOG_GPRS_MAC_UL_TBF_RELEASE_C			= 553,
-	LOG_GPRS_MAC_DL_TBF_ESTABLISH_C			= 554,
-	LOG_GPRS_MAC_DL_TBF_RELEASE_C			= 555,
-	LOG_EGPRS_MAC_UL_ACKNACK_C			= 556,
-	LOG_EGPRS_MAC_DL_ACKNACK_C			= 557,
-	LOG_EGPRS_SRB_HARD_DECISIONS_C			= 558,
-	LOG_GPRS_SM_GMM_OTA_MESSAGE_C			= 560,
-	LOG_GPRS_AIR_INTERFACE_SUMMARY_C		= 561,
-	LOG_GPRS_AGC_C					= 562,
-	LOG_GPRS_TIMING_ADVANCE_C			= 563,
-	LOG_GPRS_POWER_CONTROL_C			= 564,
-	LOG_GPRS_TRANSFER_SUMMARY_C			= 565,
-	LOG_GPRS_TX_SCHEDULED_RESULTS_C			= 567,
-	LOG_GPRS_HW_SCHEDULE_C				= 570,
-	LOG_UPLINK_TBF_DATA_BLOCK_COUNT_C		= 575,
-	LOG_GPRS_RECEIVE_BURST_METRICS_A_C		= 581,
-	LOG_GPRS_RECEIVE_BURST_METRICS_B_C		= 582,
-	LOG_GPRS_RECEIVE_BURST_METRICS_C_C		= 583,
-	LOG_GPRS_RECEIVE_BURST_METRICS_D_C		= 584,
-	LOG_GPRS_RECEIVE_MSG_METRICS_A_C		= 585,
-	LOG_GPRS_RECEIVE_MSG_METRICS_B_C		= 586,
-	LOG_GPRS_RECEIVE_MSG_METRICS_C_C		= 587,
-	LOG_GPRS_RECEIVE_MSG_METRICS_D_C		= 588,
-	LOG_GPRS_RECEIVE_MSG_METRICS_A_VER2_C		= 589,
-	LOG_GPRS_RECEIVE_MSG_METRICS_B_VER2_C		= 590,
-	LOG_GPRS_RECEIVE_MSG_METRICS_C_VER2_C		= 591,
-	LOG_GPRS_RECEIVE_MSG_METRICS_D_VER2_C		= 592,
-	LOG_GPRS_DLPTCCH_BURST_METRICS_C		= 593,
-	LOG_GPRS_DLPTCCH_MSG_METRICS_C			= 594,
-};
diff --git a/src/log_codes_wcdma.h b/src/log_codes_wcdma.h
deleted file mode 100644
index d19f82f..0000000
--- a/src/log_codes_wcdma.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-enum diag_log_code_umts {
-	LOG_WCDMA_RRC_STATES_C				= 0x125,
-	LOG_WCDMA_RRC_PROTOCOL_ERRORS_C			= 0x126,
-	LOG_WCDMA_CELL_ID_C				= 0x127,
-	LOG_WCDMA_SIGNALING_MSG_C			= 0x12f,
-};
diff --git a/src/protocol.c b/src/protocol.c
index d89603d..7574227 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -1,6 +1,6 @@
 #include <osmocom/core/msgb.h>
-#include "protocol.h"
-#include "diagcmd.h"
+#include "protocol/protocol.h"
+#include "protocol/diagcmd.h"
 
 int diag_push_subsys_hdr(struct msgb *msg, uint8_t subsys, uint8_t code)
 {
diff --git a/src/gprs_mac.h b/src/protocol/diag_log_gprs_mac.h
similarity index 100%
rename from src/gprs_mac.h
rename to src/protocol/diag_log_gprs_mac.h
diff --git a/src/gprs_rlc.h b/src/protocol/diag_log_gprs_rlc.h
similarity index 100%
rename from src/gprs_rlc.h
rename to src/protocol/diag_log_gprs_rlc.h
diff --git a/src/protocol/diag_log_gsm.h b/src/protocol/diag_log_gsm.h
new file mode 100644
index 0000000..fb67821
--- /dev/null
+++ b/src/protocol/diag_log_gsm.h
@@ -0,0 +1,211 @@
+#pragma once
+
+#include <stdint.h>
+
+#define GSM(x)	(0x5000 + x)
+
+enum diag_log_code_gsm {
+	LOG_GSM_POWER_SCAN_C				= 0x64,
+	LOG_GSM_FCCH_DECODE_C				= 0x65,
+	LOG_GSM_NCELL_ACQ_C				= 0x75,
+	LOG_GSM_AFC_ADJUST_C				= 0x7c,
+	LOG_GSM_MON_BURST_C				= 0x82,
+	LOG_GSM_BCCH_BURST_METRICS_C			= 0x85,
+	LOG_GSM_GL1_HW_CMD_C				= 0x8d,
+	LOG_GSM_RR_STATE_C				= 0x12c,
+	LOG_GSM_RR_SIGNALING_MESSAGE_C			= 0x12f,
+
+
+	LOG_GSM_RR_CONTROL_CHANNEL_PARAMS_C		= 306,
+
+	LOG_GPRS_INDICATORS_C				= 500,
+	LOG_GPRS_GENERAL_PARAMS_C			= 501,
+	LOG_GPRS_CELL_OPTIONS_C				= 502,
+	LOG_GPRS_POWER_CONTROL_PARAMS_C			= 503,
+	LOG_GPRS_MOBILE_ALLOCATION_C			= 504,
+	LOG_GPRS_PBCCH_DESCRIPTION_C			= 505,
+	LOG_GPRS_GRR_STATE_C				= 506,
+	LOG_GPRS_RR_CELL_RESELECTION_PARAMS_C		= 507,
+	LOG_GPRS_RR_CELL_RESELECTION_MEASMNTS_C		= 508,
+	LOG_GPRS_RR_PSI1_C				= 509,
+	LOG_GPRS_RR_PSI2_C				= 510,
+	LOG_GPRS_RR_PSI3_C				= 511,
+	LOG_GPRS_RLC_UL_ABNRML_RLS_COUNTS_C		= 512,
+	LOG_GPRS_RLC_UL_EVENT_COUNTS_C			= 513,
+	LOG_GPRS_RLC_UL_STATS_C				= 514,
+	LOG_EGPRS_RLC_UL_HEADER_C			= 517,
+	LOG_EGPRS_RLC_DL_HEADER_C			= 518,
+	LOG_EGPRS_RLC_UL_STATS_C			= 519,
+	LOG_EGPRS_RLC_DL_STATS_C			= 520,
+	LOG_EGPRS_RLC_EPUAN_C				= 521,
+	LOG_GPRS_RLC_DL_STATS_C				= 522,
+	LOG_GPRS_RLC_UL_ACKNACK_PARAMS_C		= 523,
+	LOG_GPRS_RLC_DL_ACKNACK_PARAMS_C		= 524,
+	LOG_GPRS_RLC_UL_RELEASE_IND_C			= 525,
+	LOG_GPRS_RLC_DL_RELEASE_IND_C			= 526,
+	LOG_GPRS_RLC_UL_ACKNACK_PARAMS_VER2_C		= 527,
+	LOG_GPRS_RLC_DL_ACKNACK_PARAMS_VER2_C		= 528,
+	LOG_EGPRS_RLC_EPDAN_C				= 529,
+	LOG_GPRS_LLC_ME_INFO_C				= 530,
+	LOG_GPRS_LLC_SAPI_STATES_C			= 531,
+	LOG_GPRS_LLC_XID_INFO_C				= 532,
+	LOG_GPRS_LLC_PDU_STATS_C			= 533,
+	LOG_GPRS_LLC_PERIODIC_STATS_C			= 534,
+	LOG_GPRS_LLC_READY_TIMER_STATUS_C		= 535,
+	LOG_GPRS_LLC_SEND_UI_FRAME_C			= 536,
+	LOG_GPRS_LLC_RECV_UI_FRAME_C			= 537,
+	LOG_GPRS_LLC_READY_TIMER_STATUS_VER2_C		= 538,
+	LOG_GPRS_SNDCP_ACTIVE_PDP_CONTEXTS_C		= 540,
+	LOG_GPRS_SNDCP_PDP_CONTEXT_INFO_C		= 541,
+	LOG_GPRS_SNDCP_STATES_C				= 542,
+	LOG_GPRS_SNDCP_PDU_STATS_C			= 543,
+	LOG_GPRS_SNDCP_UL_TCP_HDR_C			= 544,
+	LOG_GPRS_SNDCP_DL_TCP_HDR_C			= 545,
+	LOG_GPRS_MAC_SIGNALLING_MESSAGE_C		= 550,
+	LOG_GPRS_MAC_STATE_C				= 551,
+	LOG_GPRS_MAC_UL_TBF_ESTABLISH_C			= 552,
+	LOG_GPRS_MAC_UL_TBF_RELEASE_C			= 553,
+	LOG_GPRS_MAC_DL_TBF_ESTABLISH_C			= 554,
+	LOG_GPRS_MAC_DL_TBF_RELEASE_C			= 555,
+	LOG_EGPRS_MAC_UL_ACKNACK_C			= 556,
+	LOG_EGPRS_MAC_DL_ACKNACK_C			= 557,
+	LOG_EGPRS_SRB_HARD_DECISIONS_C			= 558,
+	LOG_GPRS_SM_GMM_OTA_MESSAGE_C			= 560,
+	LOG_GPRS_AIR_INTERFACE_SUMMARY_C		= 561,
+	LOG_GPRS_AGC_C					= 562,
+	LOG_GPRS_TIMING_ADVANCE_C			= 563,
+	LOG_GPRS_POWER_CONTROL_C			= 564,
+	LOG_GPRS_TRANSFER_SUMMARY_C			= 565,
+	LOG_GPRS_TX_SCHEDULED_RESULTS_C			= 567,
+	LOG_GPRS_HW_SCHEDULE_C				= 570,
+	LOG_UPLINK_TBF_DATA_BLOCK_COUNT_C		= 575,
+	LOG_GPRS_RECEIVE_BURST_METRICS_A_C		= 581,
+	LOG_GPRS_RECEIVE_BURST_METRICS_B_C		= 582,
+	LOG_GPRS_RECEIVE_BURST_METRICS_C_C		= 583,
+	LOG_GPRS_RECEIVE_BURST_METRICS_D_C		= 584,
+	LOG_GPRS_RECEIVE_MSG_METRICS_A_C		= 585,
+	LOG_GPRS_RECEIVE_MSG_METRICS_B_C		= 586,
+	LOG_GPRS_RECEIVE_MSG_METRICS_C_C		= 587,
+	LOG_GPRS_RECEIVE_MSG_METRICS_D_C		= 588,
+	LOG_GPRS_RECEIVE_MSG_METRICS_A_VER2_C		= 589,
+	LOG_GPRS_RECEIVE_MSG_METRICS_B_VER2_C		= 590,
+	LOG_GPRS_RECEIVE_MSG_METRICS_C_VER2_C		= 591,
+	LOG_GPRS_RECEIVE_MSG_METRICS_D_VER2_C		= 592,
+	LOG_GPRS_DLPTCCH_BURST_METRICS_C		= 593,
+	LOG_GPRS_DLPTCCH_MSG_METRICS_C			= 594,
+};
+
+enum diag_gsm_cmd {
+	GSM_DIAG_VERNO_F		= 0,
+	GSM_STATUS_F			= 1,
+	GSM_TMC_STATE_RETRIEVAL_F	= 2,
+	GSM_DIAG_CALL_ORIG_F		= 3,
+	GSM_DIAG_CALL_END_F		= 4,
+	GSM_GPRS_LOG_PACKET_REQ_F	= 5,
+	DIAG_GSM_MAX_F			= 6,
+};
+
+/* LOG_GSM_RR_SIGNALING_MESSAGE_C */
+struct diag_gsm_rr_msg {
+	uint8_t chan_type;
+	uint8_t msg_type;
+	uint8_t length;
+	uint8_t data[0];
+} __attribute__((packed));
+
+enum diag_gsm_rr_st {
+	DIAG_RR_ST_INACTIVE		= 0,
+	DIAG_RR_ST_GOING_ACTIVE		= 1,
+	DIAG_RR_ST_GOING_INACTIVE	= 2,
+	DIAG_RR_ST_CELL_SELECTION	= 3,
+	DIAG_RR_ST_PLMN_LIST_CONSTRUCTION = 4,
+	DIAG_RR_ST_IDLE			= 5,
+	DIAG_RR_ST_CELL_RESELECTION	= 6,
+	DIAG_RR_ST_CONNECTION_PENDING	= 7,
+	DIAG_RR_ST_CHOOSE_CELL		= 8,
+	DIAG_RR_ST_DATA_TRANSFER	= 9,
+	DIAG_RR_ST_NO_CHANNELS		= 10,
+	DIAG_RR_ST_CONNECTION_RELEASE	= 11,
+	DIAG_RR_ST_EARLY_CAMPED_WAIT_FOR_SI= 12,
+	DIAG_RR_ST_W2G_INTERRAT_HO_PROGRESS= 13,
+	DIAG_RR_ST_W2G_INTERRAT_RESELECTION_PROGRESS = 14,
+	DIAG_RR_ST_W2G_INTERRAT_CC_ORDER_PROGRESS = 15,
+	DIAG_RR_ST_G2W_INTERRAT_RESELECTION_PROGRESS = 16,
+	DIAG_RR_ST_WAIT_FOR_EARLY_PSCAN	= 17,
+	DIAG_RR_ST_GRR			= 18,
+	DIAG_RR_ST_G2W_INTERRAT_HO_PROGRESS = 20,
+	DIAG_RR_ST_BACKGROUND_PLMN_SEARCH = 21,
+	DIAG_RR_ST_W2G_SERVICE_REDIR_IN_PROGRESS = 22,
+	DIAG_RR_ST_RESET		= 23,
+	DIAG_RR_ST_W2G_BACKGROUND_PLN_SEARCH = 24,
+};
+extern const struct value_string diag_gsm_rr_st_vals[25];
+
+/* LOG_GSM_RR_STATE_C */
+struct diag_gsm_rr_state {
+	uint8_t state;
+	uint8_t substate;
+	uint8_t status;
+	uint8_t mode;
+} __attribute__((packed));
+
+enum diag_gprs_grr_st {
+	DIAG_GRR_ST_NULL	= 0,
+	DIAG_GRR_ST_ACQUIRE	= 1,
+	DIAG_GRR_ST_CAMPED	= 2,
+	DIAG_GRR_ST_CONN_PEND	= 3,
+	DIAG_GRR_ST_CELL_RESEL	= 4,
+	DIAG_GRR_ST_CELL_RESEL_G2W	= 6,
+	DIAG_GRR_ST_BG_PLMN_SEARCH	= 7,
+	DIAG_GRR_ST_PCCO	= 8,
+};
+extern const struct value_string diag_gprs_grr_st_vals[9];
+
+/* LOG_GPRS_GRR_STATE_C */
+struct diag_gprs_grr_state {
+	uint8_t	active_state;
+	uint8_t grr_state;
+} __attribute__((packed));
+
+
+enum diag_gprs_llme_state {
+	DIAG_GPRS_LLMES_TLLI_UNASS	= 0,
+	DIAG_GPRS_LLMES_TLLI_ASS	= 1,
+	DIAG_GPRS_LLMES_TEST_MODE	= 2,
+};
+const struct value_string diag_gprs_llme_st_vals[4];
+
+/* LOG_GPRS_LLC_ME_INFO_C */
+struct diag_gprs_llme_info {
+	uint8_t state;
+	uint8_t xid_version;
+	uint32_t tlli_new;
+	uint32_t tlli_old;
+	uint8_t enc_alg;
+	uint8_t enc_key[8];
+	uint32_t input_offset_iov_ui;
+} __attribute__((packed));
+
+/* LOG_GPRS_LLC_PDU_STATS_C */
+struct diag_gprs_llc_stats {
+	uint8_t	sapi;
+	uint32_t ack_l3pdu_tx;
+	uint32_t ack_octet_tx;
+	uint32_t ack_l3pdu_retrans;
+	uint32_t ack_octet_retrans;
+	uint32_t ack_l3pdu_rx;
+	uint32_t ack_octet_rx;
+	uint32_t unack_l3pdu_tx;
+	uint32_t unack_octet_tx;
+	uint32_t unack_l3pdu_rx;
+	uint32_t unack_octet_rx;
+	uint32_t llpdu_tx;
+	uint32_t llpdu_rx;
+	uint32_t llpdu_fcs_err;
+	uint32_t llpdu_frm_rej;
+	uint32_t llpdu_tlli_err;
+	uint32_t llpdu_addr_err;
+	uint32_t llpdu_short_err;
+} __attribute__((packed));
+
+struct msgb *diag_gsm_make_log_pack_req(uint16_t log_code, uint8_t zero_stats, uint8_t addl_info);
diff --git a/src/log_codes_qmi.h b/src/protocol/diag_log_qmi.h
similarity index 95%
rename from src/log_codes_qmi.h
rename to src/protocol/diag_log_qmi.h
index 54adce9..d13ed0d 100644
--- a/src/log_codes_qmi.h
+++ b/src/protocol/diag_log_qmi.h
@@ -1,3 +1,4 @@
+#pragma once
 
 #define LOG_QMI_RESERVED_CODES_BASE_C           0x38E
 #define LOG_QMI_LAST_C				(32 + LOG_QMI_RESERVED_CODES_BASE_C)
diff --git a/src/diag_wcdma.h b/src/protocol/diag_log_wcdma.h
similarity index 68%
rename from src/diag_wcdma.h
rename to src/protocol/diag_log_wcdma.h
index af4562d..82a631a 100644
--- a/src/diag_wcdma.h
+++ b/src/protocol/diag_log_wcdma.h
@@ -2,6 +2,15 @@
 
 #include <stdint.h>
 
+#define UMTS(x)	(0x4000 + x)
+
+enum diag_log_code_umts {
+	LOG_WCDMA_RRC_STATES_C				= 0x125,
+	LOG_WCDMA_RRC_PROTOCOL_ERRORS_C			= 0x126,
+	LOG_WCDMA_CELL_ID_C				= 0x127,
+	LOG_WCDMA_SIGNALING_MSG_C			= 0x12f,
+};
+
 enum diag_umts_rrc_chtype {
 	DIAG_UMTS_RRC_CHT_UL_CCCH	= 0,
 	DIAG_UMTS_RRC_CHT_DL_DCCH	= 1,
@@ -19,4 +28,3 @@
 	uint16_t	length;
 	uint8_t		msg[0];
 } __attribute__((packed));
-
diff --git a/src/diagcmd.h b/src/protocol/diagcmd.h
similarity index 100%
rename from src/diagcmd.h
rename to src/protocol/diagcmd.h
diff --git a/src/protocol.h b/src/protocol/protocol.h
similarity index 100%
rename from src/protocol.h
rename to src/protocol/protocol.h
diff --git a/src/qxdm-log.c b/src/qxdm-log.c
index 4bd5cf2..fceb9db 100644
--- a/src/qxdm-log.c
+++ b/src/qxdm-log.c
@@ -15,10 +15,10 @@
 #include <osmocom/core/serial.h>
 
 #include "diag_io.h"
-#include "protocol.h"
 #include "diag_log.h"
 #include "diag_msg.h"
-#include "diagcmd.h"
+#include "protocol/protocol.h"
+#include "protocol/diagcmd.h"
 
 /*********/