aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/osmo-nitb
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-02-10 23:42:17 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-03-03 16:19:09 +0100
commit5e47b1a1d370c187c776b29c5958f167519e94d7 (patch)
tree109151df31be3ebfb242d3345f82a0475b44a4cc /openbsc/src/osmo-nitb
parentb9e5403ef46171f58390757d002a756bd9d2d202 (diff)
mscplit: try to clarify root talloc ctx and global gsm_network.
The aim is to allow osmo-cscn to pass its own root talloc context and global gsm_network struct instance cleanly. This may stir up some old and dusty globals, but I hope it's for the better, since not all is a BSC. To ensure that a global gsm_network pointer for the bsc_vty is set, have it as argument to bsc_vty_init(). The vty configuration commands are added only after bsc_vty_init(), which are needed to configure the network struct. So split up the bsc_bootstrap_network() function into bsc_network_init() to allocate a gsm_struct, and bsc_network_configure() to read the config file once the vty commands are in place. In this way, no global bsc_gsmnet pointer is needed for the bsc vty. The atomic super glue is dissolved and osmo-cscn will be allowed to have a different name for it. Admitted, it's still called the bsc_vty, but a split thereof is probably coming soon, because the CSCN doesn't want any of the BSC nor BTS specific vty commands.
Diffstat (limited to 'openbsc/src/osmo-nitb')
-rw-r--r--openbsc/src/osmo-nitb/bsc_hack.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c
index dffe642b8..2be03ec66 100644
--- a/openbsc/src/osmo-nitb/bsc_hack.c
+++ b/openbsc/src/osmo-nitb/bsc_hack.c
@@ -242,7 +242,7 @@ static void subscr_expire_cb(void *data)
osmo_timer_schedule(&bsc_gsmnet->subscr_expire_timer, EXPIRE_INTERVAL);
}
-void talloc_ctx_init(void);
+void talloc_ctx_init(void *ctx_root);
extern int bsc_vty_go_parent(struct vty *vty);
@@ -260,7 +260,7 @@ int main(int argc, char **argv)
vty_info.copyright = openbsc_copyright;
tall_bsc_ctx = talloc_named_const(NULL, 1, "openbsc");
- talloc_ctx_init();
+ talloc_ctx_init(tall_bsc_ctx);
on_dso_load_token();
on_dso_load_rrlp();
on_dso_load_ho_dec();
@@ -270,9 +270,18 @@ int main(int argc, char **argv)
osmo_stats_init(tall_bsc_ctx);
bts_init();
+ handle_options(argc, argv);
+
+ /* internal MNCC handler or MNCC socket? */
+ rc = bsc_network_init(mncc_sock_path?
+ mncc_sock_from_cc : int_mncc_recv);
+ if (rc < 0)
+ exit(1);
+
/* This needs to precede handle_options() */
+ /* no it doesn't, does it. */
vty_init(&vty_info);
- bsc_vty_init(&log_info);
+ bsc_vty_init(&log_info, bsc_gsmnet);
ctrl_vty_init(tall_bsc_ctx);
#ifdef BUILD_SMPP
@@ -280,18 +289,16 @@ 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_bootstrap_network(mncc_sock_from_cc, config_file);
- if (rc >= 0)
- mncc_sock_init(bsc_gsmnet, mncc_sock_path);
- } else
- rc = bsc_bootstrap_network(int_mncc_recv, config_file);
+ rc = bsc_network_configure(config_file);
if (rc < 0)
exit(1);
+
+ if (mncc_sock_path) {
+ rc = mncc_sock_init(bsc_gsmnet, mncc_sock_path);
+ if (rc < 0)
+ exit(1);
+ }
+
#ifdef BUILD_SMPP
smpp_openbsc_start(bsc_gsmnet);
#endif