Skip to content

Commit

Permalink
Fix calls to setsockopt.
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
olgeni committed Oct 22, 2012
1 parent da18a8c commit 2e39dbc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/network/network.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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 )" );
Expand Down

0 comments on commit 2e39dbc

Please sign in to comment.