diff options
author | Max <msuraev@sysmocom.de> | 2018-12-03 14:00:49 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2018-12-03 16:11:58 +0000 |
commit | cb02a391cdd59de9f30b55f06974446f006bf40e (patch) | |
tree | 58a750a48d09579a6783d0704f2a18f52cd5f66a /include/osmocom | |
parent | 225bdf4779a0070648fced5b00cad9c1bfdc9908 (diff) |
Update msgb Lx helpers
* add missing L1 and L4 hexdump
* add msgb_l4() for consistency and convert msgb_sms() into simple alias
Those will be used in follow-up patches for msgb debug/test helpers.
Change-Id: I8d6dd1b1ff3aa98a452711c692ca7dee0449203b
Diffstat (limited to 'include/osmocom')
-rw-r--r-- | include/osmocom/core/msgb.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h index 2449151d..1bb5fe59 100644 --- a/include/osmocom/core/msgb.h +++ b/include/osmocom/core/msgb.h @@ -130,8 +130,10 @@ static inline struct msgb *msgb_dequeue_count(struct llist_head *queue, #define msgb_l2(m) ((void *)(m->l2h)) /*! obtain L3 header of msgb */ #define msgb_l3(m) ((void *)(m->l3h)) +/*! obtain L4 header of msgb */ +#define msgb_l4(m) ((void *)(m->l4h)) /*! obtain SMS header of msgb */ -#define msgb_sms(m) ((void *)(m->l4h)) +#define msgb_sms(m) msgb_l4(m) /*! determine length of L1 message * \param[in] msgb message buffer @@ -566,6 +568,13 @@ 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_l1(const struct msgb *msg) +{ + if (!msgb_l1(msg) || !(msgb_l1len(msg))) + return "[]"; + return osmo_hexdump((const unsigned char *) msgb_l1(msg), msgb_l1len(msg)); +} + static inline const char *msgb_hexdump_l2(const struct msgb *msg) { if (!msgb_l2(msg) || !(msgb_l2len(msg))) @@ -580,4 +589,11 @@ static inline const char *msgb_hexdump_l3(const struct msgb *msg) return osmo_hexdump((const unsigned char*) msgb_l3(msg), msgb_l3len(msg)); } +static inline const char *msgb_hexdump_l4(const struct msgb *msg) +{ + if (!msgb_l4(msg) || !(msgb_l4len(msg))) + return "[]"; + return osmo_hexdump((const unsigned char*) msgb_l4(msg), msgb_l4len(msg)); +} + /*! @} */ |