tethering: DAD Proxy Daemon
DAD proxy daemon responsible for forwarding NS/NA between tethered iface and upstream iface. Change-Id: I2e58e10e7fa7dba6a6f63ad03b000549f3afc37e
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user