- SIP DSCP value configurable

This commit is contained in:
Thomas Ries 2008-08-01 08:03:30 +00:00
parent 340628238c
commit c95510f9ac
5 changed files with 42 additions and 0 deletions

View File

@ -1,3 +1,7 @@
0.7.2
=====
01-Aug-2008: - SIP DSCP value configurable
0.7.1 0.7.1
===== =====
23-Jul-2008: - Released 0.7.1 23-Jul-2008: - Released 0.7.1

View File

@ -144,6 +144,12 @@ rtp_timeout = 300
# #
rtp_dscp = 46 rtp_dscp = 46
######################################################################
# DSCP value for sent SIP packets
# Same as above but for SIP signalling.
#
sip_dscp = 0
###################################################################### ######################################################################
# Dejitter value # Dejitter value
# Artificial delay to be used to de-jitter RTP data streams. # Artificial delay to be used to de-jitter RTP data streams.

View File

@ -86,6 +86,7 @@ static cfgopts_t main_cfg_opts[] = {
{ "obscure_loops", TYP_INT4, &configuration.obscure_loops }, { "obscure_loops", TYP_INT4, &configuration.obscure_loops },
{ "plugindir", TYP_STRING, &configuration.plugin_dir }, { "plugindir", TYP_STRING, &configuration.plugin_dir },
{ "load_plugin", TYP_STRINGA,&configuration.load_plugin }, { "load_plugin", TYP_STRINGA,&configuration.load_plugin },
{ "sip_dscp", TYP_INT4, &configuration.sip_dscp },
{0, 0, 0} {0, 0, 0}
}; };

View File

@ -99,6 +99,7 @@ struct siproxd_config {
int obscure_loops; int obscure_loops;
char *plugin_dir; char *plugin_dir;
stringa_t load_plugin; stringa_t load_plugin;
int sip_dscp;
}; };
/* /*

View File

@ -62,6 +62,36 @@ int sipsock_listen (void) {
sip_udp_socket=sockbind(ipaddr, configuration.sip_listen_port, 1); sip_udp_socket=sockbind(ipaddr, configuration.sip_listen_port, 1);
if (sip_udp_socket == 0) return STS_FAILURE; /* failure*/ if (sip_udp_socket == 0) return STS_FAILURE; /* failure*/
/* set DSCP value, need to be ROOT */
if (configuration.sip_dscp) {
int tos;
int uid,euid;
uid=getuid();
euid=geteuid();
DEBUGC(DBCLASS_SIP,"uid=%i, euid=%i", uid, euid);
if (uid != euid) seteuid(0);
if (geteuid()==0) {
/* now I'm root */
if (!(configuration.sip_dscp & ~0x3f)) {
tos = (configuration.sip_dscp << 2) & 0xff;
if(setsockopt(sip_udp_socket, SOL_IP, IP_TOS, &tos, sizeof(tos))) {
ERROR("sipsock_listen: setsockopt() failed while "
"setting DSCP value: %s", strerror(errno));
}
} else {
ERROR("sipsock_listen: Invalid DSCP value %d",
configuration.sip_dscp);
configuration.sip_dscp = 0; /* inhibit further attempts */
}
} else {
/* could not get root */
WARN("siproxd not started as root - cannot set DSCP value");
configuration.rtp_dscp = 0; /* inhibit further attempts */
}
/* drop privileges */
if (uid != euid) seteuid(euid);
}
INFO("bound to port %i", configuration.sip_listen_port); INFO("bound to port %i", configuration.sip_listen_port);
DEBUGC(DBCLASS_NET,"bound socket %i",sip_udp_socket); DEBUGC(DBCLASS_NET,"bound socket %i",sip_udp_socket);
return STS_SUCCESS; return STS_SUCCESS;