aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/mgcp
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-11-01 21:25:33 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-11-02 19:08:09 +0100
commit3f29cc8303ecca6ba9f814abd9d5241f51d25533 (patch)
treebaa5a7875f7a463b416ec149c839b83c43455012 /openbsc/src/mgcp
parent386a940736d5f8c65ba5d5409c4858f5c829a338 (diff)
mgcp: Make the transcoding forwarding work for BTS/NET
Share the implementation for the transcoded packets and forward them to the network and the bts.
Diffstat (limited to 'openbsc/src/mgcp')
-rw-r--r--openbsc/src/mgcp/mgcp_network.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c
index c90219774..aeaafc8af 100644
--- a/openbsc/src/mgcp/mgcp_network.c
+++ b/openbsc/src/mgcp/mgcp_network.c
@@ -389,47 +389,61 @@ static int rtp_data_bts(struct bsc_fd *fd, unsigned int what)
return send_to(endp, DEST_NETWORK, proto == PROTO_RTP, &addr, &buf[0], rc);
}
-static int rtp_data_transcoder(struct bsc_fd *fd, unsigned int what)
+static int rtp_data_transcoder(struct mgcp_rtp_end *end, struct mgcp_endpoint *_endp,
+ int dest, struct bsc_fd *fd)
{
char buf[4096];
struct sockaddr_in addr;
- struct mgcp_endpoint *endp;
struct mgcp_config *cfg;
int rc, proto;
- endp = (struct mgcp_endpoint *) fd->data;
- cfg = endp->cfg;
-
- rc = recevice_from(endp, fd->fd, &addr, buf, sizeof(buf));
+ cfg = _endp->cfg;
+ rc = recevice_from(_endp, fd->fd, &addr, buf, sizeof(buf));
if (rc <= 0)
return -1;
- proto = fd == &endp->trans_net.rtp ? PROTO_RTP : PROTO_RTCP;
+ proto = fd == &end->rtp ? PROTO_RTP : PROTO_RTCP;
if (memcmp(&addr.sin_addr, &cfg->transcoder_in, sizeof(addr.sin_addr)) != 0) {
LOGP(DMGCP, LOGL_ERROR,
- "Data not coming from transcoder: %s on 0x%x\n",
- inet_ntoa(addr.sin_addr), ENDPOINT_NUMBER(endp));
+ "Data not coming from transcoder dest: %d %s on 0x%x\n",
+ dest, inet_ntoa(addr.sin_addr), ENDPOINT_NUMBER(_endp));
return -1;
}
- if (endp->trans_net.rtp_port != addr.sin_port &&
- endp->trans_net.rtcp_port != addr.sin_port) {
+ if (end->rtp_port != addr.sin_port &&
+ end->rtcp_port != addr.sin_port) {
LOGP(DMGCP, LOGL_ERROR,
- "Data from wrong transcoder source port %d on 0x%x\n",
- ntohs(addr.sin_port), ENDPOINT_NUMBER(endp));
+ "Data from wrong transcoder dest %d source port %d on 0x%x\n",
+ dest, ntohs(addr.sin_port), ENDPOINT_NUMBER(_endp));
return -1;
}
/* throw away the dummy message */
if (rc == 1 && buf[0] == DUMMY_LOAD) {
- LOGP(DMGCP, LOGL_NOTICE, "Filtered dummy from transcoder on 0x%x\n",
- ENDPOINT_NUMBER(endp));
+ LOGP(DMGCP, LOGL_NOTICE, "Filtered dummy from transcoder dest %d on 0x%x\n",
+ dest, ENDPOINT_NUMBER(_endp));
return 0;
}
- endp->trans_net.packets += 1;
- return send_to(endp, DEST_NETWORK, proto == PROTO_RTP, &addr, &buf[0], rc);
+ end->packets += 1;
+ return send_to(_endp, dest, proto == PROTO_RTP, &addr, &buf[0], rc);
+}
+
+static int rtp_data_trans_net(struct bsc_fd *fd, unsigned int what)
+{
+ struct mgcp_endpoint *endp;
+ endp = (struct mgcp_endpoint *) fd->data;
+
+ return rtp_data_transcoder(&endp->trans_net, endp, DEST_NETWORK, fd);
+}
+
+static int rtp_data_trans_bts(struct bsc_fd *fd, unsigned int what)
+{
+ struct mgcp_endpoint *endp;
+ endp = (struct mgcp_endpoint *) fd->data;
+
+ return rtp_data_transcoder(&endp->trans_bts, endp, DEST_BTS, fd);
}
static int create_bind(const char *source_addr, struct bsc_fd *fd, int port)
@@ -545,13 +559,13 @@ int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int 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_transcoder, endp, rtp_port);
+ rtp_data_trans_net, endp, 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_transcoder, endp, rtp_port);
+ rtp_data_trans_bts, endp, rtp_port);
}
int mgcp_free_rtp_port(struct mgcp_rtp_end *end)