Change in osmo-hlr[master]: Reply to CHECK-IMEI GSUP messages

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/.

osmith gerrit-no-reply at lists.osmocom.org
Mon Jan 7 09:43:37 UTC 2019


osmith has submitted this change and it was merged. ( https://gerrit.osmocom.org/12411 )

Change subject: Reply to CHECK-IMEI GSUP messages
......................................................................

Reply to CHECK-IMEI GSUP messages

Decode the IMEI from incoming CHECK-IMEI messages, print the IMEI to
the log and always send ACK back to the VLR/MSC.

In the future, we will not only log the IMEI, but store it in the HLR
(OS#2541). This is not the original intention of CHECK-IMEI from the
3GPP spec, but an useful side effect.

Depends: I085819df0ea7f3bfeb0cabebb5fd1942a23c6155 (libosmocore)
Related: OS#3733
Change-Id: Ib240474b0c3c603ba840cf26babb38a44dfc9364
---
M src/hlr.c
1 file changed, 36 insertions(+), 0 deletions(-)

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



diff --git a/src/hlr.c b/src/hlr.c
index 4873a66..ce5618a 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -32,6 +32,7 @@
 #include <osmocom/vty/ports.h>
 #include <osmocom/ctrl/control_vty.h>
 #include <osmocom/gsm/apn.h>
+#include <osmocom/gsm/gsm48_ie.h>
 
 #include "db.h"
 #include "hlr.h"
@@ -399,6 +400,38 @@
 	return osmo_gsup_conn_send(conn, msg_out);
 }
 
+static int rx_check_imei_req(struct osmo_gsup_conn *conn, const struct osmo_gsup_message *gsup)
+{
+	struct osmo_gsup_message gsup_reply = {0};
+	struct msgb *msg_out;
+	char imei[GSM23003_IMEI_NUM_DIGITS+1] = {0};
+
+	/* Encoded IMEI length check */
+	if (!gsup->imei_enc || gsup->imei_enc_len < 1 || gsup->imei_enc[0] >= sizeof(imei)) {
+		LOGP(DMAIN, LOGL_ERROR, "%s: wrong encoded IMEI length\n", gsup->imsi);
+		gsup_send_err_reply(conn, gsup->imsi, gsup->message_type, GMM_CAUSE_INV_MAND_INFO);
+		return -1;
+	}
+
+	/* Decode IMEI */
+	if (gsm48_decode_bcd_number(imei, sizeof(imei), gsup->imei_enc, 0) < 0) {
+		LOGP(DMAIN, LOGL_ERROR, "%s: failed to decode IMEI\n", gsup->imsi);
+		gsup_send_err_reply(conn, gsup->imsi, gsup->message_type, GMM_CAUSE_INV_MAND_INFO);
+		return -1;
+	}
+
+	/* Only print the IMEI for now, it's planned to store it here (OS#2541) */
+	LOGP(DMAIN, LOGL_INFO, "%s: has IMEI: %s\n", gsup->imsi, imei);
+
+	/* Accept all IMEIs */
+	gsup_reply.imei_result = OSMO_GSUP_IMEI_RESULT_ACK;
+	gsup_reply.message_type = OSMO_GSUP_MSGT_CHECK_IMEI_RESULT;
+	msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP Check_IMEI response");
+	memcpy(gsup_reply.imsi, gsup->imsi, sizeof(gsup_reply.imsi));
+	osmo_gsup_encode(msg_out, &gsup_reply);
+	return osmo_gsup_conn_send(conn, msg_out);
+}
+
 static int read_cb(struct osmo_gsup_conn *conn, struct msgb *msg)
 {
 	static struct osmo_gsup_message gsup;
@@ -459,6 +492,9 @@
 			lu_op_rx_gsup(luop, &gsup);
 		}
 		break;
+	case OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST:
+		rx_check_imei_req(conn, &gsup);
+		break;
 	default:
 		LOGP(DMAIN, LOGL_DEBUG, "Unhandled GSUP message type %s\n",
 		     osmo_gsup_message_type_name(gsup.message_type));

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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib240474b0c3c603ba840cf26babb38a44dfc9364
Gerrit-Change-Number: 12411
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: osmith <osmith at sysmocom.de>
Gerrit-CC: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190107/65f310c6/attachment.htm>


More information about the gerrit-log mailing list