From 74db7744ee76958297f2a820033c5891e6beefe8 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 10 Jun 2011 00:04:55 +0200 Subject: [PATCH] mgcp: Implement RSIP based on a trunk level Implement the RSIP spec extension to work on the specified trunk instead of hardcoding it to the virtual trunk. --- openbsc/include/openbsc/mgcp.h | 2 +- openbsc/src/libmgcp/mgcp_protocol.c | 14 +++++++++++++- openbsc/src/osmo-bsc_mgcp/mgcp_main.c | 16 ++++++++++------ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h index b9f81161f..7c290c7f3 100644 --- a/openbsc/include/openbsc/mgcp.h +++ b/openbsc/include/openbsc/mgcp.h @@ -82,7 +82,7 @@ struct mgcp_trunk_config; typedef int (*mgcp_realloc)(struct mgcp_trunk_config *cfg, int endpoint); typedef int (*mgcp_change)(struct mgcp_trunk_config *cfg, int endpoint, int state); typedef int (*mgcp_policy)(struct mgcp_trunk_config *cfg, int endpoint, int state, const char *transactio_id); -typedef int (*mgcp_reset)(struct mgcp_config *cfg); +typedef int (*mgcp_reset)(struct mgcp_trunk_config *cfg); #define PORT_ALLOC_STATIC 0 #define PORT_ALLOC_DYNAMIC 1 diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c index 1d26850ba..44a3b87ff 100644 --- a/openbsc/src/libmgcp/mgcp_protocol.c +++ b/openbsc/src/libmgcp/mgcp_protocol.c @@ -831,8 +831,20 @@ out_silent: static struct msgb *handle_rsip(struct mgcp_config *cfg, struct msgb *msg) { + struct mgcp_msg_ptr data_ptrs[6]; + const char *trans_id; + struct mgcp_endpoint *endp; + int found; + + found = mgcp_analyze_header(cfg, msg, data_ptrs, ARRAY_SIZE(data_ptrs), + &trans_id, &endp); + if (found != 0) { + LOGP(DMGCP, LOGL_ERROR, "Failed to find the endpoint.\n"); + return NULL; + } + if (cfg->reset_cb) - cfg->reset_cb(cfg); + cfg->reset_cb(endp->tcfg); return NULL; } diff --git a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c index d5de4061b..ee1543cdb 100644 --- a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c +++ b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c @@ -2,8 +2,8 @@ /* The main method to drive it as a standalone process */ /* - * (C) 2009 by Holger Hans Peter Freyther - * (C) 2009 by On-Waves + * (C) 2009-2011 by Holger Hans Peter Freyther + * (C) 2009-2011 by On-Waves * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -58,6 +58,7 @@ void subscr_put() { abort(); } #warning "Make use of the rtp proxy code" static struct mgcp_config *cfg; +static struct mgcp_trunk_config *reset_trunk; static int reset_endpoints = 0; static int daemonize = 0; @@ -121,9 +122,10 @@ static void handle_options(int argc, char **argv) } /* simply remember this */ -static int mgcp_rsip_cb(struct mgcp_config *cfg) +static int mgcp_rsip_cb(struct mgcp_trunk_config *tcfg) { reset_endpoints = 1; + reset_trunk = tcfg; return 0; } @@ -170,12 +172,14 @@ static int read_call_agent(struct osmo_fd *fd, unsigned int what) } if (reset_endpoints) { - LOGP(DMGCP, LOGL_NOTICE, "Asked to reset endpoints.\n"); + LOGP(DMGCP, LOGL_NOTICE, + "Asked to reset endpoints: %d/%d\n", + reset_trunk->trunk_nr, reset_trunk->trunk_type); reset_endpoints = 0; /* is checking in_addr.s_addr == INADDR_LOOPBACK making it more secure? */ - for (i = 1; i < cfg->trunk.number_endpoints; ++i) - mgcp_free_endp(&cfg->trunk.endpoints[i]); + for (i = 1; i < reset_trunk->number_endpoints; ++i) + mgcp_free_endp(&reset_trunk->endpoints[i]); } return 0;