[mgcp] Move away from global variables and split out VTY code

In separation of using the MGCP parsing in another context, refactor
the code to operate on a struct mgcp_config, split out the vty code
from the mgcp_protocol.c, and move the callbacks into the mgcp code.

There should be no functional changes.
diff --git a/openbsc/src/mgcp/mgcp_main.c b/openbsc/src/mgcp/mgcp_main.c
index 7d318b1..32abef2 100644
--- a/openbsc/src/mgcp/mgcp_main.c
+++ b/openbsc/src/mgcp/mgcp_main.c
@@ -31,7 +31,6 @@
 #include <unistd.h>
 
 #include <sys/socket.h>
-#include <arpa/inet.h>
 
 #include <openbsc/debug.h>
 #include <openbsc/msgb.h>
@@ -41,9 +40,6 @@
 #include <openbsc/mgcp.h>
 #include <openbsc/telnet_interface.h>
 
-#include <vty/command.h>
-#include <vty/vty.h>
-
 /* this is here for the vty... it will never be called */
 void subscr_put() { abort(); }
 
@@ -52,18 +48,15 @@
 
 #warning "Make use of the rtp proxy code"
 
-static int source_port = 2427;
-static const char *source_addr = "0.0.0.0";
 static struct bsc_fd bfd;
 static int first_request = 1;
+static struct mgcp_config *cfg;
 
 static char *config_file = "mgcp.cfg";
 
 /* used by msgb and mgcp */
 void *tall_bsc_ctx = NULL;
 
-unsigned int rtp_base_port = RTP_PORT_DEFAULT;
-
 static void print_help()
 {
 	printf("Some useful help...\n");
@@ -136,7 +129,7 @@
 
 	/* handle message now */
 	msg->l2h = msgb_put(msg, rc);
-	resp = mgcp_handle_message(msg);
+	resp = mgcp_handle_message(cfg, msg);
 	msgb_reset(msg);
 
 	if (resp) {
@@ -147,15 +140,6 @@
 }
 
 
-int bsc_vty_init(struct gsm_network *dummy)
-{
-	cmd_init(1);
-	vty_init();
-
-        mgcp_vty_init();
-	return 0;
-}
-
 int main(int argc, char** argv)
 {
 	struct gsm_network dummy_network;
@@ -170,10 +154,14 @@
 	debug_add_target(stderr_target);
 	debug_set_all_filter(stderr_target, 1);
 
+	cfg = mgcp_config_alloc();
+	if (!cfg)
+		return -1;
+
 	handle_options(argc, argv);
 
 	telnet_init(&dummy_network, 4243);
-        rc = mgcp_parse_config(config_file, &dummy_network);
+        rc = mgcp_parse_config(config_file, cfg);
 	if (rc < 0)
 		return rc;
 
@@ -192,8 +180,8 @@
 
 		memset(&addr, 0, sizeof(addr));
 		addr.sin_family = AF_INET;
-		addr.sin_port = htons(source_port);
-		inet_aton(source_addr, &addr.sin_addr);
+		addr.sin_port = htons(cfg->source_port);
+		inet_aton(cfg->source_addr, &addr.sin_addr);
 
 		if (bind(bfd.fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 			perror("Gateway failed to bind");