From 7bdc637aaeb3159bcb68b9ece31356176c0a0880 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 20 Feb 2010 21:21:02 +0100 Subject: [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. --- openbsc/src/mgcp/mgcp_main.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'openbsc/src/mgcp/mgcp_main.c') 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 #include -#include #include #include @@ -41,9 +40,6 @@ #include #include -#include -#include - /* 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"); -- cgit v1.2.3