library/GSUP_Types.ttcn: add CHECK-IMEI message

Implement necessary messages for Procedure Check_IMEI_VLR (TS 23.018
Chapter 7.1.2.9). This lets the VLR ask the EIR to check if an IMEI
is valid. In the Osmocom stack, we don't have an EIR and this request
is handled by the HLR. We are able to store the IMEI in the HLR as
side-effect (OS#2541).

This is roughly based on TS 29.002 8.7.1 MAP_CHECK_IMEI service, but
only implements the bare minimum required IEs (imei and imei_result).

Related: OS#3733
Change-Id: Ie1ae5c66ad3f9b42b345020de62a0c276cd8d709
diff --git a/library/GSUP_Types.ttcn b/library/GSUP_Types.ttcn
index 6cc6dde..c024d37 100644
--- a/library/GSUP_Types.ttcn
+++ b/library/GSUP_Types.ttcn
@@ -52,7 +52,10 @@
 	OSMO_GSUP_SM_RP_UI_IE		('43'O),
 	OSMO_GSUP_SM_RP_CAUSE_IE	('44'O),
 	OSMO_GSUP_SM_RP_MMS_IE		('45'O),
-	OSMO_GSUP_SM_ALERT_RSN_IE	('46'O)
+	OSMO_GSUP_SM_ALERT_RSN_IE	('46'O),
+
+	OSMO_GSUP_IMEI_IE		('50'O),
+	OSMO_GSUP_IMEI_RESULT_IE	('51'O)
 } with { variant "FIELDLENGTH(8)" };
 
 type enumerated GSUP_MessageType {
@@ -96,7 +99,11 @@
 
 	OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST	('00101100'B),
 	OSMO_GSUP_MSGT_READY_FOR_SM_ERROR	('00101101'B),
-	OSMO_GSUP_MSGT_READY_FOR_SM_RESULT	('00101110'B)
+	OSMO_GSUP_MSGT_READY_FOR_SM_RESULT	('00101110'B),
+
+	OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST	('00110000'B),
+	OSMO_GSUP_MSGT_CHECK_IMEI_ERROR		('00110001'B),
+	OSMO_GSUP_MSGT_CHECK_IMEI_RESULT	('00110010'B)
 } with { variant "FIELDLENGTH(8)" };
 
 type enumerated GSUP_CancelType {
@@ -109,6 +116,11 @@
 	OSMO_GSUP_CN_DOMAIN_CS			(2)
 } with { variant "FIELDLENGTH(8)" };
 
+type enumerated GSUP_IMEIResult {
+	OSMO_GSUP_IMEI_RESULT_ACK		(0),
+	OSMO_GSUP_IMEI_RESULT_NACK		(1)
+} with { variant "FIELDLENGTH(8)" };
+
 type enumerated GSUP_SessionState {
 	OSMO_GSUP_SESSION_STATE_NONE		(0),
 	OSMO_GSUP_SESSION_STATE_BEGIN		(1),
@@ -121,6 +133,11 @@
 	hexstring digits optional
 } with { variant (len) "LENGTHTO(digits)" };
 
+type record GSUP_IMEI {
+	uint8_t	len,
+	hexstring digits optional
+} with { variant (len) "LENGTHTO(digits)" };
+
 type record GSUP_IE {
 	GSUP_IEI	tag,
 	uint8_t		len,
@@ -156,6 +173,8 @@
 				 sm_rp_cause, tag = OSMO_GSUP_SM_RP_CAUSE_IE;
 				 sm_rp_mms, tag = OSMO_GSUP_SM_RP_MMS_IE;
 				 sm_alert_rsn, tag = OSMO_GSUP_SM_ALERT_RSN_IE;
+				 imei, tag = OSMO_GSUP_IMEI_IE;
+				 imei_result, tag = OSMO_GSUP_IMEI_RESULT_IE;
 			)"
 };
 
@@ -197,7 +216,10 @@
 	octetstring		sm_rp_ui,
 	OCT1			sm_rp_cause,
 	OCT1			sm_rp_mms,
-	GSUP_SM_ALERT_RSN_Type	sm_alert_rsn
+	GSUP_SM_ALERT_RSN_Type	sm_alert_rsn,
+
+	GSUP_IMEI		imei,
+	GSUP_IMEIResult		imei_result
 };
 
 type record GSUP_PDU {
@@ -674,6 +696,36 @@
 	}
 }
 
+template (value) GSUP_IE ts_GSUP_IE_IMEI_IE(GSUP_IMEI imei) := {
+	tag := OSMO_GSUP_IMEI_IE,
+	len := 0, /* overwritten */
+	val := {
+		imei := imei
+	}
+}
+template GSUP_IE tr_GSUP_IE_IMEI_IE(template GSUP_IMEI imei) := {
+	tag := OSMO_GSUP_IMEI_IE,
+	len := ?,
+	val := {
+		imei := imei
+	}
+}
+
+template (value) GSUP_IE ts_GSUP_IE_IMEI_RESULT_IE(GSUP_IMEIResult result) := {
+	tag := OSMO_GSUP_IMEI_RESULT_IE,
+	len := 0, /* overwritten */
+	val := {
+		imei_result := result
+	}
+}
+template GSUP_IE tr_GSUP_IE_IMEI_RESULT_IE(template GSUP_IMEIResult result) := {
+	tag := OSMO_GSUP_IMEI_RESULT_IE,
+	len := ?,
+	val := {
+		imei_result := result
+	}
+}
+
 /* Possible identity types for SM-RP-{OA|DA} IEs */
 type enumerated GSUP_SM_RP_ODA_IdType {
 	OSMO_GSUP_SM_RP_ODA_ID_NONE		('00'O),