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
diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h
index c356840..f903223 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 @@
 	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 @@
 	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)