summaryrefslogtreecommitdiff
path: root/common/framework/com
diff options
context:
space:
mode:
authorSerik Beketayev <serikb@google.com>2021-02-04 15:39:03 -0800
committerSerik Beketayev <serikb@google.com>2021-02-04 15:42:25 -0800
commit869a7270f83aa5a70286295eccbff36e87eed3c3 (patch)
tree8f59ddc4db2d8eb8bc402dbd2af01920e2495acd /common/framework/com
parent178bc96fdde27f8322d0e15581dd88132c912c0f (diff)
downloadnet-869a7270f83aa5a70286295eccbff36e87eed3c3.tar.gz
[Mainline] Core Platform APIs migration
* java/net/InetAddress;->parseNumericAddress(Ljava/lang/String;)Ljava/net/InetAddress; * libcore/io/IoUtils;->closeQuietly(Ljava/io/FileDescriptor;)V * libcore/io/IoUtils;->closeQuietly(Ljava/lang/AutoCloseable;)V * libcore/io/IoUtils;->setBlocking(Ljava/io/FileDescriptor;Z)V * java/net/Inet4Address;->ANY:Ljava/net/InetAddress; * java/net/Inet6Address;->ANY:Ljava/net/InetAddress; Bug: 177260833 Test: mma Change-Id: I1357dba41beb27df17a7631317c4b05f98854f27
Diffstat (limited to 'common/framework/com')
-rw-r--r--common/framework/com/android/net/module/util/NetworkStackConstants.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/common/framework/com/android/net/module/util/NetworkStackConstants.java b/common/framework/com/android/net/module/util/NetworkStackConstants.java
index a2275054..b656ed2e 100644
--- a/common/framework/com/android/net/module/util/NetworkStackConstants.java
+++ b/common/framework/com/android/net/module/util/NetworkStackConstants.java
@@ -17,6 +17,7 @@
package com.android.net.module.util;
import java.net.Inet4Address;
+import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -98,7 +99,11 @@ public final class NetworkStackConstants {
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff);
public static final Inet4Address IPV4_ADDR_ANY = makeInet4Address(
(byte) 0, (byte) 0, (byte) 0, (byte) 0);
-
+ public static final Inet6Address IPV6_ADDR_ANY = makeInet6Address(new byte[]{
+ (byte) 0, (byte) 0, (byte) 0, (byte) 0,
+ (byte) 0, (byte) 0, (byte) 0, (byte) 0,
+ (byte) 0, (byte) 0, (byte) 0, (byte) 0,
+ (byte) 0, (byte) 0, (byte) 0, (byte) 0 });
/**
* IPv6 constants.
*
@@ -182,6 +187,16 @@ public final class NetworkStackConstants {
}
}
+ /**
+ * Make an Inet6Address from 16 bytes in network byte order.
+ */
+ private static Inet6Address makeInet6Address(byte[] bytes) {
+ try {
+ return (Inet6Address) InetAddress.getByAddress(bytes);
+ } catch (UnknownHostException e) {
+ throw new IllegalArgumentException("addr must be 16 bytes: this should never happen");
+ }
+ }
private NetworkStackConstants() {
throw new UnsupportedOperationException("This class is not to be instantiated");
}