pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/34124 )
Change subject: tlv: Introduce API msgb_tv32_push() ......................................................................
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 --- M TODO-RELEASE M include/osmocom/gsm/tlv.h 2 files changed, 24 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/24/34124/1
diff --git a/TODO-RELEASE b/TODO-RELEASE index acd1a61..f78104e 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -17,3 +17,4 @@ libosmogsm MODIFY osmo_auth_impl callback function signature change. No known external users libosmogsm ADD osmo_auth_c2 libosmogsm ADD OSMO_AUTH_ALG_TUAK +libosmogsm ADD new API msgb_tv32_push() \ No newline at end of file diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h index fd6659c..28e897d 100644 --- a/include/osmocom/gsm/tlv.h +++ b/include/osmocom/gsm/tlv.h @@ -457,6 +457,16 @@ 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,