aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-05-31 10:22:00 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-05-31 10:22:00 +0800
commit96d6ed25525dbf91cc369133e4942960c8307f2a (patch)
tree17e098c15e7ae641a1fc7e8dfa9701ecaac1db59
parent170619fef674a982d631d83d0c869cf99c56f711 (diff)
[mgcp] Set the IP_TOS/DSCP on RTP/RTCP IP packets.
-rw-r--r--openbsc/include/openbsc/mgcp.h1
-rw-r--r--openbsc/src/mgcp/mgcp_network.c11
-rw-r--r--openbsc/src/mgcp/mgcp_vty.c12
3 files changed, 24 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h
index bf97f96a7..5622daa51 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;
/* only used in forward mode */
char *forward_ip;
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c
index c9edf4fed..354daadb2 100644
--- a/openbsc/src/mgcp/mgcp_network.c
+++ b/openbsc/src/mgcp/mgcp_network.c
@@ -233,6 +233,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;
@@ -249,6 +257,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 38d3daf5f..717b4a333 100644
--- a/openbsc/src/mgcp/mgcp_vty.c
+++ b/openbsc/src/mgcp/mgcp_vty.c
@@ -57,6 +57,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)
@@ -165,6 +166,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>",
@@ -249,6 +260,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);