aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libbsc/bsc_vty.c
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/libbsc/bsc_vty.c
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/libbsc/bsc_vty.c')
-rw-r--r--openbsc/src/libbsc/bsc_vty.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 418e43549..29de16ca0 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -130,19 +130,21 @@ struct cmd_node ts_node = {
1,
};
-extern struct gsm_network *bsc_gsmnet;
+static struct gsm_network *vty_global_gsm_network = 0;
struct gsm_network *gsmnet_from_vty(struct vty *v)
{
/* In case we read from the config file, the vty->priv cannot
* point to a struct telnet_connection, and thus conn->priv
- * will not point to the gsm_network structure */
-#if 0
- struct telnet_connection *conn = v->priv;
- return (struct gsm_network *) conn->priv;
-#else
- return bsc_gsmnet;
-#endif
+ * will not point to the gsm_network structure.
+ * It can't hurt to force callers to continue to pass the vty instance
+ * to this function, in case we'd like to retrieve the global
+ * gsm_network instance from the vty at some point in the future. But
+ * until then, just return the global pointer, which should have been
+ * initialized by bsc_vty_init().
+ */
+ OSMO_ASSERT(vty_global_gsm_network);
+ return vty_global_gsm_network;
}
static int dummy_config_write(struct vty *v)
@@ -3620,7 +3622,7 @@ DEFUN(smscb_cmd, smscb_cmd_cmd,
uint8_t buf[88];
int rc;
- bts = gsm_bts_num(bsc_gsmnet, bts_nr);
+ bts = gsm_bts_num(vty_global_gsm_network, bts_nr);
if (!bts) {
vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
return CMD_WARNING;
@@ -3671,7 +3673,7 @@ DEFUN(pdch_act, pdch_act_cmd,
int ts_nr = atoi(argv[2]);
int activate;
- bts = gsm_bts_num(bsc_gsmnet, bts_nr);
+ bts = gsm_bts_num(vty_global_gsm_network, bts_nr);
if (!bts) {
vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
return CMD_WARNING;
@@ -3710,8 +3712,10 @@ DEFUN(pdch_act, pdch_act_cmd,
extern int bsc_vty_init_extra(void);
extern const char *openbsc_copyright;
-int bsc_vty_init(const struct log_info *cat)
+int bsc_vty_init(const struct log_info *cat, struct gsm_network *network)
{
+ vty_global_gsm_network = network;
+
cfg_ts_pchan_cmd.string =
vty_cmd_string_from_valstr(tall_bsc_ctx,
gsm_pchant_names,