- SIP DSCP value configurable
This commit is contained in:
parent
340628238c
commit
c95510f9ac
@ -1,3 +1,7 @@
|
||||
0.7.2
|
||||
=====
|
||||
01-Aug-2008: - SIP DSCP value configurable
|
||||
|
||||
0.7.1
|
||||
=====
|
||||
23-Jul-2008: - Released 0.7.1
|
||||
|
||||
@ -144,6 +144,12 @@ rtp_timeout = 300
|
||||
#
|
||||
rtp_dscp = 46
|
||||
|
||||
######################################################################
|
||||
# DSCP value for sent SIP packets
|
||||
# Same as above but for SIP signalling.
|
||||
#
|
||||
sip_dscp = 0
|
||||
|
||||
######################################################################
|
||||
# Dejitter value
|
||||
# Artificial delay to be used to de-jitter RTP data streams.
|
||||
|
||||
@ -86,6 +86,7 @@ static cfgopts_t main_cfg_opts[] = {
|
||||
{ "obscure_loops", TYP_INT4, &configuration.obscure_loops },
|
||||
{ "plugindir", TYP_STRING, &configuration.plugin_dir },
|
||||
{ "load_plugin", TYP_STRINGA,&configuration.load_plugin },
|
||||
{ "sip_dscp", TYP_INT4, &configuration.sip_dscp },
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
@ -99,6 +99,7 @@ struct siproxd_config {
|
||||
int obscure_loops;
|
||||
char *plugin_dir;
|
||||
stringa_t load_plugin;
|
||||
int sip_dscp;
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
30
src/sock.c
30
src/sock.c
@ -62,6 +62,36 @@ int sipsock_listen (void) {
|
||||
sip_udp_socket=sockbind(ipaddr, configuration.sip_listen_port, 1);
|
||||
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);
|
||||
DEBUGC(DBCLASS_NET,"bound socket %i",sip_udp_socket);
|
||||
return STS_SUCCESS;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user