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
This commit is contained in:
Oliver Smith
2019-01-11 15:30:21 +01:00
committed by Harald Welte
parent 81db389fd4
commit 851814aa7c
4 changed files with 43 additions and 2 deletions

View File

@@ -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;

View File

@@ -51,6 +51,8 @@ struct hlr {
struct llist_head ussd_routes;
struct llist_head ss_sessions;
bool store_imei;
};
extern struct hlr *g_hlr;

View File

@@ -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();
}

View File

@@ -79,6 +79,8 @@ OsmoHLR(config-hlr)# list
ussd default-route external EUSE
no ussd default-route
ncss-guard-timeout <0-255>
store-imei
no store-imei
OsmoHLR(config-hlr)# gsup
OsmoHLR(config-hlr-gsup)# list
@@ -98,6 +100,7 @@ OsmoHLR(config-hlr)# exit
OsmoHLR(config)# exit
OsmoHLR# configure terminal
OsmoHLR(config)# hlr
OsmoHLR(config-hlr)# store-imei
OsmoHLR(config-hlr)# gsup
OsmoHLR(config-hlr-gsup)# end
OsmoHLR# disable
@@ -116,6 +119,7 @@ log stderr
logging level ss info
...
hlr
store-imei
gsup
bind ip 127.0.0.1
ussd route prefix *#100# internal own-msisdn