aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gprs
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-02-23 14:09:38 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-02-25 12:18:03 +0100
commitfa0f71526c78e2f22a9a51907c40e1136e97d1e6 (patch)
tree2ed141616ba05df74e11645513645bc330092e83 /openbsc/src/gprs
parent58d5430dd5d04edadb5a98532c9854d8601f801c (diff)
enable telnet VTY bind address config for various programs
Following the 'line vty'/'bind A.B.C.D' command added in libosmocore, use the configured address to set the telnet bind for the VTY line. It is now possible to publish the VTY on a specific local interface (including 0.0.0.0 aka "any"). Implement in all of: osmo-gbproxy osmo-gtphub osmo-sgsn osmo-bsc osmo-bsc_nat osmo-bsc_mgcp osmo-nitb In some of these main programs, move the telnet initialization below the configuration parsing. Historically, this was not a good idea for programs using bsc_init.c (aka bsc_bootstrap_network()), since they expected a gsm_network struct pointer in ((struct telnet_connection*)vty->priv)->priv, so that telnet had to be either initialized or replaced by a dummy struct. In the meantime, the gsm_network struct is not actually looked up in a priv pointer but in the static bsc_vty.c scope (bsc_gsmnet), so this limitation is mere legacy (even though said legacy is still there in an "#if 0" chunk). In the other binaries I have briefly looked at the init sequence dependencies and found no reason to initialize telnet above the config file parsing. In any case, I have tested every single one of abovementioned binaries to verify that they still parse the example config successfully and launch, allowing VTY connections on the configured address(es). I hope this suffices. In all of the above, log VTY address and port. LOGL_INFO is disabled by default in some of the logging scopes, and since it is a single log message right at program launch, I decided for the slightly more aggressive LOGL_NOTICE.
Diffstat (limited to 'openbsc/src/gprs')
-rw-r--r--openbsc/src/gprs/gb_proxy_main.c12
-rw-r--r--openbsc/src/gprs/gtphub_main.c11
-rw-r--r--openbsc/src/gprs/sgsn_main.c11
3 files changed, 24 insertions, 10 deletions
diff --git a/openbsc/src/gprs/gb_proxy_main.c b/openbsc/src/gprs/gb_proxy_main.c
index f82fb5b73..0c3cfbec4 100644
--- a/openbsc/src/gprs/gb_proxy_main.c
+++ b/openbsc/src/gprs/gb_proxy_main.c
@@ -252,10 +252,6 @@ int main(int argc, char **argv)
rate_ctr_init(tall_bsc_ctx);
osmo_stats_init(tall_bsc_ctx);
- rc = telnet_init(tall_bsc_ctx, &dummy_network, OSMO_VTY_PORT_GBPROXY);
- if (rc < 0)
- exit(1);
-
bssgp_nsi = gprs_ns_instantiate(&proxy_ns_cb, tall_bsc_ctx);
if (!bssgp_nsi) {
LOGP(DGPRS, LOGL_ERROR, "Unable to instantiate NS\n");
@@ -274,6 +270,14 @@ int main(int argc, char **argv)
exit(2);
}
+ /* start telnet after reading config for vty_get_bind_addr() */
+ LOGP(DGPRS, LOGL_NOTICE, "VTY at %s %d\n",
+ vty_get_bind_addr(), OSMO_VTY_PORT_GBPROXY);
+ rc = telnet_init_dynif(tall_bsc_ctx, &dummy_network,
+ vty_get_bind_addr(), OSMO_VTY_PORT_GBPROXY);
+ if (rc < 0)
+ exit(1);
+
if (!gprs_nsvc_by_nsei(gbcfg.nsi, gbcfg.nsip_sgsn_nsei)) {
LOGP(DGPRS, LOGL_FATAL, "You cannot proxy to NSEI %u "
"without creating that NSEI before\n",
diff --git a/openbsc/src/gprs/gtphub_main.c b/openbsc/src/gprs/gtphub_main.c
index f18710d3c..89582b1d5 100644
--- a/openbsc/src/gprs/gtphub_main.c
+++ b/openbsc/src/gprs/gtphub_main.c
@@ -314,9 +314,6 @@ int main(int argc, char **argv)
gtphub_vty_init(hub, cfg);
rate_ctr_init(osmo_gtphub_ctx);
- rc = telnet_init(osmo_gtphub_ctx, 0, OSMO_VTY_PORT_GTPHUB);
- if (rc < 0)
- exit(1);
handle_options(ccfg, argc, argv);
@@ -327,6 +324,14 @@ int main(int argc, char **argv)
exit(2);
}
+ /* start telnet after reading config for vty_get_bind_addr() */
+ LOGP(DGTPHUB, LOGL_NOTICE, "VTY at %s %d\n",
+ vty_get_bind_addr(), OSMO_VTY_PORT_GTPHUB);
+ rc = telnet_init_dynif(osmo_gtphub_ctx, 0, vty_get_bind_addr(),
+ OSMO_VTY_PORT_GTPHUB);
+ if (rc < 0)
+ exit(1);
+
if (gtphub_start(hub, cfg,
next_restart_count(ccfg->restart_counter_file))
!= 0)
diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c
index 2d3a0e4a9..b10b0b37f 100644
--- a/openbsc/src/gprs/sgsn_main.c
+++ b/openbsc/src/gprs/sgsn_main.c
@@ -315,9 +315,6 @@ int main(int argc, char **argv)
handle_options(argc, argv);
rate_ctr_init(tall_bsc_ctx);
- rc = telnet_init(tall_bsc_ctx, &dummy_network, OSMO_VTY_PORT_SGSN);
- if (rc < 0)
- exit(1);
ctrl = sgsn_controlif_setup(NULL, OSMO_CTRL_PORT_SGSN);
if (!ctrl) {
@@ -357,6 +354,14 @@ int main(int argc, char **argv)
exit(2);
}
+ /* start telnet after reading config for vty_get_bind_addr() */
+ LOGP(DGPRS, LOGL_NOTICE, "VTY at %s %d\n",
+ vty_get_bind_addr(), OSMO_VTY_PORT_SGSN);
+ rc = telnet_init_dynif(tall_bsc_ctx, &dummy_network,
+ vty_get_bind_addr(), OSMO_VTY_PORT_SGSN);
+ if (rc < 0)
+ exit(1);
+
rc = sgsn_gtp_init(&sgsn_inst);
if (rc) {
LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen on GTP socket\n");