Change in osmo-hlr[master]: Optionally store IMEI in subscriber table

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
Fri Jan 11 15:34:14 UTC 2019


osmith has uploaded this change for review. ( https://gerrit.osmocom.org/12526


Change subject: Optionally store IMEI in subscriber table
......................................................................

Optionally store IMEI in subscriber table

Add VTY config option "store-imei". When it is set, store the IMEI
sent from the VLR with CHECK-IMEI in the database.

Related: OS#2541
Change-Id: I09274ecbed64224f7ae305e09ede773931da2a57
---
M src/hlr.c
M src/hlr.h
M src/hlr_vty.c
3 files changed, 37 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/26/12526/1

diff --git a/src/hlr.c b/src/hlr.c
index ce5618a..b3e2fa8 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -258,6 +258,22 @@
 	}
 }
 
+static void update_imei(const char *imsi, const char *imei)
+{
+	struct hlr_subscriber subscr;
+
+	/* Check if subscriber is known */
+	if (db_subscr_get_by_imsi(g_hlr->dbc, imsi, &subscr) < 0) {
+		LOGP(DAUC, LOGL_ERROR, "Cannot set IMEI '%s' for unknown IMSI '%s'\n", imei, imsi);
+		return;
+	}
+
+	LOGP(DAUC, LOGL_DEBUG, "IMSI='%s': storing IMEI = %s\n", imsi, imei);
+
+	if (db_subscr_update_imei_by_id(g_hlr->dbc, subscr.id, imei))
+		LOGP(DAUC, LOGL_ERROR, "IMSI='%s': Cannot update IMEI in the database\n", imsi);
+}
+
 /*! Receive Update Location Request, creates new \ref lu_operation */
 static int rx_upd_loc_req(struct osmo_gsup_conn *conn,
 			  const struct osmo_gsup_message *gsup)
@@ -420,8 +436,11 @@
 		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);
+	/* Save in DB if desired */
+	if (g_hlr->store_imei)
+		update_imei(gsup->imsi, imei);
+	else
+		LOGP(DMAIN, LOGL_INFO, "%s: has IMEI: %s (consider setting 'store-imei 1')\n", gsup->imsi, imei);
 
 	/* Accept all IMEIs */
 	gsup_reply.imei_result = OSMO_GSUP_IMEI_RESULT_ACK;
diff --git a/src/hlr.h b/src/hlr.h
index e9cc747..00fa43c 100644
--- a/src/hlr.h
+++ b/src/hlr.h
@@ -51,6 +51,8 @@
 	struct llist_head ussd_routes;
 
 	struct llist_head ss_sessions;
+
+	bool store_imei;
 };
 
 extern struct hlr *g_hlr;
diff --git a/src/hlr_vty.c b/src/hlr_vty.c
index 6706aa4..f556565 100644
--- a/src/hlr_vty.c
+++ b/src/hlr_vty.c
@@ -71,6 +71,8 @@
 static int config_write_hlr(struct vty *vty)
 {
 	vty_out(vty, "hlr%s", VTY_NEWLINE);
+	if (g_hlr->store_imei)
+		vty_out(vty, "  store-imei 1%s", VTY_NEWLINE);
 	return CMD_SUCCESS;
 }
 
@@ -305,6 +307,17 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_store_imei, cfg_store_imei_cmd,
+	"store-imei (0|1)",
+	"Save the IMEI in the database, when receiving Check IMEI requests. When using OsmoHLR with OsmoMSC, make sure"
+	" to set 'check-imei-rqd 1' in osmo-msc.cfg.\n"
+	"Do not save IMEIs in the subscriber database\n"
+	"Save IMEIs in the subscriber database\n")
+{
+	g_hlr->store_imei = atoi(argv[0]) ? true : false;
+	return CMD_SUCCESS;
+}
+
 /***********************************************************************
  * Common Code
  ***********************************************************************/
@@ -368,6 +381,7 @@
 	install_element(HLR_NODE, &cfg_ussd_defaultroute_cmd);
 	install_element(HLR_NODE, &cfg_ussd_no_defaultroute_cmd);
 	install_element(HLR_NODE, &cfg_ncss_guard_timeout_cmd);
+	install_element(HLR_NODE, &cfg_store_imei_cmd);
 
 	hlr_vty_subscriber_init();
 }

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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I09274ecbed64224f7ae305e09ede773931da2a57
Gerrit-Change-Number: 12526
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190111/9604218b/attachment.htm>


More information about the gerrit-log mailing list