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.
diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c
index 81b130b..aaad654 100644
--- a/openbsc/src/gprs/sgsn_main.c
+++ b/openbsc/src/gprs/sgsn_main.c
@@ -138,8 +138,14 @@
 	log_add_target(stderr_target);
 	log_set_all_filter(stderr_target, 1);
 
+	vty_init("Osmocom SGSN", PACKAGE_VERSION, openbsc_copyright);
+	openbsc_vty_add_cmds();
+        sgsn_vty_init();
+
 	rate_ctr_init(tall_bsc_ctx);
-	telnet_init(&dummy_network, 4245);
+	rc = telnet_init(tall_bsc_ctx, &dummy_network, 4245);
+	if (rc < 0)
+		exit(1);
 
 	sgsn_nsi = gprs_ns_instantiate(&sgsn_ns_cb);
 	if (!sgsn_nsi) {
@@ -166,15 +172,3 @@
 
 	exit(0);
 }
-
-struct gsm_network;
-int bsc_vty_init(struct gsm_network *dummy)
-{
-	cmd_init(1);
-	vty_init("Osmocom SGSN", PACKAGE_VERSION, openbsc_copyright);
-
-	openbsc_vty_add_cmds();
-        sgsn_vty_init();
-	return 0;
-}
-