]> sjero.net Git - iperf/blobdiff - src/PerfSocket.cpp
Bring DiffServ codepoint support up-to-date
[iperf] / src / PerfSocket.cpp
index 04a68b9583ced9bb44de5a7f070fdebbcd76c660..63e97ff9480b4405fe98f770498a3a2c0e67dcce 100644 (file)
@@ -99,14 +99,22 @@ void SetSocketOptions( thread_Settings *inSettings )
     }
 
 
-    // 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