summaryrefslogtreecommitdiff
path: root/packages/Tethering/src/android/net/util/TetheringUtils.java
diff options
context:
space:
mode:
authorChris Gross <chrisgross@google.com>2020-11-05 04:49:54 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-11-05 04:49:54 +0000
commit53b9724c91ca241f30ffd6eeb49ee171298ee47b (patch)
tree820e853ac9c73f8559859cb52c955cfd21362330 /packages/Tethering/src/android/net/util/TetheringUtils.java
parent6e69904a3cd0eb23298b314217f9d5dee3235eb1 (diff)
parent80cf14f0899fd7f7c0911ad04bc95bd8f0d00829 (diff)
Merge changes from topic "SP1A.201015.001" into s-keystone-qcom-dev
* changes: Adapt to IMS changes. Merge SP1A.201015.001
Diffstat (limited to 'packages/Tethering/src/android/net/util/TetheringUtils.java')
-rw-r--r--packages/Tethering/src/android/net/util/TetheringUtils.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/packages/Tethering/src/android/net/util/TetheringUtils.java b/packages/Tethering/src/android/net/util/TetheringUtils.java
index b17b4ba77cfb..53b54f7de05d 100644
--- a/packages/Tethering/src/android/net/util/TetheringUtils.java
+++ b/packages/Tethering/src/android/net/util/TetheringUtils.java
@@ -17,11 +17,15 @@ package android.net.util;
import android.net.TetherStatsParcel;
import android.net.TetheringRequestParcel;
+import android.util.Log;
import androidx.annotation.NonNull;
import java.io.FileDescriptor;
+import java.net.Inet6Address;
import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.Arrays;
import java.util.Objects;
/**
@@ -30,6 +34,24 @@ import java.util.Objects;
* {@hide}
*/
public class TetheringUtils {
+ public static final byte[] ALL_NODES = new byte[] {
+ (byte) 0xff, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
+ };
+
+ /**
+ * Configures a socket for receiving and sending ICMPv6 neighbor advertisments.
+ * @param fd the socket's {@link FileDescriptor}.
+ */
+ public static native void setupNaSocket(FileDescriptor fd)
+ throws SocketException;
+
+ /**
+ * Configures a socket for receiving and sending ICMPv6 neighbor solicitations.
+ * @param fd the socket's {@link FileDescriptor}.
+ */
+ public static native void setupNsSocket(FileDescriptor fd)
+ throws SocketException;
+
/**
* The object which records offload Tx/Rx forwarded bytes/packets.
* TODO: Replace the inner class ForwardedStats of class OffloadHardwareInterface with
@@ -129,4 +151,15 @@ public class TetheringUtils {
&& request.exemptFromEntitlementCheck == otherRequest.exemptFromEntitlementCheck
&& request.showProvisioningUi == otherRequest.showProvisioningUi;
}
+
+ /** Get inet6 address for all nodes given scope ID. */
+ public static Inet6Address getAllNodesForScopeId(int scopeId) {
+ try {
+ return Inet6Address.getByAddress("ff02::1", ALL_NODES, scopeId);
+ } catch (UnknownHostException uhe) {
+ Log.wtf("TetheringUtils", "Failed to construct Inet6Address from "
+ + Arrays.toString(ALL_NODES) + " and scopedId " + scopeId);
+ return null;
+ }
+ }
}