Fix calls to setsockopt.

On FreeBSD, the socket option length must be declared as an int.

While I'm here, translate dscp (0x92) to the appropriate constants.

(tested on FreeBSD only so far)
This commit is contained in:
olgeni
2012-10-22 14:29:39 +02:00
parent da18a8c7ea
commit 2e39dbc977
+4 -3
View File
@@ -35,6 +35,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
@@ -157,14 +158,14 @@ Connection::Socket::Socket()
#endif
/* set diffserv values to AF42 + ECT */
uint8_t dscp = 0x92;
if ( setsockopt( _fd, IPPROTO_IP, IP_TOS, &dscp, 1) < 0 ) {
int dscp = IPTOS_DSCP_AF42 | IPTOS_ECN_ECT0;
if ( setsockopt( _fd, IPPROTO_IP, IP_TOS, &dscp, sizeof (dscp)) < 0 ) {
// perror( "setsockopt( IP_TOS )" );
}
/* request explicit congestion notification on received datagrams */
#ifdef HAVE_IP_RECVTOS
char tosflag = true;
int tosflag = true;
socklen_t tosoptlen = sizeof( tosflag );
if ( setsockopt( _fd, IPPROTO_IP, IP_RECVTOS, &tosflag, tosoptlen ) < 0 ) {
perror( "setsockopt( IP_RECVTOS )" );