diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hlr.c | 10 | ||||
-rw-r--r-- | src/hlr.h | 3 | ||||
-rw-r--r-- | src/hlr_vty.c | 13 |
3 files changed, 23 insertions, 3 deletions
@@ -626,7 +626,7 @@ static struct { bool db_upgrade; } cmdline_opts = { .config_file = "osmo-hlr.cfg", - .db_file = "hlr.db", + .db_file = NULL, .daemonize = false, .db_upgrade = false, }; @@ -741,6 +741,7 @@ int main(int argc, char **argv) INIT_LLIST_HEAD(&g_hlr->iuse_list); INIT_LLIST_HEAD(&g_hlr->ss_sessions); INIT_LLIST_HEAD(&g_hlr->ussd_routes); + g_hlr->db_file_path = talloc_strdup(g_hlr, HLR_DEFAULT_DB_FILE_PATH); /* Init default (call independent) SS session guard timeout value */ g_hlr->ncss_guard_timeout = NCSS_GUARD_TIMEOUT_DEFAULT; @@ -779,9 +780,12 @@ int main(int argc, char **argv) exit(1); } - g_hlr->dbc = db_open(hlr_ctx, cmdline_opts.db_file, true, cmdline_opts.db_upgrade); + if (cmdline_opts.db_file) + osmo_talloc_replace_string(g_hlr, &g_hlr->db_file_path, cmdline_opts.db_file); + + g_hlr->dbc = db_open(hlr_ctx, g_hlr->db_file_path, true, cmdline_opts.db_upgrade); if (!g_hlr->dbc) { - LOGP(DMAIN, LOGL_FATAL, "Error opening database\n"); + LOGP(DMAIN, LOGL_FATAL, "Error opening database %s\n", osmo_quote_str(g_hlr->db_file_path, -1)); exit(1); } @@ -25,6 +25,8 @@ #include <stdbool.h> #include <osmocom/core/linuxlist.h> +#define HLR_DEFAULT_DB_FILE_PATH "hlr.db" + struct hlr_euse; struct hlr { @@ -32,6 +34,7 @@ struct hlr { struct osmo_gsup_server *gs; /* DB context */ + char *db_file_path; struct db_context *dbc; /* Control Interface */ diff --git a/src/hlr_vty.c b/src/hlr_vty.c index d0a623a..e4cc4be 100644 --- a/src/hlr_vty.c +++ b/src/hlr_vty.c @@ -74,6 +74,8 @@ 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); + 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); return CMD_SUCCESS; } @@ -224,6 +226,15 @@ DEFUN(cfg_ussd_no_defaultroute, cfg_ussd_no_defaultroute_cmd, return CMD_SUCCESS; } +DEFUN(cfg_database, cfg_database_cmd, + "database PATH", + "Set the path to the HLR database file\n" + "Relative or absolute file system path to the database file (default is '" HLR_DEFAULT_DB_FILE_PATH "')\n") +{ + osmo_talloc_replace_string(g_hlr, &g_hlr->db_file_path, argv[0]); + return CMD_SUCCESS; +} + struct cmd_node euse_node = { EUSE_NODE, "%s(config-hlr-euse)# ", @@ -380,6 +391,8 @@ void hlr_vty_init(const struct log_info *cat) install_element(GSUP_NODE, &cfg_hlr_gsup_bind_ip_cmd); + install_element(HLR_NODE, &cfg_database_cmd); + install_element(HLR_NODE, &cfg_euse_cmd); install_element(HLR_NODE, &cfg_no_euse_cmd); install_node(&euse_node, config_write_euse); |