summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-03-05 14:32:50 +0100
committerHarald Welte <laforge@gnumonks.org>2011-03-05 14:32:50 +0100
commit63196de6d899d01c4e1899e3aab2e700a47a196d (patch)
tree357afd202cf358e1950dcb18441d3f1532d73218
parent53b209655572aec79b42520ce5a5c3e429fff94c (diff)
TLV: Add tv_fixed_put() and msgb_tv_fixed_put()
This is for a Tag-Value type with fixed-length value (len > 1)
-rw-r--r--include/osmocore/tlv.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/osmocore/tlv.h b/include/osmocore/tlv.h
index 4cfce872..7bda9f92 100644
--- a/include/osmocore/tlv.h
+++ b/include/osmocore/tlv.h
@@ -132,6 +132,14 @@ static inline uint8_t *tv_put(uint8_t *buf, uint8_t tag,
return buf;
}
+static inline uint8_t *tv_fixed_put(uint8_t *buf, uint8_t tag,
+ unsigned int len, const uint8_t *val)
+{
+ *buf++ = tag;
+ memcpy(buf, val, len);
+ return buf + len;
+}
+
/* 'val' is still in host byte order! */
static inline uint8_t *tv16_put(uint8_t *buf, uint8_t tag,
uint16_t val)
@@ -160,6 +168,13 @@ static inline uint8_t *msgb_tv_put(struct msgb *msg, uint8_t tag, uint8_t val)
return tv_put(buf, tag, val);
}
+static inline uint8_t *msgb_tv_fixed_put(struct msgb *msg, uint8_t tag,
+ unsigned int len, const uint8_t *val)
+{
+ uint8_t *buf = msgb_put(msg, 1+len);
+ return tv_fixed_put(buf, tag, len, val);
+}
+
static inline uint8_t *msgb_v_put(struct msgb *msg, uint8_t val)
{
uint8_t *buf = msgb_put(msg, 1);