aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-02-28 14:46:01 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-02-28 19:40:54 +0100
commit44016fee14a494f3fa13b9f094dc205985db2e5e (patch)
tree192d27d75e1f49a4e41b50c70a6adb36bfd35db5
parent1f0c5b47426b4236ae0c91c71bc0d14a157f222f (diff)
mgcp: Fix the static allocation of E1 trunks for the BTS/NET side
-rw-r--r--openbsc/include/openbsc/mgcp.h4
-rw-r--r--openbsc/src/mgcp/mgcp_vty.c23
2 files changed, 18 insertions, 9 deletions
diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h
index 88e52302..516b76ed 100644
--- a/openbsc/include/openbsc/mgcp.h
+++ b/openbsc/include/openbsc/mgcp.h
@@ -153,6 +153,10 @@ struct mgcp_config {
/* trunk handling */
struct mgcp_trunk_config trunk;
struct llist_head trunks;
+
+ /* only used for start with a static configuration */
+ int last_net_port;
+ int last_bts_port;
};
/* config management */
diff --git a/openbsc/src/mgcp/mgcp_vty.c b/openbsc/src/mgcp/mgcp_vty.c
index f9554980..f71c17be 100644
--- a/openbsc/src/mgcp/mgcp_vty.c
+++ b/openbsc/src/mgcp/mgcp_vty.c
@@ -651,29 +651,30 @@ static int allocate_trunk(struct mgcp_trunk_config *trunk)
/* early bind */
for (i = 1; i < trunk->number_endpoints; ++i) {
struct mgcp_endpoint *endp = &trunk->endpoints[i];
- int rtp_port;
if (cfg->bts_ports.mode == PORT_ALLOC_STATIC) {
- rtp_port = rtp_calculate_port(ENDPOINT_NUMBER(endp),
- cfg->bts_ports.base_port);
- if (mgcp_bind_bts_rtp_port(endp, rtp_port) != 0) {
- LOGP(DMGCP, LOGL_FATAL, "Failed to bind: %d\n", rtp_port);
+ cfg->last_bts_port += 2;
+ if (mgcp_bind_bts_rtp_port(endp, cfg->last_bts_port) != 0) {
+ LOGP(DMGCP, LOGL_FATAL,
+ "Failed to bind: %d\n", cfg->last_bts_port);
return -1;
}
endp->bts_end.local_alloc = PORT_ALLOC_STATIC;
}
if (cfg->net_ports.mode == PORT_ALLOC_STATIC) {
- rtp_port = rtp_calculate_port(ENDPOINT_NUMBER(endp),
- cfg->net_ports.base_port);
- if (mgcp_bind_net_rtp_port(endp, rtp_port) != 0) {
- LOGP(DMGCP, LOGL_FATAL, "Failed to bind: %d\n", rtp_port);
+ cfg->last_net_port += 2;
+ if (mgcp_bind_net_rtp_port(endp, cfg->last_net_port) != 0) {
+ LOGP(DMGCP, LOGL_FATAL,
+ "Failed to bind: %d\n", cfg->last_net_port);
return -1;
}
endp->net_end.local_alloc = PORT_ALLOC_STATIC;
}
if (cfg->transcoder_ip && cfg->transcoder_ports.mode == PORT_ALLOC_STATIC) {
+ int rtp_port;
+
/* network side */
rtp_port = rtp_calculate_port(ENDPOINT_NUMBER(endp),
cfg->transcoder_ports.base_port);
@@ -718,6 +719,10 @@ int mgcp_parse_config(const char *config_file, struct mgcp_config *cfg)
return -1;
}
+ /* initialize the last ports */
+ g_cfg->last_bts_port = rtp_calculate_port(0, g_cfg->bts_ports.base_port);
+ g_cfg->last_net_port = rtp_calculate_port(0, g_cfg->net_ports.base_port);
+
if (allocate_trunk(&g_cfg->trunk) != 0) {
LOGP(DMGCP, LOGL_ERROR, "Failed to initialize the virtual trunk.\n");
return -1;