aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/core/msgb.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/osmocom/core/msgb.h')
-rw-r--r--include/osmocom/core/msgb.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index b1cb6ec7..2449151d 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
@@ -354,6 +366,15 @@ static inline void msgb_push_u32(struct msgb *msg, uint32_t word)
osmo_store32be(word, space);
}
+static inline unsigned char *msgb_wrap_with_TL(struct msgb *msgb, uint8_t tag)
+{
+ uint8_t *data = msgb_push(msgb, 2);
+
+ data[0] = tag;
+ data[1] = msgb->len - 2;
+ return data;
+}
+
/*! remove (pull) a header from the front of the message buffer
* \param[in] msgb message buffer
* \param[in] len number of octets to be pulled