src/solaris/native/java/net/Inet6AddressImpl.c

Print this page

        

*** 68,79 **** Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { int ret; char hostname[NI_MAXHOST+1]; hostname[0] = '\0'; ! ret = JVM_GetHostName(hostname, sizeof(hostname)); ! if (ret) { /* Something went wrong, maybe networking is not setup? */ strcpy(hostname, "localhost"); } else { // ensure null-terminated hostname[NI_MAXHOST] = '\0'; --- 68,79 ---- Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { int ret; char hostname[NI_MAXHOST+1]; hostname[0] = '\0'; ! ret = gethostname(hostname, NI_MAXHOST); ! if (ret == -1) { /* Something went wrong, maybe networking is not setup? */ strcpy(hostname, "localhost"); } else { // ensure null-terminated hostname[NI_MAXHOST] = '\0';
*** 138,148 **** * from all attached interfaces. (#2844683 et al) This prevents undesired * PPP dialup, but may return addresses that don't actually correspond to * the name (if the name actually matches something in DNS etc. */ myhostname[0] = '\0'; ! if (JVM_GetHostName(myhostname, NI_MAXHOST)) { /* Something went wrong, maybe networking is not setup? */ return NULL; } myhostname[NI_MAXHOST] = '\0'; --- 138,148 ---- * from all attached interfaces. (#2844683 et al) This prevents undesired * PPP dialup, but may return addresses that don't actually correspond to * the name (if the name actually matches something in DNS etc. */ myhostname[0] = '\0'; ! if (gethostname(myhostname, NI_MAXHOST) == -1) { /* Something went wrong, maybe networking is not setup? */ return NULL; } myhostname[NI_MAXHOST] = '\0';
*** 709,727 **** * otherwise we'll try a tcp socket to the Echo port (7). * Note that this is empiric, and not connecting could mean it's blocked * or the echo service has been disabled. */ ! fd = JVM_Socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6); if (fd != -1) { /* Good to go, let's do a ping */ return ping6(env, fd, &him6, timeout, netif, ttl); } /* No good, let's fall back on TCP */ ! fd = JVM_Socket(AF_INET6, SOCK_STREAM, 0); ! if (fd == JVM_IO_ERR) { /* note: if you run out of fds, you may not be able to load * the exception class, and get a NoClassDefFoundError * instead. */ NET_ThrowNew(env, errno, "Can't create socket"); --- 709,727 ---- * otherwise we'll try a tcp socket to the Echo port (7). * Note that this is empiric, and not connecting could mean it's blocked * or the echo service has been disabled. */ ! fd = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6); if (fd != -1) { /* Good to go, let's do a ping */ return ping6(env, fd, &him6, timeout, netif, ttl); } /* No good, let's fall back on TCP */ ! fd = socket(AF_INET6, SOCK_STREAM, 0); ! if (fd == -1) { /* note: if you run out of fds, you may not be able to load * the exception class, and get a NoClassDefFoundError * instead. */ NET_ThrowNew(env, errno, "Can't create socket");
*** 741,763 **** return JNI_FALSE; } } SET_NONBLOCKING(fd); - /* no need to use NET_Connect as non-blocking */ him6.sin6_port = htons((short) 7); /* Echo port */ ! connect_rv = JVM_Connect(fd, (struct sockaddr *)&him6, len); /** * connection established or refused immediately, either way it means * we were able to reach the host! */ if (connect_rv == 0 || errno == ECONNREFUSED) { close(fd); return JNI_TRUE; } else { ! int optlen; switch (errno) { case ENETUNREACH: /* Network Unreachable */ case EAFNOSUPPORT: /* Address Family not supported */ case EADDRNOTAVAIL: /* address is not available on the remote machine */ --- 741,762 ---- return JNI_FALSE; } } SET_NONBLOCKING(fd); him6.sin6_port = htons((short) 7); /* Echo port */ ! connect_rv = NET_Connect(fd, (struct sockaddr *)&him6, len); /** * connection established or refused immediately, either way it means * we were able to reach the host! */ if (connect_rv == 0 || errno == ECONNREFUSED) { close(fd); return JNI_TRUE; } else { ! socklen_t optlen = (socklen_t)sizeof(connect_rv); switch (errno) { case ENETUNREACH: /* Network Unreachable */ case EAFNOSUPPORT: /* Address Family not supported */ case EADDRNOTAVAIL: /* address is not available on the remote machine */
*** 784,795 **** timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout); if (timeout >= 0) { /* has connection been established */ ! optlen = sizeof(connect_rv); ! if (JVM_GetSockOpt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv, &optlen) <0) { connect_rv = errno; } if (connect_rv == 0 || ECONNREFUSED) { close(fd); --- 783,793 ---- timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout); if (timeout >= 0) { /* has connection been established */ ! if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv, &optlen) <0) { connect_rv = errno; } if (connect_rv == 0 || ECONNREFUSED) { close(fd);