aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-03-01 13:52:57 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-03-01 13:52:57 +0100
commit672f321eea60bb945b9f5c4a9bc754899baec44e (patch)
treecc5c7a4be9c13efc7b9921f495ded881c68c02af
parentdcc33127922112211088b4e105c63304678969d6 (diff)
mgcp: Calculate the right Audio Processor resource for high endpoints
With this commit we can have more than 30 endpoints that will work. We ignore the blocked endpoints 0x1 and 0x1f for each trunk and calculate everything from the right start point.
-rw-r--r--include/mgcp/mgcp.h2
-rw-r--r--src/mgcp_ss7.c29
2 files changed, 25 insertions, 6 deletions
diff --git a/include/mgcp/mgcp.h b/include/mgcp/mgcp.h
index 675db0c..2bd6eb5 100644
--- a/include/mgcp/mgcp.h
+++ b/include/mgcp/mgcp.h
@@ -122,7 +122,7 @@ struct mgcp_trunk_config {
/* Special MGW handling */
int target_trunk_start;
- int trunk_base;
+ int voice_base;
int endp_offset;
int vad_enabled;
diff --git a/src/mgcp_ss7.c b/src/mgcp_ss7.c
index 11c1b63..7d6f209 100644
--- a/src/mgcp_ss7.c
+++ b/src/mgcp_ss7.c
@@ -68,6 +68,25 @@ static void mgcp_ss7_do_exec(struct mgcp_ss7 *mgcp, uint8_t type, struct mgcp_en
/* Contains a mapping from UniPorte to the MGCP side of things */
static struct mgcp_endpoint *s_endpoints[240];
+static int select_voice_port(struct mgcp_endpoint *endp)
+{
+ int mgw_port;
+ int timeslot, multiplex;
+
+ mgcp_endpoint_to_timeslot(ENDPOINT_NUMBER(endp), &multiplex, &timeslot);
+ if (timeslot == 0x0 || timeslot == 0x1F) {
+ LOGP(DMGCP, LOGL_ERROR, "0x0 and 0x1F are reserved for signalling.\n");
+ return -1;
+ }
+
+ mgw_port = endp->tcfg->voice_base + 30 * multiplex;
+
+ mgw_port = mgw_port + timeslot - endp->tcfg->endp_offset;
+ fprintf(stderr, "TEST: Going to use MGW: %d for MUL: %d TS: %d\n",
+ mgw_port, multiplex, timeslot);
+ return mgw_port;
+}
+
static void check_exit(int status)
{
if (exit_on_failure && status == 21) {
@@ -326,13 +345,13 @@ static void update_mute_status(int mgw_port, int conn_mode)
static void allocate_endp(struct mgcp_ss7 *ss7, struct mgcp_endpoint *endp)
{
- int mgw_port, timeslot, multiplex;
+ int mgw_port;
unsigned long mgw_address, loc_address;
- mgcp_endpoint_to_timeslot(ENDPOINT_NUMBER(endp), &multiplex, &timeslot);
- mgw_port = timeslot - endp->tcfg->endp_offset;
- fprintf(stderr, "TEST: Going to use MGW: %d for MUL: %d TS: %d\n",
- mgw_port, multiplex, timeslot);
+ /* now find the voice processor we want to use */
+ mgw_port = select_voice_port(endp);
+ if (mgw_port < 0)
+ return;
endp->audio_port = MtnSaAllocate(mgw_port);
if (endp->audio_port == UINT_MAX) {