diff --git a/ChangeLog b/ChangeLog index be1a4ec..47e9512 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +0.7.2 +===== + 01-Aug-2008: - SIP DSCP value configurable + 0.7.1 ===== 23-Jul-2008: - Released 0.7.1 diff --git a/doc/siproxd.conf.example b/doc/siproxd.conf.example index bdd3075..c77008a 100644 --- a/doc/siproxd.conf.example +++ b/doc/siproxd.conf.example @@ -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. diff --git a/src/siproxd.c b/src/siproxd.c index b52c31b..9fbcf81 100644 --- a/src/siproxd.c +++ b/src/siproxd.c @@ -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} }; diff --git a/src/siproxd.h b/src/siproxd.h index 518a7a1..da64fbf 100644 --- a/src/siproxd.h +++ b/src/siproxd.h @@ -99,6 +99,7 @@ struct siproxd_config { int obscure_loops; char *plugin_dir; stringa_t load_plugin; + int sip_dscp; }; /* diff --git a/src/sock.c b/src/sock.c index 424f5a8..97cf114 100644 --- a/src/sock.c +++ b/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;