diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-10-24 01:53:38 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2016-12-02 12:09:15 +0000 |
commit | 2c05f75bbf3d9a69eee1fe78eb5552acf1d7671d (patch) | |
tree | 843251c808341cd27e448b7f9abc0af327451934 /openbsc/src/osmo-nitb | |
parent | e235441f73a6baf1b43da9dde3cb6828ced9d1fe (diff) |
global gsm_network: move allocation further up
Now that bsc_network_alloc() is separate, move it to before the VTY init (a
subsequent patch will pass the gsm_network instance as a parameter to
vty_init()).
bsc_hack.c: drop the comment that says about the VTY init: "This needs to
precede handle_options()" -- it is not accurate. Actually move the
handle_options() above both vty_init() and the bsc_network_alloc() calls, to be
able to decide which mncc callback to pass to bsc_network_alloc. It would make
sense to set this later on, but that would require further refactoring of the
bsc_network_init() and gsm_network_init() signatures, so not in this patch.
Change-Id: Ie6a7037e703b5a2d08ceeb20d35f197aaddc9d1b
Diffstat (limited to 'openbsc/src/osmo-nitb')
-rw-r--r-- | openbsc/src/osmo-nitb/bsc_hack.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index ccd3b7436..c3ecf4ca7 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -270,7 +270,18 @@ int main(int argc, char **argv) osmo_stats_init(tall_bsc_ctx); bts_init(); - /* This needs to precede handle_options() */ + /* Parse options */ + handle_options(argc, argv); + + /* Allocate global gsm_network struct; choose socket/internal MNCC */ + rc = bsc_network_alloc(mncc_sock_path? + mncc_sock_from_cc : int_mncc_recv); + if (rc) { + fprintf(stderr, "Allocation failed. Exiting.\n"); + exit(1); + } + + /* Initialize VTY */ vty_init(&vty_info); bsc_vty_init(&log_info, bsc_gsmnet); ctrl_vty_init(tall_bsc_ctx); @@ -280,25 +291,13 @@ int main(int argc, char **argv) return -1; #endif - /* parse options */ - handle_options(argc, argv); - - /* internal MNCC handler or MNCC socket? */ - if (mncc_sock_path) { - rc = bsc_network_alloc(mncc_sock_from_cc); - if (rc) { - fprintf(stderr, "Allocation failed. Exiting.\n"); - exit(1); - } + /* Initialize MNCC socket if appropriate */ + if (mncc_sock_path) mncc_sock_init(bsc_gsmnet, mncc_sock_path); - } else { + else DEBUGP(DMNCC, "Using internal MNCC handler.\n"); - rc = bsc_network_alloc(int_mncc_recv); - if (rc) { - fprintf(stderr, "Allocation failed. Exiting.\n"); - exit(1); - } - } + + /* Read the config */ rc = bsc_network_configure(config_file); if (rc < 0) { fprintf(stderr, "Reading config failed. Exiting.\n"); |