aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-08-05 06:19:24 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-08-08 07:19:17 +0800
commit6989b5735052bbb996e4880cdea6dde41458c084 (patch)
tree9eb524ba209fad8c5932a9fe7c3952c24ad9a5d5 /openbsc
parentedd980619c1e0f12176a0e714287076a4c1fbf20 (diff)
mgcp: Move the selection of the right source port to a new method
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/mgcp/mgcp_network.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c
index b16393b6a..76a60ee9c 100644
--- a/openbsc/src/mgcp/mgcp_network.c
+++ b/openbsc/src/mgcp/mgcp_network.c
@@ -148,15 +148,37 @@ static void patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *s
}
/*
- * There is data coming. We will have to figure out if it
- * came from the BTS or the MediaGateway of the MSC. On top
- * of that we need to figure out if it was RTP or RTCP.
- *
- * Currently we do not communicate with the BSC so we have
- * no idea where the BTS is listening for RTP and need to
- * do the classic routing trick. Wait for the first packet
- * from the BTS and then go ahead.
+ * The below code is for dispatching. We have a dedicated port for
+ * the data coming from the net and one to discover the BTS.
*/
+static int send_to(struct mgcp_endpoint *endp, int dest, int is_rtp,
+ struct sockaddr_in *addr, char *buf, int rc)
+{
+ if (dest == DEST_NETWORK) {
+ if (is_rtp) {
+ patch_and_count(endp, &endp->bts_state,
+ endp->net_end.payload_type,
+ addr, buf, rc);
+ return udp_send(endp->net_end.rtp.fd, &endp->net_end.addr,
+ endp->net_end.rtp_port, buf, rc);
+ } else {
+ return udp_send(endp->net_end.rtcp.fd, &endp->net_end.addr,
+ endp->net_end.rtcp_port, buf, rc);
+ }
+ } else {
+ if (is_rtp) {
+ patch_and_count(endp, &endp->net_state,
+ endp->bts_end.payload_type,
+ addr, buf, rc);
+ return udp_send(endp->bts_end.rtp.fd, &endp->bts_end.addr,
+ endp->bts_end.rtp_port, buf, rc);
+ } else {
+ return udp_send(endp->bts_end.rtcp.fd, &endp->bts_end.addr,
+ endp->bts_end.rtcp_port, buf, rc);
+ }
+ }
+}
+
static int rtp_data_cb(struct bsc_fd *fd, unsigned int what)
{
char buf[4096];
@@ -237,29 +259,7 @@ static int rtp_data_cb(struct bsc_fd *fd, unsigned int what)
if (endp->conn_mode == MGCP_CONN_LOOPBACK)
dest = !dest;
- if (dest == DEST_NETWORK) {
- if (proto == PROTO_RTP) {
- patch_and_count(endp, &endp->bts_state,
- endp->net_end.payload_type,
- &addr, buf, rc);
- return udp_send(endp->net_end.rtp.fd, &endp->net_end.addr,
- endp->net_end.rtp_port, buf, rc);
- } else {
- return udp_send(endp->net_end.rtcp.fd, &endp->net_end.addr,
- endp->net_end.rtcp_port, buf, rc);
- }
- } else {
- if (proto == PROTO_RTP) {
- patch_and_count(endp, &endp->net_state,
- endp->bts_end.payload_type,
- &addr, buf, rc);
- return udp_send(endp->bts_end.rtp.fd, &endp->bts_end.addr,
- endp->bts_end.rtp_port, buf, rc);
- } else {
- return udp_send(endp->bts_end.rtcp.fd, &endp->bts_end.addr,
- endp->bts_end.rtcp_port, buf, rc);
- }
- }
+ return send_to(endp, dest, proto == PROTO_RTP, &addr, &buf[0], rc);
}
static int create_bind(const char *source_addr, struct bsc_fd *fd, int port)