8046500: GetIpAddrTable function failed on Pure Ipv6 environment

Reviewed-by: chegar
This commit is contained in:
Vyom Tewari 2018-11-22 13:25:44 +05:30
parent 0126fdbef0
commit 4444bac1b1
2 changed files with 26 additions and 7 deletions

View file

@ -202,8 +202,9 @@ int enumInterfaces(JNIEnv *env, netif **netifPP)
JNU_ThrowByName(env, "java/lang/Error", JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetIfTable function failed"); "IP Helper Library GetIfTable function failed");
// this different error code is to handle the case when we call
return -1; // GetIpAddrTable in pure IPv6 environment
return -2;
} }
/* /*
@ -400,7 +401,9 @@ int enumAddresses_win(JNIEnv *env, netif *netifP, netaddr **netaddrPP)
} }
JNU_ThrowByName(env, "java/lang/Error", JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetIpAddrTable function failed"); "IP Helper Library GetIpAddrTable function failed");
return -1; // this different error code is to handle the case when we call
// GetIpAddrTable in pure IPv6 environment
return -2;
} }
/* /*
@ -557,7 +560,7 @@ jobject createNetworkInterface
*/ */
if (netaddrCount < 0) { if (netaddrCount < 0) {
netaddrCount = enumAddresses_win(env, ifs, &netaddrP); netaddrCount = enumAddresses_win(env, ifs, &netaddrP);
if (netaddrCount == -1) { if (netaddrCount < 0) {
return NULL; return NULL;
} }
} }

View file

@ -253,6 +253,10 @@ int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP)
ret = enumInterfaces(env, netifPP); ret = enumInterfaces(env, netifPP);
if (ret == -1) { if (ret == -1) {
return -1; return -1;
} else if( ret == -2){
if ((*env)->ExceptionCheck(env)) {
(*env)->ExceptionClear(env);
}
} else { } else {
count = ret; count = ret;
} }
@ -272,11 +276,17 @@ int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP)
ret = enumAddresses_win(env, curr, &netaddrP); ret = enumAddresses_win(env, curr, &netaddrP);
if (ret == -1) { if (ret == -1) {
return -1; return -1;
} else if (ret == -2) {
if ((*env)->ExceptionCheck(env)) {
(*env)->ExceptionClear(env);
} }
break;
} else{
curr->addrs = netaddrP; curr->addrs = netaddrP;
curr->naddrs += ret; curr->naddrs += ret;
curr = curr->next; curr = curr->next;
} }
}
ret = getAdapters (env, &adapters); ret = getAdapters (env, &adapters);
if (ret != ERROR_SUCCESS) { if (ret != ERROR_SUCCESS) {
@ -558,6 +568,12 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
if (netaddrCount == -1) { if (netaddrCount == -1) {
return NULL; return NULL;
} }
if (netaddrCount == -2) {
// Clear the exception and continue.
if ((*env)->ExceptionCheck(env)) {
(*env)->ExceptionClear(env);
}
}
netaddrP = netaddrPToFree; netaddrP = netaddrPToFree;
} }