aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/core
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2018-11-08 13:23:59 +0100
committerHarald Welte <laforge@gnumonks.org>2018-11-19 05:47:25 +0000
commit84fb5bb6a09a6a358f98c654c84c3b99a0f24eef (patch)
tree6593f409f0af13cee294645946edd7d0316e5891 /include/osmocom/core
parentd8d0c3e2d14588f8ae863b36f496f20775777619 (diff)
Move msgb_push helpers to public header
The msgb_wrap_with_TL() is generally useful so it make sense to make it public to facilitate code re-use. Other helpers can be implemented as trivial wrappers over existing tlv.h functions. Update headers and code accordingly. Change-Id: I37e91d031fba28cf1c6735b8069b0265746f55e6
Diffstat (limited to 'include/osmocom/core')
-rw-r--r--include/osmocom/core/msgb.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index 8843db0..2449151 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -366,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