diff options
author | Harald Welte <laforge@gnumonks.org> | 2011-09-04 22:42:03 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2011-09-04 22:47:25 +0200 |
commit | 6d7b78bde165f39dcd9033f0c5386f5699801233 (patch) | |
tree | fe80fb89129b7cfc580ec3b11b471c7da2b289ac /src/osmo-bts-sysmo/main.c | |
parent | f41f2a7f92d7eea87e3f036a849bf8b131e2b389 (diff) |
add minimal configuration file support
this config file allows configuration of unit id, oml ip,
and local rtp bind IP.
Diffstat (limited to 'src/osmo-bts-sysmo/main.c')
-rw-r--r-- | src/osmo-bts-sysmo/main.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c index e09caae4..35ac9eeb 100644 --- a/src/osmo-bts-sysmo/main.c +++ b/src/osmo-bts-sysmo/main.c @@ -47,7 +47,6 @@ const uint8_t abis_mac[6] = { 0,1,2,3,4,5 }; /* FIXME: generate from git */ const char *software_version = "0815"; -static const char *bsc_host = NULL; static const char *config_file = "osmo-bts.cfg"; extern const char *osmobts_copyright; static int daemonize = 0; @@ -103,7 +102,6 @@ static void print_help() " -T --timestamp Prefix every log line with a timestamp\n" " -V --version Print version information and exit\n" " -e --log-level Set a global log-level\n" - " -B --bsc-host Specify host-name of the BSC\n" " -p --dsp-trace Set DSP trace flags\n" ); } @@ -123,12 +121,11 @@ static void handle_options(int argc, char **argv) { "timestamp", 0, 0, 'T' }, { "version", 0, 0, 'V' }, { "log-level", 1, 0, 'e' }, - { "bsc-host", 1, 0, 'B' }, { "dsp-trace", 1, 0, 'p' }, { 0, 0, 0, 0 } }; - c = getopt_long(argc, argv, "hd:Dc:sTVe:B:p:", + c = getopt_long(argc, argv, "hc:d:Dc:sTVe:p:", long_options, &option_idx); if (c == -1) break; @@ -160,9 +157,6 @@ static void handle_options(int argc, char **argv) case 'e': log_set_log_level(osmo_stderr_target, atoi(optarg)); break; - case 'B': - bsc_host = strdup(optarg); - break; case 'p': dsp_trace = strtoul(optarg, NULL, 16); break; @@ -195,6 +189,7 @@ static void signal_handler(int signal) int main(int argc, char **argv) { + struct gsm_bts_role_bts *btsb; struct ipabis_link *link; void *tall_msgb_ctx; int rc; @@ -205,13 +200,24 @@ int main(int argc, char **argv) bts_log_init(NULL); + vty_init(&bts_vty_info); + bts_vty_init(&bts_log_info); + bts = gsm_bts_alloc(tall_bts_ctx); + if (bts_init(bts) < 0) { + fprintf(stderr, "unable to to open bts\n"); + exit(1); + } + btsb = bts_role_bts(bts); - vty_init(&bts_vty_info); - logging_vty_add_cmds(&bts_log_info); - //bts_vty_init(& + handle_options(argc, argv); - /* FIXME: parse config file */ + rc = vty_read_config_file(config_file, NULL); + if (rc < 0) { + fprintf(stderr, "Failed to parse the config file: '%s'\n", + config_file); + exit(1); + } rc = telnet_init(tall_bts_ctx, NULL, 4241); if (rc < 0) { @@ -219,25 +225,18 @@ int main(int argc, char **argv) exit(1); } - handle_options(argc, argv); - - if (!bsc_host) { - fprintf(stderr, "You need to specify the BSC hostname\n"); - exit(2); - } - signal(SIGINT, &signal_handler); //signal(SIGABRT, &signal_handler); signal(SIGUSR1, &signal_handler); signal(SIGUSR2, &signal_handler); osmo_init_ignore_signals(); - if (bts_init(bts) < 0) { - fprintf(stderr, "unable to to open bts\n"); + if (!btsb->bsc_oml_host) { + fprintf(stderr, "Cannot start BTS without knowing BSC OML IP\n"); exit(1); } - link = link_init(bts, bsc_host); + link = link_init(bts, btsb->bsc_oml_host); if (!link) { fprintf(stderr, "unable to connect to BSC\n"); exit(1); |