Change in osmo-hlr[master]: Add subscriber-create-on-demand option

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

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Sat Apr 20 09:35:16 UTC 2019


Vadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/13713


Change subject: Add subscriber-create-on-demand option
......................................................................

Add subscriber-create-on-demand option

Related: OS#2542
Change-Id: I0c9fe93f5c24b5e9fefb513c4d049fb7ebd47ecd
---
M src/hlr.c
M src/hlr.h
M src/hlr_vty.c
3 files changed, 36 insertions(+), 0 deletions(-)



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

diff --git a/src/hlr.c b/src/hlr.c
index 422a56d..b739e71 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -148,6 +148,18 @@
 	}
 }
 
+static void subscr_create_on_demand(const char *imsi) {
+	int rc;
+
+	if (!g_hlr->create_subscr_on_demand || db_subscr_exists_by_imsi(g_hlr->dbc, imsi) == 0)
+		return;
+
+	LOGP(DMAIN, LOGL_INFO, "IMSI='%s': Creating subscriber on demand\n", imsi);
+	rc = db_subscr_create(g_hlr->dbc, imsi, 0, 0);
+	if (rc)
+		LOGP(DMAIN, LOGL_ERROR, "Failed to create subscriber on demand (rc=%d): IMSI='%s'\n", rc, imsi);
+}
+
 /***********************************************************************
  * Send Auth Info handling
  ***********************************************************************/
@@ -161,6 +173,8 @@
 	struct msgb *msg_out;
 	int rc;
 
+	subscr_create_on_demand(gsup->imsi);
+
 	/* initialize return message structure */
 	memset(&gsup_out, 0, sizeof(gsup_out));
 	memcpy(&gsup_out.imsi, &gsup->imsi, sizeof(gsup_out.imsi));
@@ -291,6 +305,8 @@
 	}
 	llist_add(&luop->list, &g_lu_ops);
 
+	subscr_create_on_demand(gsup->imsi);
+
 	/* Roughly follwing "Process Update_Location_HLR" of TS 09.02 */
 
 	/* check if subscriber is known at all */
diff --git a/src/hlr.h b/src/hlr.h
index 00fa43c..dc1c720 100644
--- a/src/hlr.h
+++ b/src/hlr.h
@@ -53,6 +53,7 @@
 	struct llist_head ss_sessions;
 
 	bool store_imei;
+	bool create_subscr_on_demand;
 };
 
 extern struct hlr *g_hlr;
diff --git a/src/hlr_vty.c b/src/hlr_vty.c
index d0a623a..7bf27da 100644
--- a/src/hlr_vty.c
+++ b/src/hlr_vty.c
@@ -325,6 +325,23 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_subscr_create_on_demand, cfg_subscr_create_on_demand_cmd,
+	"subscriber-create-on-demand",
+	"Make a new record when a subscriber is first seen. If you enable this feature, you must also enforce checking"
+	" the IMEI in your MSC (OsmoMSC: 'check-imei-rqd 1').")
+{
+	g_hlr->create_subscr_on_demand = true;
+	return CMD_SUCCESS;
+}
+
+DEFUN(cfg_no_subscr_create_on_demand, cfg_no_subscr_create_on_demand_cmd,
+	"no subscriber-create-on-demand",
+	"Do not make a new record when a subscriber is first seen.")
+{
+	g_hlr->create_subscr_on_demand = false;
+	return CMD_SUCCESS;
+}
+
 /***********************************************************************
  * Common Code
  ***********************************************************************/
@@ -391,6 +408,8 @@
 	install_element(HLR_NODE, &cfg_ncss_guard_timeout_cmd);
 	install_element(HLR_NODE, &cfg_store_imei_cmd);
 	install_element(HLR_NODE, &cfg_no_store_imei_cmd);
+	install_element(HLR_NODE, &cfg_subscr_create_on_demand_cmd);
+	install_element(HLR_NODE, &cfg_no_subscr_create_on_demand_cmd);
 
 	hlr_vty_subscriber_init();
 }

-- 
To view, visit https://gerrit.osmocom.org/13713
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: I0c9fe93f5c24b5e9fefb513c4d049fb7ebd47ecd
Gerrit-Change-Number: 13713
Gerrit-PatchSet: 1
Gerrit-Owner: 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/20190420/12025751/attachment.htm>


More information about the gerrit-log mailing list