summaryrefslogtreecommitdiffstats
path: root/luni/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/main')
-rw-r--r--luni/src/main/java/java/net/InetAddress.java16
-rw-r--r--luni/src/main/native/java_net_InetAddress.cpp7
2 files changed, 17 insertions, 6 deletions
diff --git a/luni/src/main/java/java/net/InetAddress.java b/luni/src/main/java/java/net/InetAddress.java
index 89f827b..72c7669 100644
--- a/luni/src/main/java/java/net/InetAddress.java
+++ b/luni/src/main/java/java/net/InetAddress.java
@@ -227,7 +227,7 @@ public class InetAddress extends Object implements Serializable {
if (security != null) {
security.checkConnect(host, -1);
}
-
+ // BEGIN android-changed
byte[][] rawAddresses = getallbyname(host,
Socket.preferIPv4Stack());
InetAddress[] returnedAddresses = new
@@ -248,6 +248,7 @@ public class InetAddress extends Object implements Serializable {
// ok we may have to re-order to make sure the
// preferIPv6Addresses is respected
+ // END android-changed
InetAddress[] orderedAddresses = null;
if (returnedAddresses != null) {
orderedAddresses = new InetAddress[returnedAddresses.length];
@@ -525,20 +526,21 @@ public class InetAddress extends Object implements Serializable {
return anInetAddress;
}
- // BEGIN android-changed
+ // BEGIN android-added
/**
* Multiplies value by 1 billion.
*/
private static long secondsToNanos(int ttl) {
return (long) ttl * 1000000000;
}
- // END android-changed
+ // END android-added
// BEGIN android-deleted
// static native InetAddress[] getAliasesByNameImpl(String name)
// throws UnknownHostException;
// END android-deleted
+ // BEGIN android-changed
/**
* Resolves a host name to its IP addresses. Thread safe.
*/
@@ -579,7 +581,8 @@ public class InetAddress extends Object implements Serializable {
* exception, so this value should not be used as an argument. See also
* inetAddr(String).
*/
-// static native int inetAddrImpl(String host) throws UnknownHostException;
+ // BEGIN android-changed
+ // static native int inetAddrImpl(String host) throws UnknownHostException;
static int inetAddrImpl(String host) throws UnknownHostException {
// TODO Probably not exactly what we want, and also inefficient. Provide native later.
try {
@@ -595,12 +598,14 @@ public class InetAddress extends Object implements Serializable {
throw new UnknownHostException(host);
}
}
+ // END android-changed
/**
* Convert a binary address into a string containing an Ipv4 Internet
* Protocol dotted address.
*/
-// static native String inetNtoaImpl(int hipAddr);
+ // BEGIN android-changed
+ // static native String inetNtoaImpl(int hipAddr);
static String inetNtoaImpl(int hipAddr) {
// TODO Inefficient and probably wrong. Provide proper (native?) implementation later.
int a = (hipAddr >> 24) & 0xFF;
@@ -610,6 +615,7 @@ public class InetAddress extends Object implements Serializable {
return "" + a + "." + b + "." + c + "." + d;
}
+ // END android-changed
/**
* Query the IP stack for the host address. The host is in string name form.
diff --git a/luni/src/main/native/java_net_InetAddress.cpp b/luni/src/main/native/java_net_InetAddress.cpp
index 84c9751..cf026bc 100644
--- a/luni/src/main/native/java_net_InetAddress.cpp
+++ b/luni/src/main/native/java_net_InetAddress.cpp
@@ -104,11 +104,16 @@ static jobjectArray getAllByNameUsingDns(JNIEnv* env, const char* name,
memset(&hints, 0, sizeof(hints));
/*
+ * IPv4 only for now until the socket code supports IPv6; otherwise, the
+ * resolver will create two separate requests, one for IPv4 and one,
+ * currently unnecessary, for IPv6.
+ */
+ hints.ai_family = AF_INET;
+ /*
* If we don't specify a socket type, every address will appear twice, once
* for SOCK_STREAM and one for SOCK_DGRAM. Since we do not return the family
* anyway, just pick one.
*/
- hints.ai_family = preferIPv4Stack ? AF_INET : AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
int result = getaddrinfo(name, NULL, &hints, &addressList);