Mercurial > hg > icedtea8-forest > jdk
changeset 14458:bb9b9a0ad162 icedtea-3.16.0 icedtea-3.17.0pre00
8167481, PR3784: cleanup of headers and includes for native libnet
Reviewed-by: chegar
line wrap: on
line diff
--- a/src/share/classes/java/net/InetAddress.java Wed Apr 29 12:56:13 2020 +0100 +++ b/src/share/classes/java/net/InetAddress.java Wed Apr 29 13:33:10 2020 +0100 @@ -42,6 +42,7 @@ import java.io.ObjectInputStream.GetField; import java.io.ObjectOutputStream; import java.io.ObjectOutputStream.PutField; +import java.lang.annotation.Native; import sun.security.action.*; import sun.net.InetAddressCachePolicy; import sun.net.util.IPAddressUtil; @@ -192,13 +193,13 @@ * Specify the address family: Internet Protocol, Version 4 * @since 1.4 */ - static final int IPv4 = 1; + @Native static final int IPv4 = 1; /** * Specify the address family: Internet Protocol, Version 6 * @since 1.4 */ - static final int IPv6 = 2; + @Native static final int IPv6 = 2; /* Specify address family preference */ static transient boolean preferIPv6Address = false;
--- a/src/share/native/java/net/net_util.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/share/native/java/net/net_util.c Wed Apr 29 13:33:10 2020 +0100 @@ -23,18 +23,17 @@ * questions. */ -#include "jni.h" -#include "jvm.h" -#include "jni_util.h" #include "net_util.h" -int IPv6_supported() ; +#include "java_net_InetAddress.h" + +int IPv6_supported(); static int IPv6_available; JNIEXPORT jint JNICALL ipv6_available() { - return IPv6_available ; + return IPv6_available; } JNIEXPORT jint JNICALL @@ -203,11 +202,7 @@ jobject iaObj; #ifdef AF_INET6 if (him->sa_family == AF_INET6) { -#ifdef WIN32 - struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him; -#else struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; -#endif jbyte *caddr = (jbyte *)&(him6->sin6_addr); if (NET_IsIPv4Mapped(caddr)) { int address; @@ -216,7 +211,7 @@ address = NET_IPv4MappedToIPv4(caddr); setInetAddress_addr(env, iaObj, address); JNU_CHECK_EXCEPTION_RETURN(env, NULL); - setInetAddress_family(env, iaObj, IPv4); + setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4); JNU_CHECK_EXCEPTION_RETURN(env, NULL); } else { jint scope; @@ -226,7 +221,7 @@ ret = setInet6Address_ipaddress(env, iaObj, (char *)&(him6->sin6_addr)); if (ret == JNI_FALSE) return NULL; - setInetAddress_family(env, iaObj, IPv6); + setInetAddress_family(env, iaObj, java_net_InetAddress_IPv6); JNU_CHECK_EXCEPTION_RETURN(env, NULL); scope = getScopeID(him); setInet6Address_scopeid(env, iaObj, scope); @@ -238,7 +233,7 @@ struct sockaddr_in *him4 = (struct sockaddr_in *)him; iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); CHECK_NULL_RETURN(iaObj, NULL); - setInetAddress_family(env, iaObj, IPv4); + setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4); JNU_CHECK_EXCEPTION_RETURN(env, NULL); setInetAddress_addr(env, iaObj, ntohl(him4->sin_addr.s_addr)); JNU_CHECK_EXCEPTION_RETURN(env, NULL); @@ -253,14 +248,11 @@ jint family = AF_INET; #ifdef AF_INET6 - family = getInetAddress_family(env, iaObj) == IPv4? AF_INET : AF_INET6; + family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ? + AF_INET : AF_INET6; JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE); if (him->sa_family == AF_INET6) { -#ifdef WIN32 - struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him; -#else struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; -#endif jbyte *caddrNew = (jbyte *)&(him6->sin6_addr); if (NET_IsIPv4Mapped(caddrNew)) { int addrNew;
--- a/src/share/native/java/net/net_util.h Wed Apr 29 12:56:13 2020 +0100 +++ b/src/share/native/java/net/net_util.h Wed Apr 29 13:33:10 2020 +0100 @@ -36,12 +36,6 @@ #define MAX_PACKET_LEN 65536 -#define IPv4 1 -#define IPv6 2 - -#define NET_ERROR(env, ex, msg) \ -{ if (!(*env)->ExceptionOccurred(env)) JNU_ThrowByName(env, ex, msg); } - /************************************************************************ * Cached field IDs * @@ -123,46 +117,44 @@ JNIEXPORT void JNICALL Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls); JNIEXPORT void JNICALL NET_ThrowNew(JNIEnv *env, int errorNum, char *msg); + int NET_GetError(); void NET_ThrowCurrent(JNIEnv *env, char *msg); jfieldID NET_GetFileDescriptorID(JNIEnv *env); -JNIEXPORT jint JNICALL ipv6_available() ; +JNIEXPORT jint JNICALL ipv6_available(); void NET_AllocSockaddr(struct sockaddr **him, int *len); JNIEXPORT int JNICALL -NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr *him, int *len, jboolean v4MappedAddress); +NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, + struct sockaddr *him, int *len, + jboolean v4MappedAddress); JNIEXPORT jobject JNICALL NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port); void platformInit(); + void parseExclusiveBindProperty(JNIEnv *env); -void -NET_SetTrafficClass(struct sockaddr *him, int trafficClass); +void NET_SetTrafficClass(struct sockaddr *him, int trafficClass); -JNIEXPORT jint JNICALL -NET_GetPortFromSockaddr(struct sockaddr *him); +JNIEXPORT jint JNICALL NET_GetPortFromSockaddr(struct sockaddr *him); JNIEXPORT jint JNICALL NET_SockaddrEqualsInetAddress(JNIEnv *env,struct sockaddr *him, jobject iaObj); -int -NET_IsIPv4Mapped(jbyte* caddr); +int NET_IsIPv4Mapped(jbyte* caddr); -int -NET_IPv4MappedToIPv4(jbyte* caddr); +int NET_IPv4MappedToIPv4(jbyte* caddr); -int -NET_IsEqual(jbyte* caddr1, jbyte* caddr2); +int NET_IsEqual(jbyte* caddr1, jbyte* caddr2); -int -NET_IsZeroAddr(jbyte* caddr); +int NET_IsZeroAddr(jbyte* caddr); /* Socket operations * @@ -188,9 +180,9 @@ JNIEXPORT jint JNICALL NET_EnableFastTcpLoopback(int fd); -int getScopeID (struct sockaddr *); +int getScopeID(struct sockaddr *); -int cmpScopeID (unsigned int, struct sockaddr *); +int cmpScopeID(unsigned int, struct sockaddr *); unsigned short in_cksum(unsigned short *addr, int len);
--- a/src/solaris/native/java/net/Inet4AddressImpl.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/solaris/native/java/net/Inet4AddressImpl.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,27 +22,17 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - +#include <ctype.h> #include <errno.h> -#include <sys/time.h> #include <sys/types.h> -#include <sys/socket.h> +#include <netinet/in.h> #include <netinet/in_systm.h> -#include <netinet/in.h> #include <netinet/ip.h> #include <netinet/ip_icmp.h> -#include <netdb.h> +#include <stdlib.h> #include <string.h> -#include <stdlib.h> -#include <ctype.h> +#include <sys/time.h> -#ifdef _ALLBSD_SOURCE -#include <unistd.h> -#include <sys/param.h> -#endif - -#include "jvm.h" -#include "jni_util.h" #include "net_util.h" #include "java_net_Inet4AddressImpl.h" @@ -294,13 +284,12 @@ addr |= ((caddr[2] <<8) & 0xff00); addr |= (caddr[3] & 0xff); memset((char *) &him4, 0, sizeof(him4)); - him4.sin_addr.s_addr = (uint32_t) htonl(addr); + him4.sin_addr.s_addr = htonl(addr); him4.sin_family = AF_INET; sa = (struct sockaddr *) &him4; len = sizeof(him4); - error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, - NI_NAMEREQD); + error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD); if (!error) { ret = (*env)->NewStringUTF(env, host); @@ -444,7 +433,7 @@ if (!skip) { struct addrinfo *next - = (struct addrinfo*) malloc(sizeof(struct addrinfo)); + = (struct addrinfo *)malloc(sizeof(struct addrinfo)); if (!next) { JNU_ThrowOutOfMemoryError(env, "Native heap allocation failed"); ret = NULL; @@ -533,13 +522,12 @@ addr |= ((caddr[2] <<8) & 0xff00); addr |= (caddr[3] & 0xff); memset((void *) &him4, 0, sizeof(him4)); - him4.sin_addr.s_addr = (uint32_t) htonl(addr); + him4.sin_addr.s_addr = htonl(addr); him4.sin_family = AF_INET; sa = (struct sockaddr *) &him4; len = sizeof(him4); - error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, - NI_NAMEREQD); + error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD); if (!error) { ret = (*env)->NewStringUTF(env, host);
--- a/src/solaris/native/java/net/Inet6AddressImpl.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/solaris/native/java/net/Inet6AddressImpl.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,29 +22,21 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - +#include <ctype.h> #include <errno.h> +#include <stdlib.h> +#include <string.h> #include <sys/time.h> #include <sys/types.h> -#include <sys/socket.h> #include <netinet/in.h> -#include <netdb.h> -#include <string.h> -#include <strings.h> -#include <stdlib.h> -#include <ctype.h> -#ifdef MACOSX +#include <netinet/icmp6.h> + +#if defined(_ALLBSD_SOURCE) #include <ifaddrs.h> #include <net/if.h> -#include <unistd.h> /* gethostname */ #endif -#include "jvm.h" -#include "jni_util.h" #include "net_util.h" -#ifndef IPV6_DEFS_H -#include <netinet/icmp6.h> -#endif #include "java_net_Inet4AddressImpl.h" #include "java_net_Inet6AddressImpl.h" @@ -487,24 +479,23 @@ addr |= ((caddr[2] <<8) & 0xff00); addr |= (caddr[3] & 0xff); memset((void *) &him4, 0, sizeof(him4)); - him4.sin_addr.s_addr = (uint32_t) htonl(addr); + him4.sin_addr.s_addr = htonl(addr); him4.sin_family = AF_INET; - sa = (struct sockaddr *) &him4; + sa = (struct sockaddr *)&him4; len = sizeof(him4); } else { /* * For IPv6 address construct a sockaddr_in6 structure. */ (*env)->GetByteArrayRegion(env, addrArray, 0, 16, caddr); - memset((void *) &him6, 0, sizeof(him6)); - memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr) ); + memset((void *)&him6, 0, sizeof(him6)); + memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr)); him6.sin6_family = AF_INET6; - sa = (struct sockaddr *) &him6 ; - len = sizeof(him6) ; + sa = (struct sockaddr *)&him6; + len = sizeof(him6); } - error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, - NI_NAMEREQD); + error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD); if (!error) { ret = (*env)->NewStringUTF(env, host);
--- a/src/solaris/native/java/net/NetworkInterface.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/solaris/native/java/net/NetworkInterface.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,55 +22,36 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - +#include <arpa/inet.h> #include <errno.h> -#include <strings.h> -#include <netinet/in.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <arpa/inet.h> #include <net/if.h> #include <net/if_arp.h> - -#if defined(__solaris__) -#include <sys/dlpi.h> -#include <fcntl.h> -#include <stropts.h> -#include <sys/sockio.h> -#endif - -#if defined(__linux__) +#include <stdlib.h> +#include <string.h> #include <sys/ioctl.h> -#include <sys/utsname.h> -#include <stdio.h> -#endif #if defined(_AIX) -#include <sys/ioctl.h> #include <netinet/in6_var.h> #include <sys/ndd_var.h> #include <sys/kinfo.h> #endif -#if defined(_ALLBSD_SOURCE) -#include <sys/param.h> -#include <sys/ioctl.h> +#if defined(__solaris__) +#include <stropts.h> +#include <sys/dlpi.h> #include <sys/sockio.h> -#if defined(__APPLE__) +#endif + +#if defined(_ALLBSD_SOURCE) #include <net/ethernet.h> -#include <net/if_var.h> #include <net/if_dl.h> -#include <netinet/in_var.h> #include <ifaddrs.h> #endif -#endif -#include "jvm.h" -#include "jni_util.h" #include "net_util.h" +#include "java_net_InetAddress.h" + #if defined(__linux__) #define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6" #elif defined(__solaris__) @@ -338,9 +319,9 @@ int family = getInetAddress_family(env, iaObj); JNU_CHECK_EXCEPTION_RETURN(env, NULL); - if (family == IPv4) { + if (family == java_net_InetAddress_IPv4) { family = AF_INET; - } else if (family == IPv6) { + } else if (family == java_net_InetAddress_IPv6) { family = AF_INET6; } else { return NULL; // Invalid family
--- a/src/solaris/native/java/net/PlainDatagramSocketImpl.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/solaris/native/java/net/PlainDatagramSocketImpl.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,29 +22,23 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - #include <errno.h> -#include <netinet/in.h> #include <stdlib.h> #include <string.h> -#include <sys/types.h> -#include <sys/socket.h> +#include <sys/ioctl.h> -#ifdef __solaris__ -#include <fcntl.h> -#include <unistd.h> -#include <stropts.h> +#if defined(__solaris__) +#include <sys/filio.h> +#endif -#ifndef BSD_COMP -#define BSD_COMP -#endif -#endif +#include "net_util.h" + +#include "java_net_PlainDatagramSocketImpl.h" +#include "java_net_InetAddress.h" +#include "java_net_NetworkInterface.h" +#include "java_net_SocketOptions.h" + #ifdef __linux__ -#include <unistd.h> -#include <sys/sysctl.h> -#include <sys/utsname.h> -#include <netinet/ip.h> - #define IPV6_MULTICAST_IF 17 #ifndef SO_BSDCOMPAT #define SO_BSDCOMPAT 14 @@ -58,7 +52,11 @@ #endif #endif // __linux__ -#include <sys/ioctl.h> +#ifdef __solaris__ +#ifndef BSD_COMP +#define BSD_COMP +#endif +#endif #ifndef IPTOS_TOS_MASK #define IPTOS_TOS_MASK 0x1e @@ -67,13 +65,6 @@ #define IPTOS_PREC_MASK 0xe0 #endif -#include "jvm.h" -#include "jni_util.h" -#include "net_util.h" - -#include "java_net_SocketOptions.h" -#include "java_net_PlainDatagramSocketImpl.h" -#include "java_net_NetworkInterface.h" /************************************************************************ * PlainDatagramSocketImpl */ @@ -151,9 +142,6 @@ JNIEXPORT void JNICALL Java_java_net_PlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) { -#ifdef __linux__ - struct utsname sysinfo; -#endif pdsi_fdID = (*env)->GetFieldID(env, cls, "fd", "Ljava/io/FileDescriptor;"); CHECK_NULL(pdsi_fdID); @@ -551,7 +539,8 @@ iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&remote_addr, &port); #ifdef AF_INET6 - family = getInetAddress_family(env, iaObj) == IPv4? AF_INET : AF_INET6; + family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ? + AF_INET : AF_INET6; JNU_CHECK_EXCEPTION_RETURN(env, -1); #else family = AF_INET; @@ -1077,7 +1066,7 @@ addr = (*env)->GetObjectArrayElement(env, addrArray, i); family = getInetAddress_family(env, addr); JNU_CHECK_EXCEPTION(env); - if (family == IPv4) { + if (family == java_net_InetAddress_IPv4) { JNU_CHECK_EXCEPTION(env); in.s_addr = htonl(getInetAddress_addr(env, addr)); JNU_CHECK_EXCEPTION(env); @@ -1967,7 +1956,7 @@ #ifdef __linux__ family = getInetAddress_family(env, iaObj); JNU_CHECK_EXCEPTION(env); - if (family == IPv4) { + if (family == java_net_InetAddress_IPv4) { JNU_CHECK_EXCEPTION(env); ipv6_join_leave = JNI_FALSE; } @@ -2165,7 +2154,8 @@ jbyte caddr[16]; jint family; jint address; - family = getInetAddress_family(env, iaObj) == IPv4? AF_INET : AF_INET6; + family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ? + AF_INET : AF_INET6; JNU_CHECK_EXCEPTION(env); if (family == AF_INET) { /* will convert to IPv4-mapped address */ memset((char *) caddr, 0, 16);
--- a/src/solaris/native/java/net/PlainSocketImpl.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/solaris/native/java/net/PlainSocketImpl.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,32 +22,8 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ +#include <errno.h> -#include <errno.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> -#if defined(__linux__) -#include <sys/poll.h> -#endif -#include <netinet/tcp.h> /* Defines TCP_NODELAY, needed for 2.6 */ -#include <netinet/in.h> -#ifdef __linux__ -#include <netinet/ip.h> -#endif -#include <netdb.h> -#include <stdlib.h> - -#ifdef __solaris__ -#include <fcntl.h> -#endif -#ifdef __linux__ -#include <unistd.h> -#include <sys/sysctl.h> -#endif - -#include "jvm.h" -#include "jni_util.h" #include "net_util.h" #include "java_net_SocketOptions.h"
--- a/src/solaris/native/java/net/SocketInputStream.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/solaris/native/java/net/SocketInputStream.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,21 +22,15 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - +#include <errno.h> #include <stdlib.h> -#include <errno.h> #include <string.h> -#include <sys/types.h> -#include <sys/socket.h> -#include "jvm.h" -#include "jni_util.h" #include "net_util.h" #include "java_net_SocketInputStream.h" - -/************************************************************************ +/* * SocketInputStream */
--- a/src/solaris/native/java/net/SocketOutputStream.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/solaris/native/java/net/SocketOutputStream.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,15 +22,10 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - +#include <errno.h> #include <stdlib.h> -#include <errno.h> #include <string.h> -#include <sys/types.h> -#include <sys/socket.h> -#include "jni_util.h" -#include "jvm.h" #include "net_util.h" #include "java_net_SocketOutputStream.h"
--- a/src/solaris/native/java/net/net_util_md.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/solaris/native/java/net/net_util_md.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,60 +22,42 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - +#include <dlfcn.h> #include <errno.h> +#include <net/if.h> +#include <netinet/tcp.h> // defines TCP_NODELAY +#include <stdlib.h> #include <string.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/tcp.h> /* Defines TCP_NODELAY, needed for 2.6 */ -#include <netinet/in.h> -#include <net/if.h> -#include <netdb.h> -#include <stdlib.h> -#include <dlfcn.h> +#include <sys/ioctl.h> #include <sys/time.h> -#ifndef _ALLBSD_SOURCE -#include <values.h> -#else -#include <limits.h> -#include <sys/param.h> -#include <sys/sysctl.h> -#include <sys/ioctl.h> -#ifndef MAXINT -#define MAXINT INT_MAX -#endif -#endif - -#ifdef __solaris__ -#include <sys/filio.h> -#include <sys/sockio.h> -#include <stropts.h> -#include <inet/nd.h> -#endif - -#ifdef __linux__ -#include <sys/ioctl.h> +#if defined(__linux__) #include <arpa/inet.h> #include <net/route.h> #include <sys/utsname.h> +#endif -#ifndef IPV6_FLOWINFO_SEND +#if defined(__solaris__) +#include <inet/nd.h> +#include <limits.h> +#include <stropts.h> +#include <sys/filio.h> +#include <sys/sockio.h> +#endif + +#include "net_util.h" + +#include "java_net_SocketOptions.h" +#include "java_net_InetAddress.h" + +#if defined(__linux__) && !defined(IPV6_FLOWINFO_SEND) #define IPV6_FLOWINFO_SEND 33 #endif -#endif - -#ifdef _AIX -#include <sys/ioctl.h> +#if defined(__solaris__) && !defined(MAXINT) +#define MAXINT INT_MAX #endif -#include "jni_util.h" -#include "jvm.h" -#include "net_util.h" - -#include "java_net_SocketOptions.h" - /* * EXCLBIND socket options only on Solaris */ @@ -814,13 +796,15 @@ JNU_CHECK_EXCEPTION_RETURN(env, -1); #ifdef AF_INET6 /* needs work. 1. family 2. clean up him6 etc deallocate memory */ - if (ipv6_available() && !(family == IPv4 && v4MappedAddress == JNI_FALSE)) { + if (ipv6_available() && !(family == java_net_InetAddress_IPv4 && + v4MappedAddress == JNI_FALSE)) { struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; jbyte caddr[16]; jint address; - if (family == IPv4) { /* will convert to IPv4-mapped address */ + if (family == java_net_InetAddress_IPv4) { + // convert to IPv4-mapped address memset((char *) caddr, 0, 16); address = getInetAddress_addr(env, iaObj); JNU_CHECK_EXCEPTION_RETURN(env, -1); @@ -915,7 +899,7 @@ #else /* handle scope_id for solaris */ - if (family != IPv4) { + if (family != java_net_InetAddress_IPv4) { if (ia6_scopeidID) { him6->sin6_scope_id = getInet6Address_scopeid(env, iaObj); } @@ -926,7 +910,7 @@ { struct sockaddr_in *him4 = (struct sockaddr_in*)him; jint address; - if (family == IPv6) { + if (family == java_net_InetAddress_IPv6) { JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family unavailable"); return -1; } @@ -934,7 +918,7 @@ address = getInetAddress_addr(env, iaObj); JNU_CHECK_EXCEPTION_RETURN(env, -1); him4->sin_port = htons((short) port); - him4->sin_addr.s_addr = (uint32_t) htonl(address); + him4->sin_addr.s_addr = htonl(address); him4->sin_family = AF_INET; *len = sizeof(struct sockaddr_in); }
--- a/src/solaris/native/java/net/net_util_md.h Wed Apr 29 12:56:13 2020 +0100 +++ b/src/solaris/native/java/net/net_util_md.h Wed Apr 29 13:33:10 2020 +0100 @@ -26,13 +26,9 @@ #ifndef NET_UTILS_MD_H #define NET_UTILS_MD_H +#include <netdb.h> +#include <sys/poll.h> #include <sys/socket.h> -#include <sys/types.h> -#include <netdb.h> -#include <netinet/in.h> -#include <unistd.h> - -#include <sys/poll.h> int NET_Timeout(int s, long timeout); int NET_Timeout0(int s, long timeout, long currentTime);
--- a/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,10 +22,8 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -#include <windows.h> -#include <winsock2.h> -#include "jni.h" #include "net_util.h" + #include "java_net_DualStackPlainDatagramSocketImpl.h" /*
--- a/src/windows/native/java/net/DualStackPlainSocketImpl.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/windows/native/java/net/DualStackPlainSocketImpl.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,11 +22,10 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -#include <windows.h> -#include <winsock2.h> -#include "jni.h" #include "net_util.h" + #include "java_net_DualStackPlainSocketImpl.h" +#include "java_net_SocketOptions.h" #define SET_BLOCKING 0 #define SET_NONBLOCKING 1
--- a/src/windows/native/java/net/Inet4AddressImpl.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/windows/native/java/net/Inet4AddressImpl.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,24 +22,12 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ +#include <malloc.h> -#include <windows.h> -#include <winsock2.h> -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <malloc.h> -#include <sys/types.h> -#include <process.h> -#include <iphlpapi.h> -#include <icmpapi.h> -#include <WinError.h> +#include "net_util.h" #include "java_net_InetAddress.h" #include "java_net_Inet4AddressImpl.h" -#include "net_util.h" -#include "icmp.h" - /* * Returns true if hostname is in dotted IP address format. Note that this
--- a/src/windows/native/java/net/Inet6AddressImpl.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/windows/native/java/net/Inet6AddressImpl.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,38 +22,13 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ +#include <malloc.h> -#include <windows.h> -#include <winsock2.h> -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <malloc.h> -#include <sys/types.h> -#include <process.h> -#include <iphlpapi.h> -#include <icmpapi.h> +#include "net_util.h" #include "java_net_InetAddress.h" #include "java_net_Inet4AddressImpl.h" #include "java_net_Inet6AddressImpl.h" -#include "net_util.h" -#include "icmp.h" - -#ifdef WIN32 -#ifndef _WIN64 - -/* Retain this code a little longer to support building in - * old environments. _MSC_VER is defined as: - * 1200 for MSVC++ 6.0 - * 1310 for Vc7 - */ -#if defined(_MSC_VER) && _MSC_VER < 1310 -#define sockaddr_in6 SOCKADDR_IN6 -#endif -#endif -#define uint32_t UINT32 -#endif /* * Inet6AddressImpl @@ -300,7 +275,7 @@ addr |= ((caddr[2] <<8) & 0xff00); addr |= (caddr[3] & 0xff); memset((char *) &him4, 0, sizeof(him4)); - him4.sin_addr.s_addr = (uint32_t) htonl(addr); + him4.sin_addr.s_addr = htonl(addr); him4.sin_family = AF_INET; sa = (struct sockaddr *) &him4; len = sizeof(him4);
--- a/src/windows/native/java/net/NetworkInterface.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/windows/native/java/net/NetworkInterface.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,17 +22,10 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - -#include <stdlib.h> -#include <windows.h> -#include <winsock2.h> /* needed for htonl */ -#include <iprtrmib.h> -#include <assert.h> +#include "net_util.h" +#include "NetworkInterface.h" #include "java_net_NetworkInterface.h" -#include "jni_util.h" - -#include "NetworkInterface.h" /* * Windows implementation of the java.net.NetworkInterface native methods.
--- a/src/windows/native/java/net/NetworkInterface.h Wed Apr 29 12:56:13 2020 +0100 +++ b/src/windows/native/java/net/NetworkInterface.h Wed Apr 29 13:33:10 2020 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #ifndef NETWORK_INTERFACE_H #define NETWORK_INTERFACE_H -#include <iphlpapi.h> #include "net_util.h" /*
--- a/src/windows/native/java/net/NetworkInterface_winXP.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/windows/native/java/net/NetworkInterface_winXP.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,19 +22,10 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - -#include <stdlib.h> -#include <windows.h> -#include <winsock2.h> /* needed for htonl */ -#include <iprtrmib.h> -#include <assert.h> -#include <limits.h> +#include "net_util.h" +#include "NetworkInterface.h" #include "java_net_NetworkInterface.h" -#include "jni_util.h" - -#include "NetworkInterface.h" -#include "net_util.h" /* * Windows implementation of the java.net.NetworkInterface native methods.
--- a/src/windows/native/java/net/SocketInputStream.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/windows/native/java/net/SocketInputStream.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,24 +22,15 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ +#include <malloc.h> -#include <windows.h> -#include <winsock2.h> -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <malloc.h> -#include <sys/types.h> +#include "net_util.h" #include "java_net_SocketInputStream.h" -#include "net_util.h" -#include "jni_util.h" - /************************************************************************* * SocketInputStream */ - static jfieldID IO_fd_fdID; /*
--- a/src/windows/native/java/net/SocketOutputStream.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/windows/native/java/net/SocketOutputStream.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,20 +22,12 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ +#include <malloc.h> -#include <windows.h> -#include <winsock2.h> -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <malloc.h> -#include <sys/types.h> +#include "net_util.h" #include "java_net_SocketOutputStream.h" -#include "net_util.h" -#include "jni_util.h" - /************************************************************************ * SocketOutputStream */
--- a/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,15 +22,15 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ +#include <malloc.h> -#include <windows.h> -#include <winsock2.h> -#include <ws2tcpip.h> -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <malloc.h> -#include <sys/types.h> +#include "net_util.h" +#include "NetworkInterface.h" + +#include "java_net_TwoStacksPlainDatagramSocketImpl.h" +#include "java_net_SocketOptions.h" +#include "java_net_NetworkInterface.h" +#include "java_net_InetAddress.h" #ifndef IPTOS_TOS_MASK #define IPTOS_TOS_MASK 0x1e @@ -39,14 +39,6 @@ #define IPTOS_PREC_MASK 0xe0 #endif -#include "java_net_TwoStacksPlainDatagramSocketImpl.h" -#include "java_net_SocketOptions.h" -#include "java_net_NetworkInterface.h" - -#include "NetworkInterface.h" -#include "jvm.h" -#include "jni_util.h" -#include "net_util.h" #define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000) #define IN_MULTICAST(i) IN_CLASSD(i) @@ -440,7 +432,7 @@ family = getInetAddress_family(env, addressObj); JNU_CHECK_EXCEPTION(env); - if (family == IPv6 && !ipv6_supported) { + if (family == java_net_InetAddress_IPv6 && !ipv6_supported) { JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family not supported"); return; @@ -566,13 +558,13 @@ JNU_CHECK_EXCEPTION(env); family = getInetAddress_family(env, address); JNU_CHECK_EXCEPTION(env); - if (family == IPv6 && !ipv6_supported) { + if (family == java_net_InetAddress_IPv6 && !ipv6_supported) { JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family not supported"); return; } - fdc = family == IPv4? fd: fd1; + fdc = family == java_net_InetAddress_IPv4 ? fd : fd1; if (xp_or_later) { /* SIO_UDP_CONNRESET fixes a bug introduced in Windows 2000, which @@ -609,12 +601,12 @@ jint fd, len; SOCKETADDRESS addr; - if (family == IPv4) { + if (family == java_net_InetAddress_IPv4) { fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); - len = sizeof (struct sockaddr_in); + len = sizeof(struct sockaddr_in); } else { fdObj = (*env)->GetObjectField(env, this, pdsi_fd1ID); - len = sizeof (struct SOCKADDR_IN6); + len = sizeof(struct sockaddr_in6); } if (IS_NULL(fdObj)) { @@ -684,7 +676,7 @@ family = getInetAddress_family(env, iaObj); JNU_CHECK_EXCEPTION(env); - if (family == IPv4) { + if (family == java_net_InetAddress_IPv4) { fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); } else { if (!ipv6_available()) { @@ -915,7 +907,7 @@ } setInetAddress_addr(env, addressObj, ntohl(remote_addr.sin_addr.s_addr)); JNU_CHECK_EXCEPTION_RETURN(env, -1); - setInetAddress_family(env, addressObj, IPv4); + setInetAddress_family(env, addressObj, java_net_InetAddress_IPv4); JNU_CHECK_EXCEPTION_RETURN(env, -1); /* return port */ @@ -1621,7 +1613,7 @@ { jobject addr; - int ret = getInetAddrFromIf (env, IPv4, nif, &addr); + int ret = getInetAddrFromIf(env, java_net_InetAddress_IPv4, nif, &addr); if (ret == -1) { return -1; } @@ -2299,9 +2291,9 @@ len = sizeof (struct sockaddr_in); /* family==-1 when socket is not connected */ - if ((family == IPv6) || (family == -1 && fd == -1)) { + if ((family == java_net_InetAddress_IPv6) || (family == -1 && fd == -1)) { fd = fd1; /* must be IPv6 only */ - len = sizeof (struct SOCKADDR_IN6); + len = sizeof(struct sockaddr_in6); } if (fd == -1) {
--- a/src/windows/native/java/net/TwoStacksPlainSocketImpl.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/windows/native/java/net/TwoStacksPlainSocketImpl.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,23 +22,13 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - -#include <windows.h> -#include <winsock2.h> -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> #include <malloc.h> -#include <sys/types.h> - -#include "java_net_SocketOptions.h" -#include "java_net_TwoStacksPlainSocketImpl.h" -#include "java_net_InetAddress.h" -#include "java_io_FileDescriptor.h" -#include "java_lang_Integer.h" #include "net_util.h" -#include "jni_util.h" + +#include "java_net_TwoStacksPlainSocketImpl.h" +#include "java_net_SocketOptions.h" +#include "java_net_InetAddress.h" /************************************************************************ * TwoStacksPlainSocketImpl @@ -415,7 +405,7 @@ family = getInetAddress_family(env, iaObj); JNU_CHECK_EXCEPTION(env); - if (family == IPv6 && !ipv6_supported) { + if (family == java_net_InetAddress_IPv6 && !ipv6_supported) { JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family not supported"); return; @@ -657,18 +647,18 @@ return; } if (fd2 == fd) { /* v4 */ - len = sizeof (struct sockaddr_in); + len = sizeof(struct sockaddr_in); } else { - len = sizeof (struct SOCKADDR_IN6); + len = sizeof(struct sockaddr_in6); } fd = fd2; } else { int ret; if (fd1 != -1) { fd = fd1; - len = sizeof (struct SOCKADDR_IN6); + len = sizeof(struct sockaddr_in6); } else { - len = sizeof (struct sockaddr_in); + len = sizeof(struct sockaddr_in); } if (timeout) { ret = NET_Timeout(fd, timeout); @@ -731,7 +721,7 @@ setInetAddress_addr(env, socketAddressObj, ntohl(him.him4.sin_addr.s_addr)); JNU_CHECK_EXCEPTION(env); - setInetAddress_family(env, socketAddressObj, IPv4); + setInetAddress_family(env, socketAddressObj, java_net_InetAddress_IPv4); JNU_CHECK_EXCEPTION(env); (*env)->SetObjectField(env, socket, psi_addressID, socketAddressObj); } else { @@ -758,7 +748,7 @@ return; } setInet6Address_ipaddress(env, socketAddressObj, (char *)&him.him6.sin6_addr); - setInetAddress_family(env, socketAddressObj, IPv6); + setInetAddress_family(env, socketAddressObj, java_net_InetAddress_IPv6); JNU_CHECK_EXCEPTION(env); setInet6Address_scopeid(env, socketAddressObj, him.him6.sin6_scope_id);
--- a/src/windows/native/java/net/icmp.h Wed Apr 29 12:56:13 2020 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef ICMP_H -#define ICMP_H - -/* - * Structure of an internet header, naked of options. - * - * We declare ip_len and ip_off to be short, rather than ushort_t - * pragmatically since otherwise unsigned comparisons can result - * against negative integers quite easily, and fail in subtle ways. - */ -struct ip { - unsigned char ip_hl:4, /* header length */ - ip_v:4; /* version */ - unsigned char ip_tos; /* type of service */ - short ip_len; /* total length */ - unsigned short ip_id; /* identification */ - short ip_off; /* fragment offset field */ -#define IP_DF 0x4000 /* don't fragment flag */ -#define IP_MF 0x2000 /* more fragments flag */ - unsigned char ip_ttl; /* time to live */ - unsigned char ip_p; /* protocol */ - unsigned short ip_sum; /* checksum */ - struct in_addr ip_src, ip_dst; /* source and dest address */ -}; - -/* - * Structure of an icmp header. - */ -struct icmp { - unsigned char icmp_type; /* type of message, see below */ - unsigned char icmp_code; /* type sub code */ - unsigned short icmp_cksum; /* ones complement cksum of struct */ - union { - unsigned char ih_pptr; /* ICMP_PARAMPROB */ - struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ - struct ih_idseq { - unsigned short icd_id; - unsigned short icd_seq; - } ih_idseq; - int ih_void; - - /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ - struct ih_pmtu { - unsigned short ipm_void; - unsigned short ipm_nextmtu; - } ih_pmtu; - - struct ih_rtradv { - unsigned char irt_num_addrs; - unsigned char irt_wpa; - unsigned short irt_lifetime; - } ih_rtradv; - } icmp_hun; -#define icmp_pptr icmp_hun.ih_pptr -#define icmp_gwaddr icmp_hun.ih_gwaddr -#define icmp_id icmp_hun.ih_idseq.icd_id -#define icmp_seq icmp_hun.ih_idseq.icd_seq -#define icmp_void icmp_hun.ih_void -#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void -#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu - union { - struct id_ts { - unsigned int its_otime; - unsigned int its_rtime; - unsigned int its_ttime; - } id_ts; - struct id_ip { - struct ip idi_ip; - /* options and then 64 bits of data */ - } id_ip; - unsigned int id_mask; - char id_data[1]; - } icmp_dun; -#define icmp_otime icmp_dun.id_ts.its_otime -#define icmp_rtime icmp_dun.id_ts.its_rtime -#define icmp_ttime icmp_dun.id_ts.its_ttime -#define icmp_ip icmp_dun.id_ip.idi_ip -#define icmp_mask icmp_dun.id_mask -#define icmp_data icmp_dun.id_data -}; - -#define ICMP_ECHOREPLY 0 /* echo reply */ -#define ICMP_ECHO 8 /* echo service */ - -/* - * ICMPv6 structures & constants - */ - -typedef struct icmp6_hdr { - u_char icmp6_type; /* type field */ - u_char icmp6_code; /* code field */ - u_short icmp6_cksum; /* checksum field */ - union { - u_int icmp6_un_data32[1]; /* type-specific field */ - u_short icmp6_un_data16[2]; /* type-specific field */ - u_char icmp6_un_data8[4]; /* type-specific field */ - } icmp6_dataun; -} icmp6_t; - -#define icmp6_data32 icmp6_dataun.icmp6_un_data32 -#define icmp6_data16 icmp6_dataun.icmp6_un_data16 -#define icmp6_data8 icmp6_dataun.icmp6_un_data8 -#define icmp6_pptr icmp6_data32[0] /* parameter prob */ -#define icmp6_mtu icmp6_data32[0] /* packet too big */ -#define icmp6_id icmp6_data16[0] /* echo request/reply */ -#define icmp6_seq icmp6_data16[1] /* echo request/reply */ -#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ - -struct ip6_pseudo_hdr /* for calculate the ICMPv6 checksum */ -{ - struct in6_addr ip6_src; - struct in6_addr ip6_dst; - u_int ip6_plen; - u_int ip6_nxt; -}; - -#define ICMP6_ECHO_REQUEST 128 -#define ICMP6_ECHO_REPLY 129 -#define IPPROTO_ICMPV6 58 -#define IPV6_UNICAST_HOPS 4 /* Set/get IP unicast hop limit */ - - -#endif
--- a/src/windows/native/java/net/net_util_md.c Wed Apr 29 12:56:13 2020 +0100 +++ b/src/windows/native/java/net/net_util_md.c Wed Apr 29 13:33:10 2020 +0100 @@ -22,12 +22,10 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ +#include "net_util.h" -#include <winsock2.h> -#include <ws2tcpip.h> - -#include "net_util.h" -#include "jni.h" +#include "java_net_InetAddress.h" +#include "java_net_SocketOptions.h" // Taken from mstcpip.h in Windows SDK 8.0 or newer. #define SIO_LOOPBACK_FAST_PATH _WSAIOW(IOC_VENDOR,16) @@ -601,7 +599,7 @@ void dumpAddr (char *str, void *addr) { - struct SOCKADDR_IN6 *a = (struct SOCKADDR_IN6 *)addr; + struct sockaddr_in6 *a = (struct sockaddr_in6 *)addr; int family = a->sin6_family; printf ("%s\n", str); if (family == AF_INET) { @@ -821,7 +819,7 @@ * 0 if error * > 0 interface index to use */ -jint getDefaultIPv6Interface(JNIEnv *env, struct SOCKADDR_IN6 *target_addr) +jint getDefaultIPv6Interface(JNIEnv *env, struct sockaddr_in6 *target_addr) { int ret; DWORD b; @@ -876,9 +874,9 @@ jint family, iafam; iafam = getInetAddress_family(env, iaObj); JNU_CHECK_EXCEPTION_RETURN(env, -1); - family = (iafam == IPv4)? AF_INET : AF_INET6; + family = (iafam == java_net_InetAddress_IPv4)? AF_INET : AF_INET6; if (ipv6_available() && !(family == AF_INET && v4MappedAddress == JNI_FALSE)) { - struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him; + struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; jbyte caddr[16]; jint address, scopeid = 0; jint cached_scope_id = 0; @@ -905,7 +903,7 @@ cached_scope_id = (jint)(*env)->GetIntField(env, iaObj, ia6_cachedscopeidID); } - memset((char *)him6, 0, sizeof(struct SOCKADDR_IN6)); + memset((char *)him6, 0, sizeof(struct sockaddr_in6)); him6->sin6_port = (u_short) htons((u_short)port); memcpy((void *)&(him6->sin6_addr), caddr, sizeof(struct in6_addr) ); him6->sin6_family = AF_INET6; @@ -915,7 +913,7 @@ (*env)->SetIntField(env, iaObj, ia6_cachedscopeidID, cached_scope_id); } him6->sin6_scope_id = scopeid != 0 ? scopeid : cached_scope_id; - *len = sizeof(struct SOCKADDR_IN6) ; + *len = sizeof(struct sockaddr_in6) ; } else { struct sockaddr_in *him4 = (struct sockaddr_in*)him; jint address; @@ -976,12 +974,12 @@ } int getScopeID (struct sockaddr *him) { - struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him; + struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; return him6->sin6_scope_id; } int cmpScopeID (unsigned int scope, struct sockaddr *him) { - struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him; + struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; return him6->sin6_scope_id == scope; }
--- a/src/windows/native/java/net/net_util_md.h Wed Apr 29 12:56:13 2020 +0100 +++ b/src/windows/native/java/net/net_util_md.h Wed Apr 29 13:33:10 2020 +0100 @@ -22,192 +22,10 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - #include <winsock2.h> #include <WS2tcpip.h> - -/* typedefs that were defined correctly for the first time - * in Nov. 2001 SDK, which we need to include here. - * Specifically, in6_addr and sockaddr_in6 (which is defined but - * not correctly). When moving to a later SDK remove following - * code between START and END - */ - -/* --- START --- */ - -/* WIN64 already uses newer SDK */ -#ifdef _WIN64 - -#define SOCKADDR_IN6 sockaddr_in6 - -#else - -#ifdef _MSC_VER -#define WS2TCPIP_INLINE __inline -#else -#define WS2TCPIP_INLINE extern inline /* GNU style */ -#endif - -#if defined(_MSC_VER) && _MSC_VER >= 1310 - -#define SOCKADDR_IN6 sockaddr_in6 - -#else - -/* Retain this code a little longer to support building in - * old environments. _MSC_VER is defined as: - * 1200 for MSVC++ 6.0 - * 1310 for Vc7 - */ - -#define IPPROTO_IPV6 41 -#define IPV6_MULTICAST_IF 9 - -struct in6_addr { - union { - u_char Byte[16]; - u_short Word[8]; - } u; -}; - -/* -** Defines to match RFC 2553. -*/ -#define _S6_un u -#define _S6_u8 Byte -#define s6_addr _S6_un._S6_u8 - -/* -** Defines for our implementation. -*/ -#define s6_bytes u.Byte -#define s6_words u.Word - -/* IPv6 socket address structure, RFC 2553 */ - -struct SOCKADDR_IN6 { - short sin6_family; /* AF_INET6 */ - u_short sin6_port; /* Transport level port number */ - u_long sin6_flowinfo; /* IPv6 flow information */ - struct in6_addr sin6_addr; /* IPv6 address */ - u_long sin6_scope_id; /* set of interfaces for a scope */ -}; - - -/* Error codes from getaddrinfo() */ - -#define EAI_AGAIN WSATRY_AGAIN -#define EAI_BADFLAGS WSAEINVAL -#define EAI_FAIL WSANO_RECOVERY -#define EAI_FAMILY WSAEAFNOSUPPORT -#define EAI_MEMORY WSA_NOT_ENOUGH_MEMORY -//#define EAI_NODATA WSANO_DATA -#define EAI_NONAME WSAHOST_NOT_FOUND -#define EAI_SERVICE WSATYPE_NOT_FOUND -#define EAI_SOCKTYPE WSAESOCKTNOSUPPORT - -#define EAI_NODATA EAI_NONAME - -/* Structure used in getaddrinfo() call */ - -typedef struct addrinfo { - int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */ - int ai_family; /* PF_xxx */ - int ai_socktype; /* SOCK_xxx */ - int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ - size_t ai_addrlen; /* Length of ai_addr */ - char *ai_canonname; /* Canonical name for nodename */ - struct sockaddr *ai_addr; /* Binary address */ - struct addrinfo *ai_next; /* Next structure in linked list */ -} ADDRINFO, FAR * LPADDRINFO; - -/* Flags used in "hints" argument to getaddrinfo() */ - -#define AI_PASSIVE 0x1 /* Socket address will be used in bind() call */ -#define AI_CANONNAME 0x2 /* Return canonical name in first ai_canonname */ -#define AI_NUMERICHOST 0x4 /* Nodename must be a numeric address string */ - -/* IPv6 Multicasting definitions */ - -/* Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP */ - -typedef struct ipv6_mreq { - struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast address */ - unsigned int ipv6mr_interface; /* Interface index */ -} IPV6_MREQ; - -#define IPV6_ADD_MEMBERSHIP 12 /* Add an IP group membership */ -#define IPV6_DROP_MEMBERSHIP 13 /* Drop an IP group membership */ -#define IPV6_MULTICAST_LOOP 11 /* Set/get IP multicast loopback */ - -WS2TCPIP_INLINE int -IN6_IS_ADDR_MULTICAST(const struct in6_addr *a) -{ - return (a->s6_bytes[0] == 0xff); -} - -WS2TCPIP_INLINE int -IN6_IS_ADDR_LINKLOCAL(const struct in6_addr *a) -{ - return (a->s6_bytes[0] == 0xfe - && a->s6_bytes[1] == 0x80); -} - -#define NI_MAXHOST 1025 /* Max size of a fully-qualified domain name */ -#define NI_MAXSERV 32 /* Max size of a service name */ - -#define INET_ADDRSTRLEN 16 /* Max size of numeric form of IPv4 address */ -#define INET6_ADDRSTRLEN 46 /* Max size of numeric form of IPv6 address */ - -/* Flags for getnameinfo() */ - -#define NI_NOFQDN 0x01 /* Only return nodename portion for local hosts */ -#define NI_NUMERICHOST 0x02 /* Return numeric form of the host's address */ -#define NI_NAMEREQD 0x04 /* Error if the host's name not in DNS */ -#define NI_NUMERICSERV 0x08 /* Return numeric form of the service (port #) */ -#define NI_DGRAM 0x10 /* Service is a datagram service */ - - -#define IN6_IS_ADDR_V4MAPPED(a) \ - (((a)->s6_words[0] == 0) && ((a)->s6_words[1] == 0) && \ - ((a)->s6_words[2] == 0) && ((a)->s6_words[3] == 0) && \ - ((a)->s6_words[4] == 0) && ((a)->s6_words[5] == 0xffff)) - - -/* --- END --- */ -#endif /* end 'else older build environment' */ - -#endif - -#if !INCL_WINSOCK_API_TYPEDEFS - -typedef -int -(WSAAPI * LPFN_GETADDRINFO)( - IN const char FAR * nodename, - IN const char FAR * servname, - IN const struct addrinfo FAR * hints, - OUT struct addrinfo FAR * FAR * res - ); - -typedef -void -(WSAAPI * LPFN_FREEADDRINFO)( - IN struct addrinfo FAR * ai - ); - -typedef -int -(WSAAPI * LPFN_GETNAMEINFO)( - IN const struct sockaddr FAR * sa, - IN int salen, - OUT char FAR * host, - IN DWORD hostlen, - OUT char FAR * serv, - IN DWORD servlen, - IN int flags - ); -#endif +#include <iphlpapi.h> +#include <icmpapi.h> /* used to disable connection reset messages on Windows XP */ #ifndef SIO_UDP_CONNRESET @@ -226,13 +44,9 @@ #define IPV6_V6ONLY 27 /* Treat wildcard bind as AF_INET6-only. */ #endif -#include "java_io_FileDescriptor.h" -#include "java_net_SocketOptions.h" - #define MAX_BUFFER_LEN 2048 #define MAX_HEAP_BUFFER_LEN 65536 - /* true if SO_RCVTIMEO is supported by underlying provider */ extern jboolean isRcvTimeoutSupported; @@ -246,7 +60,7 @@ typedef union { struct sockaddr him; struct sockaddr_in him4; - struct SOCKADDR_IN6 him6; + struct sockaddr_in6 sa6; } SOCKETADDRESS; /* @@ -265,7 +79,7 @@ #define SOCKETADDRESS_COPY(DST,SRC) { \ if ((SRC)->sa_family == AF_INET6) { \ - memcpy ((DST), (SRC), sizeof (struct SOCKADDR_IN6)); \ + memcpy ((DST), (SRC), sizeof (struct sockaddr_in6)); \ } else { \ memcpy ((DST), (SRC), sizeof (struct sockaddr_in)); \ } \