aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-06-17 14:37:10 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-06-17 14:37:10 +0800
commit8cc2a6d62dd681e70bb27af656b745bdbd081cc7 (patch)
treed105b9c5974e71670ae3ec374447bdc9b2fcad8b /openbsc
parent57c4decd1d8861dfdc664be240d084ffd7e3bbe8 (diff)
parent75492e6e5451e691f3eea9e5dc91f87dab0552f0 (diff)
Merge branch 'on-waves/mgcp'
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/mgcp.h1
-rw-r--r--openbsc/src/mgcp/mgcp_network.c17
-rw-r--r--openbsc/src/mgcp/mgcp_vty.c12
3 files changed, 28 insertions, 2 deletions
diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h
index 71b7fc14e..a66f0ca70 100644
--- a/openbsc/include/openbsc/mgcp.h
+++ b/openbsc/include/openbsc/mgcp.h
@@ -93,6 +93,7 @@ struct mgcp_config {
int audio_loop;
int early_bind;
int rtp_base_port;
+ int endp_tos;
char *forward_ip;
int forward_port;
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c
index 1f51233d3..911bb2602 100644
--- a/openbsc/src/mgcp/mgcp_network.c
+++ b/openbsc/src/mgcp/mgcp_network.c
@@ -193,12 +193,14 @@ 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);
+ if (proto == PROTO_RTP)
+ 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);
+ if (proto == PROTO_RTP)
+ 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);
@@ -229,6 +231,14 @@ static int create_bind(const char *source_addr, struct bsc_fd *fd, int port)
return 0;
}
+static int set_ip_tos(int fd, int tos)
+{
+ int ret;
+ ret = setsockopt(fd, IPPROTO_IP, IP_TOS,
+ &tos, sizeof(tos));
+ return ret != 0;
+}
+
static int bind_rtp(struct mgcp_endpoint *endp)
{
struct mgcp_config *cfg = endp->cfg;
@@ -245,6 +255,9 @@ static int bind_rtp(struct mgcp_endpoint *endp)
goto cleanup1;
}
+ set_ip_tos(endp->local_rtp.fd, cfg->endp_tos);
+ set_ip_tos(endp->local_rtcp.fd, cfg->endp_tos);
+
endp->local_rtp.cb = rtp_data_cb;
endp->local_rtp.data = endp;
endp->local_rtp.when = BSC_FD_READ;
diff --git a/openbsc/src/mgcp/mgcp_vty.c b/openbsc/src/mgcp/mgcp_vty.c
index ea59abf15..f923b22d5 100644
--- a/openbsc/src/mgcp/mgcp_vty.c
+++ b/openbsc/src/mgcp/mgcp_vty.c
@@ -58,6 +58,7 @@ static int config_write_mgcp(struct vty *vty)
vty_out(vty, " bind port %u%s", g_cfg->source_port, VTY_NEWLINE);
vty_out(vty, " bind early %u%s", !!g_cfg->early_bind, VTY_NEWLINE);
vty_out(vty, " rtp base %u%s", g_cfg->rtp_base_port, VTY_NEWLINE);
+ vty_out(vty, " rtp ip-tos %d%s", g_cfg->endp_tos, VTY_NEWLINE);
if (g_cfg->audio_payload != -1)
vty_out(vty, " sdp audio payload number %d%s", g_cfg->audio_payload, VTY_NEWLINE);
if (g_cfg->audio_name)
@@ -166,6 +167,16 @@ DEFUN(cfg_mgcp_rtp_base_port,
return CMD_SUCCESS;
}
+DEFUN(cfg_mgcp_rtp_ip_tos,
+ cfg_mgcp_rtp_ip_tos_cmd,
+ "rtp ip-tos <0-255>",
+ "Set the IP_TOS socket attribute on the RTP/RTCP sockets.\n" "The TOS value.")
+{
+ int tos = atoi(argv[0]);
+ g_cfg->endp_tos = tos;
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_mgcp_sdp_payload_number,
cfg_mgcp_sdp_payload_number_cmd,
"sdp audio payload number <1-255>",
@@ -252,6 +263,7 @@ int mgcp_vty_init(void)
install_element(MGCP_NODE, &cfg_mgcp_bind_port_cmd);
install_element(MGCP_NODE, &cfg_mgcp_bind_early_cmd);
install_element(MGCP_NODE, &cfg_mgcp_rtp_base_port_cmd);
+ install_element(MGCP_NODE, &cfg_mgcp_rtp_ip_tos_cmd);
install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_number_cmd);
install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_name_cmd);
install_element(MGCP_NODE, &cfg_mgcp_loop_cmd);