aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/core
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-11-07 03:53:03 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-11-07 03:58:10 +0700
commite521edefdaa69d1b78b3d4318e046bb8457123b0 (patch)
tree4e6bab1f3185ff298597578fa5b81ea8c9b22497 /include/osmocom/core
parentfa3b48227796e66d9dd05a53ff4b3062b2c19b46 (diff)
core/msgb.h: introduce msgb_l4len() helper
There is already a group of similar functions for L1, L2 and L3, but L4 was missing. The L4 is usually used for parsing of complex L3 messages, such as SS/USSD and SMS. This change introduces a similar halper for L4. Change-Id: I755f2d654bbdad2a8b4f94df9023bdd370b07ae6
Diffstat (limited to 'include/osmocom/core')
-rw-r--r--include/osmocom/core/msgb.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index b1cb6ec..8843db0 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -169,6 +169,18 @@ static inline unsigned int msgb_l3len(const struct msgb *msgb)
return msgb->tail - (uint8_t *)msgb_l3(msgb);
}
+/*! determine length of L4 message
+ * \param[in] msgb message buffer
+ * \returns size of L4 message in bytes
+ *
+ * This function computes the number of bytes between the tail of the
+ * message and the layer 4 header.
+ */
+static inline unsigned int msgb_l4len(const struct msgb *msgb)
+{
+ return msgb->tail - (uint8_t *)msgb_sms(msgb);
+}
+
/*! determine the length of the header
* \param[in] msgb message buffer
* \returns number of bytes between start of buffer and start of msg