From 2c02043f490704805c17f787394403de93d0b9c6 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 22 Jan 2012 23:03:38 +0100 Subject: TLV/msgb: Return first byte of newly-pushed data from msgb_*_push() The msgb_*_push() functions erroneously returned the firsrt byte after newly-pushed information, which makes no sense at all. --- include/osmocom/gsm/tlv.h | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'include/osmocom') diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h index 7b41d2d7..d2936d6d 100644 --- a/include/osmocom/gsm/tlv.h +++ b/include/osmocom/gsm/tlv.h @@ -178,28 +178,32 @@ static inline uint8_t *tv16_put(uint8_t *buf, uint8_t tag, return buf; } -/*! \brief put (append) a LV field to a \ref msgb */ +/*! \brief put (append) a LV field to a \ref msgb + * \returns pointer to first byte after newly-put information */ static inline uint8_t *msgb_lv_put(struct msgb *msg, uint8_t len, const uint8_t *val) { uint8_t *buf = msgb_put(msg, LV_GROSS_LEN(len)); return lv_put(buf, len, val); } -/*! \brief put (append) a TLV field to a \ref msgb */ +/*! \brief put (append) a TLV field to a \ref msgb + * \returns pointer to first byte after newly-put information */ static inline uint8_t *msgb_tlv_put(struct msgb *msg, uint8_t tag, uint8_t len, const uint8_t *val) { uint8_t *buf = msgb_put(msg, TLV_GROSS_LEN(len)); return tlv_put(buf, tag, len, val); } -/*! \brief put (append) a TV field to a \ref msgb */ +/*! \brief put (append) a TV field to a \ref msgb + * \returns pointer to first byte after newly-put information */ static inline uint8_t *msgb_tv_put(struct msgb *msg, uint8_t tag, uint8_t val) { uint8_t *buf = msgb_put(msg, 2); return tv_put(buf, tag, val); } -/*! \brief put (append) a TVfixed field to a \ref msgb */ +/*! \brief put (append) a TVfixed field to a \ref msgb + * \returns pointer to first byte after newly-put information */ static inline uint8_t *msgb_tv_fixed_put(struct msgb *msg, uint8_t tag, unsigned int len, const uint8_t *val) { @@ -207,47 +211,57 @@ static inline uint8_t *msgb_tv_fixed_put(struct msgb *msg, uint8_t tag, return tv_fixed_put(buf, tag, len, val); } -/*! \brief put (append) a V field to a \ref msgb */ +/*! \brief put (append) a V field to a \ref msgb + * \returns pointer to first byte after newly-put information */ static inline uint8_t *msgb_v_put(struct msgb *msg, uint8_t val) { uint8_t *buf = msgb_put(msg, 1); return v_put(buf, val); } -/*! \brief put (append) a TV16 field to a \ref msgb */ +/*! \brief put (append) a TV16 field to a \ref msgb + * \returns pointer to first byte after newly-put information */ static inline uint8_t *msgb_tv16_put(struct msgb *msg, uint8_t tag, uint16_t val) { uint8_t *buf = msgb_put(msg, 3); return tv16_put(buf, tag, val); } -/*! \brief push (prepend) a TLV field to a \ref msgb */ +/*! \brief push (prepend) a TLV field to a \ref msgb + * \returns pointer to first byte of newly-pushed information */ static inline uint8_t *msgb_tlv_push(struct msgb *msg, uint8_t tag, uint8_t len, const uint8_t *val) { uint8_t *buf = msgb_push(msg, TLV_GROSS_LEN(len)); - return tlv_put(buf, tag, len, val); + tlv_put(buf, tag, len, val); + return buf; } -/*! \brief push (prepend) a TV field to a \ref msgb */ +/*! \brief push (prepend) a TV field to a \ref msgb + * \returns pointer to first byte of newly-pushed information */ static inline uint8_t *msgb_tv_push(struct msgb *msg, uint8_t tag, uint8_t val) { uint8_t *buf = msgb_push(msg, 2); - return tv_put(buf, tag, val); + tv_put(buf, tag, val); + return buf; } -/*! \brief push (prepend) a TV16 field to a \ref msgb */ +/*! \brief push (prepend) a TV16 field to a \ref msgb + * \returns pointer to first byte of newly-pushed information */ static inline uint8_t *msgb_tv16_push(struct msgb *msg, uint8_t tag, uint16_t val) { uint8_t *buf = msgb_push(msg, 3); - return tv16_put(buf, tag, val); + tv16_put(buf, tag, val); + return buf; } -/*! \brief push (prepend) a TvLV field to a \ref msgb */ +/*! \brief 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, const uint8_t *val) { uint8_t *buf = msgb_push(msg, TVLV_GROSS_LEN(len)); - return tvlv_put(buf, tag, len, val); + tvlv_put(buf, tag, len, val); + return buf; } /* TLV parsing */ -- cgit v1.2.3