diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-05-16 20:52:23 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-05-16 20:52:23 +0200 |
commit | dcccb1818da12041d08469ce2ab2ccd191187100 (patch) | |
tree | f2bb70dd3b130e8afa4c8c4c2a8e7689867843ec /openbsc/src/mgcp | |
parent | 88907a2f92523c56bf5250c3c75230601eb2f604 (diff) |
VTY: decouple telnet_interface from 'struct gsmnet'
We want the VTY and telnet code to be independent from the BSC
application(s). As a side note, we also like to eliminate static
global variables for 'struct gsm_network' all over the code.
As such, telnet_init() is now passed along a "private" pointer,
which getst stored in telnet_connection.priv. This telnet_connection
is then stored in vty->priv, which in turn gets dereferenced if
anyone needs a reference to 'struct gsm_network' from the BSC vty
code.
Also:
* vty_init() now calls cmd_init()
* the ugliness that telnet_init() calls back into the application by means of
bsc_vty_init() function has been removed.
* telnet_init() now returns any errors, so the main program can exit
e.g. if the port is already in use.
Diffstat (limited to 'openbsc/src/mgcp')
-rw-r--r-- | openbsc/src/mgcp/mgcp_main.c | 20 | ||||
-rw-r--r-- | openbsc/src/mgcp/mgcp_vty.c | 2 |
2 files changed, 8 insertions, 14 deletions
diff --git a/openbsc/src/mgcp/mgcp_main.c b/openbsc/src/mgcp/mgcp_main.c index fd03c9943..63955e7d5 100644 --- a/openbsc/src/mgcp/mgcp_main.c +++ b/openbsc/src/mgcp/mgcp_main.c @@ -193,7 +193,9 @@ int main(int argc, char** argv) if (!cfg) return -1; - telnet_init(&dummy_network, 4243); + vty_init("OpenBSC MGCP", PACKAGE_VERSION, openbsc_copyright); + openbsc_vty_add_cmds(); + mgcp_vty_init(); handle_options(argc, argv); @@ -201,6 +203,10 @@ int main(int argc, char** argv) if (rc < 0) return rc; + rc = telnet_init(tall_bsc_ctx, &dummy_network, 4243); + if (rc < 0) + return rc; + /* set some callbacks */ cfg->reset_cb = mgcp_rsip_cb; cfg->change_cb = mgcp_change_cb; @@ -253,15 +259,3 @@ int main(int argc, char** argv) return 0; } - -struct gsm_network; -int bsc_vty_init(struct gsm_network *dummy) -{ - cmd_init(1); - vty_init("OpenBSC MGCP", PACKAGE_VERSION, openbsc_copyright); - - openbsc_vty_add_cmds(); - mgcp_vty_init(); - return 0; -} - diff --git a/openbsc/src/mgcp/mgcp_vty.c b/openbsc/src/mgcp/mgcp_vty.c index 2804ce9b7..1e76839a3 100644 --- a/openbsc/src/mgcp/mgcp_vty.c +++ b/openbsc/src/mgcp/mgcp_vty.c @@ -267,7 +267,7 @@ int mgcp_parse_config(const char *config_file, struct mgcp_config *cfg) int i, rc; g_cfg = cfg; - rc = vty_read_config_file(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); return rc; |