working state up to location update and classmark inquiry

diff --git a/include/openbsc/abis_rsl.h b/include/openbsc/abis_rsl.h
index cbbb797..219fdd3 100644
--- a/include/openbsc/abis_rsl.h
+++ b/include/openbsc/abis_rsl.h
@@ -244,6 +244,45 @@
 #endif
 } __attribute__ ((packed));
 
+/* Chapter 9.3.26 */
+#define RSL_ERRCLS_NORMAL		0x00
+#define RSL_ERRCLS_RESOURCE_UNAVAIL	0x20
+#define RSL_ERRCLS_SERVICE_UNAVAIL	0x30
+#define RSL_ERRCLS_SERVICE_UNIMPL	0x40
+#define RSL_ERRCLS_INVAL_MSG		0x50
+#define RSL_ERRCLS_PROTO_ERROR		0x60
+#define RSL_ERRCLS_INTERWORKING		0x70
+
+#define RSL_ERR_RADIO_IF_FAIL		0x00
+#define RSL_ERR_RADIO_LINK_FAIL		0x01
+#define RSL_ERR_HANDOVER_ACC_FAIL	0x02
+#define RSL_ERR_TALKER_ACC_FAIL		0x03
+#define RSL_ERR_OM_INTERVENTION		0x07
+#define RSL_ERR_EQUIPMENT_FAIL		0x20
+#define RSL_ERR_RR_UNAVAIL		0x21
+#define RSL_ERR_TERR_CH_FAIL		0x22
+#define RSL_ERR_CCCH_OVERLOAD		0x23
+#define RSL_ERR_ACCH_OVERLOAD		0x24
+#define RSL_ERR_PROCESSOR_OVERLOAD	0x25
+#define RSL_ERR_RES_UNAVAIL		0x2f
+#define RSL_ERR_TRANSC_UNAVAIL		0x30
+#define RSL_ERR_SERV_OPT_UNAVAIL	0x3f
+#define RSL_ERR_ENCR_UNIMPL		0x40
+#define RSL_ERR_SEV_OPT_UNIMPL		0x4f
+#define RSL_ERR_RCH_ALR_ACTV_ALLOC	0x50
+#define RSL_ERR_INVALID_MESSAGE		0x5f
+#define RSL_ERR_MSG_DISCR		0x60
+#define RSL_ERR_MSG_TYPE		0x61
+#define RSL_ERR_MSG_SEQA		0x62
+#define RSL_ERR_IE_ERROR		0x63
+#define RSL_ERR_MAND_IE_ERROR		0x64
+#define RSL_ERR_OPT_IE_ERROR		0x65
+#define RSL_ERR_IE_NONEXIST		0x66
+#define RSL_ERR_IE_LENGTH		0x67
+#define RSL_ERR_IE_CONTENT		0x68
+#define RSL_ERR_PROTO			0x6f
+#define RSL_ERR_INTERWORKING		0x7f
+
 /* Chapter 9.3.30 */
 #define RSL_SYSTEM_INFO_8	0x00
 #define RSL_SYSTEM_INFO_1	0x01
diff --git a/include/openbsc/debug.h b/include/openbsc/debug.h
index 02ae699..b95b1a7 100644
--- a/include/openbsc/debug.h
+++ b/include/openbsc/debug.h
@@ -17,6 +17,6 @@
 #define DEBUGP(xss, fmt, args...) 
 #endif
 
-void debugp(int subsys, char *file, int line, const char *format, ...);
+void debugp(unsigned int subsys, char *file, int line, const char *format, ...);
 
 #endif /* _DEBUG_H */
diff --git a/include/openbsc/tlv.h b/include/openbsc/tlv.h
index 4c00772..38ca811 100644
--- a/include/openbsc/tlv.h
+++ b/include/openbsc/tlv.h
@@ -6,6 +6,7 @@
 
 #define TLV_GROSS_LEN(x)	(x+2)
 #define TLV16_GROSS_LEN(x)	((2*x)+2)
+#define TL16V_GROSS_LEN(x)	(x+3)
 
 static inline u_int8_t *tlv_put(u_int8_t *buf, u_int8_t tag, u_int8_t len,
 				const u_int8_t *val)
@@ -25,12 +26,29 @@
 	return buf + len*2;
 }
 
+static inline u_int8_t *tl16v_put(u_int8_t *buf, u_int8_t tag, u_int16_t len,
+				const u_int8_t *val)
+{
+	*buf++ = tag;
+	*buf++ = len >> 8;
+	*buf++ = len & 0xff;
+	memcpy(buf, val, len);
+	return buf + len*2;
+}
+
 static inline u_int8_t *msgb_tlv16_put(struct msgb *msg, u_int8_t tag, u_int8_t len, const u_int16_t *val)
 {
 	u_int8_t *buf = msgb_put(msg, TLV16_GROSS_LEN(len));
 	return tlv16_put(buf, tag, len, val);
 }
 
+static inline u_int8_t *msgb_tl16v_put(struct msgb *msg, u_int8_t tag, u_int16_t len,
+					const u_int8_t *val)
+{
+	u_int8_t *buf = msgb_put(msg, TL16V_GROSS_LEN(len));
+	return tl16v_put(buf, tag, len, val);
+}
+
 static inline u_int8_t *tv_put(u_int8_t *buf, u_int8_t tag, 
 				u_int8_t val)
 {