From 701d175653c037b8cab4b02a3092a6df79e2fdd2 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 9 Feb 2010 16:26:49 +0100 Subject: [PATCH] [tlv] Implement a variant for the IDTAG list for the IPA Implement a helper that will allow to easily fill the tag list with data. --- openbsc/include/openbsc/tlv.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/openbsc/include/openbsc/tlv.h b/openbsc/include/openbsc/tlv.h index c90643eed..6141b1f07 100644 --- a/openbsc/include/openbsc/tlv.h +++ b/openbsc/include/openbsc/tlv.h @@ -22,6 +22,7 @@ #define TLV_GROSS_LEN(x) (x+2) #define TLV16_GROSS_LEN(x) ((2*x)+2) #define TL16V_GROSS_LEN(x) (x+3) +#define L16TV_GROSS_LEN(x) (x+3) #define TVLV_MAX_ONEBYTE 0x7f @@ -105,6 +106,18 @@ static inline u_int8_t *msgb_tvlv_put(struct msgb *msg, u_int8_t tag, u_int16_t return tvlv_put(buf, tag, len, val); } +static inline u_int8_t *msgb_l16tv_put(struct msgb *msg, u_int16_t len, u_int8_t tag, + const u_int8_t *val) +{ + u_int8_t *buf = msgb_put(msg, L16TV_GROSS_LEN(len)); + + *buf++ = len >> 8; + *buf++ = len & 0xff; + *buf++ = tag; + memcpy(buf, val, len); + return buf + len; +} + static inline u_int8_t *v_put(u_int8_t *buf, u_int8_t val) { *buf++ = val;