subscriber-create-on-demand: add mode for MSISDN=IMSI

In may be desirable for some users to assign deterministic MSISDNs
when subscriber-create-on-demand is enabled.  This can be achieved
by assigning MSISDN=IMSI.  This commit adds a new mode for that.

Change-Id: I3470492f5e46de7246d9a74e80c37f80f455d851
This commit is contained in:
Vadim Yanitskiy
2024-08-07 16:14:57 +07:00
committed by Vadim Yanitskiy
parent d4693f652a
commit 7c06eea5b2
5 changed files with 20 additions and 2 deletions

View File

@@ -43,6 +43,7 @@ enum subscr_create_on_demand_mode {
SUBSCR_COD_MODE_DISABLED = 0,
SUBSCR_COD_MODE_NO_MSISDN,
SUBSCR_COD_MODE_RAND_MSISDN,
SUBSCR_COD_MODE_MSISDN_FROM_IMSI,
};
struct hlr {

View File

@@ -209,6 +209,9 @@ static int subscr_create_on_demand(const char *imsi)
return -1;
switch (g_hlr->subscr_create_on_demand.mode) {
case SUBSCR_COD_MODE_MSISDN_FROM_IMSI:
OSMO_STRLCPY_ARRAY(msisdn, imsi);
break;
case SUBSCR_COD_MODE_RAND_MSISDN:
if (generate_new_msisdn(msisdn, imsi, g_hlr->subscr_create_on_demand.rand_msisdn_len) != 0)
return -1;

View File

@@ -288,6 +288,9 @@ static void config_write_subscr_create_on_demand(struct vty *vty)
const char *flags_str;
switch (g_hlr->subscr_create_on_demand.mode) {
case SUBSCR_COD_MODE_MSISDN_FROM_IMSI:
vty_out(vty, " subscriber-create-on-demand msisdn-from-imsi");
break;
case SUBSCR_COD_MODE_RAND_MSISDN:
vty_out(vty, " subscriber-create-on-demand %u",
g_hlr->subscr_create_on_demand.rand_msisdn_len);
@@ -810,9 +813,10 @@ DEFUN(cfg_no_store_imei, cfg_no_store_imei_cmd,
}
DEFUN(cfg_subscr_create_on_demand, cfg_subscr_create_on_demand_cmd,
"subscriber-create-on-demand (no-msisdn|<3-15>) (none|cs|ps|cs+ps)",
"subscriber-create-on-demand (no-msisdn|msisdn-from-imsi|<3-15>) (none|cs|ps|cs+ps)",
"Make a new record when a subscriber is first seen.\n"
"Do not automatically assign MSISDN.\n"
"Assign MSISDN identical to subscriber's IMSI.\n"
"Length of an automatically assigned MSISDN.\n"
"Do not allow any NAM (Network Access Mode) by default.\n"
"Allow access to circuit switched NAM by default.\n"
@@ -825,6 +829,8 @@ DEFUN(cfg_subscr_create_on_demand, cfg_subscr_create_on_demand_cmd,
if (strcmp(argv[0], "no-msisdn") == 0) {
mode = SUBSCR_COD_MODE_NO_MSISDN;
} else if (strcmp(argv[0], "msisdn-from-imsi") == 0) {
mode = SUBSCR_COD_MODE_MSISDN_FROM_IMSI;
} else { /* random MSISDN */
mode = SUBSCR_COD_MODE_RAND_MSISDN;
rand_msisdn_len = atoi(argv[0]);

View File

@@ -73,7 +73,7 @@ OsmoHLR(config-hlr)# list
reject-cause (not-found|no-proxy) (imsi-unknown|illegal-ms|plmn-not-allowed|la-not-allowed|roaming-not-allowed|no-suitable-cell-in-la|net-fail|congestion|auth-unacceptable|proto-error-unspec)
store-imei
no store-imei
subscriber-create-on-demand (no-msisdn|<3-15>) (none|cs|ps|cs+ps)
subscriber-create-on-demand (no-msisdn|msisdn-from-imsi|<3-15>) (none|cs|ps|cs+ps)
no subscriber-create-on-demand
OsmoHLR(config-hlr)# gsup

View File

@@ -10,6 +10,14 @@ hlr
subscriber-create-on-demand no-msisdn none
...
OsmoHLR(config-hlr)# subscriber-create-on-demand msisdn-from-imsi cs+ps
OsmoHLR(config-hlr)# show running-config
...
hlr
...
subscriber-create-on-demand msisdn-from-imsi cs+ps
...
OsmoHLR(config-hlr)# subscriber-create-on-demand 3 none
OsmoHLR(config-hlr)# show running-config
...