From 74e61110e5f8231dd11a921252157dd924aefce6 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 28 Feb 2011 14:13:47 +0100 Subject: mgcp: Look up the E1 trunks through the trunk configuration --- openbsc/src/mgcp/mgcp_protocol.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c index 8e5c9501e..46214a559 100644 --- a/openbsc/src/mgcp/mgcp_protocol.c +++ b/openbsc/src/mgcp/mgcp_protocol.c @@ -271,7 +271,8 @@ static struct mgcp_endpoint *find_e1_endpoint(struct mgcp_config *cfg, const char *mgcp) { char *rest = NULL; - int trunk, endp, mgcp_endp; + struct mgcp_trunk_config *tcfg; + int trunk, endp; trunk = strtoul(mgcp + 6, &rest, 10); if (rest == NULL || rest[0] != '/' || trunk < 1) { @@ -289,13 +290,23 @@ static struct mgcp_endpoint *find_e1_endpoint(struct mgcp_config *cfg, if (endp == 1) return NULL; - mgcp_endp = mgcp_timeslot_to_endpoint(trunk - 1, endp); - if (mgcp_endp < 1 || mgcp_endp >= cfg->trunk.number_endpoints) { + tcfg = mgcp_trunk_num(cfg, trunk); + if (!tcfg) { + LOGP(DMGCP, LOGL_ERROR, "The trunk %d is not declared.\n", trunk); + return NULL; + } + + if (!tcfg->endpoints) { + LOGP(DMGCP, LOGL_ERROR, "Endpoints of trunk %d not allocated.\n", trunk); + return NULL; + } + + if (endp < 1 || endp >= tcfg->number_endpoints) { LOGP(DMGCP, LOGL_ERROR, "Failed to find endpoint '%s'\n", mgcp); return NULL; } - return &cfg->trunk.endpoints[mgcp_endp]; + return &tcfg->endpoints[endp]; } static struct mgcp_endpoint *find_endpoint(struct mgcp_config *cfg, const char *mgcp) -- cgit v1.2.3