}
- // set IP TOS (type-of-service) field
-#ifdef IP_TOS
+ // Set the DiffServ codepoint for IPv4 TOS or IPv6 traffic class
if ( inSettings->mTOS > 0 ) {
val = inSettings->mTOS;
- rc = setsockopt( inSettings->mSock, IPPROTO_IP, IP_TOS, &val, len );
- WARN_errno( rc == SOCKET_ERROR, "setsockopt IP_TOS" );
- }
+#if defined(IP_TOS)
+ if ( inSettings->mSockAF == AF_INET ) {
+ rc = setsockopt( inSettings->mSock, IPPROTO_IP, IP_TOS, &val, len );
+ WARN_errno( rc == SOCKET_ERROR, "setsockopt IP_TOS" );
+ }
#endif
+#if defined(IPV6_TCLASS)
+ if ( inSettings->mSockAF == AF_INET6 ) {
+ rc = setsockopt( inSettings->mSock, IPPROTO_IPV6, IPV6_TCLASS, &val, len );
+ WARN_errno( rc == SOCKET_ERROR, "setsockopt IPV6_TCLASS" );
+ }
+#endif
+ }
// TCP-specific options