From 3c2c1f8dafb34e8b5c7e4a218a855a162cf0d89d Mon Sep 17 00:00:00 2001 From: Aki Niemi Date: Sun, 14 Nov 2010 18:33:05 +0200 Subject: [PATCH] isimodem: Adapt and refactor debugging --- drivers/isimodem/debug.c | 85 +++++++++++++++++++----------------------------- drivers/isimodem/debug.h | 12 ++----- 2 files changed, 37 insertions(+), 60 deletions(-) diff --git a/drivers/isimodem/debug.c b/drivers/isimodem/debug.c index c724b41..d7c41e4 100644 --- a/drivers/isimodem/debug.c +++ b/drivers/isimodem/debug.c @@ -1019,16 +1019,17 @@ const char *gpds_transfer_cause_name(enum gpds_transfer_cause value) #undef _ -static void hex_dump(const char *name, const uint8_t m[], size_t len) +static void hex_dump(const char *resname, uint8_t res, const char *name, + uint8_t id, uint8_t utid, const uint8_t m[], size_t len) { char hex[3 * 16 + 1]; char ascii[16 + 1]; size_t i, j, k; - ofono_debug("%s [%s=0x%02X len=%zu]:", name, - "message_id", m[0], len); + ofono_debug("%s (0x%02X): %s [id=0x%02X utid=0x%02X len=%zu]:", + resname, res, name, id, utid, len); - strcpy(hex, " **"), j = 3; + strcpy(hex, ""), j = 0; strcpy(ascii, "."), k = 1; for (i = 0; i < len; i++) { @@ -1045,56 +1046,38 @@ static void hex_dump(const char *name, const uint8_t m[], size_t len) ofono_debug(" *%-48s : %.*s", hex, (int)k, ascii); } -void ss_debug(const void *restrict buf, size_t len, void *data) +static const char *res_to_name(uint8_t res, uint8_t id) { - const uint8_t *m = buf; - hex_dump(ss_message_id_name(m[0]), m, len); -} - -void mtc_debug(const void *restrict buf, size_t len, void *data) -{ - const uint8_t *m = buf; - hex_dump(mtc_message_id_name(m[0]), m, len); -} - -void sms_debug(const void *restrict buf, size_t len, void *data) -{ - const uint8_t *m = buf; - hex_dump(sms_message_id_name(m[0]), m, len); -} - -void sim_debug(const void *restrict buf, size_t len, void *data) -{ - const uint8_t *m = buf; - hex_dump(sim_message_id_name(m[0]), m, len); -} - -void info_debug(const void *restrict buf, size_t len, void *data) -{ - const uint8_t *m = buf; - hex_dump(info_message_id_name(m[0]), m, len); -} - -void call_debug(const void *restrict buf, size_t len, void *data) -{ - const uint8_t *m = buf; - hex_dump(call_message_id_name(m[0]), m, len); -} - -void net_debug(const void *restrict buf, size_t len, void *data) -{ - const uint8_t *m = buf; - hex_dump(net_message_id_name(m[0]), m, len); + switch (res) { + case PN_NETWORK: + return net_message_id_name(id); + case PN_PHONE_INFO: + return info_message_id_name(id); + case PN_SS: + return ss_message_id_name(id); + case PN_CALL: + return call_message_id_name(id); + case PN_SMS: + return sms_message_id_name(id); + case PN_SIM: + return sim_message_id_name(id); + case PN_MTC: + return mtc_message_id_name(id); + case PN_GSS: + return gss_message_id_name(id); + case PN_GPDS: + return gpds_message_id_name(id); + } + return "UNKNOWN"; } -void gss_debug(const void *restrict buf, size_t len, void *data) +void isi_debug(const GIsiMessage *msg, void *data) { - const uint8_t *m = buf; - hex_dump(gss_message_id_name(m[0]), m, len); -} + uint8_t id = g_isi_msg_id(msg); + uint8_t res = g_isi_msg_resource(msg); + const char *resname = pn_resource_name(res); + const char *name = res_to_name(res, id); -void gpds_debug(const void *restrict buf, size_t len, void *data) -{ - const uint8_t *m = buf; - hex_dump(gpds_message_id_name(m[0]), m, len); + hex_dump(resname, res, name, id, g_isi_msg_utid(msg), g_isi_msg_data(msg), + g_isi_msg_data_len(msg)); } diff --git a/drivers/isimodem/debug.h b/drivers/isimodem/debug.h index dbdc4de..c5955d9 100644 --- a/drivers/isimodem/debug.h +++ b/drivers/isimodem/debug.h @@ -22,6 +22,8 @@ #ifndef __ISIMODEM_DEBUG_H #define __ISIMODEM_DEBUG_H +#include + #include "ss.h" #include "mtc.h" #include "sms.h" @@ -74,15 +76,7 @@ const char *gpds_isi_cause_name(enum gpds_isi_cause value); const char *gpds_transfer_status_name(enum gpds_transfer_status value); const char *gpds_transfer_cause_name(enum gpds_transfer_cause value); -void ss_debug(const void *restrict buf, size_t len, void *data); -void mtc_debug(const void *restrict buf, size_t len, void *data); -void sms_debug(const void *restrict buf, size_t len, void *data); -void sim_debug(const void *restrict buf, size_t len, void *data); -void info_debug(const void *restrict buf, size_t len, void *data); -void call_debug(const void *restrict buf, size_t len, void *data); -void net_debug(const void *restrict buf, size_t len, void *data); -void gss_debug(const void *restrict buf, size_t len, void *data); -void gpds_debug(const void *restrict buf, size_t len, void *data); +void isi_debug(const GIsiMessage *msg, void *data); const char *pn_resource_name(int value); -- 2.7.4