8168771: Remove #ifdef AF_INET6 guards in libnet native coding

Reviewed-by: chegar
This commit is contained in:
Christoph Langer 2016-11-02 11:52:51 +01:00
parent fb5635d6df
commit cc20838f95
10 changed files with 89 additions and 272 deletions

View File

@ -203,7 +203,6 @@ jobject getInetAddress_hostName(JNIEnv *env, jobject iaObj) {
JNIEXPORT jobject JNICALL JNIEXPORT jobject JNICALL
NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) { NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
jobject iaObj; jobject iaObj;
#ifdef AF_INET6
if (him->sa_family == AF_INET6) { if (him->sa_family == AF_INET6) {
struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
jbyte *caddr = (jbyte *)&(him6->sin6_addr); jbyte *caddr = (jbyte *)&(him6->sin6_addr);
@ -227,9 +226,7 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
setInet6Address_scopeid(env, iaObj, scope); setInet6Address_scopeid(env, iaObj, scope);
} }
*port = ntohs(him6->sin6_port); *port = ntohs(him6->sin6_port);
} else } else {
#endif /* AF_INET6 */
{
struct sockaddr_in *him4 = (struct sockaddr_in *)him; struct sockaddr_in *him4 = (struct sockaddr_in *)him;
iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
CHECK_NULL_RETURN(iaObj, NULL); CHECK_NULL_RETURN(iaObj, NULL);
@ -245,7 +242,6 @@ NET_SockaddrEqualsInetAddress(JNIEnv *env, struct sockaddr *him, jobject iaObj)
{ {
jint family = AF_INET; jint family = AF_INET;
#ifdef AF_INET6
family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ? family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
AF_INET : AF_INET6; AF_INET : AF_INET6;
if (him->sa_family == AF_INET6) { if (him->sa_family == AF_INET6) {
@ -279,9 +275,7 @@ NET_SockaddrEqualsInetAddress(JNIEnv *env, struct sockaddr *him, jobject iaObj)
return JNI_FALSE; return JNI_FALSE;
} }
} }
} else } else {
#endif /* AF_INET6 */
{
struct sockaddr_in *him4 = (struct sockaddr_in *)him; struct sockaddr_in *him4 = (struct sockaddr_in *)him;
int addrNew, addrCur; int addrNew, addrCur;
if (family != AF_INET) { if (family != AF_INET) {

View File

@ -72,7 +72,7 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
hostname[NI_MAXHOST] = '\0'; hostname[NI_MAXHOST] = '\0';
} }
#if defined(__solaris__) && defined(AF_INET6) #if defined(__solaris__)
if (ret == 0) { if (ret == 0) {
/* Solaris doesn't want to give us a fully qualified domain name. /* Solaris doesn't want to give us a fully qualified domain name.
* We do a reverse lookup to try and get one. This works * We do a reverse lookup to try and get one. This works
@ -251,9 +251,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
int retLen = 0; int retLen = 0;
int getaddrinfo_error=0; int getaddrinfo_error=0;
#ifdef AF_INET6
struct addrinfo hints, *res, *resNew = NULL; struct addrinfo hints, *res, *resNew = NULL;
#endif /* AF_INET6 */
initInetAddressIDs(env); initInetAddressIDs(env);
JNU_CHECK_EXCEPTION_RETURN(env, NULL); JNU_CHECK_EXCEPTION_RETURN(env, NULL);
@ -265,7 +263,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE); hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE);
CHECK_NULL_RETURN(hostname, NULL); CHECK_NULL_RETURN(hostname, NULL);
#ifdef AF_INET6
/* Try once, with our static buffer. */ /* Try once, with our static buffer. */
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME; hints.ai_flags = AI_CANONNAME;
@ -459,7 +456,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
} }
freeaddrinfo(res); freeaddrinfo(res);
#endif /* AF_INET6 */
return ret; return ret;
} }
@ -475,7 +471,6 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
jstring ret = NULL; jstring ret = NULL;
#ifdef AF_INET6
char host[NI_MAXHOST+1]; char host[NI_MAXHOST+1];
int error = 0; int error = 0;
int len = 0; int len = 0;
@ -518,7 +513,6 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
ret = (*env)->NewStringUTF(env, host); ret = (*env)->NewStringUTF(env, host);
CHECK_NULL_RETURN(ret, NULL); CHECK_NULL_RETURN(ret, NULL);
} }
#endif /* AF_INET6 */
if (ret == NULL) { if (ret == NULL) {
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", NULL); JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", NULL);
@ -533,7 +527,6 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
fcntl(fd, F_SETFL, flags); \ fcntl(fd, F_SETFL, flags); \
} }
#ifdef AF_INET6
static jboolean static jboolean
ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout, ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout,
struct sockaddr_in6* netif, jint ttl) { struct sockaddr_in6* netif, jint ttl) {
@ -640,7 +633,6 @@ ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout,
close(fd); close(fd);
return JNI_FALSE; return JNI_FALSE;
} }
#endif /* AF_INET6 */
/* /*
* Class: java_net_Inet6AddressImpl * Class: java_net_Inet6AddressImpl
@ -654,7 +646,6 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
jint timeout, jint timeout,
jbyteArray ifArray, jbyteArray ifArray,
jint ttl, jint if_scope) { jint ttl, jint if_scope) {
#ifdef AF_INET6
jbyte caddr[16]; jbyte caddr[16];
jint fd, sz; jint fd, sz;
struct sockaddr_in6 him6; struct sockaddr_in6 him6;
@ -803,7 +794,4 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
close(fd); close(fd);
return JNI_FALSE; return JNI_FALSE;
} }
#else /* AF_INET6 */
return JNI_FALSE;
#endif /* AF_INET6 */
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -37,14 +37,10 @@
* Signature: ()I * Signature: ()I
*/ */
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
Java_java_net_InetAddressImplFactory_isIPv6Supported(JNIEnv *env, jclass cls) Java_java_net_InetAddressImplFactory_isIPv6Supported(JNIEnv *env, jclass cls) {
{
#ifdef AF_INET6
if (ipv6_available()) { if (ipv6_available()) {
return JNI_TRUE; return JNI_TRUE;
} else } else {
#endif /* AF_INET6 */
{
return JNI_FALSE; return JNI_FALSE;
} }
} }

View File

@ -126,10 +126,7 @@ static int getFlags0(JNIEnv *env, jstring ifname);
static netif *enumInterfaces(JNIEnv *env); static netif *enumInterfaces(JNIEnv *env);
static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs); static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs);
#if defined(AF_INET6)
static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs); static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs);
#endif
static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs, static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs,
struct sockaddr *ifr_addrP, struct sockaddr *ifr_addrP,
@ -312,11 +309,8 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
(JNIEnv *env, jclass cls, jobject iaObj) (JNIEnv *env, jclass cls, jobject iaObj)
{ {
netif *ifs, *curr; netif *ifs, *curr;
#if defined(AF_INET6) int family = (getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4) ?
int family = (getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4) ? AF_INET : AF_INET6; AF_INET : AF_INET6;
#else
int family = AF_INET;
#endif
jobject obj = NULL; jobject obj = NULL;
jboolean match = JNI_FALSE; jboolean match = JNI_FALSE;
@ -342,9 +336,7 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
match = JNI_TRUE; match = JNI_TRUE;
break; break;
} }
} } else if (family == AF_INET6) {
#if defined(AF_INET6)
if (family == AF_INET6) {
jbyte *bytes = (jbyte *)&( jbyte *bytes = (jbyte *)&(
((struct sockaddr_in6*)addrP->addr)->sin6_addr); ((struct sockaddr_in6*)addrP->addr)->sin6_addr);
jbyte caddr[16]; jbyte caddr[16];
@ -362,7 +354,6 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
break; break;
} }
} }
#endif
} }
if (match) { if (match) {
@ -706,7 +697,6 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
return NULL; return NULL;
} }
} }
#if defined(AF_INET6)
if (addrP->family == AF_INET6) { if (addrP->family == AF_INET6) {
int scope=0; int scope=0;
iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
@ -735,7 +725,6 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
return NULL; return NULL;
} }
} }
#endif
(*env)->SetObjectArrayElement(env, addrArr, addr_index++, iaObj); (*env)->SetObjectArrayElement(env, addrArr, addr_index++, iaObj);
addrP = addrP->next; addrP = addrP->next;
@ -796,7 +785,6 @@ static netif *enumInterfaces(JNIEnv *env) {
} }
// If IPv6 is available then enumerate IPv6 addresses. // If IPv6 is available then enumerate IPv6 addresses.
#if defined(AF_INET6)
// User can disable ipv6 explicitly by -Djava.net.preferIPv4Stack=true, // User can disable ipv6 explicitly by -Djava.net.preferIPv4Stack=true,
// so we have to call ipv6_available() // so we have to call ipv6_available()
if (ipv6_available()) { if (ipv6_available()) {
@ -814,7 +802,6 @@ static netif *enumInterfaces(JNIEnv *env) {
return NULL; return NULL;
} }
} }
#endif
return ifs; return ifs;
} }
@ -870,12 +857,8 @@ static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs,
// Allocate for addr and brdcast at once // Allocate for addr and brdcast at once
#if defined(AF_INET6)
addr_size = (family == AF_INET) ? sizeof(struct sockaddr_in) addr_size = (family == AF_INET) ? sizeof(struct sockaddr_in)
: sizeof(struct sockaddr_in6); : sizeof(struct sockaddr_in6);
#else
addr_size = sizeof(struct sockaddr_in);
#endif
CHECKED_MALLOC3(addrP, netaddr *, sizeof(netaddr) + 2 * addr_size); CHECKED_MALLOC3(addrP, netaddr *, sizeof(netaddr) + 2 * addr_size);
addrP->addr = (struct sockaddr *)((char *)addrP + sizeof(netaddr)); addrP->addr = (struct sockaddr *)((char *)addrP + sizeof(netaddr));
@ -1064,7 +1047,6 @@ static int openSocket(JNIEnv *env, int proto) {
/** Linux **/ /** Linux **/
#if defined(__linux__) #if defined(__linux__)
#if defined(AF_INET6)
/* /*
* Opens a socket for further ioctl calls. Tries AF_INET socket first and * Opens a socket for further ioctl calls. Tries AF_INET socket first and
* if it fails return AF_INET6 socket. * if it fails return AF_INET6 socket.
@ -1090,11 +1072,6 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
// IPv6 socket regardless of type of address of an interface. // IPv6 socket regardless of type of address of an interface.
return sock; return sock;
} }
#else
static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
return openSocket(env, AF_INET);
}
#endif
/* /*
* Enumerates and returns all IPv4 interfaces on Linux. * Enumerates and returns all IPv4 interfaces on Linux.
@ -1178,8 +1155,6 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
return ifs; return ifs;
} }
#if defined(AF_INET6)
/* /*
* Enumerates and returns all IPv6 interfaces on Linux. * Enumerates and returns all IPv6 interfaces on Linux.
*/ */
@ -1221,8 +1196,6 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
return ifs; return ifs;
} }
#endif /* AF_INET6 */
/* /*
* Try to get the interface index. * Try to get the interface index.
*/ */
@ -1311,7 +1284,6 @@ static int getFlags(int sock, const char *ifname, int *flags) {
/** AIX **/ /** AIX **/
#if defined(_AIX) #if defined(_AIX)
#if defined(AF_INET6)
/* /*
* Opens a socket for further ioctl calls. Tries AF_INET socket first and * Opens a socket for further ioctl calls. Tries AF_INET socket first and
* if it fails return AF_INET6 socket. * if it fails return AF_INET6 socket.
@ -1335,11 +1307,6 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
return sock; return sock;
} }
#else
static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
return openSocket(env, AF_INET);
}
#endif
/* /*
* Enumerates and returns all IPv4 interfaces on AIX. * Enumerates and returns all IPv4 interfaces on AIX.
@ -1423,8 +1390,6 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
return ifs; return ifs;
} }
#if defined(AF_INET6)
/* /*
* Enumerates and returns all IPv6 interfaces on AIX. * Enumerates and returns all IPv6 interfaces on AIX.
*/ */
@ -1499,8 +1464,6 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
return ifs; return ifs;
} }
#endif /* AF_INET6 */
/* /*
* Try to get the interface index. * Try to get the interface index.
*/ */
@ -1595,7 +1558,6 @@ static int getFlags(int sock, const char *ifname, int *flags) {
/** Solaris **/ /** Solaris **/
#if defined(__solaris__) #if defined(__solaris__)
#if defined(AF_INET6)
/* /*
* Opens a socket for further ioctl calls. Tries AF_INET socket first and * Opens a socket for further ioctl calls. Tries AF_INET socket first and
* if it fails return AF_INET6 socket. * if it fails return AF_INET6 socket.
@ -1640,11 +1602,6 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
return sock; return sock;
} }
#else
static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
return openSocket(env, AF_INET);
}
#endif
/* /*
* Enumerates and returns all IPv4 interfaces on Solaris. * Enumerates and returns all IPv4 interfaces on Solaris.
@ -1720,8 +1677,6 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
return ifs; return ifs;
} }
#if defined(AF_INET6)
/* /*
* Enumerates and returns all IPv6 interfaces on Solaris. * Enumerates and returns all IPv6 interfaces on Solaris.
*/ */
@ -1784,8 +1739,6 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
return ifs; return ifs;
} }
#endif /* AF_INET6 */
/* /*
* Try to get the interface index. * Try to get the interface index.
* (Not supported on Solaris 2.6 or 7) * (Not supported on Solaris 2.6 or 7)
@ -1957,7 +1910,6 @@ static int getFlags(int sock, const char *ifname, int *flags) {
/** BSD **/ /** BSD **/
#if defined(_ALLBSD_SOURCE) #if defined(_ALLBSD_SOURCE)
#if defined(AF_INET6)
/* /*
* Opens a socket for further ioctl calls. Tries AF_INET socket first and * Opens a socket for further ioctl calls. Tries AF_INET socket first and
* if it fails return AF_INET6 socket. * if it fails return AF_INET6 socket.
@ -1981,11 +1933,6 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
return sock; return sock;
} }
#else
static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
return openSocket(env, AF_INET);
}
#endif
/* /*
* Enumerates and returns all IPv4 interfaces on BSD. * Enumerates and returns all IPv4 interfaces on BSD.
@ -2031,8 +1978,6 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
return ifs; return ifs;
} }
#if defined(AF_INET6)
/* /*
* Enumerates and returns all IPv6 interfaces on BSD. * Enumerates and returns all IPv6 interfaces on BSD.
*/ */
@ -2073,8 +2018,6 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
return ifs; return ifs;
} }
#endif /* AF_INET6 */
/* /*
* Try to get the interface index. * Try to get the interface index.
*/ */

View File

@ -299,13 +299,10 @@ Java_java_net_PlainDatagramSocketImpl_disconnect0(JNIEnv *env, jobject this, jin
#if defined(__linux__) || defined(_ALLBSD_SOURCE) #if defined(__linux__) || defined(_ALLBSD_SOURCE)
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
#ifdef AF_INET6
if (ipv6_available()) { if (ipv6_available()) {
addr.sa6.sin6_family = AF_UNSPEC; addr.sa6.sin6_family = AF_UNSPEC;
len = sizeof(struct sockaddr_in6); len = sizeof(struct sockaddr_in6);
} else } else {
#endif
{
addr.sa4.sin_family = AF_UNSPEC; addr.sa4.sin_family = AF_UNSPEC;
len = sizeof(struct sockaddr_in); len = sizeof(struct sockaddr_in);
} }
@ -319,12 +316,9 @@ Java_java_net_PlainDatagramSocketImpl_disconnect0(JNIEnv *env, jobject this, jin
localPort = NET_GetPortFromSockaddr(&addr.sa); localPort = NET_GetPortFromSockaddr(&addr.sa);
if (localPort == 0) { if (localPort == 0) {
localPort = (*env)->GetIntField(env, this, pdsi_localPortID); localPort = (*env)->GetIntField(env, this, pdsi_localPortID);
#ifdef AF_INET6
if (addr.sa.sa_family == AF_INET6) { if (addr.sa.sa_family == AF_INET6) {
addr.sa6.sin6_port = htons(localPort); addr.sa6.sin6_port = htons(localPort);
} else } else {
#endif /* AF_INET6 */
{
addr.sa4.sin_port = htons(localPort); addr.sa4.sin_port = htons(localPort);
} }
@ -432,12 +426,9 @@ Java_java_net_PlainDatagramSocketImpl_send(JNIEnv *env, jobject this,
(*env)->GetByteArrayRegion(env, packetBuffer, packetBufferOffset, packetBufferLen, (*env)->GetByteArrayRegion(env, packetBuffer, packetBufferOffset, packetBufferLen,
(jbyte *)fullPacket); (jbyte *)fullPacket);
#ifdef AF_INET6
if (trafficClass != 0 && ipv6_available()) { if (trafficClass != 0 && ipv6_available()) {
NET_SetTrafficClass(&rmtaddr.sa, trafficClass); NET_SetTrafficClass(&rmtaddr.sa, trafficClass);
} }
#endif /* AF_INET6 */
/* /*
* Send the datagram. * Send the datagram.
@ -538,12 +529,8 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
} }
iaObj = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &port); iaObj = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &port);
#ifdef AF_INET6
family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ? family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
AF_INET : AF_INET6; AF_INET : AF_INET6;
#else
family = AF_INET;
#endif
if (family == AF_INET) { /* this API can't handle IPV6 addresses */ if (family == AF_INET) { /* this API can't handle IPV6 addresses */
int address = getInetAddress_addr(env, iaObj); int address = getInetAddress_addr(env, iaObj);
setInetAddress_addr(env, addressObj, address); setInetAddress_addr(env, addressObj, address);
@ -908,11 +895,7 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env,
jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
int arg, fd, t = 1; int arg, fd, t = 1;
char tmpbuf[1024]; char tmpbuf[1024];
#ifdef AF_INET6
int domain = ipv6_available() ? AF_INET6 : AF_INET; int domain = ipv6_available() ? AF_INET6 : AF_INET;
#else
int domain = AF_INET;
#endif
if (IS_NULL(fdObj)) { if (IS_NULL(fdObj)) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
@ -926,7 +909,6 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env,
return; return;
} }
#ifdef AF_INET6
/* Disable IPV6_V6ONLY to ensure dual-socket support */ /* Disable IPV6_V6ONLY to ensure dual-socket support */
if (domain == AF_INET6) { if (domain == AF_INET6) {
arg = 0; arg = 0;
@ -937,7 +919,6 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env,
return; return;
} }
} }
#endif /* AF_INET6 */
#ifdef __APPLE__ #ifdef __APPLE__
arg = 65507; arg = 65507;
@ -977,7 +958,7 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env,
} }
#endif #endif
#if defined (__linux__) && defined (AF_INET6) #if defined (__linux__)
/* /*
* On Linux for IPv6 sockets we must set the hop limit * On Linux for IPv6 sockets we must set the hop limit
* to 1 to be compatible with default TTL of 1 for IPv4 sockets. * to 1 to be compatible with default TTL of 1 for IPv4 sockets.
@ -1078,7 +1059,6 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val
* Set outgoing multicast interface designated by a NetworkInterface. * Set outgoing multicast interface designated by a NetworkInterface.
* Throw exception if failed. * Throw exception if failed.
*/ */
#ifdef AF_INET6
static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject value) { static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject value) {
static jfieldID ni_indexID; static jfieldID ni_indexID;
int index; int index;
@ -1103,9 +1083,7 @@ static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject val
} }
return; return;
} }
} }
#endif /* AF_INET6 */
/* /*
* Set outgoing multicast interface designated by an InetAddress. * Set outgoing multicast interface designated by an InetAddress.
@ -1127,7 +1105,6 @@ static void mcast_set_if_by_addr_v4(JNIEnv *env, jobject this, int fd, jobject v
* Set outgoing multicast interface designated by an InetAddress. * Set outgoing multicast interface designated by an InetAddress.
* Throw exception if failed. * Throw exception if failed.
*/ */
#ifdef AF_INET6
static void mcast_set_if_by_addr_v6(JNIEnv *env, jobject this, int fd, jobject value) { static void mcast_set_if_by_addr_v6(JNIEnv *env, jobject this, int fd, jobject value) {
static jclass ni_class; static jclass ni_class;
if (ni_class == NULL) { if (ni_class == NULL) {
@ -1149,7 +1126,6 @@ static void mcast_set_if_by_addr_v6(JNIEnv *env, jobject this, int fd, jobject v
mcast_set_if_by_if_v6(env, this, fd, value); mcast_set_if_by_if_v6(env, this, fd, value);
} }
#endif
/* /*
* Sets the multicast interface. * Sets the multicast interface.
@ -1181,7 +1157,6 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd,
/* /*
* value is an InetAddress. * value is an InetAddress.
*/ */
#ifdef AF_INET6
#ifdef __linux__ #ifdef __linux__
mcast_set_if_by_addr_v4(env, this, fd, value); mcast_set_if_by_addr_v4(env, this, fd, value);
if (ipv6_available()) { if (ipv6_available()) {
@ -1197,16 +1172,12 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd,
mcast_set_if_by_addr_v4(env, this, fd, value); mcast_set_if_by_addr_v4(env, this, fd, value);
} }
#endif /* __linux__ */ #endif /* __linux__ */
#else
mcast_set_if_by_addr_v4(env, this, fd, value);
#endif /* AF_INET6 */
} }
if (opt == java_net_SocketOptions_IP_MULTICAST_IF2) { if (opt == java_net_SocketOptions_IP_MULTICAST_IF2) {
/* /*
* value is a NetworkInterface. * value is a NetworkInterface.
*/ */
#ifdef AF_INET6
#ifdef __linux__ #ifdef __linux__
mcast_set_if_by_if_v4(env, this, fd, value); mcast_set_if_by_if_v4(env, this, fd, value);
if (ipv6_available()) { if (ipv6_available()) {
@ -1222,9 +1193,6 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd,
mcast_set_if_by_if_v4(env, this, fd, value); mcast_set_if_by_if_v4(env, this, fd, value);
} }
#endif /* __linux__ */ #endif /* __linux__ */
#else
mcast_set_if_by_if_v4(env, this, fd, value);
#endif /* AF_INET6 */
} }
} }
@ -1256,7 +1224,6 @@ static void mcast_set_loop_v4(JNIEnv *env, jobject this, int fd, jobject value)
/* /*
* Enable/disable local loopback of multicast datagrams. * Enable/disable local loopback of multicast datagrams.
*/ */
#ifdef AF_INET6
static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value) { static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value) {
jclass cls; jclass cls;
jfieldID fid; jfieldID fid;
@ -1279,14 +1246,12 @@ static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value)
} }
} }
#endif /* AF_INET6 */
/* /*
* Sets the multicast loopback mode. * Sets the multicast loopback mode.
*/ */
static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd, static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd,
jint opt, jobject value) { jint opt, jobject value) {
#ifdef AF_INET6
#ifdef __linux__ #ifdef __linux__
mcast_set_loop_v4(env, this, fd, value); mcast_set_loop_v4(env, this, fd, value);
if (ipv6_available()) { if (ipv6_available()) {
@ -1302,9 +1267,6 @@ static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd,
mcast_set_loop_v4(env, this, fd, value); mcast_set_loop_v4(env, this, fd, value);
} }
#endif /* __linux__ */ #endif /* __linux__ */
#else
mcast_set_loop_v4(env, this, fd, value);
#endif /* AF_INET6 */
} }
/* /*
@ -1446,11 +1408,9 @@ Java_java_net_PlainDatagramSocketImpl_socketSetOption0
jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, jint opt) { jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, jint opt) {
jboolean isIPV4 = JNI_TRUE; jboolean isIPV4 = JNI_TRUE;
#ifdef AF_INET6
if (ipv6_available()) { if (ipv6_available()) {
isIPV4 = JNI_FALSE; isIPV4 = JNI_FALSE;
} }
#endif
/* /*
* IPv4 implementation * IPv4 implementation
@ -1549,7 +1509,6 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, jint opt) {
} }
#ifdef AF_INET6
/* /*
* IPv6 implementation * IPv6 implementation
*/ */
@ -1667,7 +1626,6 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, jint opt) {
} }
return ni; return ni;
} }
#endif
return NULL; return NULL;
} }
@ -1805,7 +1763,6 @@ static void setTTL(JNIEnv *env, int fd, jint ttl) {
/* /*
* Set hops limit for a socket. Throw exception if failed. * Set hops limit for a socket. Throw exception if failed.
*/ */
#ifdef AF_INET6
static void setHopLimit(JNIEnv *env, int fd, jint ttl) { static void setHopLimit(JNIEnv *env, int fd, jint ttl) {
int ittl = (int)ttl; int ittl = (int)ttl;
if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
@ -1814,7 +1771,6 @@ static void setHopLimit(JNIEnv *env, int fd, jint ttl) {
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option"); (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
} }
} }
#endif
/* /*
* Class: java_net_PlainDatagramSocketImpl * Class: java_net_PlainDatagramSocketImpl
@ -1837,7 +1793,6 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive(JNIEnv *env, jobject this,
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID); fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
} }
/* setsockopt to be correct TTL */ /* setsockopt to be correct TTL */
#ifdef AF_INET6
#ifdef __linux__ #ifdef __linux__
setTTL(env, fd, ttl); setTTL(env, fd, ttl);
JNU_CHECK_EXCEPTION(env); JNU_CHECK_EXCEPTION(env);
@ -1851,9 +1806,6 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive(JNIEnv *env, jobject this,
setTTL(env, fd, ttl); setTTL(env, fd, ttl);
} }
#endif /* __linux__ */ #endif /* __linux__ */
#else
setTTL(env, fd, ttl);
#endif /* AF_INET6 */
} }
/* /*
@ -1886,7 +1838,6 @@ Java_java_net_PlainDatagramSocketImpl_getTimeToLive(JNIEnv *env, jobject this) {
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID); fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
} }
/* getsockopt of TTL */ /* getsockopt of TTL */
#ifdef AF_INET6
if (ipv6_available()) { if (ipv6_available()) {
int ttl = 0; int ttl = 0;
socklen_t len = sizeof(ttl); socklen_t len = sizeof(ttl);
@ -1898,9 +1849,7 @@ Java_java_net_PlainDatagramSocketImpl_getTimeToLive(JNIEnv *env, jobject this) {
return -1; return -1;
} }
return (jint)ttl; return (jint)ttl;
} else } else {
#endif /* AF_INET6 */
{
u_char ttl = 0; u_char ttl = 0;
socklen_t len = sizeof(ttl); socklen_t len = sizeof(ttl);
if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL,
@ -1956,7 +1905,6 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
/* /*
* Determine if this is an IPv4 or IPv6 join/leave. * Determine if this is an IPv4 or IPv6 join/leave.
*/ */
#ifdef AF_INET6
ipv6_join_leave = ipv6_available(); ipv6_join_leave = ipv6_available();
#ifdef __linux__ #ifdef __linux__
@ -1965,13 +1913,6 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
} }
#endif #endif
#else
/*
* IPv6 not compiled in
*/
ipv6_join_leave = JNI_FALSE;
#endif
/* /*
* For IPv4 join use IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP socket option * For IPv4 join use IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP socket option
* *
@ -1996,7 +1937,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
* NetworkInterface * NetworkInterface
*/ */
if (niObj != NULL) { if (niObj != NULL) {
#if defined(__linux__) && defined(AF_INET6) #if defined(__linux__)
if (ipv6_available()) { if (ipv6_available()) {
static jfieldID ni_indexID; static jfieldID ni_indexID;
@ -2052,7 +1993,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
if (niObj == NULL) { if (niObj == NULL) {
#if defined(__linux__) && defined(AF_INET6) #if defined(__linux__)
if (ipv6_available()) { if (ipv6_available()) {
int index; int index;
@ -2108,7 +2049,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
* should return ENOPROTOOPT. We assume this will be fixed in Linux * should return ENOPROTOOPT. We assume this will be fixed in Linux
* at some stage. * at some stage.
*/ */
#if defined(__linux__) && defined(AF_INET6) #if defined(__linux__)
if (errno == ENOPROTOOPT) { if (errno == ENOPROTOOPT) {
if (ipv6_available()) { if (ipv6_available()) {
ipv6_join_leave = JNI_TRUE; ipv6_join_leave = JNI_TRUE;
@ -2145,7 +2086,6 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
* IPv6 join. If it's an IPv4 multicast group then we use an IPv4-mapped * IPv6 join. If it's an IPv4 multicast group then we use an IPv4-mapped
* address. * address.
*/ */
#ifdef AF_INET6
{ {
struct ipv6_mreq mname6; struct ipv6_mreq mname6;
jbyteArray ipaddress; jbyteArray ipaddress;
@ -2233,7 +2173,6 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
} }
} }
} }
#endif
} }
/* /*

View File

@ -162,11 +162,7 @@ Java_java_net_PlainSocketImpl_socketCreate(JNIEnv *env, jobject this,
jobject fdObj, ssObj; jobject fdObj, ssObj;
int fd; int fd;
int type = (stream ? SOCK_STREAM : SOCK_DGRAM); int type = (stream ? SOCK_STREAM : SOCK_DGRAM);
#ifdef AF_INET6
int domain = ipv6_available() ? AF_INET6 : AF_INET; int domain = ipv6_available() ? AF_INET6 : AF_INET;
#else
int domain = AF_INET;
#endif
if (socketExceptionCls == NULL) { if (socketExceptionCls == NULL) {
jclass c = (*env)->FindClass(env, "java/net/SocketException"); jclass c = (*env)->FindClass(env, "java/net/SocketException");
@ -190,7 +186,6 @@ Java_java_net_PlainSocketImpl_socketCreate(JNIEnv *env, jobject this,
return; return;
} }
#ifdef AF_INET6
/* Disable IPV6_V6ONLY to ensure dual-socket support */ /* Disable IPV6_V6ONLY to ensure dual-socket support */
if (domain == AF_INET6) { if (domain == AF_INET6) {
int arg = 0; int arg = 0;
@ -201,7 +196,6 @@ Java_java_net_PlainSocketImpl_socketCreate(JNIEnv *env, jobject this,
return; return;
} }
} }
#endif /* AF_INET6 */
/* /*
* If this is a server socket then enable SO_REUSEADDR * If this is a server socket then enable SO_REUSEADDR
@ -271,11 +265,10 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this,
} }
setDefaultScopeID(env, &him.sa); setDefaultScopeID(env, &him.sa);
#ifdef AF_INET6
if (trafficClass != 0 && ipv6_available()) { if (trafficClass != 0 && ipv6_available()) {
NET_SetTrafficClass(&him.sa, trafficClass); NET_SetTrafficClass(&him.sa, trafficClass);
} }
#endif /* AF_INET6 */
if (timeout <= 0) { if (timeout <= 0) {
connect_rv = NET_Connect(fd, &him.sa, len); connect_rv = NET_Connect(fd, &him.sa, len);
#ifdef __solaris__ #ifdef __solaris__

View File

@ -56,11 +56,7 @@ static int create(JNIEnv* env)
int s; int s;
#if defined(__solaris__) #if defined(__solaris__)
#ifdef AF_INET6
int domain = ipv6_available() ? AF_INET6 : AF_INET; int domain = ipv6_available() ? AF_INET6 : AF_INET;
#else
int domain = AF_INET;
#endif
s = socket(domain, SOCK_STREAM, PROTO_SDP); s = socket(domain, SOCK_STREAM, PROTO_SDP);
#elif defined(__linux__) #elif defined(__linux__)
/** /**

View File

@ -306,11 +306,6 @@ jint IPv6_supported()
jint IPv6_supported() jint IPv6_supported()
{ {
#ifndef AF_INET6
return JNI_FALSE;
#endif
#ifdef AF_INET6
int fd; int fd;
void *ipv6_fn; void *ipv6_fn;
SOCKETADDRESS sa; SOCKETADDRESS sa;
@ -415,7 +410,6 @@ jint IPv6_supported()
} else { } else {
return JNI_TRUE; return JNI_TRUE;
} }
#endif /* AF_INET6 */
} }
#endif /* DONT_ENABLE_IPV6 */ #endif /* DONT_ENABLE_IPV6 */
@ -466,7 +460,7 @@ void NET_ThrowUnknownHostExceptionWithGaiError(JNIEnv *env,
} }
} }
#if defined(__linux__) && defined(AF_INET6) #if defined(__linux__)
/* following code creates a list of addresses from the kernel /* following code creates a list of addresses from the kernel
* routing table that are routed via the loopback address. * routing table that are routed via the loopback address.
@ -786,7 +780,6 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
int *len, jboolean v4MappedAddress) { int *len, jboolean v4MappedAddress) {
jint family; jint family;
family = getInetAddress_family(env, iaObj); family = getInetAddress_family(env, iaObj);
#ifdef AF_INET6
/* needs work. 1. family 2. clean up him6 etc deallocate memory */ /* needs work. 1. family 2. clean up him6 etc deallocate memory */
if (ipv6_available() && !(family == java_net_InetAddress_IPv4 && if (ipv6_available() && !(family == java_net_InetAddress_IPv4 &&
v4MappedAddress == JNI_FALSE)) { v4MappedAddress == JNI_FALSE)) {
@ -794,7 +787,6 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
jbyte caddr[16]; jbyte caddr[16];
jint address; jint address;
if (family == java_net_InetAddress_IPv4) { if (family == java_net_InetAddress_IPv4) {
// convert to IPv4-mapped address // convert to IPv4-mapped address
memset((char *) caddr, 0, 16); memset((char *) caddr, 0, 16);
@ -818,9 +810,9 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
him6->sin6_port = htons(port); him6->sin6_port = htons(port);
memcpy((void *)&(him6->sin6_addr), caddr, sizeof(struct in6_addr) ); memcpy((void *)&(him6->sin6_addr), caddr, sizeof(struct in6_addr) );
him6->sin6_family = AF_INET6; him6->sin6_family = AF_INET6;
*len = sizeof(struct sockaddr_in6) ; *len = sizeof(struct sockaddr_in6);
#if defined(_ALLBSD_SOURCE) && defined(_AF_INET6) #if defined(_ALLBSD_SOURCE)
// XXXBSD: should we do something with scope id here ? see below linux comment // XXXBSD: should we do something with scope id here ? see below linux comment
/* MMM: Come back to this! */ /* MMM: Come back to this! */
#endif #endif
@ -864,11 +856,11 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
* try determine the appropriate interface. * try determine the appropriate interface.
*/ */
if (kernelIsV24()) { if (kernelIsV24()) {
cached_scope_id = getDefaultIPv6Interface( &(him6->sin6_addr) ); cached_scope_id = getDefaultIPv6Interface(&(him6->sin6_addr));
} else { } else {
cached_scope_id = getLocalScopeID( (char *)&(him6->sin6_addr) ); cached_scope_id = getLocalScopeID((char *)&(him6->sin6_addr));
if (cached_scope_id == 0) { if (cached_scope_id == 0) {
cached_scope_id = getDefaultIPv6Interface( &(him6->sin6_addr) ); cached_scope_id = getDefaultIPv6Interface(&(him6->sin6_addr));
} }
} }
(*env)->SetIntField(env, iaObj, ia6_cachedscopeidID, cached_scope_id); (*env)->SetIntField(env, iaObj, ia6_cachedscopeidID, cached_scope_id);
@ -896,16 +888,14 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
} }
} }
#endif #endif
} else } else {
#endif /* AF_INET6 */ struct sockaddr_in *him4 = (struct sockaddr_in *)him;
{
struct sockaddr_in *him4 = (struct sockaddr_in*)him;
jint address; jint address;
if (family == java_net_InetAddress_IPv6) { if (family == java_net_InetAddress_IPv6) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family unavailable"); JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family unavailable");
return -1; return -1;
} }
memset((char *) him4, 0, sizeof(struct sockaddr_in)); memset((char *)him4, 0, sizeof(struct sockaddr_in));
address = getInetAddress_addr(env, iaObj); address = getInetAddress_addr(env, iaObj);
him4->sin_port = htons((short) port); him4->sin_port = htons((short) port);
him4->sin_addr.s_addr = htonl(address); him4->sin_addr.s_addr = htonl(address);
@ -917,23 +907,17 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
void void
NET_SetTrafficClass(struct sockaddr *him, int trafficClass) { NET_SetTrafficClass(struct sockaddr *him, int trafficClass) {
#ifdef AF_INET6
if (him->sa_family == AF_INET6) { if (him->sa_family == AF_INET6) {
struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
him6->sin6_flowinfo = htonl((trafficClass & 0xff) << 20); him6->sin6_flowinfo = htonl((trafficClass & 0xff) << 20);
} }
#endif /* AF_INET6 */
} }
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
NET_GetPortFromSockaddr(struct sockaddr *him) { NET_GetPortFromSockaddr(struct sockaddr *him) {
#ifdef AF_INET6
if (him->sa_family == AF_INET6) { if (him->sa_family == AF_INET6) {
return ntohs(((struct sockaddr_in6*)him)->sin6_port); return ntohs(((struct sockaddr_in6*)him)->sin6_port);
} else {
} else
#endif /* AF_INET6 */
{
return ntohs(((struct sockaddr_in*)him)->sin_port); return ntohs(((struct sockaddr_in*)him)->sin_port);
} }
} }
@ -1008,7 +992,6 @@ NET_MapSocketOption(jint cmd, int *level, int *optname) {
int i; int i;
#ifdef AF_INET6
if (ipv6_available()) { if (ipv6_available()) {
switch (cmd) { switch (cmd) {
// Different multicast options if IPv6 is enabled // Different multicast options if IPv6 is enabled
@ -1031,7 +1014,6 @@ NET_MapSocketOption(jint cmd, int *level, int *optname) {
#endif #endif
} }
} }
#endif
/* /*
* Map the Java level option to the native level * Map the Java level option to the native level
@ -1063,7 +1045,7 @@ NET_MapSocketOption(jint cmd, int *level, int *optname) {
* 0 if no matching interface * 0 if no matching interface
* >1 interface index to use for the link-local address. * >1 interface index to use for the link-local address.
*/ */
#if defined(__linux__) && defined(AF_INET6) #if defined(__linux__)
int getDefaultIPv6Interface(struct in6_addr *target_addr) { int getDefaultIPv6Interface(struct in6_addr *target_addr) {
FILE *f; FILE *f;
char srcp[8][5]; char srcp[8][5];
@ -1300,7 +1282,7 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg,
if (level == IPPROTO_IP && opt == IP_TOS) { if (level == IPPROTO_IP && opt == IP_TOS) {
int *iptos; int *iptos;
#if defined(AF_INET6) && defined(__linux__) #if defined(__linux__)
if (ipv6_available()) { if (ipv6_available()) {
int optval = 1; int optval = 1;
if (setsockopt(fd, IPPROTO_IPV6, IPV6_FLOWINFO_SEND, if (setsockopt(fd, IPPROTO_IPV6, IPV6_FLOWINFO_SEND,
@ -1504,7 +1486,7 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg,
int int
NET_Bind(int fd, struct sockaddr *him, int len) NET_Bind(int fd, struct sockaddr *him, int len)
{ {
#if defined(__solaris__) && defined(AF_INET6) #if defined(__solaris__)
int level = -1; int level = -1;
int exclbind = -1; int exclbind = -1;
#endif #endif
@ -1568,7 +1550,7 @@ NET_Bind(int fd, struct sockaddr *him, int len)
rv = bind(fd, him, len); rv = bind(fd, him, len);
#if defined(__solaris__) && defined(AF_INET6) #if defined(__solaris__)
if (rv < 0) { if (rv < 0) {
int en = errno; int en = errno;
/* Restore *_EXCLBIND if the bind fails */ /* Restore *_EXCLBIND if the bind fails */

View File

@ -84,18 +84,11 @@ void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
#define MAX_HEAP_BUFFER_LEN 65536 #define MAX_HEAP_BUFFER_LEN 65536
#endif #endif
#ifdef AF_INET6
typedef union { typedef union {
struct sockaddr sa; struct sockaddr sa;
struct sockaddr_in sa4; struct sockaddr_in sa4;
struct sockaddr_in6 sa6; struct sockaddr_in6 sa6;
} SOCKETADDRESS; } SOCKETADDRESS;
#else
typedef union {
struct sockaddr sa;
struct sockaddr_in sa4;
} SOCKETADDRESS;
#endif
/************************************************************************ /************************************************************************
* Utilities * Utilities
@ -103,10 +96,8 @@ typedef union {
#ifdef __linux__ #ifdef __linux__
int kernelIsV24(); int kernelIsV24();
#ifdef AF_INET6
int getDefaultIPv6Interface(struct in6_addr *target_addr); int getDefaultIPv6Interface(struct in6_addr *target_addr);
#endif #endif
#endif
#ifdef __solaris__ #ifdef __solaris__
int net_getParam(char *driver, char *param); int net_getParam(char *driver, char *param);

View File

@ -305,8 +305,6 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
return ret; return ret;
} }
#ifdef AF_INET6
/** /**
* ping implementation using tcp port 7 (echo) * ping implementation using tcp port 7 (echo)
*/ */
@ -468,7 +466,6 @@ ping6(JNIEnv *env,
return JNI_FALSE; return JNI_FALSE;
} }
} }
#endif /* AF_INET6 */
/* /*
* Class: java_net_Inet6AddressImpl * Class: java_net_Inet6AddressImpl
@ -482,7 +479,6 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
jint timeout, jint timeout,
jbyteArray ifArray, jbyteArray ifArray,
jint ttl, jint if_scope) { jint ttl, jint if_scope) {
#ifdef AF_INET6
jbyte caddr[16]; jbyte caddr[16];
jint sz; jint sz;
struct sockaddr_in6 him6; struct sockaddr_in6 him6;
@ -548,6 +544,5 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
return ping6(env, netif, &him6, timeout, hIcmpFile); return ping6(env, netif, &him6, timeout, hIcmpFile);
} }
#endif /* AF_INET6 */
return JNI_FALSE; return JNI_FALSE;
} }