diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-02-28 14:13:47 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-02-28 19:40:53 +0100 |
commit | 74e61110e5f8231dd11a921252157dd924aefce6 (patch) | |
tree | 3a64db7d100b0473d249354cd5c0f21f9b8db0f6 /openbsc | |
parent | 6ea7e777f5edec004da8e82f0f415abb1aee2d48 (diff) |
mgcp: Look up the E1 trunks through the trunk configuration
Diffstat (limited to 'openbsc')
-rw-r--r-- | openbsc/src/mgcp/mgcp_protocol.c | 19 |
1 files 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) |