Permalink
Browse files

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)
  • Loading branch information...
1 parent da18a8c commit 2e39dbc9773d4924791ee4e13f8e1edf2e61e27d @olgeni olgeni committed Oct 22, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/network/network.cc
@@ -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 )" );

0 comments on commit 2e39dbc

Please sign in to comment.