aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-08-08 07:17:22 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-08-08 07:17:22 +0800
commit7cf7d27d10a3b60b2f605e946a55a730adc3bc73 (patch)
tree41ae2041c6b9d4ac6d1b1013722da43972642566
parent9002169dcd7251f9556ae5ed02797620cb6a1607 (diff)
mgcp: Attempt to separate the RTP/RTCP port for the Network and for the BTS
We plan to have two different ports for the network and for the BTS to avoid detecting the BTS and to dynamically allocate the port to have old data not go to a new socket. Conflicts: openbsc/src/nat/bsc_mgcp_utils.c
-rw-r--r--openbsc/include/openbsc/mgcp.h2
-rw-r--r--openbsc/include/openbsc/mgcp_internal.h5
-rw-r--r--openbsc/src/mgcp/mgcp_network.c15
-rw-r--r--openbsc/src/mgcp/mgcp_protocol.c20
4 files changed, 22 insertions, 20 deletions
diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h
index 5ff536a3c..9ba826223 100644
--- a/openbsc/include/openbsc/mgcp.h
+++ b/openbsc/include/openbsc/mgcp.h
@@ -74,7 +74,7 @@ struct mgcp_config;
#define MGCP_POLICY_REJECT 5
#define MGCP_POLICY_DEFER 6
-typedef int (*mgcp_change)(struct mgcp_config *cfg, int endpoint, int state, int local_rtp);
+typedef int (*mgcp_change)(struct mgcp_config *cfg, int endpoint, int state);
typedef int (*mgcp_policy)(struct mgcp_config *cfg, int endpoint, int state, const char *transactio_id);
typedef int (*mgcp_reset)(struct mgcp_config *cfg);
diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h
index 1ac8ad42f..872afbf2e 100644
--- a/openbsc/include/openbsc/mgcp_internal.h
+++ b/openbsc/include/openbsc/mgcp_internal.h
@@ -58,6 +58,8 @@ struct mgcp_rtp_end {
int rtp_port, rtcp_port;
int payload_type;
+
+ int local_port;
};
struct mgcp_endpoint {
@@ -67,9 +69,6 @@ struct mgcp_endpoint {
int conn_mode;
int orig_mode;
- /* the local rtp port we are binding to */
- int rtp_port;
-
/*
* RTP mangling:
* - we get RTP and RTCP to us and need to forward to the BTS
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c
index ecf264234..c29f645e7 100644
--- a/openbsc/src/mgcp/mgcp_network.c
+++ b/openbsc/src/mgcp/mgcp_network.c
@@ -292,15 +292,15 @@ static int bind_rtp(struct mgcp_endpoint *endp)
{
struct mgcp_config *cfg = endp->cfg;
- if (create_bind(cfg->source_addr, &endp->local_rtp, endp->rtp_port) != 0) {
+ if (create_bind(cfg->source_addr, &endp->local_rtp, endp->bts_end.local_port) != 0) {
LOGP(DMGCP, LOGL_ERROR, "Failed to create RTP port: %s:%d on 0x%x\n",
- cfg->source_addr, endp->rtp_port, ENDPOINT_NUMBER(endp));
+ cfg->source_addr, endp->bts_end.local_port, ENDPOINT_NUMBER(endp));
goto cleanup0;
}
- if (create_bind(cfg->source_addr, &endp->local_rtcp, endp->rtp_port + 1) != 0) {
+ if (create_bind(cfg->source_addr, &endp->local_rtcp, endp->bts_end.local_port + 1) != 0) {
LOGP(DMGCP, LOGL_ERROR, "Failed to create RTCP port: %s:%d on 0x%x\n",
- cfg->source_addr, endp->rtp_port + 1, ENDPOINT_NUMBER(endp));
+ cfg->source_addr, endp->bts_end.local_port + 1, ENDPOINT_NUMBER(endp));
goto cleanup1;
}
@@ -312,7 +312,7 @@ static int bind_rtp(struct mgcp_endpoint *endp)
endp->local_rtp.when = BSC_FD_READ;
if (bsc_register_fd(&endp->local_rtp) != 0) {
LOGP(DMGCP, LOGL_ERROR, "Failed to register RTP port %d on 0x%x\n",
- endp->rtp_port, ENDPOINT_NUMBER(endp));
+ endp->bts_end.local_port, ENDPOINT_NUMBER(endp));
goto cleanup2;
}
@@ -321,7 +321,7 @@ static int bind_rtp(struct mgcp_endpoint *endp)
endp->local_rtcp.when = BSC_FD_READ;
if (bsc_register_fd(&endp->local_rtcp) != 0) {
LOGP(DMGCP, LOGL_ERROR, "Failed to register RTCP port %d on 0x%x\n",
- endp->rtp_port + 1, ENDPOINT_NUMBER(endp));
+ endp->bts_end.local_port + 1, ENDPOINT_NUMBER(endp));
goto cleanup3;
}
@@ -341,6 +341,7 @@ cleanup0:
int mgcp_bind_rtp_port(struct mgcp_endpoint *endp, int rtp_port)
{
- endp->rtp_port = rtp_port;
+ endp->bts_end.local_port = rtp_port;
+ endp->net_end.local_port = rtp_port;
return bind_rtp(endp);
}
diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c
index bdf376fbc..35d39fa38 100644
--- a/openbsc/src/mgcp/mgcp_protocol.c
+++ b/openbsc/src/mgcp/mgcp_protocol.c
@@ -174,7 +174,7 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp,
"c=IN IP4 %s\r\n"
"m=audio %d RTP/AVP %d\r\n"
"a=rtpmap:%d %s\r\n",
- endp->ci, addr, endp->rtp_port,
+ endp->ci, addr, endp->net_end.local_port,
endp->bts_end.payload_type, endp->bts_end.payload_type,
endp->cfg->audio_name);
return mgcp_create_response_with_data(200, msg, trans_id, sdp_record);
@@ -428,9 +428,10 @@ static struct msgb *handle_create_con(struct mgcp_config *cfg, struct msgb *msg)
/* bind to the port now */
port = rtp_calculate_port(ENDPOINT_NUMBER(endp), cfg->rtp_base_port);
- if (cfg->early_bind)
- endp->rtp_port = port;
- else if (mgcp_bind_rtp_port(endp, port) != 0)
+ if (cfg->early_bind) {
+ endp->bts_end.local_port = port;
+ endp->net_end.local_port = port;
+ } else if (mgcp_bind_rtp_port(endp, port) != 0)
goto error2;
/* assign a local call identifier or fail */
@@ -459,10 +460,11 @@ static struct msgb *handle_create_con(struct mgcp_config *cfg, struct msgb *msg)
}
}
- LOGP(DMGCP, LOGL_NOTICE, "Creating endpoint on: 0x%x CI: %u port: %u\n",
- ENDPOINT_NUMBER(endp), endp->ci, endp->rtp_port);
+ LOGP(DMGCP, LOGL_NOTICE, "Creating endpoint on: 0x%x CI: %u port: %u/%u\n",
+ ENDPOINT_NUMBER(endp), endp->ci,
+ endp->net_end.local_port, endp->bts_end.local_port);
if (cfg->change_cb)
- cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_CRCX, endp->rtp_port);
+ cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_CRCX);
return create_response_with_sdp(endp, "CRCX", trans_id);
error:
@@ -583,7 +585,7 @@ static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg)
LOGP(DMGCP, LOGL_NOTICE, "Modified endpoint on: 0x%x Server: %s:%u\n",
ENDPOINT_NUMBER(endp), inet_ntoa(endp->net_end.addr), ntohs(endp->net_end.rtp_port));
if (cfg->change_cb)
- cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_MDCX, endp->rtp_port);
+ cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_MDCX);
if (silent)
goto out_silent;
@@ -669,7 +671,7 @@ static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg)
ENDPOINT_NUMBER(endp), inet_ntoa(endp->net_end.addr), ntohs(endp->net_end.rtp_port));
mgcp_free_endp(endp);
if (cfg->change_cb)
- cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_DLCX, endp->rtp_port);
+ cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_DLCX);
if (silent)
goto out_silent;