aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-02-09 16:26:49 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-02-09 17:40:59 +0100
commit701d175653c037b8cab4b02a3092a6df79e2fdd2 (patch)
tree6c1ac05c87167ace4a837cb64a26a4547c59f8be
parentfb0b6fcaeacbc49ef8473f62a373cf77afb1502c (diff)
[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.
-rw-r--r--openbsc/include/openbsc/tlv.h13
1 files changed, 13 insertions, 0 deletions
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;