mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
8196224: Even better Internet address support
Reviewed-by: chegar, rriggs, rhalade, vtewari
This commit is contained in:
parent
d68506157a
commit
3a7104760a
2 changed files with 12 additions and 8 deletions
|
@ -1017,6 +1017,7 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val
|
|||
struct in_addr in;
|
||||
jobjectArray addrArray;
|
||||
jsize len;
|
||||
jint family;
|
||||
jobject addr;
|
||||
int i;
|
||||
|
||||
|
@ -1047,8 +1048,9 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val
|
|||
in.s_addr = 0;
|
||||
for (i = 0; i < len; i++) {
|
||||
addr = (*env)->GetObjectArrayElement(env, addrArray, i);
|
||||
if (getInetAddress_family(env, addr) == java_net_InetAddress_IPv4) {
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
family = getInetAddress_family(env, addr);
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
if (family == java_net_InetAddress_IPv4) {
|
||||
in.s_addr = htonl(getInetAddress_addr(env, addr));
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
break;
|
||||
|
@ -1896,6 +1898,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
|
|||
|
||||
jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
|
||||
jint fd;
|
||||
jint family;
|
||||
jint ipv6_join_leave;
|
||||
|
||||
if (IS_NULL(fdObj)) {
|
||||
|
@ -1916,8 +1919,9 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
|
|||
ipv6_join_leave = ipv6_available();
|
||||
|
||||
#ifdef __linux__
|
||||
if (getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4) {
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
family = getInetAddress_family(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
if (family == java_net_InetAddress_IPv4) {
|
||||
ipv6_join_leave = JNI_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -219,16 +219,16 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this,
|
|||
jobject fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID);
|
||||
int ipv6_supported = ipv6_available();
|
||||
int fd, fd1 = -1, lcladdrlen = 0;
|
||||
jint family;
|
||||
SOCKETADDRESS lcladdr;
|
||||
|
||||
if (getInetAddress_family(env, addressObj) == java_net_InetAddress_IPv6 &&
|
||||
!ipv6_supported)
|
||||
{
|
||||
family = getInetAddress_family(env, addressObj);
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
if (family == java_net_InetAddress_IPv6 && !ipv6_supported) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
|
||||
"Protocol family not supported");
|
||||
return;
|
||||
}
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
if (IS_NULL(fdObj) || (ipv6_supported && IS_NULL(fd1Obj))) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "socket closed");
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue