aboutsummaryrefslogtreecommitdiffstats
path: root/src/hlr_vty.c
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2019-03-04 15:10:44 +0100
committerVadim Yanitskiy <axilirator@gmail.com>2019-05-19 14:42:46 +0700
commitc7f1787c187e12355bbbe029a38cddaebb2b00e8 (patch)
treefc4300aa90a3136391ef26dd4cf08ba4f13a212b /src/hlr_vty.c
parentc13599dc696fcab64219eba99afd0a2da9d0eec5 (diff)
Create subscribers on demand
Add a new vty option and allow to optionally generate a random msisdn, as well as setting the default NAM: subscriber-create-on-demand (no-msisdn|<3-15>) (none|cs|ps|both) Thanks to Vadim for the random MSISDN patch [1], which was squashed into this one. [1] Change-Id: I475c71f9902950fa7498855a616e1ec231fad6ac Depends on: Idc74f4d94ad44b9fc1b6d43178f5f33d551ebfb1 (libosmocore) Change-Id: I0c9fe93f5c24b5e9fefb513c4d049fb7ebd47ecd Related: OS#2542
Diffstat (limited to 'src/hlr_vty.c')
-rw-r--r--src/hlr_vty.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/hlr_vty.c b/src/hlr_vty.c
index e4cc4be..e6567cc 100644
--- a/src/hlr_vty.c
+++ b/src/hlr_vty.c
@@ -33,6 +33,7 @@
#include <osmocom/vty/misc.h>
#include <osmocom/abis/ipa.h>
+#include "db.h"
#include "hlr.h"
#include "hlr_vty.h"
#include "hlr_vty_subscr.h"
@@ -76,6 +77,23 @@ static int config_write_hlr(struct vty *vty)
vty_out(vty, " store-imei%s", VTY_NEWLINE);
if (g_hlr->db_file_path && strcmp(g_hlr->db_file_path, HLR_DEFAULT_DB_FILE_PATH))
vty_out(vty, " database %s%s", g_hlr->db_file_path, VTY_NEWLINE);
+ if (g_hlr->subscr_create_on_demand) {
+ const char *flags_str = "none";
+ uint8_t flags = g_hlr->subscr_create_on_demand_flags;
+ unsigned int rand_msisdn_len = g_hlr->subscr_create_on_demand_rand_msisdn_len;
+
+ if ((flags & DB_SUBSCR_FLAG_NAM_CS) && (flags & DB_SUBSCR_FLAG_NAM_PS))
+ flags_str = "cs+ps";
+ else if (flags & DB_SUBSCR_FLAG_NAM_CS)
+ flags_str = "cs";
+ else if (flags & DB_SUBSCR_FLAG_NAM_PS)
+ flags_str = "ps";
+
+ if (rand_msisdn_len)
+ vty_out(vty, " subscriber-create-on-demand %i %s%s", rand_msisdn_len, flags_str, VTY_NEWLINE);
+ else
+ vty_out(vty, " subscriber-create-on-demand no-msisdn %s%s", flags_str, VTY_NEWLINE);
+ }
return CMD_SUCCESS;
}
@@ -336,6 +354,42 @@ DEFUN(cfg_no_store_imei, cfg_no_store_imei_cmd,
return CMD_SUCCESS;
}
+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)",
+ "Make a new record when a subscriber is first seen.\n"
+ "Do not automatically assign MSISDN.\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"
+ "Allow access to packet switched NAM by default.\n"
+ "Allow access to circuit and packet switched NAM by default.\n")
+{
+ unsigned int rand_msisdn_len = 0;
+ uint8_t flags = 0x00;
+
+ if (strcmp(argv[0], "no-msisdn") != 0)
+ rand_msisdn_len = atoi(argv[0]);
+
+ if (strstr(argv[1], "cs"))
+ flags |= DB_SUBSCR_FLAG_NAM_CS;
+ if (strstr(argv[1], "ps"))
+ flags |= DB_SUBSCR_FLAG_NAM_PS;
+
+ g_hlr->subscr_create_on_demand = true;
+ g_hlr->subscr_create_on_demand_rand_msisdn_len = rand_msisdn_len;
+ g_hlr->subscr_create_on_demand_flags = flags;
+
+ 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.\n")
+{
+ g_hlr->subscr_create_on_demand = false;
+ return CMD_SUCCESS;
+}
+
/***********************************************************************
* Common Code
***********************************************************************/
@@ -404,6 +458,8 @@ void hlr_vty_init(const struct log_info *cat)
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();
}