aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/mgcp/mgcp_main.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-02-20 21:21:02 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-02-22 12:09:24 +0100
commit7bdc637aaeb3159bcb68b9ece31356176c0a0880 (patch)
treec78b932f86f8688e0edc23adfb5a8d3b5c67e7c7 /openbsc/src/mgcp/mgcp_main.c
parent92026f1cef5d8c187302e1ad2103a4826584ec1d (diff)
[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.
Diffstat (limited to 'openbsc/src/mgcp/mgcp_main.c')
-rw-r--r--openbsc/src/mgcp/mgcp_main.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/openbsc/src/mgcp/mgcp_main.c b/openbsc/src/mgcp/mgcp_main.c
index 7d318b191..32abef2c6 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 @@ void subscr_put() { abort(); }
#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 @@ static int read_call_agent(struct bsc_fd *fd, unsigned int what)
/* 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 @@ static int read_call_agent(struct bsc_fd *fd, unsigned int what)
}
-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 @@ int main(int argc, char** argv)
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 @@ int main(int argc, char** argv)
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");