aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2019-01-11 15:30:21 +0100
committerHarald Welte <laforge@gnumonks.org>2019-01-24 15:29:08 +0000
commit851814aa7c6a89faa536d5ec60d16dd37826e2d0 (patch)
tree8d1ceaeba706d82a6ae7a4c82bb42c5650fd719c /src
parent81db389fd489f1b7962e72105a5a2cc5f3feb3fb (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/hlr.c18
-rw-r--r--src/hlr.h2
-rw-r--r--src/hlr_vty.c21
3 files changed, 39 insertions, 2 deletions
diff --git a/src/hlr.c b/src/hlr.c
index 614e99f..0098a32 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -419,8 +419,22 @@ static int rx_check_imei_req(struct osmo_gsup_conn *conn, const struct osmo_gsup
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) {
+ LOGP(DAUC, LOGL_DEBUG, "IMSI='%s': storing IMEI = %s\n", gsup->imsi, imei);
+ if (db_subscr_update_imei_by_imsi(g_hlr->dbc, gsup->imsi, imei) < 0) {
+ gsup_send_err_reply(conn, gsup->imsi, gsup->message_type, GMM_CAUSE_INV_MAND_INFO);
+ return -1;
+ }
+ } else {
+ /* Check if subscriber exists and print IMEI */
+ LOGP(DMAIN, LOGL_INFO, "IMSI='%s': has IMEI = %s (consider setting 'store-imei')\n", gsup->imsi, imei);
+ struct hlr_subscriber subscr;
+ if (db_subscr_get_by_imsi(g_hlr->dbc, gsup->imsi, &subscr) < 0) {
+ gsup_send_err_reply(conn, gsup->imsi, gsup->message_type, GMM_CAUSE_INV_MAND_INFO);
+ return -1;
+ }
+ }
/* 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 hlr {
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..04e0191 100644
--- a/src/hlr_vty.c
+++ b/src/hlr_vty.c
@@ -71,6 +71,8 @@ DEFUN(cfg_gsup,
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%s", VTY_NEWLINE);
return CMD_SUCCESS;
}
@@ -305,6 +307,23 @@ DEFUN(cfg_ncss_guard_timeout, cfg_ncss_guard_timeout_cmd,
return CMD_SUCCESS;
}
+DEFUN(cfg_store_imei, cfg_store_imei_cmd,
+ "store-imei",
+ "Save the IMEI in the database when receiving Check IMEI requests. Note that an MSC does not necessarily send"
+ " Check IMEI requests (for OsmoMSC, you may want to set 'check-imei-rqd 1').")
+{
+ g_hlr->store_imei = true;
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_no_store_imei, cfg_no_store_imei_cmd,
+ "no store-imei",
+ "Do not save the IMEI in the database, when receiving Check IMEI requests.")
+{
+ g_hlr->store_imei = false;
+ return CMD_SUCCESS;
+}
+
/***********************************************************************
* Common Code
***********************************************************************/
@@ -368,6 +387,8 @@ void hlr_vty_init(const struct log_info *cat)
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);
+ install_element(HLR_NODE, &cfg_no_store_imei_cmd);
hlr_vty_subscriber_init();
}