summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-02-09 02:01:48 +0100
committerHarald Welte <laforge@gnumonks.org>2018-02-09 02:21:34 +0100
commit572177063d4cf2416b9f622d5031212204563720 (patch)
tree7d84544c38ebd84e9fcde7418d6938a4c9618e1d
parentbf383a1d83661af26ccd6521c49b655fb22531d4 (diff)
msgb: Add msgb_hexdump_{l2,l3}() to dump l2 or l3 part of message buffer
Change-Id: I98e85397fb541ee0fd711f2e1852f63f3bb87359
-rw-r--r--include/osmocom/core/msgb.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index 335067ea..9f4c444c 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -509,4 +509,18 @@ void *msgb_talloc_ctx_init(void *root_ctx, unsigned int pool_size);
void msgb_set_talloc_ctx(void *ctx) OSMO_DEPRECATED("Use msgb_talloc_ctx_init() instead");
int msgb_printf(struct msgb *msgb, const char *format, ...);
+static inline const char *msgb_hexdump_l2(const struct msgb *msg)
+{
+ if (!msgb_l2(msg) || !(msgb_l2len(msg)))
+ return "[]";
+ return osmo_hexdump(msgb_l2(msg), msgb_l2len(msg));
+}
+
+static inline const char *msgb_hexdump_l3(const struct msgb *msg)
+{
+ if (!msgb_l3(msg) || !(msgb_l3len(msg)))
+ return "[]";
+ return osmo_hexdump(msgb_l3(msg), msgb_l3len(msg));
+}
+
/*! @} */