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/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/12056 )
Change subject: implement removal of MSISDN
......................................................................
implement removal of MSISDN
Add the first "official" way to remove the MSISDN from a subscriber entry, to
go back to 'MSISDN: none' like just after 'subscriber create'.
Add VTY command 'subscriber <ID> update msisdn none' to drop the MSISDN from
the subscriber. (Like 'subscriber <ID> update aud3g none')
Add DB_STMT_DELETE_MSISDN_BY_IMSI.
In db_subscr_update_msisdn_by_imsi(), allow passing a NULL msisdn, and if NULL,
call above delete SQL statement.
Change-Id: I15419105ea461137776adb92d384d8985210c90e
---
M src/db.c
M src/db.h
M src/db_hlr.c
M src/hlr_vty_subscr.c
M tests/test_subscriber.vty
5 files changed, 56 insertions(+), 20 deletions(-)
Approvals:
Jenkins Builder: Verified
Pau Espin Pedrol: Looks good to me, approved
Vadim Yanitskiy: Looks good to me, but someone else must approve
Harald Welte: Looks good to me, approved
diff --git a/src/db.c b/src/db.c
index 4b0577f..bcf83c6 100644
--- a/src/db.c
+++ b/src/db.c
@@ -62,6 +62,7 @@
[DB_STMT_SUBSCR_CREATE] = "INSERT INTO subscriber (imsi) VALUES ($imsi)",
[DB_STMT_DEL_BY_ID] = "DELETE FROM subscriber WHERE id = $subscriber_id",
[DB_STMT_SET_MSISDN_BY_IMSI] = "UPDATE subscriber SET msisdn = $msisdn WHERE imsi = $imsi",
+ [DB_STMT_DELETE_MSISDN_BY_IMSI] = "UPDATE subscriber SET msisdn = NULL WHERE imsi = $imsi",
[DB_STMT_AUC_2G_INSERT] =
"INSERT INTO auc_2g (subscriber_id, algo_id_2g, ki)"
" VALUES($subscriber_id, $algo_id_2g, $ki)",
diff --git a/src/db.h b/src/db.h
index 956b5ed..34582c8 100644
--- a/src/db.h
+++ b/src/db.h
@@ -20,6 +20,7 @@
DB_STMT_SUBSCR_CREATE,
DB_STMT_DEL_BY_ID,
DB_STMT_SET_MSISDN_BY_IMSI,
+ DB_STMT_DELETE_MSISDN_BY_IMSI,
DB_STMT_AUC_2G_INSERT,
DB_STMT_AUC_2G_DELETE,
DB_STMT_AUC_3G_INSERT,
diff --git a/src/db_hlr.c b/src/db_hlr.c
index c4d4974..2bccc38 100644
--- a/src/db_hlr.c
+++ b/src/db_hlr.c
@@ -135,7 +135,7 @@
/*! Set a subscriber's MSISDN in the HLR database.
* \param[in,out] dbc database context.
- * \param[in] imsi ASCII string of IMSI digits.
+ * \param[in] imsi ASCII string of IMSI digits, or NULL to remove the MSISDN.
* \param[in] msisdn ASCII string of MSISDN digits.
* \returns 0 on success, -EINVAL in case of invalid MSISDN string, -EIO on
* database failure, -ENOENT if no such subscriber exists.
@@ -146,19 +146,22 @@
int rc;
int ret = 0;
- if (!osmo_msisdn_str_valid(msisdn)) {
+ if (msisdn && !osmo_msisdn_str_valid(msisdn)) {
LOGHLR(imsi, LOGL_ERROR,
"Cannot update subscriber: invalid MSISDN: '%s'\n",
msisdn);
return -EINVAL;
}
- sqlite3_stmt *stmt = dbc->stmt[DB_STMT_SET_MSISDN_BY_IMSI];
+ sqlite3_stmt *stmt = dbc->stmt[
+ msisdn ? DB_STMT_SET_MSISDN_BY_IMSI : DB_STMT_DELETE_MSISDN_BY_IMSI];
if (!db_bind_text(stmt, "$imsi", imsi))
return -EIO;
- if (!db_bind_text(stmt, "$msisdn", msisdn))
- return -EIO;
+ if (msisdn) {
+ if (!db_bind_text(stmt, "$msisdn", msisdn))
+ return -EIO;
+ }
/* execute the statement */
rc = sqlite3_step(stmt);
diff --git a/src/hlr_vty_subscr.c b/src/hlr_vty_subscr.c
index ddbaf26..bc6f6a5 100644
--- a/src/hlr_vty_subscr.c
+++ b/src/hlr_vty_subscr.c
@@ -142,6 +142,7 @@
#define SUBSCR_UPDATE SUBSCR "update "
#define SUBSCR_UPDATE_HELP SUBSCR_HELP "Set or update subscriber data\n"
+#define SUBSCR_MSISDN_HELP "Set MSISDN (phone number) of the subscriber\n"
DEFUN(subscriber_show,
subscriber_show_cmd,
@@ -228,9 +229,9 @@
DEFUN(subscriber_msisdn,
subscriber_msisdn_cmd,
- SUBSCR_UPDATE "msisdn MSISDN",
- SUBSCR_UPDATE_HELP
- "Set MSISDN (phone number) of the subscriber\n"
+ SUBSCR_UPDATE "msisdn (none|MSISDN)",
+ SUBSCR_UPDATE_HELP SUBSCR_MSISDN_HELP
+ "Remove MSISDN (phone number)\n"
"New MSISDN (phone number)\n")
{
struct hlr_subscriber subscr;
@@ -238,15 +239,19 @@
const char *id = argv[1];
const char *msisdn = argv[2];
- if (strlen(msisdn) > sizeof(subscr.msisdn) - 1) {
- vty_out(vty, "%% MSISDN is too long, max. %zu characters are allowed%s",
- sizeof(subscr.msisdn)-1, VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (strcmp(msisdn, "none") == 0)
+ msisdn = NULL;
+ else {
+ if (strlen(msisdn) > sizeof(subscr.msisdn) - 1) {
+ vty_out(vty, "%% MSISDN is too long, max. %zu characters are allowed%s",
+ sizeof(subscr.msisdn)-1, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
- if (!osmo_msisdn_str_valid(msisdn)) {
- vty_out(vty, "%% MSISDN invalid: '%s'%s", msisdn, VTY_NEWLINE);
- return CMD_WARNING;
+ if (!osmo_msisdn_str_valid(msisdn)) {
+ vty_out(vty, "%% MSISDN invalid: '%s'%s", msisdn, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
}
if (get_subscr_by_argv(vty, id_type, id, &subscr))
@@ -258,11 +263,18 @@
return CMD_WARNING;
}
- vty_out(vty, "%% Updated subscriber IMSI='%s' to MSISDN='%s'%s",
- subscr.imsi, msisdn, VTY_NEWLINE);
+ if (msisdn) {
+ vty_out(vty, "%% Updated subscriber IMSI='%s' to MSISDN='%s'%s",
+ subscr.imsi, msisdn, VTY_NEWLINE);
- if (db_subscr_get_by_msisdn(g_hlr->dbc, msisdn, &subscr) == 0)
+ if (db_subscr_get_by_msisdn(g_hlr->dbc, msisdn, &subscr) == 0)
+ osmo_hlr_subscriber_update_notify(&subscr);
+ } else {
+ vty_out(vty, "%% Updated subscriber IMSI='%s': removed MSISDN%s",
+ subscr.imsi, VTY_NEWLINE);
+
osmo_hlr_subscriber_update_notify(&subscr);
+ }
return CMD_SUCCESS;
}
diff --git a/tests/test_subscriber.vty b/tests/test_subscriber.vty
index c22f2df..8677c9b 100644
--- a/tests/test_subscriber.vty
+++ b/tests/test_subscriber.vty
@@ -6,7 +6,7 @@
show subscriber (imsi|msisdn|id) IDENT
subscriber imsi IDENT create
subscriber (imsi|msisdn|id) IDENT delete
- subscriber (imsi|msisdn|id) IDENT update msisdn MSISDN
+ subscriber (imsi|msisdn|id) IDENT update msisdn (none|MSISDN)
subscriber (imsi|msisdn|id) IDENT update aud2g none
subscriber (imsi|msisdn|id) IDENT update aud2g (comp128v1|comp128v2|comp128v3|xor) ki KI
subscriber (imsi|msisdn|id) IDENT update aud3g none
@@ -86,6 +86,21 @@
OsmoHLR# subscriber msisdn 12345 show
% No subscriber for msisdn = '12345'
+OsmoHLR# subscriber msisdn 423 update msisdn none
+% Updated subscriber IMSI='123456789023000': removed MSISDN
+OsmoHLR# subscriber msisdn 423 show
+% No subscriber for msisdn = '423'
+OsmoHLR# subscriber imsi 123456789023000 show
+ ID: 1
+ IMSI: 123456789023000
+ MSISDN: none
+OsmoHLR# subscriber imsi 123456789023000 update msisdn 423
+% Updated subscriber IMSI='123456789023000' to MSISDN='423'
+OsmoHLR# subscriber msisdn 423 show
+ ID: 1
+ IMSI: 123456789023000
+ MSISDN: 423
+
OsmoHLR# subscriber imsi 123456789023000 show
ID: 1
IMSI: 123456789023000
@@ -104,6 +119,10 @@
aud2g Set 2G authentication data
aud3g Set UMTS authentication data (3G, and 2G with UMTS AKA)
+OsmoHLR# subscriber imsi 123456789023000 update msisdn ?
+ none Remove MSISDN (phone number)
+ MSISDN New MSISDN (phone number)
+
OsmoHLR# subscriber imsi 123456789023000 update aud2g ?
none Delete 2G authentication data
comp128v1 Use COMP128v1 algorithm
--
To view, visit https://gerrit.osmocom.org/12056
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: I15419105ea461137776adb92d384d8985210c90e
Gerrit-Change-Number: 12056
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181203/2dbc8890/attachment.htm>