FreeBSD TOS issues
This commit is contained in:
@@ -175,8 +175,11 @@ Connection::Socket::Socket( int family )
|
|||||||
int tosflag = true;
|
int tosflag = true;
|
||||||
socklen_t tosoptlen = sizeof( tosflag );
|
socklen_t tosoptlen = sizeof( tosflag );
|
||||||
if ( setsockopt( _fd, IPPROTO_IP, IP_RECVTOS, &tosflag, tosoptlen ) < 0 ) {
|
if ( setsockopt( _fd, IPPROTO_IP, IP_RECVTOS, &tosflag, tosoptlen ) < 0 ) {
|
||||||
|
/* FreeBSD disallows this option on IPv6 sockets. */
|
||||||
|
if ( family == IPPROTO_IP ) {
|
||||||
perror( "setsockopt( IP_RECVTOS )" );
|
perror( "setsockopt( IP_RECVTOS )" );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,7 +506,11 @@ string Connection::recv_one( int sock_to_recv, bool nonblocking )
|
|||||||
struct cmsghdr *ecn_hdr = CMSG_FIRSTHDR( &header );
|
struct cmsghdr *ecn_hdr = CMSG_FIRSTHDR( &header );
|
||||||
if ( ecn_hdr
|
if ( ecn_hdr
|
||||||
&& (ecn_hdr->cmsg_level == IPPROTO_IP)
|
&& (ecn_hdr->cmsg_level == IPPROTO_IP)
|
||||||
&& (ecn_hdr->cmsg_type == IP_TOS) ) {
|
&& ((ecn_hdr->cmsg_type == IP_TOS)
|
||||||
|
#ifdef IP_RECVTOS
|
||||||
|
|| (ecn_hdr->cmsg_type == IP_RECVTOS)
|
||||||
|
#endif
|
||||||
|
)) {
|
||||||
/* got one */
|
/* got one */
|
||||||
uint8_t *ecn_octet_p = (uint8_t *)CMSG_DATA( ecn_hdr );
|
uint8_t *ecn_octet_p = (uint8_t *)CMSG_DATA( ecn_hdr );
|
||||||
assert( ecn_octet_p );
|
assert( ecn_octet_p );
|
||||||
|
|||||||
Reference in New Issue
Block a user