aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/gsm/tlv.h
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-08-09 17:21:01 +0200
committerpespin <pespin@sysmocom.de>2023-08-11 15:36:27 +0000
commit6df53dc769d6b9c633307fa70de4a0e27cf950fa (patch)
tree6123661a5d3b950fdfcf9bf4934db1577c41e1f8 /include/osmocom/gsm/tlv.h
parent3c577269c8e7bff56c46d642994b4540a10db27f (diff)
tlv: Introduce API msgb_tv32_push()
msgb_tv32_put() already exists, but msgb_tv32_push doesn't. The tv16 counterparts are already present, and having to pass 32bit integers is also quite common, so let's add an API for it. Change-Id: I68d5693a18d55ce8d0647359044157d7e5bfae50
Diffstat (limited to 'include/osmocom/gsm/tlv.h')
-rw-r--r--include/osmocom/gsm/tlv.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h
index fd6659c6..28e897d7 100644
--- a/include/osmocom/gsm/tlv.h
+++ b/include/osmocom/gsm/tlv.h
@@ -457,6 +457,16 @@ static inline uint8_t *msgb_tv16_push(struct msgb *msg, uint8_t tag, uint16_t va
return buf;
}
+/*! push (prepend) a TV32 field to a \ref msgb
+ * \returns pointer to first byte of newly-pushed information */
+static inline uint8_t *msgb_tv32_push(struct msgb *msg, uint8_t tag, uint32_t val)
+{
+ uint8_t *buf = msgb_push(msg, 5);
+ *buf++ = tag;
+ osmo_store32be(val, buf);
+ return buf;
+}
+
/*! push (prepend) a TvLV field to a \ref msgb
* \returns pointer to first byte of newly-pushed information */
static inline uint8_t *msgb_tvlv_push(struct msgb *msg, uint8_t tag, uint16_t len,