path: root/openbsc/src/osmo-bsc_nat
diff options
authorNeels Hofmeyr <>2016-02-23 14:09:38 +0100
committerNeels Hofmeyr <>2016-02-25 12:18:03 +0100
commitfa0f71526c78e2f22a9a51907c40e1136e97d1e6 (patch)
tree2ed141616ba05df74e11645513645bc330092e83 /openbsc/src/osmo-bsc_nat
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 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/osmo-bsc_nat')
1 files changed, 9 insertions, 4 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 2d4f2a8..04c12e3 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -1628,15 +1628,20 @@ int main(int argc, char **argv)
/* init vty and parse */
- if (telnet_init(tall_bsc_ctx, NULL, OSMO_VTY_PORT_BSC_NAT)) {
- fprintf(stderr, "Creating VTY telnet line failed\n");
- return -5;
- }
if (mgcp_parse_config(config_file, nat->mgcp_cfg, MGCP_BSC_NAT) < 0) {
fprintf(stderr, "Failed to parse the config file: '%s'\n", config_file);
return -3;
+ /* start telnet after reading config for vty_get_bind_addr() */
+ LOGP(DNAT, LOGL_NOTICE, "VTY at %s %d\n",
+ vty_get_bind_addr(), OSMO_VTY_PORT_BSC_NAT);
+ if (telnet_init_dynif(tall_bsc_ctx, NULL, vty_get_bind_addr(),
+ fprintf(stderr, "Creating VTY telnet line failed\n");
+ return -5;
+ }
/* over rule the VTY config for MSC IP */
if (msc_ip)
bsc_nat_set_msc_ip(nat, msc_ip);