diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-05-11 18:48:39 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2016-12-02 12:09:16 +0000 |
commit | b90eabfb46aaf5efcc3b5f16fe89b914db4542ea (patch) | |
tree | 560bc4da553e66e0c02d5a9e882ea9e7e052ec74 /openbsc/src/libcommon-cs | |
parent | 2c05f75bbf3d9a69eee1fe78eb5552acf1d7671d (diff) |
move to libcommon-cs: global vty gsm_network pointer
Move gsmnet_from_vty() and the bsc_gsmnet global to common_cs_vty.c.
Rename bsc_gsmnet to vty_global_gsm_network and make it static to common_cs_vty.c, to
clearly mark the global variable for VTY use only.
Introduce common_cs_vty_init() to set vty_global_gsm_network.
Change-Id: I26c5c47de08f899b896813d09612d5cb2f8e42d6
Diffstat (limited to 'openbsc/src/libcommon-cs')
-rw-r--r-- | openbsc/src/libcommon-cs/common_cs_vty.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/openbsc/src/libcommon-cs/common_cs_vty.c b/openbsc/src/libcommon-cs/common_cs_vty.c index 99aa0cf76..11ed50f09 100644 --- a/openbsc/src/libcommon-cs/common_cs_vty.c +++ b/openbsc/src/libcommon-cs/common_cs_vty.c @@ -1,6 +1,7 @@ /* Code used by both libbsc and libmsc (common_cs means "BSC or MSC"). * * (C) 2016 by sysmocom s.m.f.c. <info@sysmocom.de> + * (C) 2008-2010 by Harald Welte <laforge@gnumonks.org> * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -17,3 +18,26 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + +#include <openbsc/gsm_data.h> + +static struct gsm_network *vty_global_gsm_network = NULL; + +/* initialize VTY elements used in both BSC and MSC */ +int common_cs_vty_init(struct gsm_network *network) +{ + OSMO_ASSERT(vty_global_gsm_network == NULL); + vty_global_gsm_network = network; +} + +struct gsm_network *gsmnet_from_vty(struct vty *v) +{ + /* 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 common_cs_vty_init(). + */ + OSMO_ASSERT(vty_global_gsm_network); + return vty_global_gsm_network; +} |