diff options
Diffstat (limited to 'include/openbsc/tlv.h')
-rw-r--r-- | include/openbsc/tlv.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/openbsc/tlv.h b/include/openbsc/tlv.h index 38ca81150..70d0319e8 100644 --- a/include/openbsc/tlv.h +++ b/include/openbsc/tlv.h @@ -57,6 +57,15 @@ static inline u_int8_t *tv_put(u_int8_t *buf, u_int8_t tag, return buf; } +static inline u_int8_t *tv16_put(u_int8_t *buf, u_int8_t tag, + u_int16_t val) +{ + *buf++ = tag; + *buf++ = val >> 8; + *buf++ = val & 0xff; + return buf; +} + static inline u_int8_t *msgb_tlv_put(struct msgb *msg, u_int8_t tag, u_int8_t len, const u_int8_t *val) { u_int8_t *buf = msgb_put(msg, TLV_GROSS_LEN(len)); @@ -69,6 +78,12 @@ static inline u_int8_t *msgb_tv_put(struct msgb *msg, u_int8_t tag, u_int8_t val return tv_put(buf, tag, val); } +static inline u_int8_t *msgb_tv16_put(struct msgb *msg, u_int8_t tag, u_int16_t val) +{ + u_int8_t *buf = msgb_put(msg, 3); + return tv16_put(buf, tag, val); +} + static inline u_int8_t *msgb_tlv_push(struct msgb *msg, u_int8_t tag, u_int8_t len, const u_int8_t *val) { u_int8_t *buf = msgb_push(msg, TLV_GROSS_LEN(len)); @@ -81,4 +96,11 @@ static inline u_int8_t *msgb_tv_push(struct msgb *msg, u_int8_t tag, u_int8_t va return tv_put(buf, tag, val); } +static inline u_int8_t *msgb_tv16_push(struct msgb *msg, u_int8_t tag, u_int16_t val) +{ + u_int8_t *buf = msgb_push(msg, 3); + return tv16_put(buf, tag, val); +} + + #endif /* _TLV_H */ |