summaryrefslogtreecommitdiffstats
path: root/openbsc/src/mgcp/mgcp_network.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-02-26 13:42:58 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-02-26 13:42:58 +0100
commit36ed8cc4c33e3b69bb0f84f1b5b593ae46aff08f (patch)
tree8de0efbf69ee8963d39e52fa08467cb485e66ea0 /openbsc/src/mgcp/mgcp_network.c
parentef6bb25aa5b7dcb4a10469c6a39ace3534c08376 (diff)
[mgcp] Patch the rtp payload depending on the direction.
The RTP header code is taken from the rtp_proxy, we will need to figure out how to unite these properly in the long run.
Diffstat (limited to 'openbsc/src/mgcp/mgcp_network.c')
-rw-r--r--openbsc/src/mgcp/mgcp_network.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c
index e92b0742e..c61f0a858 100644
--- a/openbsc/src/mgcp/mgcp_network.c
+++ b/openbsc/src/mgcp/mgcp_network.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <unistd.h>
+#include <endian.h>
#include <sys/socket.h>
#include <arpa/inet.h>
@@ -37,6 +38,28 @@
#warning "Make use of the rtp proxy code"
+/* according to rtp_proxy.c RFC 3550 */
+struct rtp_hdr {
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ u_int8_t csrc_count:4,
+ extension:1,
+ padding:1,
+ version:2;
+ u_int8_t payload_type:7,
+ marker:1;
+#elif __BYTE_ORDER == __BIG_ENDIAN
+ u_int8_t version:2,
+ padding:1,
+ extension:1,
+ csrc_count:4;
+ u_int8_t marker:1,
+ payload_type:7;
+#endif
+ u_int16_t sequence;
+ u_int32_t timestamp;
+ u_int32_t ssrc;
+} __attribute__((packed));
+
enum {
DEST_NETWORK = 0,
@@ -59,6 +82,17 @@ static int udp_send(int fd, struct in_addr *addr, int port, char *buf, int len)
return sendto(fd, buf, len, 0, (struct sockaddr *)&out, sizeof(out));
}
+static void patch_payload(int payload, char *data, int len)
+{
+ struct rtp_hdr *rtp_hdr;
+
+ if (len < sizeof(*rtp_hdr))
+ return;
+
+ rtp_hdr = (struct rtp_hdr *) data;
+ rtp_hdr->payload_type = payload;
+}
+
/*
* There is data coming. We will have to figure out if it
* came from the BTS or the MediaGateway of the MSC. On top
@@ -129,10 +163,12 @@ static int rtp_data_cb(struct bsc_fd *fd, unsigned int what)
dest = !dest;
if (dest == DEST_NETWORK) {
+ patch_payload(endp->net_payload_type, buf, rc);
return udp_send(fd->fd, &endp->remote,
proto == PROTO_RTP ? endp->net_rtp : endp->net_rtcp,
buf, rc);
} else {
+ patch_payload(endp->bts_payload_type, buf, rc);
return udp_send(fd->fd, &endp->bts,
proto == PROTO_RTP ? endp->bts_rtp : endp->bts_rtcp,
buf, rc);