aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-01-01 11:41:02 +0100
committerHarald Welte <laforge@gnumonks.org>2017-01-01 19:51:50 +0100
commitefb3ecadd761c68d0b5b89d9f70dd825723385eb (patch)
tree0cadab5fa576804a928190c227e940fdf9efeeef
parentdc2cafcd97be63232a1fc513013987064477cf86 (diff)
add ability to hexdump all received and transmitted messages
-rw-r--r--src/diag_io.c7
-rw-r--r--src/diag_io.h3
2 files changed, 10 insertions, 0 deletions
diff --git a/src/diag_io.c b/src/diag_io.c
index b4313bb..087eecf 100644
--- a/src/diag_io.c
+++ b/src/diag_io.c
@@ -41,6 +41,9 @@ int diag_transmit_msgb(struct diag_instance *di, struct msgb *msg)
struct diag_send_desc_type send;
struct diag_hdlc_dest_type enc = { NULL, NULL, 0 };
+ if (di->flags & DIAG_INST_F_HEXDUMP)
+ printf("Tx: %s\n", msgb_hexdump(msg));
+
send.state = DIAG_STATE_START;
send.pkt = msgb_data(msg);
send.last = msgb_data(msg) + msgb_length(msg) - 1;
@@ -128,6 +131,10 @@ struct msgb *diag_read_msg(struct diag_instance *di)
msgb_free(msg);
return NULL;
}
+
+ if (di->flags & DIAG_INST_F_HEXDUMP)
+ printf("Rx: %s\n", msgb_hexdump(msg));
+
return msg;
}
diff --git a/src/diag_io.h b/src/diag_io.h
index 953a089..1dffa15 100644
--- a/src/diag_io.h
+++ b/src/diag_io.h
@@ -4,6 +4,8 @@
#include <osmocom/core/msgb.h>
#include <osmocom/core/gsmtap_util.h>
+#define DIAG_INST_F_HEXDUMP 0x00000001
+
struct diag_instance {
int fd;
struct {
@@ -12,6 +14,7 @@ struct diag_instance {
struct {
} tx;
struct gsmtap_inst *gsmtap;
+ uint32_t flags;
};
struct msgb *msgb_alloc_diag(void);