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.
This commit is contained in:
parent
ceef936ea8
commit
e6ed009a36
|
@ -320,3 +320,17 @@ enum {
|
|||
int mgcp_parse_sdp_data(struct mgcp_endpoint *endp, struct mgcp_rtp_end *rtp, struct mgcp_parse_data *p);
|
||||
int mgcp_set_audio_info(void *ctx, struct mgcp_rtp_codec *codec,
|
||||
int payload_type, const char *audio_name);
|
||||
|
||||
|
||||
/**
|
||||
* Internal network related
|
||||
*/
|
||||
static inline const char *mgcp_net_src_addr(struct mgcp_endpoint *endp)
|
||||
{
|
||||
return endp->cfg->source_addr;
|
||||
}
|
||||
|
||||
static inline const char *mgcp_bts_src_addr(struct mgcp_endpoint *endp)
|
||||
{
|
||||
return endp->cfg->source_addr;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -275,7 +275,7 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp,
|
|||
char osmux_extension[strlen("\nX-Osmux: 255") + 1];
|
||||
|
||||
if (!addr)
|
||||
addr = endp->cfg->source_addr;
|
||||
addr = mgcp_net_src_addr(endp);
|
||||
|
||||
if (endp->osmux.state == OSMUX_STATE_ACTIVATING)
|
||||
sprintf(osmux_extension, "\nX-Osmux: %u", endp->osmux.cid);
|
||||
|
@ -1389,8 +1389,7 @@ static void send_msg(struct mgcp_endpoint *endp, int endpoint, int port,
|
|||
if (len < 0)
|
||||
return;
|
||||
|
||||
nchars = write_response_sdp(endp, buf + len, sizeof(buf) + len - 1,
|
||||
endp->cfg->source_addr);
|
||||
nchars = write_response_sdp(endp, buf + len, sizeof(buf) + len - 1, NULL);
|
||||
if (nchars < 0)
|
||||
return;
|
||||
|
||||
|
|
|
@ -269,7 +269,7 @@ static void bsc_mgcp_send_mdcx(struct bsc_connection *bsc, int port, struct mgcp
|
|||
"\r\n"
|
||||
"c=IN IP4 %s\r\n"
|
||||
"m=audio %d RTP/AVP 255\r\n",
|
||||
port, bsc->nat->mgcp_cfg->source_addr,
|
||||
port, mgcp_bts_src_addr(endp),
|
||||
endp->bts_end.local_port);
|
||||
if (len < 0) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "snprintf for MDCX failed.\n");
|
||||
|
@ -550,7 +550,7 @@ static int bsc_mgcp_policy_cb(struct mgcp_trunk_config *tcfg, int endpoint, int
|
|||
|
||||
/* we need to generate a new and patched message */
|
||||
bsc_msg = bsc_mgcp_rewrite((char *) nat->mgcp_msg, nat->mgcp_length,
|
||||
sccp->bsc_endp, nat->mgcp_cfg->source_addr,
|
||||
sccp->bsc_endp, mgcp_bts_src_addr(mgcp_endp),
|
||||
mgcp_endp->bts_end.local_port, osmux_cid,
|
||||
&mgcp_endp->net_end.codec.payload_type,
|
||||
nat->sdp_ensure_amr_mode_set);
|
||||
|
@ -745,7 +745,7 @@ void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg)
|
|||
* with the value of 0 should be no problem.
|
||||
*/
|
||||
output = bsc_mgcp_rewrite((char * ) msg->l2h, msgb_l2len(msg), -1,
|
||||
bsc->nat->mgcp_cfg->source_addr,
|
||||
mgcp_net_src_addr(endp),
|
||||
endp->net_end.local_port, -1,
|
||||
&endp->bts_end.codec.payload_type,
|
||||
bsc->nat->sdp_ensure_amr_mode_set);
|
||||
|
|
Loading…
Reference in New Issue