Change in libosmocore[master]: Update msgb Lx helpers

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Dec 3 16:11:59 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/12079 )

Change subject: Update msgb Lx helpers
......................................................................

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
---
M include/osmocom/core/msgb.h
1 file changed, 17 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index 2449151..1bb5fe5 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -130,8 +130,10 @@
 #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_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 @@
 	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));
+}
+
 /*! @} */

-- 
To view, visit https://gerrit.osmocom.org/12079
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8d6dd1b1ff3aa98a452711c692ca7dee0449203b
Gerrit-Change-Number: 12079
Gerrit-PatchSet: 2
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181203/70873176/attachment.htm>


More information about the gerrit-log mailing list