aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmgcp/mgcp_network.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-08-20 14:58:19 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-08-20 14:58:19 +0200
commite6ed009a36d410fc0cbac7a82d92313bd6d4c084 (patch)
tree23ad7fed198f621cc414a3dee3341ebc934f3c76 /openbsc/src/libmgcp/mgcp_network.c
parentceef936ea894781a14584efc9256856cca6d1c0f (diff)
mgcp: Begin to separate network and bts endpoints
Make it possible to bind the call-agent to a specific IP address and the network and bts end to different ip addresses. Begin by clarifying which source ip address we want to have.
Diffstat (limited to 'openbsc/src/libmgcp/mgcp_network.c')
-rw-r--r--openbsc/src/libmgcp/mgcp_network.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c
index 07e1515d..c39b627c 100644
--- a/openbsc/src/libmgcp/mgcp_network.c
+++ b/openbsc/src/libmgcp/mgcp_network.c
@@ -912,19 +912,20 @@ int mgcp_set_ip_tos(int fd, int tos)
return ret != 0;
}
-static int bind_rtp(struct mgcp_config *cfg, struct mgcp_rtp_end *rtp_end, int endpno)
+static int bind_rtp(struct mgcp_config *cfg, const char *source_addr,
+ struct mgcp_rtp_end *rtp_end, int endpno)
{
- if (mgcp_create_bind(cfg->source_addr, &rtp_end->rtp,
+ if (mgcp_create_bind(source_addr, &rtp_end->rtp,
rtp_end->local_port) != 0) {
LOGP(DMGCP, LOGL_ERROR, "Failed to create RTP port: %s:%d on 0x%x\n",
- cfg->source_addr, rtp_end->local_port, endpno);
+ source_addr, rtp_end->local_port, endpno);
goto cleanup0;
}
- if (mgcp_create_bind(cfg->source_addr, &rtp_end->rtcp,
+ if (mgcp_create_bind(source_addr, &rtp_end->rtcp,
rtp_end->local_port + 1) != 0) {
LOGP(DMGCP, LOGL_ERROR, "Failed to create RTCP port: %s:%d on 0x%x\n",
- cfg->source_addr, rtp_end->local_port + 1, endpno);
+ source_addr, rtp_end->local_port + 1, endpno);
goto cleanup1;
}
@@ -961,7 +962,8 @@ cleanup0:
static int int_bind(const char *port,
struct mgcp_rtp_end *end, int (*cb)(struct osmo_fd *, unsigned),
- struct mgcp_endpoint *_endp, int rtp_port)
+ struct mgcp_endpoint *_endp,
+ const char *source_addr, int rtp_port)
{
if (end->rtp.fd != -1 || end->rtcp.fd != -1) {
LOGP(DMGCP, LOGL_ERROR, "Previous %s was still bound on %d\n",
@@ -974,32 +976,35 @@ static int int_bind(const char *port,
end->rtp.data = _endp;
end->rtcp.data = _endp;
end->rtcp.cb = cb;
- return bind_rtp(_endp->cfg, end, ENDPOINT_NUMBER(_endp));
+ return bind_rtp(_endp->cfg, source_addr, end, ENDPOINT_NUMBER(_endp));
}
-
int mgcp_bind_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port)
{
return int_bind("bts-port", &endp->bts_end,
- rtp_data_bts, endp, rtp_port);
+ rtp_data_bts, endp,
+ mgcp_bts_src_addr(endp), rtp_port);
}
int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port)
{
return int_bind("net-port", &endp->net_end,
- rtp_data_net, endp, rtp_port);
+ rtp_data_net, endp,
+ mgcp_net_src_addr(endp), rtp_port);
}
int mgcp_bind_trans_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port)
{
return int_bind("trans-net", &endp->trans_net,
- rtp_data_trans_net, endp, rtp_port);
+ rtp_data_trans_net, endp,
+ endp->cfg->source_addr, rtp_port);
}
int mgcp_bind_trans_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port)
{
return int_bind("trans-bts", &endp->trans_bts,
- rtp_data_trans_bts, endp, rtp_port);
+ rtp_data_trans_bts, endp,
+ endp->cfg->source_addr, rtp_port);
}
int mgcp_free_rtp_port(struct mgcp_rtp_end *end)