Change in libosmocore[master]: GSUP: add CHECK-IMEI message

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Dec 21 12:45:18 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/12409 )

Change subject: GSUP: add CHECK-IMEI message
......................................................................

GSUP: 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
will be handled by the HLR. We will be 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: I085819df0ea7f3bfeb0cabebb5fd1942a23c6155
---
M include/osmocom/gsm/gsup.h
M src/gsm/gsup.c
M tests/gsup/gsup_test.c
M tests/gsup/gsup_test.err
M tests/gsup/gsup_test.ok
5 files changed, 93 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h
index 37e474c..6adb0bf 100644
--- a/include/osmocom/gsm/gsup.h
+++ b/include/osmocom/gsm/gsup.h
@@ -99,6 +99,9 @@
 	OSMO_GSUP_SM_RP_MMS_IE			= 0x45,
 	OSMO_GSUP_SM_ALERT_RSN_IE		= 0x46,
 
+	OSMO_GSUP_IMEI_IE			= 0x50,
+	OSMO_GSUP_IMEI_RESULT_IE		= 0x51,
+
 	_OSMO_GSUP_IEI_END_MARKER
 };
 
@@ -145,6 +148,10 @@
 	OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST	= 0b00101100,
 	OSMO_GSUP_MSGT_READY_FOR_SM_ERROR	= 0b00101101,
 	OSMO_GSUP_MSGT_READY_FOR_SM_RESULT	= 0b00101110,
+
+	OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST	= 0b00110000,
+	OSMO_GSUP_MSGT_CHECK_IMEI_ERROR		= 0b00110001,
+	OSMO_GSUP_MSGT_CHECK_IMEI_RESULT	= 0b00110010,
 };
 
 #define OSMO_GSUP_IS_MSGT_REQUEST(msgt) (((msgt) & 0b00000011) == 0b00)
@@ -166,6 +173,11 @@
 	OSMO_GSUP_CN_DOMAIN_CS			= 2,
 };
 
+enum osmo_gsup_imei_result {
+	OSMO_GSUP_IMEI_RESULT_ACK		= 1,
+	OSMO_GSUP_IMEI_RESULT_NACK		= 2,
+};
+
 /*! TCAP-like session state */
 enum osmo_gsup_session_state {
 	/*! Undefined session state */
@@ -259,6 +271,10 @@
 	const uint8_t			*sm_rp_mms;
 	/*! Alert reason (see 3GPP TS 29.002, 7.6.8.8) */
 	enum osmo_gsup_sms_sm_alert_rsn_t	sm_alert_rsn;
+
+	const uint8_t			*imei_enc;
+	size_t				imei_enc_len;
+	enum osmo_gsup_imei_result	imei_result;
 };
 
 int osmo_gsup_decode(const uint8_t *data, size_t data_len,
diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c
index 3b31d03..3d2a8e2 100644
--- a/src/gsm/gsup.c
+++ b/src/gsm/gsup.c
@@ -79,6 +79,10 @@
 	OSMO_VALUE_STRING(OSMO_GSUP_MSGT_READY_FOR_SM_ERROR),
 	OSMO_VALUE_STRING(OSMO_GSUP_MSGT_READY_FOR_SM_RESULT),
 
+	OSMO_VALUE_STRING(OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST),
+	OSMO_VALUE_STRING(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR),
+	OSMO_VALUE_STRING(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT),
+
 	{ 0, NULL }
 };
 
@@ -116,6 +120,8 @@
 		return OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR;
 	case OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST:
 		return OSMO_GSUP_MSGT_READY_FOR_SM_ERROR;
+	case OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST:
+		return OSMO_GSUP_MSGT_CHECK_IMEI_ERROR;
 	default:
 		return -1;
 	}
@@ -487,6 +493,15 @@
 			gsup_msg->sm_alert_rsn = *value;
 			break;
 
+		case OSMO_GSUP_IMEI_IE:
+			gsup_msg->imei_enc = value;
+			gsup_msg->imei_enc_len = value_len;
+			break;
+
+		case OSMO_GSUP_IMEI_RESULT_IE:
+			gsup_msg->imei_result = osmo_decode_big_endian(value, value_len) + 1;
+			break;
+
 		default:
 			LOGP(DLGSUP, LOGL_NOTICE,
 			     "GSUP IE type %d unknown\n", iei);
@@ -720,6 +735,14 @@
 				sizeof(u8), &u8);
 	}
 
+	if (gsup_msg->imei_enc)
+		msgb_tlv_put(msg, OSMO_GSUP_IMEI_IE, gsup_msg->imei_enc_len, gsup_msg->imei_enc);
+
+	if ((u8 = gsup_msg->imei_result)) {
+		u8 -= 1;
+		msgb_tlv_put(msg, OSMO_GSUP_IMEI_RESULT_IE, sizeof(u8), &u8);
+	}
+
 	return 0;
 }
 
diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c
index 079a703..f194573 100644
--- a/tests/gsup/gsup_test.c
+++ b/tests/gsup/gsup_test.c
@@ -289,6 +289,33 @@
 			0x02, /* Memory Available (SMMA) */
 	};
 
+	static const uint8_t send_check_imei_req[] = {
+		0x30, /* OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST */
+		TEST_IMSI_IE,
+
+		/* imei */
+		0x50, 0x09,
+			0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
+	};
+
+	static const uint8_t send_check_imei_err[] = {
+		0x31, /* OSMO_GSUP_MSGT_CHECK_IMEI_ERROR */
+		TEST_IMSI_IE,
+
+		/* cause */
+		0x02, 0x01,
+			0x60, /* GMM_CAUSE_INV_MAND_INFO */
+	};
+
+	static const uint8_t send_check_imei_res[] = {
+		0x32, /* OSMO_GSUP_MSGT_CHECK_IMEI_RESULT */
+		TEST_IMSI_IE,
+
+		/* imei_result */
+		0x51, 0x01,
+			0x00, /* OSMO_GSUP_IMEI_RESULT_ACK */
+	};
+
 	static const struct test {
 		char *name;
 		const uint8_t *data;
@@ -338,6 +365,12 @@
 			send_mo_mt_forward_sm_err, sizeof(send_mo_mt_forward_sm_err)},
 		{"ReadyForSM (MSC -> SMSC) Indication",
 			send_ready_for_sm_ind, sizeof(send_ready_for_sm_ind)},
+		{"Check IMEI Request",
+			send_check_imei_req, sizeof(send_check_imei_req)},
+		{"Check IMEI Error",
+			send_check_imei_err, sizeof(send_check_imei_err)},
+		{"Check IMEI Result",
+			send_check_imei_res, sizeof(send_check_imei_res)},
 	};
 
 	printf("Test GSUP message decoding/encoding\n");
diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err
index 236c38a..73b35fc 100644
--- a/tests/gsup/gsup_test.err
+++ b/tests/gsup/gsup_test.err
@@ -64,6 +64,15 @@
   generated message: 2c 01 08 21 43 65 87 09 21 43 f5 46 01 02 
   original message:  2c 01 08 21 43 65 87 09 21 43 f5 46 01 02 
   IMSI:              123456789012345
+  generated message: 30 01 08 21 43 65 87 09 21 43 f5 50 09 42 42 42 42 42 42 42 42 42 
+  original message:  30 01 08 21 43 65 87 09 21 43 f5 50 09 42 42 42 42 42 42 42 42 42 
+  IMSI:              123456789012345
+  generated message: 31 01 08 21 43 65 87 09 21 43 f5 02 01 60 
+  original message:  31 01 08 21 43 65 87 09 21 43 f5 02 01 60 
+  IMSI:              123456789012345
+  generated message: 32 01 08 21 43 65 87 09 21 43 f5 51 01 00 
+  original message:  32 01 08 21 43 65 87 09 21 43 f5 51 01 00 
+  IMSI:              123456789012345
   message 0: tested 11 truncations, 11 parse failures
   message 1: tested 14 truncations, 13 parse failures
   message 2: tested 83 truncations, 81 parse failures
@@ -86,6 +95,9 @@
   message 19: tested 20 truncations, 18 parse failures
   message 20: tested 26 truncations, 22 parse failures
   message 21: tested 14 truncations, 13 parse failures
+  message 22: tested 22 truncations, 21 parse failures
+  message 23: tested 14 truncations, 13 parse failures
+  message 24: tested 14 truncations, 13 parse failures
 DLGSUP Stopping DLGSUP logging
   message 0: tested 2816 modifications, 510 parse failures
   message 1: tested 3584 modifications, 770 parse failures
@@ -109,3 +121,6 @@
   message 19: tested 5120 modifications, 1031 parse failures
   message 20: tested 6656 modifications, 1546 parse failures
   message 21: tested 3584 modifications, 771 parse failures
+  message 22: tested 5632 modifications, 771 parse failures
+  message 23: tested 3584 modifications, 770 parse failures
+  message 24: tested 3584 modifications, 771 parse failures
diff --git a/tests/gsup/gsup_test.ok b/tests/gsup/gsup_test.ok
index 36e35c8..70f723c 100644
--- a/tests/gsup/gsup_test.ok
+++ b/tests/gsup/gsup_test.ok
@@ -43,4 +43,10 @@
           MO-/MT-ForwardSM Error OK
   Testing ReadyForSM (MSC -> SMSC) Indication
           ReadyForSM (MSC -> SMSC) Indication OK
+  Testing Check IMEI Request
+          Check IMEI Request OK
+  Testing Check IMEI Error
+          Check IMEI Error OK
+  Testing Check IMEI Result
+          Check IMEI Result OK
 Done.

-- 
To view, visit https://gerrit.osmocom.org/12409
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I085819df0ea7f3bfeb0cabebb5fd1942a23c6155
Gerrit-Change-Number: 12409
Gerrit-PatchSet: 3
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181221/adf2bc82/attachment.htm>


More information about the gerrit-log mailing list