aboutsummaryrefslogtreecommitdiffstats
path: root/src/hnbgw.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-08-17 13:54:00 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-08-18 02:37:11 +0200
commit085cd67672c9006be6e6f89abb80cff8926ef245 (patch)
treeadd9f8dfb4cd42ef84026554d129ded887a2f213 /src/hnbgw.c
parent4d675a7df9fd9f3b435da4cbea8446a1e9df22b3 (diff)
hnbgw: add config file and -c cmdline option
Diffstat (limited to 'src/hnbgw.c')
-rw-r--r--src/hnbgw.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/hnbgw.c b/src/hnbgw.c
index ff5fafe..01f64a7 100644
--- a/src/hnbgw.c
+++ b/src/hnbgw.c
@@ -389,8 +389,10 @@ static void hnbgw_vty_init(void)
static struct {
int daemonize;
+ const char *config_file;
} hnbgw_cmdline_config = {
- 0
+ 0,
+ "osmo-hnbgw.cfg"
};
static void print_usage()
@@ -403,6 +405,7 @@ static void print_help()
printf(" -h --help This text.\n");
printf(" -d option --debug=DHNBAP:DSUA:DRUA:DRANAP:DMAIN Enable debugging.\n");
printf(" -D --daemonize Fork the process into a background daemon.\n");
+ printf(" -c --config-file filename The config file to use.\n");
printf(" -s --disable-color\n");
printf(" -T --timestamp Prefix every log line with a timestamp.\n");
printf(" -V --version Print the version of OsmoHNBGW.\n");
@@ -417,6 +420,7 @@ static void handle_options(int argc, char **argv)
{"help", 0, 0, 'h'},
{"debug", 1, 0, 'd'},
{"daemonize", 0, 0, 'D'},
+ {"config-file", 1, 0, 'c'},
{"disable-color", 0, 0, 's'},
{"timestamp", 0, 0, 'T'},
{"version", 0, 0, 'V' },
@@ -424,7 +428,7 @@ static void handle_options(int argc, char **argv)
{0, 0, 0, 0}
};
- c = getopt_long(argc, argv, "hd:DsTVe:",
+ c = getopt_long(argc, argv, "hd:Dc:sTVe:",
long_options, &option_index);
if (c == -1)
break;
@@ -443,6 +447,9 @@ static void handle_options(int argc, char **argv)
case 'D':
hnbgw_cmdline_config.daemonize = 1;
break;
+ case 'c':
+ hnbgw_cmdline_config.config_file = optarg;
+ break;
case 'T':
log_set_print_timestamp(osmo_stderr_target, 1);
break;
@@ -488,8 +495,13 @@ int main(int argc, char **argv)
/* Handle options after vty_init(), for --version */
handle_options(argc, argv);
- /* NOTE: if we add a config file, read the config before
- * fetching the telnet address with vty_get_bind_addr() */
+ rc = vty_read_config_file(hnbgw_cmdline_config.config_file, NULL);
+ if (rc < 0) {
+ LOGP(DMAIN, LOGL_FATAL, "Failed to parse the config file: '%s'\n",
+ hnbgw_cmdline_config.config_file);
+ return 1;
+ }
+
LOGP(DMAIN, LOGL_NOTICE, "VTY at %s %d\n",
vty_get_bind_addr(), 2323);
rc = telnet_init_dynif(NULL, g_hnb_gw, vty_get_bind_addr(), 2323);