diff --git a/ChangeLog b/ChangeLog index ddb12ac..b1e66db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 0.5.11 ====== + 19-Apr-2005: - feature: DSCP value for RTP packets defineable (by Nick + Vermeer, Internet Express) 15-Apr-2005: - feature: auto-save registration table during operation 10-Apr-2005: - started DocBook documentation 3-Apr-2005: - fix: changing public IP address diff --git a/doc/siproxd.conf.example b/doc/siproxd.conf.example index 4bdf173..97b97c8 100644 --- a/doc/siproxd.conf.example +++ b/doc/siproxd.conf.example @@ -123,9 +123,25 @@ rtp_port_high = 7079 # and proxying for it will be stopped. # Be aware that this timeout also applies to streams that are # in HOLD. -# +# rtp_timeout = 300 +###################################################################### +# DSCP value for sent RTP packets +# The Differentiated Service Code Point is a selector for +# router's per-hop behaviours. +# RFC2598 defined a "expedited forwarding" service. This service +# is designed to allow ISPs to offer a service with attributes +# similar to a "leased line". This service offers the ULTIMATE IN LOW +# LOSS, LOW LATENCY AND LOW JITTER by ensuring that there is always +# sufficent room in output queues for the contracted expedited forwarding +# traffic. +# The Expedited Forwarding service has a DSCP of 46. +# Putting a 0 here means that siproxd does NOT set the DSCP field. +# Siproxd must be started as root for this to work. +# +rtp_dscp = 46 + ###################################################################### # Default Expiration timeout for Registrations # If a REGISTER request does not contain an Expires header diff --git a/src/readconf.c b/src/readconf.c index 7859c63..6ceac63 100644 --- a/src/readconf.c +++ b/src/readconf.c @@ -155,6 +155,7 @@ static int parse_config (FILE *configfile) { { "rtp_port_high", TYP_INT4, &configuration.rtp_port_high }, { "rtp_timeout", TYP_INT4, &configuration.rtp_timeout }, { "rtp_proxy_enable", TYP_INT4, &configuration.rtp_proxy_enable }, + { "rtp_dscp", TYP_INT4, &configuration.rtp_dscp }, { "user", TYP_STRING, &configuration.user }, { "chrootjail", TYP_STRING, &configuration.chrootjail }, { "hosts_allow_reg", TYP_STRING, &configuration.hosts_allow_reg }, diff --git a/src/rtpproxy_relay.c b/src/rtpproxy_relay.c index 6d27a18..77019b0 100644 --- a/src/rtpproxy_relay.c +++ b/src/rtpproxy_relay.c @@ -395,6 +395,7 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id, int sock, port; int freeidx; int sts=STS_SUCCESS; + int tos; osip_call_id_t cid; @@ -566,6 +567,35 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id, goto unlock_and_exit; } + /* set DSCP value, need to be ROOT */ + if (configuration.rtp_dscp) { + int uid,euid; + uid=getuid(); + euid=geteuid(); + DEBUGC(DBCLASS_RTP,"uid=%i, euid=%i", uid, euid); + if (uid != euid) seteuid(0); + if (geteuid()==0) { + /* now I'm root */ + if (!(configuration.rtp_dscp & ~0x3f)) { + tos = (configuration.rtp_dscp << 2) & 0xff; + if(setsockopt(sock, SOL_IP, IP_TOS, &tos, sizeof(tos))) { + ERROR("rtp_relay_start_fwd: setsockopt() failed while " + "setting DSCP value: ", strerror(errno)); + } + } else { + ERROR("rtp_relay_start_fwd: Invalid DSCP value %d", + configuration.rtp_dscp); + configuration.rtp_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); + } + /* write entry into rtp_proxytable slot (freeidx) */ rtp_proxytable[freeidx].rtp_rx_sock=sock; diff --git a/src/siproxd.h b/src/siproxd.h index 753f31c..ec398ac 100644 --- a/src/siproxd.h +++ b/src/siproxd.h @@ -67,6 +67,7 @@ struct siproxd_config { int rtp_port_low; int rtp_port_high; int rtp_timeout; + int rtp_dscp; int rtp_proxy_enable; char *user; char *chrootjail;