summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-08-09 19:00:09 +0200
committerHarald Welte <laforge@gnumonks.org>2017-08-09 19:02:12 +0200
commit4a29f348135671ba59107a1659fab6c8c9362f58 (patch)
tree1dfe81d9699c6d3da51f1e9db42ff450b0260adc /include
parent35b263240f12b7d3b1c62c26b91fa555935c5703 (diff)
tlv: add [msgb_]t16lv_put() for 16bit tag + 8 bit len TLVs
In the Protocol Configuration Options IE (see 3GPP TS 24.008 10.5.6.3) there is yet another new TLV format (derived from PPP IPCP/LCP/...) which uses 16bit tag and 8bit length. Let's add functions so we can generate related TLVs. Parsing is unfortunately not possible in our existing structure as our tlv_parsed array only has 256 entries and thus cannot cope with 16bit tags. Change-Id: I9799130e2eba8fae8c4480fbb8a900c30232b694
Diffstat (limited to 'include')
-rw-r--r--include/osmocom/gsm/tlv.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h
index c3568400..f9032237 100644
--- a/include/osmocom/gsm/tlv.h
+++ b/include/osmocom/gsm/tlv.h
@@ -21,7 +21,7 @@
TLV16 8 8 N * 16
TvLV 8 8/16 N * 8
vTvLV 8/16 8/16 N * 8
-
+ T16LV 16 8 N * 8
*/
/*! gross length of a LV type field */
@@ -34,6 +34,8 @@
#define TL16V_GROSS_LEN(x) (x+3)
/*! gross length of a L16TV type field */
#define L16TV_GROSS_LEN(x) (x+3)
+/*! gross length of a T16LV type field */
+#define T16LV_GROSS_LEN(x) (x+3)
/*! maximum length of TLV of one byte length */
#define TVLV_MAX_ONEBYTE 0x7f
@@ -119,6 +121,17 @@ static inline uint8_t *tl16v_put(uint8_t *buf, uint8_t tag, uint16_t len,
return buf + len*2;
}
+/*! put (append) a TL16V field */
+static inline uint8_t *t16lv_put(uint8_t *buf, uint16_t tag, uint8_t len,
+ const uint8_t *val)
+{
+ *buf++ = tag >> 8;
+ *buf++ = tag & 0xff;
+ *buf++ = len;
+ memcpy(buf, val, len);
+ return buf + len + 2;
+}
+
/*! put (append) a TvLV field */
static inline uint8_t *tvlv_put(uint8_t *buf, uint8_t tag, uint16_t len,
const uint8_t *val)
@@ -185,6 +198,12 @@ static inline uint8_t *msgb_tl16v_put(struct msgb *msg, uint8_t tag, uint16_t le
return tl16v_put(buf, tag, len, val);
}
+static inline uint8_t *msgb_t16lv_put(struct msgb *msg, uint16_t tag, uint8_t len, const uint8_t *val)
+{
+ uint8_t *buf = msgb_put(msg, T16LV_GROSS_LEN(len));
+ return t16lv_put(buf, tag, len, val);
+}
+
/*! put (append) a TvLV field to \ref msgb */
static inline uint8_t *msgb_tvlv_put(struct msgb *msg, uint8_t tag, uint16_t len,
const uint8_t *val)