src/windows/native/sun/nio/ch/Net.c
Print this page
rev 7400 : 8029607: Type of Service (TOS) cannot be set in IPv6 header
Reviewed-by: alanb
rev 7401 : 8048212: Two tests failed with "java.net.SocketException: Bad protocol option" on Windows after 8029607
Reviewed-by: alanb
@@ -292,13 +292,13 @@
}
/**
* HACK: IP_TOS is deprecated on Windows and querying the option
* returns a protocol error. NET_GetSockOpt handles this and uses
- * a fallback mechanism.
+ * a fallback mechanism. Same applies to IPV6_TCLASS
*/
- if (level == IPPROTO_IP && opt == IP_TOS) {
+ if ((level == IPPROTO_IP && opt == IP_TOS) || (level == IPPROTO_IPV6 && opt == IPV6_TCLASS)) {
mayNeedConversion = JNI_TRUE;
}
if (mayNeedConversion) {
n = NET_GetSockOpt(fdval(env, fdo), level, opt, arg, &arglen);
@@ -316,11 +316,11 @@
return result;
}
JNIEXPORT void JNICALL
Java_sun_nio_ch_Net_setIntOption0(JNIEnv *env, jclass clazz, jobject fdo,
- jboolean mayNeedConversion, jint level, jint opt, jint arg)
+ jboolean mayNeedConversion, jint level, jint opt, jint arg, jboolean ipv6)
{
struct linger linger;
char *parg;
int arglen, n;
@@ -337,10 +337,15 @@
} else {
parg = (char *)&arg;
arglen = sizeof(arg);
}
+ if (level == IPPROTO_IPV6 && opt == IPV6_TCLASS) {
+ /* No op */
+ return;
+ }
+
if (mayNeedConversion) {
n = NET_SetSockOpt(fdval(env, fdo), level, opt, parg, arglen);
} else {
n = setsockopt(fdval(env, fdo), level, opt, parg, arglen);
}