Snap for 8426163 from 64b5b6cf53e926095d0281818c6ae6cca8200185 to mainline-tzdata2-release
Change-Id: I4c10ea799f88bca0f494e30e490ee069b8ec2c09
diff --git a/client-libs/Android.bp b/client-libs/Android.bp
index 8c79d2a..9cedd29 100644
--- a/client-libs/Android.bp
+++ b/client-libs/Android.bp
@@ -12,7 +12,7 @@
"com.android.tethering"
],
visibility: [
- "//packages/modules/Connectivity:__subpackages__",
+ "//packages/modules/Connectivity/Tethering",
"//frameworks/base/services:__subpackages__",
"//frameworks/base/packages:__subpackages__",
"//frameworks/libs/net/client-libs/tests:__subpackages__",
diff --git a/client-libs/tests/unit/Android.bp b/client-libs/tests/unit/Android.bp
index 220a6c1..2cd39bd 100644
--- a/client-libs/tests/unit/Android.bp
+++ b/client-libs/tests/unit/Android.bp
@@ -23,8 +23,7 @@
// Visible for Tethering and NetworkStack integration test and link NetdStaticLibTestsLib
// there, so that the tests under client-libs can also be run when running tethering and
// NetworkStack MTS.
- "//packages/modules/Connectivity/tests:__subpackages__",
- "//packages/modules/Connectivity/Tethering/tests:__subpackages__",
+ "//packages/modules/Connectivity/Tethering/tests/integration",
"//packages/modules/NetworkStack/tests/integration",
]
}
diff --git a/client-libs/tests/unit/lint-baseline.xml b/client-libs/tests/unit/lint-baseline.xml
new file mode 100644
index 0000000..713e300
--- /dev/null
+++ b/client-libs/tests/unit/lint-baseline.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#all`"
+ errorLine1=" CollectionUtils.all(Arrays.asList(expectedFinalFlags),"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/client-libs/tests/unit/src/com/android/net/module/util/NetdUtilsTest.java"
+ line="79"
+ column="41"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#all`"
+ errorLine1=" && CollectionUtils.all(Arrays.asList(config.flags),"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/client-libs/tests/unit/src/com/android/net/module/util/NetdUtilsTest.java"
+ line="81"
+ column="44"/>
+ </issue>
+
+</issues>
diff --git a/common/Android.bp b/common/Android.bp
index a7a027c..74aafd3 100644
--- a/common/Android.bp
+++ b/common/Android.bp
@@ -34,12 +34,9 @@
java_library {
name: "net-utils-device-common",
srcs: [
- "device/com/android/net/module/util/DeviceConfigUtils.java",
- "device/com/android/net/module/util/FdEventsReader.java",
- "device/com/android/net/module/util/HexDump.java",
- "device/com/android/net/module/util/PacketReader.java",
+ "device/**/*.java",
// This library is used by system modules, for which the system health impact of Kotlin
- // has not yet been evaluated. Annotations may need jarjar'ing.
+ // has not yet been evaluated.
// "src_devicecommon/**/*.kt",
":framework-annotations",
],
@@ -52,12 +49,13 @@
],
visibility: [
"//frameworks/base/packages/Tethering",
- "//packages/modules/Connectivity:__subpackages__",
- "//packages/modules/Connectivity/framework:__subpackages__",
+ "//packages/modules/Connectivity/Tethering",
"//frameworks/opt/net/ike",
"//frameworks/opt/net/wifi/service",
"//packages/modules/Wifi/service",
"//frameworks/opt/net/telephony",
+ "//frameworks/base/packages/Connectivity:__subpackages__",
+ "//packages/modules/Connectivity:__subpackages__",
"//packages/modules/NetworkStack:__subpackages__",
"//packages/modules/CaptivePortalLogin",
"//frameworks/libs/net/common/tests:__subpackages__",
@@ -86,42 +84,7 @@
name: "net-utils-framework-common-srcs",
srcs: ["framework/**/*.java"],
path: "framework",
- visibility: [
- "//frameworks/base",
- "//packages/modules/Connectivity:__subpackages__",
- "//frameworks/base/packages/Connectivity/framework",
- ],
-}
-
-java_library {
- name: "net-utils-device-common-netlink",
- // TODO: Ipv6Utils and Struct stuff could be separated out of th netlink library into
- // an individual Struct library, and remove the net-utils-framework-common lib dependency.
- // But there is no need doing this at the moment.
- srcs: [
- "device/com/android/net/module/util/HexDump.java",
- "device/com/android/net/module/util/Ipv6Utils.java",
- "device/com/android/net/module/util/Struct.java",
- "device/com/android/net/module/util/netlink/*.java",
- "device/com/android/net/module/util/structs/*.java",
- ],
- sdk_version: "system_current",
- min_sdk_version: "29",
- visibility: [
- "//frameworks/libs/net/common/testutils:__subpackages__",
- "//packages/modules/Connectivity:__subpackages__",
- "//packages/modules/NetworkStack:__subpackages__",
- ],
- static_libs: [
- "net-utils-framework-common",
- ],
- libs: [
- "androidx.annotation_annotation",
- ],
- apex_available: [
- "com.android.tethering",
- "//apex_available:platform",
- ],
+ visibility: ["//frameworks/base"],
}
java_library {
@@ -151,15 +114,13 @@
"//frameworks/libs/net/common/tests:__subpackages__",
"//frameworks/libs/net/common/device",
"//packages/modules/Wifi/framework/tests:__subpackages__",
- ],
+ ]
}
+
filegroup {
name: "net-utils-services-common-srcs",
srcs: [
"device/android/net/NetworkFactory.java",
- "device/android/net/NetworkFactoryImpl.java",
- "device/android/net/NetworkFactoryLegacyImpl.java",
- "device/android/net/NetworkFactoryShim.java",
],
visibility: [
"//frameworks/base/services/net",
@@ -174,9 +135,6 @@
],
sdk_version: "system_current",
min_sdk_version: "30",
- static_libs: [
- "modules-utils-build_system",
- ],
visibility: [
"//frameworks/base/services/net",
],
@@ -189,9 +147,6 @@
srcs: [
// Any class here *must* have a corresponding jarjar rule in the telephony build rules.
"device/android/net/NetworkFactory.java",
- "device/android/net/NetworkFactoryImpl.java",
- "device/android/net/NetworkFactoryLegacyImpl.java",
- "device/android/net/NetworkFactoryShim.java",
],
path: "device",
visibility: [
@@ -220,9 +175,7 @@
name: "net-utils-wifi-service-common-srcs",
srcs: [
"device/android/net/NetworkFactory.java",
- "device/android/net/NetworkFactoryImpl.java",
- "device/android/net/NetworkFactoryLegacyImpl.java",
- "device/android/net/NetworkFactoryShim.java",
+ "framework/com/android/net/module/util/NetUtils.java",
],
visibility: [
"//frameworks/opt/net/wifi/service",
diff --git a/common/device/android/net/NetworkFactory.java b/common/device/android/net/NetworkFactory.java
index 87f6dee..bcc6089 100644
--- a/common/device/android/net/NetworkFactory.java
+++ b/common/device/android/net/NetworkFactory.java
@@ -16,11 +16,9 @@
package android.net;
-import static com.android.modules.utils.build.SdkLevel.isAtLeastS;
-
import android.annotation.NonNull;
-import android.annotation.Nullable;
import android.content.Context;
+import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
@@ -29,6 +27,8 @@
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.util.LinkedHashMap;
+import java.util.Map;
/**
* A NetworkFactory is an entity that creates NetworkAgent objects.
@@ -43,72 +43,211 @@
* functions can be overridden. If the bearer needs more interaction, it can
* override addNetworkRequest and removeNetworkRequest which will give it each
* request that passes their current filters.
- *
- * This class is mostly a shim which delegates to one of two implementations depending
- * on the SDK level of the device it's running on.
- *
* @hide
**/
-public class NetworkFactory {
- static final boolean DBG = true;
- static final boolean VDBG = false;
+public class NetworkFactory extends Handler {
+ private static final boolean DBG = true;
+ private static final boolean VDBG = false;
+ /**
+ * Pass a network request to the bearer. If the bearer believes it can
+ * satisfy the request it should connect to the network and create a
+ * NetworkAgent. Once the NetworkAgent is fully functional it will
+ * register itself with ConnectivityService using registerNetworkAgent.
+ * If the bearer cannot immediately satisfy the request (no network,
+ * user disabled the radio, lower-scored network) it should remember
+ * any NetworkRequests it may be able to satisfy in the future. It may
+ * disregard any that it will never be able to service, for example
+ * those requiring a different bearer.
+ * msg.obj = NetworkRequest
+ * msg.arg1 = score - the score of the network currently satisfying this
+ * request. If this bearer knows in advance it cannot
+ * exceed this score it should not try to connect, holding the request
+ * for the future.
+ * Note that subsequent events may give a different (lower
+ * or higher) score for this request, transmitted to each
+ * NetworkFactory through additional CMD_REQUEST_NETWORK msgs
+ * with the same NetworkRequest but an updated score.
+ * Also, network conditions may change for this bearer
+ * allowing for a better score in the future.
+ * msg.arg2 = the ID of the NetworkProvider currently responsible for the
+ * NetworkAgent handling this request, or NetworkProvider.ID_NONE if none.
+ */
+ public static final int CMD_REQUEST_NETWORK = 1;
- final NetworkFactoryShim mImpl;
+ /**
+ * Cancel a network request
+ * msg.obj = NetworkRequest
+ */
+ public static final int CMD_CANCEL_REQUEST = 2;
+ /**
+ * Internally used to set our best-guess score.
+ * msg.arg1 = new score
+ */
+ private static final int CMD_SET_SCORE = 3;
+
+ /**
+ * Internally used to set our current filter for coarse bandwidth changes with
+ * technology changes.
+ * msg.obj = new filter
+ */
+ private static final int CMD_SET_FILTER = 4;
+
+ private final Context mContext;
private final String LOG_TAG;
- // Ideally the filter argument would be non-null, but null has historically meant to see
- // no requests and telephony passes null.
- public NetworkFactory(Looper looper, Context context, String logTag,
- @Nullable final NetworkCapabilities filter) {
- LOG_TAG = logTag;
- if (isAtLeastS()) {
- mImpl = new NetworkFactoryImpl(this, looper, context, filter);
- } else {
- mImpl = new NetworkFactoryLegacyImpl(this, looper, context, filter);
- }
- }
+ private final Map<NetworkRequest, NetworkRequestInfo> mNetworkRequests =
+ new LinkedHashMap<>();
- // TODO : these two constants and the method are only used by telephony tests. Replace it in
- // the tests and remove them and the associated code.
- public static final int CMD_REQUEST_NETWORK = 1;
- public static final int CMD_CANCEL_REQUEST = 2;
- /** Like Handler#obtainMessage */
- @VisibleForTesting
- public Message obtainMessage(final int what, final int arg1, final int arg2,
- final @Nullable Object obj) {
- return mImpl.obtainMessage(what, arg1, arg2, obj);
- }
+ private int mScore;
+ private NetworkCapabilities mCapabilityFilter;
- // Called by BluetoothNetworkFactory
- public final Looper getLooper() {
- return mImpl.getLooper();
- }
-
- // Refcount for simple mode requests
private int mRefCount = 0;
+ private NetworkProvider mProvider = null;
+
+ public NetworkFactory(Looper looper, Context context, String logTag,
+ NetworkCapabilities filter) {
+ super(looper);
+ LOG_TAG = logTag;
+ mContext = context;
+ mCapabilityFilter = filter;
+ }
/* Registers this NetworkFactory with the system. May only be called once per factory. */
public void register() {
- mImpl.register(LOG_TAG);
- }
+ if (mProvider != null) {
+ throw new IllegalStateException("A NetworkFactory must only be registered once");
+ }
+ if (DBG) log("Registering NetworkFactory");
- /**
- * Registers this NetworkFactory with the system ignoring the score filter. This will let
- * the factory always see all network requests matching its capabilities filter.
- * May only be called once per factory.
- */
- public void registerIgnoringScore() {
- mImpl.registerIgnoringScore(LOG_TAG);
+ mProvider = new NetworkProvider(mContext, NetworkFactory.this.getLooper(), LOG_TAG) {
+ @Override
+ public void onNetworkRequested(@NonNull NetworkRequest request, int score,
+ int servingProviderId) {
+ handleAddRequest(request, score, servingProviderId);
+ }
+
+ @Override
+ public void onNetworkRequestWithdrawn(@NonNull NetworkRequest request) {
+ handleRemoveRequest(request);
+ }
+ };
+
+ ((ConnectivityManager) mContext.getSystemService(
+ Context.CONNECTIVITY_SERVICE)).registerNetworkProvider(mProvider);
}
/** Unregisters this NetworkFactory. After this call, the object can no longer be used. */
public void terminate() {
- mImpl.terminate();
+ if (mProvider == null) {
+ throw new IllegalStateException("This NetworkFactory was never registered");
+ }
+ if (DBG) log("Unregistering NetworkFactory");
+
+ ((ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
+ .unregisterNetworkProvider(mProvider);
+
+ // Remove all pending messages, since this object cannot be reused. Any message currently
+ // being processed will continue to run.
+ removeCallbacksAndMessages(null);
}
- protected final void reevaluateAllRequests() {
- mImpl.reevaluateAllRequests();
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case CMD_REQUEST_NETWORK: {
+ handleAddRequest((NetworkRequest) msg.obj, msg.arg1, msg.arg2);
+ break;
+ }
+ case CMD_CANCEL_REQUEST: {
+ handleRemoveRequest((NetworkRequest) msg.obj);
+ break;
+ }
+ case CMD_SET_SCORE: {
+ handleSetScore(msg.arg1);
+ break;
+ }
+ case CMD_SET_FILTER: {
+ handleSetFilter((NetworkCapabilities) msg.obj);
+ break;
+ }
+ }
+ }
+
+ private static class NetworkRequestInfo {
+ public final NetworkRequest request;
+ public int score;
+ public boolean requested; // do we have a request outstanding, limited by score
+ public int providerId;
+
+ NetworkRequestInfo(NetworkRequest request, int score, int providerId) {
+ this.request = request;
+ this.score = score;
+ this.requested = false;
+ this.providerId = providerId;
+ }
+
+ @Override
+ public String toString() {
+ return "{" + request + ", score=" + score + ", requested=" + requested + "}";
+ }
+ }
+
+ /**
+ * Add a NetworkRequest that the bearer may want to attempt to satisfy.
+ * @see #CMD_REQUEST_NETWORK
+ *
+ * @param request the request to handle.
+ * @param score the score of the NetworkAgent currently satisfying this request.
+ * @param servingProviderId the ID of the NetworkProvider that created the NetworkAgent
+ * currently satisfying this request.
+ */
+ @VisibleForTesting
+ protected void handleAddRequest(NetworkRequest request, int score, int servingProviderId) {
+ NetworkRequestInfo n = mNetworkRequests.get(request);
+ if (n == null) {
+ if (DBG) {
+ log("got request " + request + " with score " + score
+ + " and providerId " + servingProviderId);
+ }
+ n = new NetworkRequestInfo(request, score, servingProviderId);
+ mNetworkRequests.put(n.request, n);
+ } else {
+ if (VDBG) {
+ log("new score " + score + " for existing request " + request
+ + " and providerId " + servingProviderId);
+ }
+ n.score = score;
+ n.providerId = servingProviderId;
+ }
+ if (VDBG) log(" my score=" + mScore + ", my filter=" + mCapabilityFilter);
+
+ evalRequest(n);
+ }
+
+ @VisibleForTesting
+ protected void handleRemoveRequest(NetworkRequest request) {
+ NetworkRequestInfo n = mNetworkRequests.get(request);
+ if (n != null) {
+ mNetworkRequests.remove(request);
+ if (n.requested) releaseNetworkFor(n.request);
+ }
+ }
+
+ private void handleSetScore(int score) {
+ mScore = score;
+ evalRequests();
+ }
+
+ private void handleSetFilter(NetworkCapabilities netCap) {
+ mCapabilityFilter = netCap;
+ evalRequests();
+ }
+
+ /** @deprecated None of the implementors use the score, remove this method */
+ @Deprecated
+ public boolean acceptRequest(NetworkRequest request, int score) {
+ return acceptRequest(request);
}
/**
@@ -130,10 +269,75 @@
*
* @return {@code true} to accept the request.
*/
- public boolean acceptRequest(@NonNull final NetworkRequest request) {
+ public boolean acceptRequest(NetworkRequest request) {
return true;
}
+ private void evalRequest(NetworkRequestInfo n) {
+ if (VDBG) {
+ log("evalRequest");
+ log(" n.requests = " + n.requested);
+ log(" n.score = " + n.score);
+ log(" mScore = " + mScore);
+ log(" request.providerId = " + n.providerId);
+ log(" mProvider.id = " + mProvider.getProviderId());
+ }
+ if (shouldNeedNetworkFor(n)) {
+ if (VDBG) log(" needNetworkFor");
+ needNetworkFor(n.request, n.score);
+ n.requested = true;
+ } else if (shouldReleaseNetworkFor(n)) {
+ if (VDBG) log(" releaseNetworkFor");
+ releaseNetworkFor(n.request);
+ n.requested = false;
+ } else {
+ if (VDBG) log(" done");
+ }
+ }
+
+ private boolean shouldNeedNetworkFor(NetworkRequestInfo n) {
+ // If this request is already tracked, it doesn't qualify for need
+ return !n.requested
+ // If the score of this request is higher or equal to that of this factory and some
+ // other factory is responsible for it, then this factory should not track the request
+ // because it has no hope of satisfying it.
+ && (n.score < mScore || n.providerId == mProvider.getProviderId())
+ // If this factory can't satisfy the capability needs of this request, then it
+ // should not be tracked.
+ && n.request.canBeSatisfiedBy(mCapabilityFilter)
+ // Finally if the concrete implementation of the factory rejects the request, then
+ // don't track it.
+ && acceptRequest(n.request, n.score);
+ }
+
+ private boolean shouldReleaseNetworkFor(NetworkRequestInfo n) {
+ // Don't release a request that's not tracked.
+ return n.requested
+ // The request should be released if it can't be satisfied by this factory. That
+ // means either of the following conditions are met :
+ // - Its score is too high to be satisfied by this factory and it's not already
+ // assigned to the factory
+ // - This factory can't satisfy the capability needs of the request
+ // - The concrete implementation of the factory rejects the request
+ && ((n.score > mScore && n.providerId != mProvider.getProviderId())
+ || !n.request.canBeSatisfiedBy(mCapabilityFilter)
+ || !acceptRequest(n.request, n.score));
+ }
+
+ private void evalRequests() {
+ for (NetworkRequestInfo n : mNetworkRequests.values()) {
+ evalRequest(n);
+ }
+ }
+
+ /**
+ * Post a command, on this NetworkFactory Handler, to re-evaluate all
+ * outstanding requests. Can be called from a factory implementation.
+ */
+ protected void reevaluateAllRequests() {
+ post(this::evalRequests);
+ }
+
/**
* Can be called by a factory to release a request as unfulfillable: the request will be
* removed, and the caller will get a
@@ -144,60 +348,56 @@
* is able to fulfill this request!
*/
protected void releaseRequestAsUnfulfillableByAnyFactory(NetworkRequest r) {
- mImpl.releaseRequestAsUnfulfillableByAnyFactory(r);
+ post(() -> {
+ if (DBG) log("releaseRequestAsUnfulfillableByAnyFactory: " + r);
+ final NetworkProvider provider = mProvider;
+ if (provider == null) {
+ Log.e(LOG_TAG, "Ignoring attempt to release unregistered request as unfulfillable");
+ return;
+ }
+ provider.declareNetworkRequestUnfulfillable(r);
+ });
}
// override to do simple mode (request independent)
protected void startNetwork() { }
protected void stopNetwork() { }
+ /** @deprecated none of the implementors use the score : migrate them */
+ @Deprecated
+ protected void needNetworkFor(NetworkRequest networkRequest, int score) {
+ needNetworkFor(networkRequest);
+ }
+
// override to do fancier stuff
- protected void needNetworkFor(@NonNull final NetworkRequest networkRequest) {
+ protected void needNetworkFor(NetworkRequest networkRequest) {
if (++mRefCount == 1) startNetwork();
}
- protected void releaseNetworkFor(@NonNull final NetworkRequest networkRequest) {
+ protected void releaseNetworkFor(NetworkRequest networkRequest) {
if (--mRefCount == 0) stopNetwork();
}
- /**
- * @deprecated this method was never part of the API (system or public) and is only added
- * for migration of existing clients.
- */
- @Deprecated
- public void setScoreFilter(final int score) {
- mImpl.setScoreFilter(score);
- }
-
- /**
- * Set a score filter for this factory.
- *
- * This should include the transports the factory knows its networks will have, and
- * an optimistic view of the attributes it may have. This does not commit the factory
- * to being able to bring up such a network ; it only lets it avoid hearing about
- * requests that it has no chance of fulfilling.
- *
- * @param score the filter
- */
- public void setScoreFilter(@NonNull final NetworkScore score) {
- mImpl.setScoreFilter(score);
+ public void setScoreFilter(int score) {
+ sendMessage(obtainMessage(CMD_SET_SCORE, score, 0));
}
public void setCapabilityFilter(NetworkCapabilities netCap) {
- mImpl.setCapabilityFilter(netCap);
+ sendMessage(obtainMessage(CMD_SET_FILTER, new NetworkCapabilities(netCap)));
}
@VisibleForTesting
protected int getRequestCount() {
- return mImpl.getRequestCount();
+ return mNetworkRequests.size();
}
+ /* TODO: delete when all callers have migrated to NetworkProvider IDs. */
public int getSerialNumber() {
- return mImpl.getSerialNumber();
+ return mProvider.getProviderId();
}
public NetworkProvider getProvider() {
- return mImpl.getProvider();
+ return mProvider;
}
protected void log(String s) {
@@ -205,11 +405,18 @@
}
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
- mImpl.dump(fd, writer, args);
+ writer.println(toString());
+ for (NetworkRequestInfo n : mNetworkRequests.values()) {
+ writer.println(" " + n);
+ }
}
@Override
public String toString() {
- return "{" + LOG_TAG + " " + mImpl.toString() + "}";
+ return "{" + LOG_TAG + " - providerId="
+ + mProvider.getProviderId() + ", ScoreFilter="
+ + mScore + ", Filter=" + mCapabilityFilter + ", requests="
+ + mNetworkRequests.size() + ", refCount=" + mRefCount
+ + "}";
}
}
diff --git a/common/device/android/net/NetworkFactoryImpl.java b/common/device/android/net/NetworkFactoryImpl.java
deleted file mode 100644
index 439ea14..0000000
--- a/common/device/android/net/NetworkFactoryImpl.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.content.Context;
-import android.net.NetworkProvider.NetworkOfferCallback;
-import android.os.Looper;
-import android.os.Message;
-
-import java.io.FileDescriptor;
-import java.io.PrintWriter;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.concurrent.Executor;
-
-/**
- * A NetworkFactory is an entity that creates NetworkAgent objects.
- * The bearers register with ConnectivityService using {@link #register} and
- * their factory will start receiving scored NetworkRequests. NetworkRequests
- * can be filtered 3 ways: by NetworkCapabilities, by score and more complexly by
- * overridden function. All of these can be dynamic - changing NetworkCapabilities
- * or score forces re-evaluation of all current requests.
- *
- * If any requests pass the filter some overrideable functions will be called.
- * If the bearer only cares about very simple start/stopNetwork callbacks, those
- * functions can be overridden. If the bearer needs more interaction, it can
- * override addNetworkRequest and removeNetworkRequest which will give it each
- * request that passes their current filters.
- * @hide
- **/
-// TODO(b/187083878): factor out common code between this and NetworkFactoryLegacyImpl
-class NetworkFactoryImpl extends NetworkFactoryLegacyImpl {
- private static final boolean DBG = NetworkFactory.DBG;
- private static final boolean VDBG = NetworkFactory.VDBG;
-
- // A score that will win against everything, so that score filtering will let all requests
- // through
- // TODO : remove this and replace with an API to listen to all requests.
- @NonNull
- private static final NetworkScore INVINCIBLE_SCORE =
- new NetworkScore.Builder().setLegacyInt(1000).build();
-
- // TODO(b/187082970): Replace CMD_* with Handler.post(() -> { ... }) since all the CMDs do is to
- // run the tasks asynchronously on the Handler thread.
-
- /**
- * Pass a network request to the bearer. If the bearer believes it can
- * satisfy the request it should connect to the network and create a
- * NetworkAgent. Once the NetworkAgent is fully functional it will
- * register itself with ConnectivityService using registerNetworkAgent.
- * If the bearer cannot immediately satisfy the request (no network,
- * user disabled the radio, lower-scored network) it should remember
- * any NetworkRequests it may be able to satisfy in the future. It may
- * disregard any that it will never be able to service, for example
- * those requiring a different bearer.
- * msg.obj = NetworkRequest
- */
- // TODO : this and CANCEL_REQUEST are only used by telephony tests. Replace it in the tests
- // and remove them and the associated code.
- private static final int CMD_REQUEST_NETWORK = NetworkFactory.CMD_REQUEST_NETWORK;
-
- /**
- * Cancel a network request
- * msg.obj = NetworkRequest
- */
- private static final int CMD_CANCEL_REQUEST = NetworkFactory.CMD_CANCEL_REQUEST;
-
- /**
- * Internally used to set our best-guess score.
- * msg.obj = new score
- */
- private static final int CMD_SET_SCORE = 3;
-
- /**
- * Internally used to set our current filter for coarse bandwidth changes with
- * technology changes.
- * msg.obj = new filter
- */
- private static final int CMD_SET_FILTER = 4;
-
- /**
- * Internally used to send the network offer associated with this factory.
- * No arguments, will read from members
- */
- private static final int CMD_OFFER_NETWORK = 5;
-
- /**
- * Internally used to send the request to listen to all requests.
- * No arguments, will read from members
- */
- private static final int CMD_LISTEN_TO_ALL_REQUESTS = 6;
-
- private final Map<NetworkRequest, NetworkRequestInfo> mNetworkRequests =
- new LinkedHashMap<>();
-
- @NonNull private NetworkScore mScore = new NetworkScore.Builder().setLegacyInt(0).build();
-
- private final NetworkOfferCallback mRequestCallback = new NetworkOfferCallback() {
- @Override
- public void onNetworkNeeded(@NonNull final NetworkRequest request) {
- handleAddRequest(request);
- }
-
- @Override
- public void onNetworkUnneeded(@NonNull final NetworkRequest request) {
- handleRemoveRequest(request);
- }
- };
- @NonNull private final Executor mExecutor = command -> post(command);
-
-
- // Ideally the filter argument would be non-null, but null has historically meant to see
- // no requests and telephony passes null.
- NetworkFactoryImpl(NetworkFactory parent, Looper looper, Context context,
- @Nullable final NetworkCapabilities filter) {
- super(parent, looper, context,
- null != filter ? filter :
- NetworkCapabilities.Builder.withoutDefaultCapabilities().build());
- }
-
- /* Registers this NetworkFactory with the system. May only be called once per factory. */
- @Override public void register(final String logTag) {
- register(logTag, false);
- }
-
- /**
- * Registers this NetworkFactory with the system ignoring the score filter. This will let
- * the factory always see all network requests matching its capabilities filter.
- * May only be called once per factory.
- */
- @Override public void registerIgnoringScore(final String logTag) {
- register(logTag, true);
- }
-
- private void register(final String logTag, final boolean listenToAllRequests) {
- if (mProvider != null) {
- throw new IllegalStateException("A NetworkFactory must only be registered once");
- }
- if (DBG) mParent.log("Registering NetworkFactory");
-
- mProvider = new NetworkProvider(mContext, NetworkFactoryImpl.this.getLooper(), logTag) {
- @Override
- public void onNetworkRequested(@NonNull NetworkRequest request, int score,
- int servingProviderId) {
- handleAddRequest(request);
- }
-
- @Override
- public void onNetworkRequestWithdrawn(@NonNull NetworkRequest request) {
- handleRemoveRequest(request);
- }
- };
-
- ((ConnectivityManager) mContext.getSystemService(
- Context.CONNECTIVITY_SERVICE)).registerNetworkProvider(mProvider);
-
- // The mScore and mCapabilityFilter members can only be accessed on the handler thread.
- // TODO : offer a separate API to listen to all requests instead
- if (listenToAllRequests) {
- sendMessage(obtainMessage(CMD_LISTEN_TO_ALL_REQUESTS));
- } else {
- sendMessage(obtainMessage(CMD_OFFER_NETWORK));
- }
- }
-
- private void handleOfferNetwork(@NonNull final NetworkScore score) {
- mProvider.registerNetworkOffer(score, mCapabilityFilter, mExecutor, mRequestCallback);
- }
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case CMD_REQUEST_NETWORK: {
- handleAddRequest((NetworkRequest) msg.obj);
- break;
- }
- case CMD_CANCEL_REQUEST: {
- handleRemoveRequest((NetworkRequest) msg.obj);
- break;
- }
- case CMD_SET_SCORE: {
- handleSetScore((NetworkScore) msg.obj);
- break;
- }
- case CMD_SET_FILTER: {
- handleSetFilter((NetworkCapabilities) msg.obj);
- break;
- }
- case CMD_OFFER_NETWORK: {
- handleOfferNetwork(mScore);
- break;
- }
- case CMD_LISTEN_TO_ALL_REQUESTS: {
- handleOfferNetwork(INVINCIBLE_SCORE);
- break;
- }
- }
- }
-
- private static class NetworkRequestInfo {
- @NonNull public final NetworkRequest request;
- public boolean requested; // do we have a request outstanding, limited by score
-
- NetworkRequestInfo(@NonNull final NetworkRequest request) {
- this.request = request;
- this.requested = false;
- }
-
- @Override
- public String toString() {
- return "{" + request + ", requested=" + requested + "}";
- }
- }
-
- /**
- * Add a NetworkRequest that the bearer may want to attempt to satisfy.
- * @see #CMD_REQUEST_NETWORK
- *
- * @param request the request to handle.
- */
- private void handleAddRequest(@NonNull final NetworkRequest request) {
- NetworkRequestInfo n = mNetworkRequests.get(request);
- if (n == null) {
- if (DBG) mParent.log("got request " + request);
- n = new NetworkRequestInfo(request);
- mNetworkRequests.put(n.request, n);
- } else {
- if (VDBG) mParent.log("handle existing request " + request);
- }
- if (VDBG) mParent.log(" my score=" + mScore + ", my filter=" + mCapabilityFilter);
-
- if (mParent.acceptRequest(request)) {
- n.requested = true;
- mParent.needNetworkFor(request);
- }
- }
-
- private void handleRemoveRequest(NetworkRequest request) {
- NetworkRequestInfo n = mNetworkRequests.get(request);
- if (n != null) {
- mNetworkRequests.remove(request);
- if (n.requested) mParent.releaseNetworkFor(n.request);
- }
- }
-
- private void handleSetScore(@NonNull final NetworkScore score) {
- if (mScore.equals(score)) return;
- mScore = score;
- mParent.reevaluateAllRequests();
- }
-
- private void handleSetFilter(@NonNull final NetworkCapabilities netCap) {
- if (netCap.equals(mCapabilityFilter)) return;
- mCapabilityFilter = netCap;
- mParent.reevaluateAllRequests();
- }
-
- @Override public final void reevaluateAllRequests() {
- if (mProvider == null) return;
- mProvider.registerNetworkOffer(mScore, mCapabilityFilter, mExecutor, mRequestCallback);
- }
-
- /**
- * @deprecated this method was never part of the API (system or public) and is only added
- * for migration of existing clients.
- */
- @Deprecated
- public void setScoreFilter(final int score) {
- setScoreFilter(new NetworkScore.Builder().setLegacyInt(score).build());
- }
-
- /**
- * Set a score filter for this factory.
- *
- * This should include the transports the factory knows its networks will have, and
- * an optimistic view of the attributes it may have. This does not commit the factory
- * to being able to bring up such a network ; it only lets it avoid hearing about
- * requests that it has no chance of fulfilling.
- *
- * @param score the filter
- */
- @Override public void setScoreFilter(@NonNull final NetworkScore score) {
- sendMessage(obtainMessage(CMD_SET_SCORE, score));
- }
-
- @Override public void setCapabilityFilter(NetworkCapabilities netCap) {
- sendMessage(obtainMessage(CMD_SET_FILTER, new NetworkCapabilities(netCap)));
- }
-
- @Override public int getRequestCount() {
- return mNetworkRequests.size();
- }
-
- @Override public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
- writer.println(toString());
- for (NetworkRequestInfo n : mNetworkRequests.values()) {
- writer.println(" " + n);
- }
- }
-
- @Override public String toString() {
- return "providerId="
- + mProvider.getProviderId() + ", ScoreFilter="
- + mScore + ", Filter=" + mCapabilityFilter + ", requests="
- + mNetworkRequests.size();
- }
-}
diff --git a/common/device/android/net/NetworkFactoryLegacyImpl.java b/common/device/android/net/NetworkFactoryLegacyImpl.java
deleted file mode 100644
index 6dd0adb..0000000
--- a/common/device/android/net/NetworkFactoryLegacyImpl.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-import android.annotation.NonNull;
-import android.content.Context;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-
-import com.android.internal.annotations.VisibleForTesting;
-
-import java.io.FileDescriptor;
-import java.io.PrintWriter;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * A NetworkFactory is an entity that creates NetworkAgent objects.
- * The bearers register with ConnectivityService using {@link #register} and
- * their factory will start receiving scored NetworkRequests. NetworkRequests
- * can be filtered 3 ways: by NetworkCapabilities, by score and more complexly by
- * overridden function. All of these can be dynamic - changing NetworkCapabilities
- * or score forces re-evaluation of all current requests.
- *
- * If any requests pass the filter some overrideable functions will be called.
- * If the bearer only cares about very simple start/stopNetwork callbacks, those
- * functions can be overridden. If the bearer needs more interaction, it can
- * override addNetworkRequest and removeNetworkRequest which will give it each
- * request that passes their current filters.
- * @hide
- **/
-// TODO(b/187083878): factor out common code between this and NetworkFactoryImpl
-class NetworkFactoryLegacyImpl extends Handler
- implements NetworkFactoryShim {
- private static final boolean DBG = NetworkFactory.DBG;
- private static final boolean VDBG = NetworkFactory.VDBG;
-
- // TODO(b/187082970): Replace CMD_* with Handler.post(() -> { ... }) since all the CMDs do is to
- // run the tasks asynchronously on the Handler thread.
-
- /**
- * Pass a network request to the bearer. If the bearer believes it can
- * satisfy the request it should connect to the network and create a
- * NetworkAgent. Once the NetworkAgent is fully functional it will
- * register itself with ConnectivityService using registerNetworkAgent.
- * If the bearer cannot immediately satisfy the request (no network,
- * user disabled the radio, lower-scored network) it should remember
- * any NetworkRequests it may be able to satisfy in the future. It may
- * disregard any that it will never be able to service, for example
- * those requiring a different bearer.
- * msg.obj = NetworkRequest
- * msg.arg1 = score - the score of the network currently satisfying this
- * request. If this bearer knows in advance it cannot
- * exceed this score it should not try to connect, holding the request
- * for the future.
- * Note that subsequent events may give a different (lower
- * or higher) score for this request, transmitted to each
- * NetworkFactory through additional CMD_REQUEST_NETWORK msgs
- * with the same NetworkRequest but an updated score.
- * Also, network conditions may change for this bearer
- * allowing for a better score in the future.
- * msg.arg2 = the ID of the NetworkProvider currently responsible for the
- * NetworkAgent handling this request, or NetworkProvider.ID_NONE if none.
- */
- public static final int CMD_REQUEST_NETWORK = 1;
-
- /**
- * Cancel a network request
- * msg.obj = NetworkRequest
- */
- public static final int CMD_CANCEL_REQUEST = 2;
-
- /**
- * Internally used to set our best-guess score.
- * msg.arg1 = new score
- */
- private static final int CMD_SET_SCORE = 3;
-
- /**
- * Internally used to set our current filter for coarse bandwidth changes with
- * technology changes.
- * msg.obj = new filter
- */
- private static final int CMD_SET_FILTER = 4;
-
- final Context mContext;
- final NetworkFactory mParent;
-
- private final Map<NetworkRequest, NetworkRequestInfo> mNetworkRequests =
- new LinkedHashMap<>();
-
- private int mScore;
- NetworkCapabilities mCapabilityFilter;
-
- NetworkProvider mProvider = null;
-
- NetworkFactoryLegacyImpl(NetworkFactory parent, Looper looper, Context context,
- NetworkCapabilities filter) {
- super(looper);
- mParent = parent;
- mContext = context;
- mCapabilityFilter = filter;
- }
-
- /* Registers this NetworkFactory with the system. May only be called once per factory. */
- @Override public void register(final String logTag) {
- if (mProvider != null) {
- throw new IllegalStateException("A NetworkFactory must only be registered once");
- }
- if (DBG) mParent.log("Registering NetworkFactory");
-
- mProvider = new NetworkProvider(mContext, NetworkFactoryLegacyImpl.this.getLooper(),
- logTag) {
- @Override
- public void onNetworkRequested(@NonNull NetworkRequest request, int score,
- int servingProviderId) {
- handleAddRequest(request, score, servingProviderId);
- }
-
- @Override
- public void onNetworkRequestWithdrawn(@NonNull NetworkRequest request) {
- handleRemoveRequest(request);
- }
- };
-
- ((ConnectivityManager) mContext.getSystemService(
- Context.CONNECTIVITY_SERVICE)).registerNetworkProvider(mProvider);
- }
-
- /** Unregisters this NetworkFactory. After this call, the object can no longer be used. */
- @Override public void terminate() {
- if (mProvider == null) {
- throw new IllegalStateException("This NetworkFactory was never registered");
- }
- if (DBG) mParent.log("Unregistering NetworkFactory");
-
- ((ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
- .unregisterNetworkProvider(mProvider);
-
- // Remove all pending messages, since this object cannot be reused. Any message currently
- // being processed will continue to run.
- removeCallbacksAndMessages(null);
- }
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case CMD_REQUEST_NETWORK: {
- handleAddRequest((NetworkRequest) msg.obj, msg.arg1, msg.arg2);
- break;
- }
- case CMD_CANCEL_REQUEST: {
- handleRemoveRequest((NetworkRequest) msg.obj);
- break;
- }
- case CMD_SET_SCORE: {
- handleSetScore(msg.arg1);
- break;
- }
- case CMD_SET_FILTER: {
- handleSetFilter((NetworkCapabilities) msg.obj);
- break;
- }
- }
- }
-
- private static class NetworkRequestInfo {
- public final NetworkRequest request;
- public int score;
- public boolean requested; // do we have a request outstanding, limited by score
- public int providerId;
-
- NetworkRequestInfo(NetworkRequest request, int score, int providerId) {
- this.request = request;
- this.score = score;
- this.requested = false;
- this.providerId = providerId;
- }
-
- @Override
- public String toString() {
- return "{" + request + ", score=" + score + ", requested=" + requested + "}";
- }
- }
-
- /**
- * Add a NetworkRequest that the bearer may want to attempt to satisfy.
- * @see #CMD_REQUEST_NETWORK
- *
- * @param request the request to handle.
- * @param score the score of the NetworkAgent currently satisfying this request.
- * @param servingProviderId the ID of the NetworkProvider that created the NetworkAgent
- * currently satisfying this request.
- */
- @VisibleForTesting
- protected void handleAddRequest(NetworkRequest request, int score, int servingProviderId) {
- NetworkRequestInfo n = mNetworkRequests.get(request);
- if (n == null) {
- if (DBG) {
- mParent.log("got request " + request + " with score " + score
- + " and providerId " + servingProviderId);
- }
- n = new NetworkRequestInfo(request, score, servingProviderId);
- mNetworkRequests.put(n.request, n);
- } else {
- if (VDBG) {
- mParent.log("new score " + score + " for existing request " + request
- + " and providerId " + servingProviderId);
- }
- n.score = score;
- n.providerId = servingProviderId;
- }
- if (VDBG) mParent.log(" my score=" + mScore + ", my filter=" + mCapabilityFilter);
-
- evalRequest(n);
- }
-
- private void handleRemoveRequest(NetworkRequest request) {
- NetworkRequestInfo n = mNetworkRequests.get(request);
- if (n != null) {
- mNetworkRequests.remove(request);
- if (n.requested) mParent.releaseNetworkFor(n.request);
- }
- }
-
- private void handleSetScore(int score) {
- mScore = score;
- evalRequests();
- }
-
- private void handleSetFilter(NetworkCapabilities netCap) {
- mCapabilityFilter = netCap;
- evalRequests();
- }
-
- /**
- * Overridable function to provide complex filtering.
- * Called for every request every time a new NetworkRequest is seen
- * and whenever the filterScore or filterNetworkCapabilities change.
- *
- * acceptRequest can be overridden to provide complex filter behavior
- * for the incoming requests
- *
- * For output, this class will call {@link NetworkFactory#needNetworkFor} and
- * {@link NetworkFactory#releaseNetworkFor} for every request that passes the filters.
- * If you don't need to see every request, you can leave the base
- * implementations of those two functions and instead override
- * {@link NetworkFactory#startNetwork} and {@link NetworkFactory#stopNetwork}.
- *
- * If you want to see every score fluctuation on every request, set
- * your score filter to a very high number and watch {@link NetworkFactory#needNetworkFor}.
- *
- * @return {@code true} to accept the request.
- */
- public boolean acceptRequest(NetworkRequest request) {
- return mParent.acceptRequest(request);
- }
-
- private void evalRequest(NetworkRequestInfo n) {
- if (VDBG) {
- mParent.log("evalRequest");
- mParent.log(" n.requests = " + n.requested);
- mParent.log(" n.score = " + n.score);
- mParent.log(" mScore = " + mScore);
- mParent.log(" request.providerId = " + n.providerId);
- mParent.log(" mProvider.id = " + mProvider.getProviderId());
- }
- if (shouldNeedNetworkFor(n)) {
- if (VDBG) mParent.log(" needNetworkFor");
- mParent.needNetworkFor(n.request);
- n.requested = true;
- } else if (shouldReleaseNetworkFor(n)) {
- if (VDBG) mParent.log(" releaseNetworkFor");
- mParent.releaseNetworkFor(n.request);
- n.requested = false;
- } else {
- if (VDBG) mParent.log(" done");
- }
- }
-
- private boolean shouldNeedNetworkFor(NetworkRequestInfo n) {
- // If this request is already tracked, it doesn't qualify for need
- return !n.requested
- // If the score of this request is higher or equal to that of this factory and some
- // other factory is responsible for it, then this factory should not track the request
- // because it has no hope of satisfying it.
- && (n.score < mScore || n.providerId == mProvider.getProviderId())
- // If this factory can't satisfy the capability needs of this request, then it
- // should not be tracked.
- && n.request.canBeSatisfiedBy(mCapabilityFilter)
- // Finally if the concrete implementation of the factory rejects the request, then
- // don't track it.
- && acceptRequest(n.request);
- }
-
- private boolean shouldReleaseNetworkFor(NetworkRequestInfo n) {
- // Don't release a request that's not tracked.
- return n.requested
- // The request should be released if it can't be satisfied by this factory. That
- // means either of the following conditions are met :
- // - Its score is too high to be satisfied by this factory and it's not already
- // assigned to the factory
- // - This factory can't satisfy the capability needs of the request
- // - The concrete implementation of the factory rejects the request
- && ((n.score > mScore && n.providerId != mProvider.getProviderId())
- || !n.request.canBeSatisfiedBy(mCapabilityFilter)
- || !acceptRequest(n.request));
- }
-
- private void evalRequests() {
- for (NetworkRequestInfo n : mNetworkRequests.values()) {
- evalRequest(n);
- }
- }
-
- /**
- * Post a command, on this NetworkFactory Handler, to re-evaluate all
- * outstanding requests. Can be called from a factory implementation.
- */
- @Override public void reevaluateAllRequests() {
- post(this::evalRequests);
- }
-
- /**
- * Can be called by a factory to release a request as unfulfillable: the request will be
- * removed, and the caller will get a
- * {@link ConnectivityManager.NetworkCallback#onUnavailable()} callback after this function
- * returns.
- *
- * Note: this should only be called by factory which KNOWS that it is the ONLY factory which
- * is able to fulfill this request!
- */
- @Override public void releaseRequestAsUnfulfillableByAnyFactory(NetworkRequest r) {
- post(() -> {
- if (DBG) mParent.log("releaseRequestAsUnfulfillableByAnyFactory: " + r);
- final NetworkProvider provider = mProvider;
- if (provider == null) {
- mParent.log("Ignoring attempt to release unregistered request as unfulfillable");
- return;
- }
- provider.declareNetworkRequestUnfulfillable(r);
- });
- }
-
- @Override public void setScoreFilter(int score) {
- sendMessage(obtainMessage(CMD_SET_SCORE, score, 0));
- }
-
- @Override public void setScoreFilter(@NonNull final NetworkScore score) {
- setScoreFilter(score.getLegacyInt());
- }
-
- @Override public void setCapabilityFilter(NetworkCapabilities netCap) {
- sendMessage(obtainMessage(CMD_SET_FILTER, new NetworkCapabilities(netCap)));
- }
-
- @Override public int getRequestCount() {
- return mNetworkRequests.size();
- }
-
- /* TODO: delete when all callers have migrated to NetworkProvider IDs. */
- @Override public int getSerialNumber() {
- return mProvider.getProviderId();
- }
-
- @Override public NetworkProvider getProvider() {
- return mProvider;
- }
-
- @Override public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
- writer.println(toString());
- for (NetworkRequestInfo n : mNetworkRequests.values()) {
- writer.println(" " + n);
- }
- }
-
- @Override public String toString() {
- return "providerId="
- + mProvider.getProviderId() + ", ScoreFilter="
- + mScore + ", Filter=" + mCapabilityFilter + ", requests="
- + mNetworkRequests.size();
- }
-}
diff --git a/common/device/android/net/NetworkFactoryShim.java b/common/device/android/net/NetworkFactoryShim.java
deleted file mode 100644
index dfbb5ec..0000000
--- a/common/device/android/net/NetworkFactoryShim.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.os.Looper;
-import android.os.Message;
-
-import com.android.internal.annotations.VisibleForTesting;
-
-import java.io.FileDescriptor;
-import java.io.PrintWriter;
-
-/**
- * Extract an interface for multiple implementation of {@link NetworkFactory}, depending on the SDK
- * version.
- *
- * Known implementations:
- * - {@link NetworkFactoryImpl}: For Android S+
- * - {@link NetworkFactoryLegacyImpl}: For Android R-
- *
- * @hide
- */
-interface NetworkFactoryShim {
- void register(String logTag);
-
- default void registerIgnoringScore(String logTag) {
- throw new UnsupportedOperationException();
- }
-
- void terminate();
-
- void releaseRequestAsUnfulfillableByAnyFactory(NetworkRequest r);
-
- void reevaluateAllRequests();
-
- void setScoreFilter(int score);
-
- void setScoreFilter(@NonNull NetworkScore score);
-
- void setCapabilityFilter(NetworkCapabilities netCap);
-
- int getRequestCount();
-
- int getSerialNumber();
-
- NetworkProvider getProvider();
-
- void dump(FileDescriptor fd, PrintWriter writer, String[] args);
-
- // All impls inherit Handler
- @VisibleForTesting
- Message obtainMessage(int what, int arg1, int arg2, @Nullable Object obj);
-
- Looper getLooper();
-}
diff --git a/common/device/com/android/net/module/util/HexDump.java b/common/device/com/android/net/module/util/HexDump.java
index a27c0a3..6d36487 100644
--- a/common/device/com/android/net/module/util/HexDump.java
+++ b/common/device/com/android/net/module/util/HexDump.java
@@ -16,7 +16,7 @@
package com.android.net.module.util;
-import androidx.annotation.Nullable;
+import android.annotation.Nullable;
/**
* Hex utility functions.
diff --git a/common/device/com/android/net/module/util/Struct.java b/common/device/com/android/net/module/util/Struct.java
index b43e2c4..d95c303 100644
--- a/common/device/com/android/net/module/util/Struct.java
+++ b/common/device/com/android/net/module/util/Struct.java
@@ -16,11 +16,10 @@
package com.android.net.module.util;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.net.MacAddress;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
diff --git a/common/device/com/android/net/module/util/netlink/ConntrackMessage.java b/common/device/com/android/net/module/util/netlink/ConntrackMessage.java
deleted file mode 100644
index dfed3ef..0000000
--- a/common/device/com/android/net/module/util/netlink/ConntrackMessage.java
+++ /dev/null
@@ -1,560 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static android.system.OsConstants.IPPROTO_TCP;
-import static android.system.OsConstants.IPPROTO_UDP;
-
-import static com.android.net.module.util.netlink.StructNlAttr.findNextAttrOfType;
-import static com.android.net.module.util.netlink.StructNlAttr.makeNestedType;
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_ACK;
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REPLACE;
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REQUEST;
-
-import static java.nio.ByteOrder.BIG_ENDIAN;
-
-import android.system.OsConstants;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.annotation.VisibleForTesting;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Objects;
-
-/**
- * A NetlinkMessage subclass for netlink conntrack messages.
- *
- * see also: <linux_src>/include/uapi/linux/netfilter/nfnetlink_conntrack.h
- *
- * @hide
- */
-public class ConntrackMessage extends NetlinkMessage {
- public static final int STRUCT_SIZE = StructNlMsgHdr.STRUCT_SIZE + StructNfGenMsg.STRUCT_SIZE;
-
- // enum ctattr_type
- public static final short CTA_TUPLE_ORIG = 1;
- public static final short CTA_TUPLE_REPLY = 2;
- public static final short CTA_STATUS = 3;
- public static final short CTA_TIMEOUT = 7;
-
- // enum ctattr_tuple
- public static final short CTA_TUPLE_IP = 1;
- public static final short CTA_TUPLE_PROTO = 2;
-
- // enum ctattr_ip
- public static final short CTA_IP_V4_SRC = 1;
- public static final short CTA_IP_V4_DST = 2;
-
- // enum ctattr_l4proto
- public static final short CTA_PROTO_NUM = 1;
- public static final short CTA_PROTO_SRC_PORT = 2;
- public static final short CTA_PROTO_DST_PORT = 3;
-
- // enum ip_conntrack_status
- public static final int IPS_EXPECTED = 0x00000001;
- public static final int IPS_SEEN_REPLY = 0x00000002;
- public static final int IPS_ASSURED = 0x00000004;
- public static final int IPS_CONFIRMED = 0x00000008;
- public static final int IPS_SRC_NAT = 0x00000010;
- public static final int IPS_DST_NAT = 0x00000020;
- public static final int IPS_SEQ_ADJUST = 0x00000040;
- public static final int IPS_SRC_NAT_DONE = 0x00000080;
- public static final int IPS_DST_NAT_DONE = 0x00000100;
- public static final int IPS_DYING = 0x00000200;
- public static final int IPS_FIXED_TIMEOUT = 0x00000400;
- public static final int IPS_TEMPLATE = 0x00000800;
- public static final int IPS_UNTRACKED = 0x00001000;
- public static final int IPS_HELPER = 0x00002000;
- public static final int IPS_OFFLOAD = 0x00004000;
- public static final int IPS_HW_OFFLOAD = 0x00008000;
-
- // ip_conntrack_status mask
- // Interesting on the NAT conntrack session which has already seen two direction traffic.
- // TODO: Probably IPS_{SRC, DST}_NAT_DONE are also interesting.
- public static final int ESTABLISHED_MASK = IPS_CONFIRMED | IPS_ASSURED | IPS_SEEN_REPLY
- | IPS_SRC_NAT;
- // Interesting on the established NAT conntrack session which is dying.
- public static final int DYING_MASK = ESTABLISHED_MASK | IPS_DYING;
-
- /**
- * A tuple for the conntrack connection information.
- *
- * see also CTA_TUPLE_ORIG and CTA_TUPLE_REPLY.
- */
- public static class Tuple {
- public final Inet4Address srcIp;
- public final Inet4Address dstIp;
-
- // Both port and protocol number are unsigned numbers stored in signed integers, and that
- // callers that want to compare them to integers should either cast those integers, or
- // convert them to unsigned using Byte.toUnsignedInt() and Short.toUnsignedInt().
- public final short srcPort;
- public final short dstPort;
- public final byte protoNum;
-
- public Tuple(TupleIpv4 ip, TupleProto proto) {
- this.srcIp = ip.src;
- this.dstIp = ip.dst;
- this.srcPort = proto.srcPort;
- this.dstPort = proto.dstPort;
- this.protoNum = proto.protoNum;
- }
-
- @Override
- @VisibleForTesting
- public boolean equals(Object o) {
- if (!(o instanceof Tuple)) return false;
- Tuple that = (Tuple) o;
- return Objects.equals(this.srcIp, that.srcIp)
- && Objects.equals(this.dstIp, that.dstIp)
- && this.srcPort == that.srcPort
- && this.dstPort == that.dstPort
- && this.protoNum == that.protoNum;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(srcIp, dstIp, srcPort, dstPort, protoNum);
- }
-
- @Override
- public String toString() {
- final String srcIpStr = (srcIp == null) ? "null" : srcIp.getHostAddress();
- final String dstIpStr = (dstIp == null) ? "null" : dstIp.getHostAddress();
- final String protoStr = NetlinkConstants.stringForProtocol(protoNum);
-
- return "Tuple{"
- + protoStr + ": "
- + srcIpStr + ":" + Short.toUnsignedInt(srcPort) + " -> "
- + dstIpStr + ":" + Short.toUnsignedInt(dstPort)
- + "}";
- }
- }
-
- /**
- * A tuple for the conntrack connection address.
- *
- * see also CTA_TUPLE_IP.
- */
- public static class TupleIpv4 {
- public final Inet4Address src;
- public final Inet4Address dst;
-
- public TupleIpv4(Inet4Address src, Inet4Address dst) {
- this.src = src;
- this.dst = dst;
- }
- }
-
- /**
- * A tuple for the conntrack connection protocol.
- *
- * see also CTA_TUPLE_PROTO.
- */
- public static class TupleProto {
- public final byte protoNum;
- public final short srcPort;
- public final short dstPort;
-
- public TupleProto(byte protoNum, short srcPort, short dstPort) {
- this.protoNum = protoNum;
- this.srcPort = srcPort;
- this.dstPort = dstPort;
- }
- }
-
- /**
- * Create a netlink message to refresh IPv4 conntrack entry timeout.
- */
- public static byte[] newIPv4TimeoutUpdateRequest(
- int proto, Inet4Address src, int sport, Inet4Address dst, int dport, int timeoutSec) {
- // *** STYLE WARNING ***
- //
- // Code below this point uses extra block indentation to highlight the
- // packing of nested tuple netlink attribute types.
- final StructNlAttr ctaTupleOrig = new StructNlAttr(CTA_TUPLE_ORIG,
- new StructNlAttr(CTA_TUPLE_IP,
- new StructNlAttr(CTA_IP_V4_SRC, src),
- new StructNlAttr(CTA_IP_V4_DST, dst)),
- new StructNlAttr(CTA_TUPLE_PROTO,
- new StructNlAttr(CTA_PROTO_NUM, (byte) proto),
- new StructNlAttr(CTA_PROTO_SRC_PORT, (short) sport, BIG_ENDIAN),
- new StructNlAttr(CTA_PROTO_DST_PORT, (short) dport, BIG_ENDIAN)));
-
- final StructNlAttr ctaTimeout = new StructNlAttr(CTA_TIMEOUT, timeoutSec, BIG_ENDIAN);
-
- final int payloadLength = ctaTupleOrig.getAlignedLength() + ctaTimeout.getAlignedLength();
- final byte[] bytes = new byte[STRUCT_SIZE + payloadLength];
- final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
- byteBuffer.order(ByteOrder.nativeOrder());
-
- final ConntrackMessage ctmsg = new ConntrackMessage();
- ctmsg.mHeader.nlmsg_len = bytes.length;
- ctmsg.mHeader.nlmsg_type = (NetlinkConstants.NFNL_SUBSYS_CTNETLINK << 8)
- | NetlinkConstants.IPCTNL_MSG_CT_NEW;
- ctmsg.mHeader.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_REPLACE;
- ctmsg.mHeader.nlmsg_seq = 1;
- ctmsg.pack(byteBuffer);
-
- ctaTupleOrig.pack(byteBuffer);
- ctaTimeout.pack(byteBuffer);
-
- return bytes;
- }
-
- /**
- * Parses a netfilter conntrack message from a {@link ByteBuffer}.
- *
- * @param header the netlink message header.
- * @param byteBuffer The buffer from which to parse the netfilter conntrack message.
- * @return the parsed netfilter conntrack message, or {@code null} if the netfilter conntrack
- * message could not be parsed successfully (for example, if it was truncated).
- */
- @Nullable
- public static ConntrackMessage parse(@NonNull StructNlMsgHdr header,
- @NonNull ByteBuffer byteBuffer) {
- // Just build the netlink header and netfilter header for now and pretend the whole message
- // was consumed.
- // TODO: Parse the conntrack attributes.
- final StructNfGenMsg nfGenMsg = StructNfGenMsg.parse(byteBuffer);
- if (nfGenMsg == null) {
- return null;
- }
-
- final int baseOffset = byteBuffer.position();
- StructNlAttr nlAttr = findNextAttrOfType(CTA_STATUS, byteBuffer);
- int status = 0;
- if (nlAttr != null) {
- status = nlAttr.getValueAsBe32(0);
- }
-
- byteBuffer.position(baseOffset);
- nlAttr = findNextAttrOfType(CTA_TIMEOUT, byteBuffer);
- int timeoutSec = 0;
- if (nlAttr != null) {
- timeoutSec = nlAttr.getValueAsBe32(0);
- }
-
- byteBuffer.position(baseOffset);
- nlAttr = findNextAttrOfType(makeNestedType(CTA_TUPLE_ORIG), byteBuffer);
- Tuple tupleOrig = null;
- if (nlAttr != null) {
- tupleOrig = parseTuple(nlAttr.getValueAsByteBuffer());
- }
-
- byteBuffer.position(baseOffset);
- nlAttr = findNextAttrOfType(makeNestedType(CTA_TUPLE_REPLY), byteBuffer);
- Tuple tupleReply = null;
- if (nlAttr != null) {
- tupleReply = parseTuple(nlAttr.getValueAsByteBuffer());
- }
-
- // Advance to the end of the message.
- byteBuffer.position(baseOffset);
- final int kMinConsumed = StructNlMsgHdr.STRUCT_SIZE + StructNfGenMsg.STRUCT_SIZE;
- final int kAdditionalSpace = NetlinkConstants.alignedLengthOf(
- header.nlmsg_len - kMinConsumed);
- if (byteBuffer.remaining() < kAdditionalSpace) {
- return null;
- }
- byteBuffer.position(baseOffset + kAdditionalSpace);
-
- return new ConntrackMessage(header, nfGenMsg, tupleOrig, tupleReply, status, timeoutSec);
- }
-
- /**
- * Parses a conntrack tuple from a {@link ByteBuffer}.
- *
- * The attribute parsing is interesting on:
- * - CTA_TUPLE_IP
- * CTA_IP_V4_SRC
- * CTA_IP_V4_DST
- * - CTA_TUPLE_PROTO
- * CTA_PROTO_NUM
- * CTA_PROTO_SRC_PORT
- * CTA_PROTO_DST_PORT
- *
- * Assume that the minimum size is the sum of CTA_TUPLE_IP (size: 20) and CTA_TUPLE_PROTO
- * (size: 28). Here is an example for an expected CTA_TUPLE_ORIG message in raw data:
- * +--------------------------------------------------------------------------------------+
- * | CTA_TUPLE_ORIG |
- * +--------------------------+-----------------------------------------------------------+
- * | 1400 | nla_len = 20 |
- * | 0180 | nla_type = nested CTA_TUPLE_IP |
- * | 0800 0100 C0A8500C | nla_type=CTA_IP_V4_SRC, ip=192.168.80.12 |
- * | 0800 0200 8C700874 | nla_type=CTA_IP_V4_DST, ip=140.112.8.116 |
- * | 1C00 | nla_len = 28 |
- * | 0280 | nla_type = nested CTA_TUPLE_PROTO |
- * | 0500 0100 06 000000 | nla_type=CTA_PROTO_NUM, proto=IPPROTO_TCP (6) |
- * | 0600 0200 F3F1 0000 | nla_type=CTA_PROTO_SRC_PORT, port=62449 (big endian) |
- * | 0600 0300 01BB 0000 | nla_type=CTA_PROTO_DST_PORT, port=433 (big endian) |
- * +--------------------------+-----------------------------------------------------------+
- *
- * The position of the byte buffer doesn't set to the end when the function returns. It is okay
- * because the caller ConntrackMessage#parse has passed a copy which is used for this parser
- * only. Moreover, the parser behavior is the same as other existing netlink struct class
- * parser. Ex: StructInetDiagMsg#parse.
- */
- @Nullable
- private static Tuple parseTuple(@Nullable ByteBuffer byteBuffer) {
- if (byteBuffer == null) return null;
-
- TupleIpv4 tupleIpv4 = null;
- TupleProto tupleProto = null;
-
- final int baseOffset = byteBuffer.position();
- StructNlAttr nlAttr = findNextAttrOfType(makeNestedType(CTA_TUPLE_IP), byteBuffer);
- if (nlAttr != null) {
- tupleIpv4 = parseTupleIpv4(nlAttr.getValueAsByteBuffer());
- }
- if (tupleIpv4 == null) return null;
-
- byteBuffer.position(baseOffset);
- nlAttr = findNextAttrOfType(makeNestedType(CTA_TUPLE_PROTO), byteBuffer);
- if (nlAttr != null) {
- tupleProto = parseTupleProto(nlAttr.getValueAsByteBuffer());
- }
- if (tupleProto == null) return null;
-
- return new Tuple(tupleIpv4, tupleProto);
- }
-
- @Nullable
- private static Inet4Address castToInet4Address(@Nullable InetAddress address) {
- if (address == null || !(address instanceof Inet4Address)) return null;
- return (Inet4Address) address;
- }
-
- @Nullable
- private static TupleIpv4 parseTupleIpv4(@Nullable ByteBuffer byteBuffer) {
- if (byteBuffer == null) return null;
-
- Inet4Address src = null;
- Inet4Address dst = null;
-
- final int baseOffset = byteBuffer.position();
- StructNlAttr nlAttr = findNextAttrOfType(CTA_IP_V4_SRC, byteBuffer);
- if (nlAttr != null) {
- src = castToInet4Address(nlAttr.getValueAsInetAddress());
- }
- if (src == null) return null;
-
- byteBuffer.position(baseOffset);
- nlAttr = findNextAttrOfType(CTA_IP_V4_DST, byteBuffer);
- if (nlAttr != null) {
- dst = castToInet4Address(nlAttr.getValueAsInetAddress());
- }
- if (dst == null) return null;
-
- return new TupleIpv4(src, dst);
- }
-
- @Nullable
- private static TupleProto parseTupleProto(@Nullable ByteBuffer byteBuffer) {
- if (byteBuffer == null) return null;
-
- byte protoNum = 0;
- short srcPort = 0;
- short dstPort = 0;
-
- final int baseOffset = byteBuffer.position();
- StructNlAttr nlAttr = findNextAttrOfType(CTA_PROTO_NUM, byteBuffer);
- if (nlAttr != null) {
- protoNum = nlAttr.getValueAsByte((byte) 0);
- }
- if (!(protoNum == IPPROTO_TCP || protoNum == IPPROTO_UDP)) return null;
-
- byteBuffer.position(baseOffset);
- nlAttr = StructNlAttr.findNextAttrOfType(CTA_PROTO_SRC_PORT, byteBuffer);
- if (nlAttr != null) {
- srcPort = nlAttr.getValueAsBe16((short) 0);
- }
- if (srcPort == 0) return null;
-
- byteBuffer.position(baseOffset);
- nlAttr = StructNlAttr.findNextAttrOfType(CTA_PROTO_DST_PORT, byteBuffer);
- if (nlAttr != null) {
- dstPort = nlAttr.getValueAsBe16((short) 0);
- }
- if (dstPort == 0) return null;
-
- return new TupleProto(protoNum, srcPort, dstPort);
- }
-
- /**
- * Netfilter header.
- */
- public final StructNfGenMsg nfGenMsg;
- /**
- * Original direction conntrack tuple.
- *
- * The tuple is determined by the parsed attribute value CTA_TUPLE_ORIG, or null if the
- * tuple could not be parsed successfully (for example, if it was truncated or absent).
- */
- @Nullable
- public final Tuple tupleOrig;
- /**
- * Reply direction conntrack tuple.
- *
- * The tuple is determined by the parsed attribute value CTA_TUPLE_REPLY, or null if the
- * tuple could not be parsed successfully (for example, if it was truncated or absent).
- */
- @Nullable
- public final Tuple tupleReply;
- /**
- * Connection status. A bitmask of ip_conntrack_status enum flags.
- *
- * The status is determined by the parsed attribute value CTA_STATUS, or 0 if the status could
- * not be parsed successfully (for example, if it was truncated or absent). For the message
- * from kernel, the valid status is non-zero. For the message from user space, the status may
- * be 0 (absent).
- */
- public final int status;
- /**
- * Conntrack timeout.
- *
- * The timeout is determined by the parsed attribute value CTA_TIMEOUT, or 0 if the timeout
- * could not be parsed successfully (for example, if it was truncated or absent). For
- * IPCTNL_MSG_CT_NEW event, the valid timeout is non-zero. For IPCTNL_MSG_CT_DELETE event, the
- * timeout is 0 (absent).
- */
- public final int timeoutSec;
-
- private ConntrackMessage() {
- super(new StructNlMsgHdr());
- nfGenMsg = new StructNfGenMsg((byte) OsConstants.AF_INET);
-
- // This constructor is only used by #newIPv4TimeoutUpdateRequest which doesn't use these
- // data member for packing message. Simply fill them to null or 0.
- tupleOrig = null;
- tupleReply = null;
- status = 0;
- timeoutSec = 0;
- }
-
- private ConntrackMessage(@NonNull StructNlMsgHdr header, @NonNull StructNfGenMsg nfGenMsg,
- @Nullable Tuple tupleOrig, @Nullable Tuple tupleReply, int status, int timeoutSec) {
- super(header);
- this.nfGenMsg = nfGenMsg;
- this.tupleOrig = tupleOrig;
- this.tupleReply = tupleReply;
- this.status = status;
- this.timeoutSec = timeoutSec;
- }
-
- /**
- * Write a netfilter message to {@link ByteBuffer}.
- */
- public void pack(ByteBuffer byteBuffer) {
- mHeader.pack(byteBuffer);
- nfGenMsg.pack(byteBuffer);
- }
-
- public short getMessageType() {
- return (short) (getHeader().nlmsg_type & ~(NetlinkConstants.NFNL_SUBSYS_CTNETLINK << 8));
- }
-
- /**
- * Convert an ip conntrack status to a string.
- */
- public static String stringForIpConntrackStatus(int flags) {
- final StringBuilder sb = new StringBuilder();
-
- if ((flags & IPS_EXPECTED) != 0) {
- sb.append("IPS_EXPECTED");
- }
- if ((flags & IPS_SEEN_REPLY) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_SEEN_REPLY");
- }
- if ((flags & IPS_ASSURED) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_ASSURED");
- }
- if ((flags & IPS_CONFIRMED) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_CONFIRMED");
- }
- if ((flags & IPS_SRC_NAT) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_SRC_NAT");
- }
- if ((flags & IPS_DST_NAT) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_DST_NAT");
- }
- if ((flags & IPS_SEQ_ADJUST) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_SEQ_ADJUST");
- }
- if ((flags & IPS_SRC_NAT_DONE) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_SRC_NAT_DONE");
- }
- if ((flags & IPS_DST_NAT_DONE) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_DST_NAT_DONE");
- }
- if ((flags & IPS_DYING) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_DYING");
- }
- if ((flags & IPS_FIXED_TIMEOUT) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_FIXED_TIMEOUT");
- }
- if ((flags & IPS_TEMPLATE) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_TEMPLATE");
- }
- if ((flags & IPS_UNTRACKED) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_UNTRACKED");
- }
- if ((flags & IPS_HELPER) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_HELPER");
- }
- if ((flags & IPS_OFFLOAD) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_OFFLOAD");
- }
- if ((flags & IPS_HW_OFFLOAD) != 0) {
- if (sb.length() > 0) sb.append("|");
- sb.append("IPS_HW_OFFLOAD");
- }
- return sb.toString();
- }
-
- @Override
- public String toString() {
- return "ConntrackMessage{"
- + "nlmsghdr{"
- + (mHeader == null ? "" : mHeader.toString(OsConstants.NETLINK_NETFILTER))
- + "}, "
- + "nfgenmsg{" + nfGenMsg + "}, "
- + "tuple_orig{" + tupleOrig + "}, "
- + "tuple_reply{" + tupleReply + "}, "
- + "status{" + status + "(" + stringForIpConntrackStatus(status) + ")" + "}, "
- + "timeout_sec{" + Integer.toUnsignedLong(timeoutSec) + "}"
- + "}";
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/InetDiagMessage.java b/common/device/com/android/net/module/util/netlink/InetDiagMessage.java
deleted file mode 100644
index a8aef7b..0000000
--- a/common/device/com/android/net/module/util/netlink/InetDiagMessage.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static android.os.Process.INVALID_UID;
-import static android.system.OsConstants.AF_INET;
-import static android.system.OsConstants.AF_INET6;
-import static android.system.OsConstants.IPPROTO_UDP;
-import static android.system.OsConstants.NETLINK_INET_DIAG;
-
-import static com.android.net.module.util.netlink.NetlinkConstants.SOCK_DIAG_BY_FAMILY;
-import static com.android.net.module.util.netlink.NetlinkSocket.DEFAULT_RECV_BUFSIZE;
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_DUMP;
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REQUEST;
-
-import android.net.util.SocketUtils;
-import android.system.ErrnoException;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetSocketAddress;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * A NetlinkMessage subclass for netlink inet_diag messages.
- *
- * see also: <linux_src>/include/uapi/linux/inet_diag.h
- *
- * @hide
- */
-public class InetDiagMessage extends NetlinkMessage {
- public static final String TAG = "InetDiagMessage";
- private static final int TIMEOUT_MS = 500;
-
- /**
- * Construct an inet_diag_req_v2 message. This method will throw {@code NullPointerException}
- * if local and remote are not both null or both non-null.
- */
- public static byte[] inetDiagReqV2(int protocol, InetSocketAddress local,
- InetSocketAddress remote, int family, short flags) {
- return inetDiagReqV2(protocol, local, remote, family, flags, 0 /* pad */,
- 0 /* idiagExt */, StructInetDiagReqV2.INET_DIAG_REQ_V2_ALL_STATES);
- }
-
- /**
- * Construct an inet_diag_req_v2 message. This method will throw {@code NullPointerException}
- * if local and remote are not both null or both non-null.
- *
- * @param protocol the request protocol type. This should be set to one of IPPROTO_TCP,
- * IPPROTO_UDP, or IPPROTO_UDPLITE.
- * @param local local socket address of the target socket. This will be packed into a
- * {@Code StructInetDiagSockId}. Request to diagnose for all sockets if both of
- * local or remote address is null.
- * @param remote remote socket address of the target socket. This will be packed into a
- * {@Code StructInetDiagSockId}. Request to diagnose for all sockets if both of
- * local or remote address is null.
- * @param family the ip family of the request message. This should be set to either AF_INET or
- * AF_INET6 for IPv4 or IPv6 sockets respectively.
- * @param flags message flags. See <linux_src>/include/uapi/linux/netlink.h.
- * @param pad for raw socket protocol specification.
- * @param idiagExt a set of flags defining what kind of extended information to report.
- * @param state a bit mask that defines a filter of socket states.
- *
- * @return bytes array representation of the message
- */
- public static byte[] inetDiagReqV2(int protocol, @Nullable InetSocketAddress local,
- @Nullable InetSocketAddress remote, int family, short flags, int pad, int idiagExt,
- int state) throws NullPointerException {
- final byte[] bytes = new byte[StructNlMsgHdr.STRUCT_SIZE + StructInetDiagReqV2.STRUCT_SIZE];
- final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
- byteBuffer.order(ByteOrder.nativeOrder());
-
- final StructNlMsgHdr nlMsgHdr = new StructNlMsgHdr();
- nlMsgHdr.nlmsg_len = bytes.length;
- nlMsgHdr.nlmsg_type = SOCK_DIAG_BY_FAMILY;
- nlMsgHdr.nlmsg_flags = flags;
- nlMsgHdr.pack(byteBuffer);
- final StructInetDiagReqV2 inetDiagReqV2 =
- new StructInetDiagReqV2(protocol, local, remote, family, pad, idiagExt, state);
-
- inetDiagReqV2.pack(byteBuffer);
- return bytes;
- }
-
- public StructInetDiagMsg mStructInetDiagMsg;
-
- private InetDiagMessage(@NonNull StructNlMsgHdr header) {
- super(header);
- mStructInetDiagMsg = new StructInetDiagMsg();
- }
-
- /**
- * Parse an inet_diag_req_v2 message from buffer.
- */
- @NonNull
- public static InetDiagMessage parse(@NonNull StructNlMsgHdr header,
- @NonNull ByteBuffer byteBuffer) {
- final InetDiagMessage msg = new InetDiagMessage(header);
- msg.mStructInetDiagMsg = StructInetDiagMsg.parse(byteBuffer);
- return msg;
- }
-
- private static int lookupUidByFamily(int protocol, InetSocketAddress local,
- InetSocketAddress remote, int family, short flags,
- FileDescriptor fd)
- throws ErrnoException, InterruptedIOException {
- byte[] msg = inetDiagReqV2(protocol, local, remote, family, flags);
- NetlinkSocket.sendMessage(fd, msg, 0, msg.length, TIMEOUT_MS);
- ByteBuffer response = NetlinkSocket.recvMessage(fd, DEFAULT_RECV_BUFSIZE, TIMEOUT_MS);
-
- final NetlinkMessage nlMsg = NetlinkMessage.parse(response, NETLINK_INET_DIAG);
- final StructNlMsgHdr hdr = nlMsg.getHeader();
- if (hdr.nlmsg_type == NetlinkConstants.NLMSG_DONE) {
- return INVALID_UID;
- }
- if (nlMsg instanceof InetDiagMessage) {
- return ((InetDiagMessage) nlMsg).mStructInetDiagMsg.idiag_uid;
- }
- return INVALID_UID;
- }
-
- private static final int[] FAMILY = {AF_INET6, AF_INET};
-
- private static int lookupUid(int protocol, InetSocketAddress local,
- InetSocketAddress remote, FileDescriptor fd)
- throws ErrnoException, InterruptedIOException {
- int uid;
-
- for (int family : FAMILY) {
- /**
- * For exact match lookup, swap local and remote for UDP lookups due to kernel
- * bug which will not be fixed. See aosp/755889 and
- * https://www.mail-archive.com/netdev@vger.kernel.org/msg248638.html
- */
- if (protocol == IPPROTO_UDP) {
- uid = lookupUidByFamily(protocol, remote, local, family, NLM_F_REQUEST, fd);
- } else {
- uid = lookupUidByFamily(protocol, local, remote, family, NLM_F_REQUEST, fd);
- }
- if (uid != INVALID_UID) {
- return uid;
- }
- }
-
- /**
- * For UDP it's possible for a socket to send packets to arbitrary destinations, even if the
- * socket is not connected (and even if the socket is connected to a different destination).
- * If we want this API to work for such packets, then on miss we need to do a second lookup
- * with only the local address and port filled in.
- * Always use flags == NLM_F_REQUEST | NLM_F_DUMP for wildcard.
- */
- if (protocol == IPPROTO_UDP) {
- try {
- InetSocketAddress wildcard = new InetSocketAddress(
- Inet6Address.getByName("::"), 0);
- uid = lookupUidByFamily(protocol, local, wildcard, AF_INET6,
- (short) (NLM_F_REQUEST | NLM_F_DUMP), fd);
- if (uid != INVALID_UID) {
- return uid;
- }
- wildcard = new InetSocketAddress(Inet4Address.getByName("0.0.0.0"), 0);
- uid = lookupUidByFamily(protocol, local, wildcard, AF_INET,
- (short) (NLM_F_REQUEST | NLM_F_DUMP), fd);
- if (uid != INVALID_UID) {
- return uid;
- }
- } catch (UnknownHostException e) {
- Log.e(TAG, e.toString());
- }
- }
- return INVALID_UID;
- }
-
- /**
- * Use an inet_diag socket to look up the UID associated with the input local and remote
- * address/port and protocol of a connection.
- */
- public static int getConnectionOwnerUid(int protocol, InetSocketAddress local,
- InetSocketAddress remote) {
- int uid = INVALID_UID;
- FileDescriptor fd = null;
- try {
- fd = NetlinkSocket.forProto(NETLINK_INET_DIAG);
- NetlinkSocket.connectToKernel(fd);
- uid = lookupUid(protocol, local, remote, fd);
- } catch (ErrnoException | SocketException | IllegalArgumentException
- | InterruptedIOException e) {
- Log.e(TAG, e.toString());
- } finally {
- if (fd != null) {
- try {
- SocketUtils.closeSocket(fd);
- } catch (IOException e) {
- Log.e(TAG, e.toString());
- }
- }
- }
- return uid;
- }
-
- @Override
- public String toString() {
- return "InetDiagMessage{ "
- + "nlmsghdr{"
- + (mHeader == null ? "" : mHeader.toString(NETLINK_INET_DIAG)) + "}, "
- + "inet_diag_msg{"
- + (mStructInetDiagMsg == null ? "" : mStructInetDiagMsg.toString()) + "} "
- + "}";
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/NdOption.java b/common/device/com/android/net/module/util/netlink/NdOption.java
deleted file mode 100644
index defc88a..0000000
--- a/common/device/com/android/net/module/util/netlink/NdOption.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import androidx.annotation.NonNull;
-
-import java.nio.ByteBuffer;
-
-/**
- * Base class for IPv6 neighbour discovery options.
- */
-public class NdOption {
- public static final int STRUCT_SIZE = 2;
-
- /** The option type. */
- public final byte type;
- /** The length of the option in 8-byte units. Actually an unsigned 8-bit integer */
- public final int length;
-
- /** Constructs a new NdOption. */
- NdOption(byte type, int length) {
- this.type = type;
- this.length = length;
- }
-
- /**
- * Parses a neighbour discovery option.
- *
- * Parses (and consumes) the option if it is of a known type. If the option is of an unknown
- * type, advances the buffer (so the caller can continue parsing if desired) and returns
- * {@link #UNKNOWN}. If the option claims a length of 0, returns null because parsing cannot
- * continue.
- *
- * No checks are performed on the length other than ensuring it is not 0, so if a caller wants
- * to deal with options that might overflow the structure that contains them, it must explicitly
- * set the buffer's limit to the position at which that structure ends.
- *
- * @param buf the buffer to parse.
- * @return a subclass of {@link NdOption}, or {@code null} for an unknown or malformed option.
- */
- public static NdOption parse(@NonNull ByteBuffer buf) {
- if (buf.remaining() < STRUCT_SIZE) return null;
-
- // Peek the type without advancing the buffer.
- byte type = buf.get(buf.position());
- int length = Byte.toUnsignedInt(buf.get(buf.position() + 1));
- if (length == 0) return null;
-
- switch (type) {
- case StructNdOptPref64.TYPE:
- return StructNdOptPref64.parse(buf);
-
- case StructNdOptRdnss.TYPE:
- return StructNdOptRdnss.parse(buf);
-
- default:
- int newPosition = Math.min(buf.limit(), buf.position() + length * 8);
- buf.position(newPosition);
- return UNKNOWN;
- }
- }
-
- void writeToByteBuffer(ByteBuffer buf) {
- buf.put(type);
- buf.put((byte) length);
- }
-
- @Override
- public String toString() {
- return String.format("NdOption(%d, %d)", Byte.toUnsignedInt(type), length);
- }
-
- public static final NdOption UNKNOWN = new NdOption((byte) 0, 0);
-}
diff --git a/common/device/com/android/net/module/util/netlink/NduseroptMessage.java b/common/device/com/android/net/module/util/netlink/NduseroptMessage.java
deleted file mode 100644
index bdf574d..0000000
--- a/common/device/com/android/net/module/util/netlink/NduseroptMessage.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static android.system.OsConstants.AF_INET6;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.BufferUnderflowException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * A NetlinkMessage subclass for RTM_NEWNDUSEROPT messages.
- */
-public class NduseroptMessage extends NetlinkMessage {
- public static final int STRUCT_SIZE = 16;
-
- static final int NDUSEROPT_SRCADDR = 1;
-
- /** The address family. Presumably always AF_INET6. */
- public final byte family;
- /**
- * The total length in bytes of the options that follow this structure.
- * Actually a 16-bit unsigned integer.
- */
- public final int opts_len;
- /** The interface index on which the options were received. */
- public final int ifindex;
- /** The ICMP type of the packet that contained the options. */
- public final byte icmp_type;
- /** The ICMP code of the packet that contained the options. */
- public final byte icmp_code;
-
- /**
- * ND option that was in this message.
- * Even though the length field is called "opts_len", the kernel only ever sends one option per
- * message. It is unlikely that this will ever change as it would break existing userspace code.
- * But if it does, we can simply update this code, since userspace is typically newer than the
- * kernel.
- */
- @Nullable
- public final NdOption option;
-
- /** The IP address that sent the packet containing the option. */
- public final InetAddress srcaddr;
-
- NduseroptMessage(@NonNull StructNlMsgHdr header, @NonNull ByteBuffer buf)
- throws UnknownHostException {
- super(header);
-
- // The structure itself.
- buf.order(ByteOrder.nativeOrder()); // Restored in the finally clause inside parse().
- final int start = buf.position();
- family = buf.get();
- buf.get(); // Skip 1 byte of padding.
- opts_len = Short.toUnsignedInt(buf.getShort());
- ifindex = buf.getInt();
- icmp_type = buf.get();
- icmp_code = buf.get();
- buf.position(buf.position() + 6); // Skip 6 bytes of padding.
-
- // The ND option.
- // Ensure we don't read past opts_len even if the option length is invalid.
- // Note that this check is not really necessary since if the option length is not valid,
- // this struct won't be very useful to the caller.
- //
- // It's safer to pass the slice of original ByteBuffer to just parse the ND option field,
- // although parsing ND option might throw exception or return null, it won't break the
- // original ByteBuffer position.
- buf.order(ByteOrder.BIG_ENDIAN);
- try {
- final ByteBuffer slice = buf.slice();
- slice.limit(opts_len);
- option = NdOption.parse(slice);
- } finally {
- // Advance buffer position according to opts_len in the header. ND option length might
- // be incorrect in the malformed packet.
- int newPosition = start + STRUCT_SIZE + opts_len;
- if (newPosition >= buf.limit()) {
- throw new IllegalArgumentException("ND option extends past end of buffer");
- }
- buf.position(newPosition);
- }
-
- // The source address attribute.
- StructNlAttr nla = StructNlAttr.parse(buf);
- if (nla == null || nla.nla_type != NDUSEROPT_SRCADDR || nla.nla_value == null) {
- throw new IllegalArgumentException("Invalid source address in ND useropt");
- }
- if (family == AF_INET6) {
- // InetAddress.getByAddress only looks at the ifindex if the address type needs one.
- srcaddr = Inet6Address.getByAddress(null /* hostname */, nla.nla_value, ifindex);
- } else {
- srcaddr = InetAddress.getByAddress(nla.nla_value);
- }
- }
-
- /**
- * Parses a StructNduseroptmsg from a {@link ByteBuffer}.
- *
- * @param header the netlink message header.
- * @param buf The buffer from which to parse the option. The buffer's byte order must be
- * {@link java.nio.ByteOrder#BIG_ENDIAN}.
- * @return the parsed option, or {@code null} if the option could not be parsed successfully
- * (for example, if it was truncated, or if the prefix length code was wrong).
- */
- @Nullable
- public static NduseroptMessage parse(@NonNull StructNlMsgHdr header, @NonNull ByteBuffer buf) {
- if (buf == null || buf.remaining() < STRUCT_SIZE) return null;
- ByteOrder oldOrder = buf.order();
- try {
- return new NduseroptMessage(header, buf);
- } catch (IllegalArgumentException | UnknownHostException | BufferUnderflowException e) {
- // Not great, but better than throwing an exception that might crash the caller.
- // Convention in this package is that null indicates that the option was truncated, so
- // callers must already handle it.
- return null;
- } finally {
- buf.order(oldOrder);
- }
- }
-
- @Override
- public String toString() {
- return String.format("Nduseroptmsg(%d, %d, %d, %d, %d, %s)",
- family, opts_len, ifindex, Byte.toUnsignedInt(icmp_type),
- Byte.toUnsignedInt(icmp_code), srcaddr.getHostAddress());
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/NetlinkConstants.java b/common/device/com/android/net/module/util/netlink/NetlinkConstants.java
deleted file mode 100644
index cf9d2c5..0000000
--- a/common/device/com/android/net/module/util/netlink/NetlinkConstants.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import android.system.OsConstants;
-
-import androidx.annotation.NonNull;
-
-import java.nio.ByteBuffer;
-
-/**
- * Various constants and static helper methods for netlink communications.
- *
- * Values taken from:
- *
- * include/uapi/linux/netfilter/nfnetlink.h
- * include/uapi/linux/netfilter/nfnetlink_conntrack.h
- * include/uapi/linux/netlink.h
- * include/uapi/linux/rtnetlink.h
- *
- * @hide
- */
-public class NetlinkConstants {
- private NetlinkConstants() {}
-
- public static final int NLA_ALIGNTO = 4;
- /**
- * Flag for dumping struct tcp_info.
- * Corresponding to enum definition in external/strace/linux/inet_diag.h.
- */
- public static final int INET_DIAG_MEMINFO = 1;
-
- public static final int SOCKDIAG_MSG_HEADER_SIZE =
- StructNlMsgHdr.STRUCT_SIZE + StructInetDiagMsg.STRUCT_SIZE;
-
- /**
- * Get the aligned length based on a Short type number.
- */
- public static final int alignedLengthOf(short length) {
- final int intLength = (int) length & 0xffff;
- return alignedLengthOf(intLength);
- }
-
- /**
- * Get the aligned length based on a Integer type number.
- */
- public static final int alignedLengthOf(int length) {
- if (length <= 0) return 0;
- return (((length + NLA_ALIGNTO - 1) / NLA_ALIGNTO) * NLA_ALIGNTO);
- }
-
- /**
- * Convert a address family type to a string.
- */
- public static String stringForAddressFamily(int family) {
- if (family == OsConstants.AF_INET) return "AF_INET";
- if (family == OsConstants.AF_INET6) return "AF_INET6";
- if (family == OsConstants.AF_NETLINK) return "AF_NETLINK";
- return String.valueOf(family);
- }
-
- /**
- * Convert a protocol type to a string.
- */
- public static String stringForProtocol(int protocol) {
- if (protocol == OsConstants.IPPROTO_TCP) return "IPPROTO_TCP";
- if (protocol == OsConstants.IPPROTO_UDP) return "IPPROTO_UDP";
- return String.valueOf(protocol);
- }
-
- /**
- * Convert a byte array to a hexadecimal string.
- */
- public static String hexify(byte[] bytes) {
- if (bytes == null) return "(null)";
- return toHexString(bytes, 0, bytes.length);
- }
-
- /**
- * Convert a {@link ByteBuffer} to a hexadecimal string.
- */
- public static String hexify(ByteBuffer buffer) {
- if (buffer == null) return "(null)";
- return toHexString(
- buffer.array(), buffer.position(), buffer.remaining());
- }
-
- // Known values for struct nlmsghdr nlm_type.
- public static final short NLMSG_NOOP = 1; // Nothing
- public static final short NLMSG_ERROR = 2; // Error
- public static final short NLMSG_DONE = 3; // End of a dump
- public static final short NLMSG_OVERRUN = 4; // Data lost
- public static final short NLMSG_MAX_RESERVED = 15; // Max reserved value
-
- public static final short RTM_NEWLINK = 16;
- public static final short RTM_DELLINK = 17;
- public static final short RTM_GETLINK = 18;
- public static final short RTM_SETLINK = 19;
- public static final short RTM_NEWADDR = 20;
- public static final short RTM_DELADDR = 21;
- public static final short RTM_GETADDR = 22;
- public static final short RTM_NEWROUTE = 24;
- public static final short RTM_DELROUTE = 25;
- public static final short RTM_GETROUTE = 26;
- public static final short RTM_NEWNEIGH = 28;
- public static final short RTM_DELNEIGH = 29;
- public static final short RTM_GETNEIGH = 30;
- public static final short RTM_NEWRULE = 32;
- public static final short RTM_DELRULE = 33;
- public static final short RTM_GETRULE = 34;
- public static final short RTM_NEWNDUSEROPT = 68;
-
- // Netfilter netlink message types are presented by two bytes: high byte subsystem and
- // low byte operation. See the macro NFNL_SUBSYS_ID and NFNL_MSG_TYPE in
- // include/uapi/linux/netfilter/nfnetlink.h
- public static final short NFNL_SUBSYS_CTNETLINK = 1;
-
- public static final short IPCTNL_MSG_CT_NEW = 0;
- public static final short IPCTNL_MSG_CT_GET = 1;
- public static final short IPCTNL_MSG_CT_DELETE = 2;
- public static final short IPCTNL_MSG_CT_GET_CTRZERO = 3;
- public static final short IPCTNL_MSG_CT_GET_STATS_CPU = 4;
- public static final short IPCTNL_MSG_CT_GET_STATS = 5;
- public static final short IPCTNL_MSG_CT_GET_DYING = 6;
- public static final short IPCTNL_MSG_CT_GET_UNCONFIRMED = 7;
-
- /* see include/uapi/linux/sock_diag.h */
- public static final short SOCK_DIAG_BY_FAMILY = 20;
-
- // Netlink groups.
- public static final int RTNLGRP_ND_USEROPT = 20;
- public static final int RTMGRP_ND_USEROPT = 1 << (RTNLGRP_ND_USEROPT - 1);
-
- /**
- * Convert a netlink message type to a string for control message.
- */
- @NonNull
- private static String stringForCtlMsgType(short nlmType) {
- switch (nlmType) {
- case NLMSG_NOOP: return "NLMSG_NOOP";
- case NLMSG_ERROR: return "NLMSG_ERROR";
- case NLMSG_DONE: return "NLMSG_DONE";
- case NLMSG_OVERRUN: return "NLMSG_OVERRUN";
- default: return "unknown control message type: " + String.valueOf(nlmType);
- }
- }
-
- /**
- * Convert a netlink message type to a string for NETLINK_ROUTE.
- */
- @NonNull
- private static String stringForRtMsgType(short nlmType) {
- switch (nlmType) {
- case RTM_NEWLINK: return "RTM_NEWLINK";
- case RTM_DELLINK: return "RTM_DELLINK";
- case RTM_GETLINK: return "RTM_GETLINK";
- case RTM_SETLINK: return "RTM_SETLINK";
- case RTM_NEWADDR: return "RTM_NEWADDR";
- case RTM_DELADDR: return "RTM_DELADDR";
- case RTM_GETADDR: return "RTM_GETADDR";
- case RTM_NEWROUTE: return "RTM_NEWROUTE";
- case RTM_DELROUTE: return "RTM_DELROUTE";
- case RTM_GETROUTE: return "RTM_GETROUTE";
- case RTM_NEWNEIGH: return "RTM_NEWNEIGH";
- case RTM_DELNEIGH: return "RTM_DELNEIGH";
- case RTM_GETNEIGH: return "RTM_GETNEIGH";
- case RTM_NEWRULE: return "RTM_NEWRULE";
- case RTM_DELRULE: return "RTM_DELRULE";
- case RTM_GETRULE: return "RTM_GETRULE";
- case RTM_NEWNDUSEROPT: return "RTM_NEWNDUSEROPT";
- default: return "unknown RTM type: " + String.valueOf(nlmType);
- }
- }
-
- /**
- * Convert a netlink message type to a string for NETLINK_INET_DIAG.
- */
- @NonNull
- private static String stringForInetDiagMsgType(short nlmType) {
- switch (nlmType) {
- case SOCK_DIAG_BY_FAMILY: return "SOCK_DIAG_BY_FAMILY";
- default: return "unknown SOCK_DIAG type: " + String.valueOf(nlmType);
- }
- }
-
- /**
- * Convert a netlink message type to a string for NETLINK_NETFILTER.
- */
- @NonNull
- private static String stringForNfMsgType(short nlmType) {
- final byte subsysId = (byte) (nlmType >> 8);
- final byte msgType = (byte) nlmType;
- switch (subsysId) {
- case NFNL_SUBSYS_CTNETLINK:
- switch (msgType) {
- case IPCTNL_MSG_CT_NEW: return "IPCTNL_MSG_CT_NEW";
- case IPCTNL_MSG_CT_GET: return "IPCTNL_MSG_CT_GET";
- case IPCTNL_MSG_CT_DELETE: return "IPCTNL_MSG_CT_DELETE";
- case IPCTNL_MSG_CT_GET_CTRZERO: return "IPCTNL_MSG_CT_GET_CTRZERO";
- case IPCTNL_MSG_CT_GET_STATS_CPU: return "IPCTNL_MSG_CT_GET_STATS_CPU";
- case IPCTNL_MSG_CT_GET_STATS: return "IPCTNL_MSG_CT_GET_STATS";
- case IPCTNL_MSG_CT_GET_DYING: return "IPCTNL_MSG_CT_GET_DYING";
- case IPCTNL_MSG_CT_GET_UNCONFIRMED: return "IPCTNL_MSG_CT_GET_UNCONFIRMED";
- }
- break;
- }
- return "unknown NETFILTER type: " + String.valueOf(nlmType);
- }
-
- /**
- * Convert a netlink message type to a string by netlink family.
- */
- @NonNull
- public static String stringForNlMsgType(short nlmType, int nlFamily) {
- // Reserved control messages. The netlink family is ignored.
- // See NLMSG_MIN_TYPE in include/uapi/linux/netlink.h.
- if (nlmType <= NLMSG_MAX_RESERVED) return stringForCtlMsgType(nlmType);
-
- // Netlink family messages. The netlink family is required. Note that the reason for using
- // if-statement is that switch-case can't be used because the OsConstants.NETLINK_* are
- // not constant.
- if (nlFamily == OsConstants.NETLINK_ROUTE) return stringForRtMsgType(nlmType);
- if (nlFamily == OsConstants.NETLINK_INET_DIAG) return stringForInetDiagMsgType(nlmType);
- if (nlFamily == OsConstants.NETLINK_NETFILTER) return stringForNfMsgType(nlmType);
-
- return "unknown type: " + String.valueOf(nlmType);
- }
-
- private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- 'A', 'B', 'C', 'D', 'E', 'F' };
- /**
- * Convert a byte array to a hexadecimal string.
- */
- public static String toHexString(byte[] array, int offset, int length) {
- char[] buf = new char[length * 2];
-
- int bufIndex = 0;
- for (int i = offset; i < offset + length; i++) {
- byte b = array[i];
- buf[bufIndex++] = HEX_DIGITS[(b >>> 4) & 0x0F];
- buf[bufIndex++] = HEX_DIGITS[b & 0x0F];
- }
-
- return new String(buf);
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/NetlinkErrorMessage.java b/common/device/com/android/net/module/util/netlink/NetlinkErrorMessage.java
deleted file mode 100644
index 4831432..0000000
--- a/common/device/com/android/net/module/util/netlink/NetlinkErrorMessage.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import java.nio.ByteBuffer;
-
-/**
- * A NetlinkMessage subclass for netlink error messages.
- *
- * @hide
- */
-public class NetlinkErrorMessage extends NetlinkMessage {
-
- /**
- * Parse a netlink error message from a {@link ByteBuffer}.
- *
- * @param byteBuffer The buffer from which to parse the netlink error message.
- * @return the parsed netlink error message, or {@code null} if the netlink error message
- * could not be parsed successfully (for example, if it was truncated).
- */
- @Nullable
- public static NetlinkErrorMessage parse(@NonNull StructNlMsgHdr header,
- @NonNull ByteBuffer byteBuffer) {
- final NetlinkErrorMessage errorMsg = new NetlinkErrorMessage(header);
-
- errorMsg.mNlMsgErr = StructNlMsgErr.parse(byteBuffer);
- if (errorMsg.mNlMsgErr == null) {
- return null;
- }
-
- return errorMsg;
- }
-
- private StructNlMsgErr mNlMsgErr;
-
- NetlinkErrorMessage(@NonNull StructNlMsgHdr header) {
- super(header);
- mNlMsgErr = null;
- }
-
- public StructNlMsgErr getNlMsgError() {
- return mNlMsgErr;
- }
-
- @Override
- public String toString() {
- return "NetlinkErrorMessage{ "
- + "nlmsghdr{" + (mHeader == null ? "" : mHeader.toString()) + "}, "
- + "nlmsgerr{" + (mNlMsgErr == null ? "" : mNlMsgErr.toString()) + "} "
- + "}";
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/NetlinkMessage.java b/common/device/com/android/net/module/util/netlink/NetlinkMessage.java
deleted file mode 100644
index 723d682..0000000
--- a/common/device/com/android/net/module/util/netlink/NetlinkMessage.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import android.system.OsConstants;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import java.nio.ByteBuffer;
-
-/**
- * NetlinkMessage base class for other, more specific netlink message types.
- *
- * Classes that extend NetlinkMessage should:
- * - implement a public static parse(StructNlMsgHdr, ByteBuffer) method
- * - returning either null (parse errors) or a new object of the subclass
- * type (cast-able to NetlinkMessage)
- *
- * NetlinkMessage.parse() should be updated to know which nlmsg_type values
- * correspond with which message subclasses.
- *
- * @hide
- */
-public class NetlinkMessage {
- private static final String TAG = "NetlinkMessage";
-
- /**
- * Parsing netlink messages for reserved control message or specific netlink message. The
- * netlink family is required for parsing specific netlink message. See man-pages/netlink.
- */
- @Nullable
- public static NetlinkMessage parse(@NonNull ByteBuffer byteBuffer, int nlFamily) {
- final int startPosition = (byteBuffer != null) ? byteBuffer.position() : -1;
- final StructNlMsgHdr nlmsghdr = StructNlMsgHdr.parse(byteBuffer);
- if (nlmsghdr == null) {
- return null;
- }
-
- int payloadLength = NetlinkConstants.alignedLengthOf(nlmsghdr.nlmsg_len);
- payloadLength -= StructNlMsgHdr.STRUCT_SIZE;
- if (payloadLength < 0 || payloadLength > byteBuffer.remaining()) {
- // Malformed message or runt buffer. Pretend the buffer was consumed.
- byteBuffer.position(byteBuffer.limit());
- return null;
- }
-
- // Reserved control messages. The netlink family is ignored.
- // See NLMSG_MIN_TYPE in include/uapi/linux/netlink.h.
- if (nlmsghdr.nlmsg_type <= NetlinkConstants.NLMSG_MAX_RESERVED) {
- return parseCtlMessage(nlmsghdr, byteBuffer, payloadLength);
- }
-
- // Netlink family messages. The netlink family is required. Note that the reason for using
- // if-statement is that switch-case can't be used because the OsConstants.NETLINK_* are
- // not constant.
- if (nlFamily == OsConstants.NETLINK_ROUTE) {
- return parseRtMessage(nlmsghdr, byteBuffer);
- } else if (nlFamily == OsConstants.NETLINK_INET_DIAG) {
- return parseInetDiagMessage(nlmsghdr, byteBuffer);
- } else if (nlFamily == OsConstants.NETLINK_NETFILTER) {
- return parseNfMessage(nlmsghdr, byteBuffer);
- }
-
- return null;
- }
-
- @NonNull
- protected final StructNlMsgHdr mHeader;
-
- public NetlinkMessage(@NonNull StructNlMsgHdr nlmsghdr) {
- mHeader = nlmsghdr;
- }
-
- @NonNull
- public StructNlMsgHdr getHeader() {
- return mHeader;
- }
-
- @Override
- public String toString() {
- // The netlink family is not provided to StructNlMsgHdr#toString because NetlinkMessage
- // doesn't store the information. So the netlink message type can't be transformed into
- // a string by StructNlMsgHdr#toString and just keep as an integer. The specific message
- // which inherits NetlinkMessage could override NetlinkMessage#toString and provide the
- // specific netlink family to StructNlMsgHdr#toString.
- return "NetlinkMessage{" + mHeader.toString() + "}";
- }
-
- @NonNull
- private static NetlinkMessage parseCtlMessage(@NonNull StructNlMsgHdr nlmsghdr,
- @NonNull ByteBuffer byteBuffer, int payloadLength) {
- switch (nlmsghdr.nlmsg_type) {
- case NetlinkConstants.NLMSG_ERROR:
- return (NetlinkMessage) NetlinkErrorMessage.parse(nlmsghdr, byteBuffer);
- default: {
- // Other netlink control messages. Just parse the header for now,
- // pretending the whole message was consumed.
- byteBuffer.position(byteBuffer.position() + payloadLength);
- return new NetlinkMessage(nlmsghdr);
- }
- }
- }
-
- @Nullable
- private static NetlinkMessage parseRtMessage(@NonNull StructNlMsgHdr nlmsghdr,
- @NonNull ByteBuffer byteBuffer) {
- switch (nlmsghdr.nlmsg_type) {
- case NetlinkConstants.RTM_NEWNEIGH:
- case NetlinkConstants.RTM_DELNEIGH:
- case NetlinkConstants.RTM_GETNEIGH:
- return (NetlinkMessage) RtNetlinkNeighborMessage.parse(nlmsghdr, byteBuffer);
- case NetlinkConstants.RTM_NEWNDUSEROPT:
- return (NetlinkMessage) NduseroptMessage.parse(nlmsghdr, byteBuffer);
- default: return null;
- }
- }
-
- @Nullable
- private static NetlinkMessage parseInetDiagMessage(@NonNull StructNlMsgHdr nlmsghdr,
- @NonNull ByteBuffer byteBuffer) {
- switch (nlmsghdr.nlmsg_type) {
- case NetlinkConstants.SOCK_DIAG_BY_FAMILY:
- return (NetlinkMessage) InetDiagMessage.parse(nlmsghdr, byteBuffer);
- default: return null;
- }
- }
-
- @Nullable
- private static NetlinkMessage parseNfMessage(@NonNull StructNlMsgHdr nlmsghdr,
- @NonNull ByteBuffer byteBuffer) {
- switch (nlmsghdr.nlmsg_type) {
- case NetlinkConstants.NFNL_SUBSYS_CTNETLINK << 8
- | NetlinkConstants.IPCTNL_MSG_CT_NEW:
- case NetlinkConstants.NFNL_SUBSYS_CTNETLINK << 8
- | NetlinkConstants.IPCTNL_MSG_CT_DELETE:
- return (NetlinkMessage) ConntrackMessage.parse(nlmsghdr, byteBuffer);
- default: return null;
- }
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/NetlinkSocket.java b/common/device/com/android/net/module/util/netlink/NetlinkSocket.java
deleted file mode 100644
index ec326dd..0000000
--- a/common/device/com/android/net/module/util/netlink/NetlinkSocket.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static android.net.util.SocketUtils.makeNetlinkSocketAddress;
-import static android.system.OsConstants.AF_NETLINK;
-import static android.system.OsConstants.EIO;
-import static android.system.OsConstants.EPROTO;
-import static android.system.OsConstants.ETIMEDOUT;
-import static android.system.OsConstants.SOCK_DGRAM;
-import static android.system.OsConstants.SOL_SOCKET;
-import static android.system.OsConstants.SO_RCVBUF;
-import static android.system.OsConstants.SO_RCVTIMEO;
-import static android.system.OsConstants.SO_SNDTIMEO;
-
-import android.net.util.SocketUtils;
-import android.system.ErrnoException;
-import android.system.Os;
-import android.system.StructTimeval;
-import android.util.Log;
-
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.SocketException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-
-/**
- * NetlinkSocket
- *
- * A small static class to assist with AF_NETLINK socket operations.
- *
- * @hide
- */
-public class NetlinkSocket {
- private static final String TAG = "NetlinkSocket";
- private static final long IO_TIMEOUT_MS = 300L;
-
- public static final int DEFAULT_RECV_BUFSIZE = 8 * 1024;
- public static final int SOCKET_RECV_BUFSIZE = 64 * 1024;
-
- /**
- * Send one netlink message to kernel via netlink socket.
- *
- * @param nlProto netlink protocol type.
- * @param msg the raw bytes of netlink message to be sent.
- */
- public static void sendOneShotKernelMessage(int nlProto, byte[] msg) throws ErrnoException {
- final String errPrefix = "Error in NetlinkSocket.sendOneShotKernelMessage";
- final FileDescriptor fd = forProto(nlProto);
-
- try {
- connectToKernel(fd);
- sendMessage(fd, msg, 0, msg.length, IO_TIMEOUT_MS);
- final ByteBuffer bytes = recvMessage(fd, DEFAULT_RECV_BUFSIZE, IO_TIMEOUT_MS);
- // recvMessage() guaranteed to not return null if it did not throw.
- final NetlinkMessage response = NetlinkMessage.parse(bytes, nlProto);
- if (response != null && response instanceof NetlinkErrorMessage
- && (((NetlinkErrorMessage) response).getNlMsgError() != null)) {
- final int errno = ((NetlinkErrorMessage) response).getNlMsgError().error;
- if (errno != 0) {
- // TODO: consider ignoring EINVAL (-22), which appears to be
- // normal when probing a neighbor for which the kernel does
- // not already have / no longer has a link layer address.
- Log.e(TAG, errPrefix + ", errmsg=" + response.toString());
- // Note: convert kernel errnos (negative) into userspace errnos (positive).
- throw new ErrnoException(response.toString(), Math.abs(errno));
- }
- } else {
- final String errmsg;
- if (response == null) {
- bytes.position(0);
- errmsg = "raw bytes: " + NetlinkConstants.hexify(bytes);
- } else {
- errmsg = response.toString();
- }
- Log.e(TAG, errPrefix + ", errmsg=" + errmsg);
- throw new ErrnoException(errmsg, EPROTO);
- }
- } catch (InterruptedIOException e) {
- Log.e(TAG, errPrefix, e);
- throw new ErrnoException(errPrefix, ETIMEDOUT, e);
- } catch (SocketException e) {
- Log.e(TAG, errPrefix, e);
- throw new ErrnoException(errPrefix, EIO, e);
- } finally {
- try {
- SocketUtils.closeSocket(fd);
- } catch (IOException e) {
- // Nothing we can do here
- }
- }
- }
-
- /**
- * Create netlink socket with the given netlink protocol type.
- *
- * @return fd the fileDescriptor of the socket.
- * Throw ErrnoException if the exception is thrown.
- */
- public static FileDescriptor forProto(int nlProto) throws ErrnoException {
- final FileDescriptor fd = Os.socket(AF_NETLINK, SOCK_DGRAM, nlProto);
- Os.setsockoptInt(fd, SOL_SOCKET, SO_RCVBUF, SOCKET_RECV_BUFSIZE);
- return fd;
- }
-
- /**
- * Connect to kernel via netlink socket.
- *
- * Throw ErrnoException, SocketException if the exception is thrown.
- */
- public static void connectToKernel(FileDescriptor fd) throws ErrnoException, SocketException {
- Os.connect(fd, makeNetlinkSocketAddress(0, 0));
- }
-
- private static void checkTimeout(long timeoutMs) {
- if (timeoutMs < 0) {
- throw new IllegalArgumentException("Negative timeouts not permitted");
- }
- }
-
- /**
- * Wait up to |timeoutMs| (or until underlying socket error) for a
- * netlink message of at most |bufsize| size.
- *
- * Multi-threaded calls with different timeouts will cause unexpected results.
- */
- public static ByteBuffer recvMessage(FileDescriptor fd, int bufsize, long timeoutMs)
- throws ErrnoException, IllegalArgumentException, InterruptedIOException {
- checkTimeout(timeoutMs);
-
- Os.setsockoptTimeval(fd, SOL_SOCKET, SO_RCVTIMEO, StructTimeval.fromMillis(timeoutMs));
-
- ByteBuffer byteBuffer = ByteBuffer.allocate(bufsize);
- int length = Os.read(fd, byteBuffer);
- if (length == bufsize) {
- Log.w(TAG, "maximum read");
- }
- byteBuffer.position(0);
- byteBuffer.limit(length);
- byteBuffer.order(ByteOrder.nativeOrder());
- return byteBuffer;
- }
-
- /**
- * Send a message to a peer to which this socket has previously connected,
- * waiting at most |timeoutMs| milliseconds for the send to complete.
- *
- * Multi-threaded calls with different timeouts will cause unexpected results.
- */
- public static int sendMessage(
- FileDescriptor fd, byte[] bytes, int offset, int count, long timeoutMs)
- throws ErrnoException, IllegalArgumentException, InterruptedIOException {
- checkTimeout(timeoutMs);
- Os.setsockoptTimeval(fd, SOL_SOCKET, SO_SNDTIMEO, StructTimeval.fromMillis(timeoutMs));
- return Os.write(fd, bytes, offset, count);
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/RtNetlinkNeighborMessage.java b/common/device/com/android/net/module/util/netlink/RtNetlinkNeighborMessage.java
deleted file mode 100644
index 4a09015..0000000
--- a/common/device/com/android/net/module/util/netlink/RtNetlinkNeighborMessage.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_ACK;
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_DUMP;
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REPLACE;
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REQUEST;
-
-import android.system.OsConstants;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * A NetlinkMessage subclass for rtnetlink neighbor messages.
- *
- * see also: <linux_src>/include/uapi/linux/neighbour.h
- *
- * @hide
- */
-public class RtNetlinkNeighborMessage extends NetlinkMessage {
- public static final short NDA_UNSPEC = 0;
- public static final short NDA_DST = 1;
- public static final short NDA_LLADDR = 2;
- public static final short NDA_CACHEINFO = 3;
- public static final short NDA_PROBES = 4;
- public static final short NDA_VLAN = 5;
- public static final short NDA_PORT = 6;
- public static final short NDA_VNI = 7;
- public static final short NDA_IFINDEX = 8;
- public static final short NDA_MASTER = 9;
-
- /**
- * Parse routing socket netlink neighbor message from ByteBuffer.
- *
- * @param header netlink message header.
- * @param byteBuffer the ByteBuffer instance that wraps the raw netlink message bytes.
- */
- @Nullable
- public static RtNetlinkNeighborMessage parse(@NonNull StructNlMsgHdr header,
- @NonNull ByteBuffer byteBuffer) {
- final RtNetlinkNeighborMessage neighMsg = new RtNetlinkNeighborMessage(header);
-
- neighMsg.mNdmsg = StructNdMsg.parse(byteBuffer);
- if (neighMsg.mNdmsg == null) {
- return null;
- }
-
- // Some of these are message-type dependent, and not always present.
- final int baseOffset = byteBuffer.position();
- StructNlAttr nlAttr = StructNlAttr.findNextAttrOfType(NDA_DST, byteBuffer);
- if (nlAttr != null) {
- neighMsg.mDestination = nlAttr.getValueAsInetAddress();
- }
-
- byteBuffer.position(baseOffset);
- nlAttr = StructNlAttr.findNextAttrOfType(NDA_LLADDR, byteBuffer);
- if (nlAttr != null) {
- neighMsg.mLinkLayerAddr = nlAttr.nla_value;
- }
-
- byteBuffer.position(baseOffset);
- nlAttr = StructNlAttr.findNextAttrOfType(NDA_PROBES, byteBuffer);
- if (nlAttr != null) {
- neighMsg.mNumProbes = nlAttr.getValueAsInt(0);
- }
-
- byteBuffer.position(baseOffset);
- nlAttr = StructNlAttr.findNextAttrOfType(NDA_CACHEINFO, byteBuffer);
- if (nlAttr != null) {
- neighMsg.mCacheInfo = StructNdaCacheInfo.parse(nlAttr.getValueAsByteBuffer());
- }
-
- final int kMinConsumed = StructNlMsgHdr.STRUCT_SIZE + StructNdMsg.STRUCT_SIZE;
- final int kAdditionalSpace = NetlinkConstants.alignedLengthOf(
- neighMsg.mHeader.nlmsg_len - kMinConsumed);
- if (byteBuffer.remaining() < kAdditionalSpace) {
- byteBuffer.position(byteBuffer.limit());
- } else {
- byteBuffer.position(baseOffset + kAdditionalSpace);
- }
-
- return neighMsg;
- }
-
- /**
- * A convenience method to create an RTM_GETNEIGH request message.
- */
- public static byte[] newGetNeighborsRequest(int seqNo) {
- final int length = StructNlMsgHdr.STRUCT_SIZE + StructNdMsg.STRUCT_SIZE;
- final byte[] bytes = new byte[length];
- final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
- byteBuffer.order(ByteOrder.nativeOrder());
-
- final StructNlMsgHdr nlmsghdr = new StructNlMsgHdr();
- nlmsghdr.nlmsg_len = length;
- nlmsghdr.nlmsg_type = NetlinkConstants.RTM_GETNEIGH;
- nlmsghdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
- nlmsghdr.nlmsg_seq = seqNo;
- nlmsghdr.pack(byteBuffer);
-
- final StructNdMsg ndmsg = new StructNdMsg();
- ndmsg.pack(byteBuffer);
-
- return bytes;
- }
-
- /**
- * A convenience method to create an RTM_NEWNEIGH message, to modify
- * the kernel's state information for a specific neighbor.
- */
- public static byte[] newNewNeighborMessage(
- int seqNo, InetAddress ip, short nudState, int ifIndex, byte[] llAddr) {
- final StructNlMsgHdr nlmsghdr = new StructNlMsgHdr();
- nlmsghdr.nlmsg_type = NetlinkConstants.RTM_NEWNEIGH;
- nlmsghdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_REPLACE;
- nlmsghdr.nlmsg_seq = seqNo;
-
- final RtNetlinkNeighborMessage msg = new RtNetlinkNeighborMessage(nlmsghdr);
- msg.mNdmsg = new StructNdMsg();
- msg.mNdmsg.ndm_family =
- (byte) ((ip instanceof Inet6Address) ? OsConstants.AF_INET6 : OsConstants.AF_INET);
- msg.mNdmsg.ndm_ifindex = ifIndex;
- msg.mNdmsg.ndm_state = nudState;
- msg.mDestination = ip;
- msg.mLinkLayerAddr = llAddr; // might be null
-
- final byte[] bytes = new byte[msg.getRequiredSpace()];
- nlmsghdr.nlmsg_len = bytes.length;
- final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
- byteBuffer.order(ByteOrder.nativeOrder());
- msg.pack(byteBuffer);
- return bytes;
- }
-
- private StructNdMsg mNdmsg;
- private InetAddress mDestination;
- private byte[] mLinkLayerAddr;
- private int mNumProbes;
- private StructNdaCacheInfo mCacheInfo;
-
- private RtNetlinkNeighborMessage(@NonNull StructNlMsgHdr header) {
- super(header);
- mNdmsg = null;
- mDestination = null;
- mLinkLayerAddr = null;
- mNumProbes = 0;
- mCacheInfo = null;
- }
-
- public StructNdMsg getNdHeader() {
- return mNdmsg;
- }
-
- public InetAddress getDestination() {
- return mDestination;
- }
-
- public byte[] getLinkLayerAddress() {
- return mLinkLayerAddr;
- }
-
- public int getProbes() {
- return mNumProbes;
- }
-
- public StructNdaCacheInfo getCacheInfo() {
- return mCacheInfo;
- }
-
- private int getRequiredSpace() {
- int spaceRequired = StructNlMsgHdr.STRUCT_SIZE + StructNdMsg.STRUCT_SIZE;
- if (mDestination != null) {
- spaceRequired += NetlinkConstants.alignedLengthOf(
- StructNlAttr.NLA_HEADERLEN + mDestination.getAddress().length);
- }
- if (mLinkLayerAddr != null) {
- spaceRequired += NetlinkConstants.alignedLengthOf(
- StructNlAttr.NLA_HEADERLEN + mLinkLayerAddr.length);
- }
- // Currently we don't write messages with NDA_PROBES nor NDA_CACHEINFO
- // attributes appended. Fix later, if necessary.
- return spaceRequired;
- }
-
- private static void packNlAttr(short nlType, byte[] nlValue, ByteBuffer byteBuffer) {
- final StructNlAttr nlAttr = new StructNlAttr();
- nlAttr.nla_type = nlType;
- nlAttr.nla_value = nlValue;
- nlAttr.nla_len = (short) (StructNlAttr.NLA_HEADERLEN + nlAttr.nla_value.length);
- nlAttr.pack(byteBuffer);
- }
-
- /**
- * Write a neighbor discovery netlink message to {@link ByteBuffer}.
- */
- public void pack(ByteBuffer byteBuffer) {
- getHeader().pack(byteBuffer);
- mNdmsg.pack(byteBuffer);
-
- if (mDestination != null) {
- packNlAttr(NDA_DST, mDestination.getAddress(), byteBuffer);
- }
- if (mLinkLayerAddr != null) {
- packNlAttr(NDA_LLADDR, mLinkLayerAddr, byteBuffer);
- }
- }
-
- @Override
- public String toString() {
- final String ipLiteral = (mDestination == null) ? "" : mDestination.getHostAddress();
- return "RtNetlinkNeighborMessage{ "
- + "nlmsghdr{"
- + (mHeader == null ? "" : mHeader.toString(OsConstants.NETLINK_ROUTE)) + "}, "
- + "ndmsg{" + (mNdmsg == null ? "" : mNdmsg.toString()) + "}, "
- + "destination{" + ipLiteral + "} "
- + "linklayeraddr{" + NetlinkConstants.hexify(mLinkLayerAddr) + "} "
- + "probes{" + mNumProbes + "} "
- + "cacheinfo{" + (mCacheInfo == null ? "" : mCacheInfo.toString()) + "} "
- + "}";
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/StructInetDiagMsg.java b/common/device/com/android/net/module/util/netlink/StructInetDiagMsg.java
deleted file mode 100644
index 205656e..0000000
--- a/common/device/com/android/net/module/util/netlink/StructInetDiagMsg.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import java.nio.ByteBuffer;
-
-/**
- * struct inet_diag_msg
- *
- * see <linux_src>/include/uapi/linux/inet_diag.h
- *
- * struct inet_diag_msg {
- * __u8 idiag_family;
- * __u8 idiag_state;
- * __u8 idiag_timer;
- * __u8 idiag_retrans;
- * struct inet_diag_sockid id;
- * __u32 idiag_expires;
- * __u32 idiag_rqueue;
- * __u32 idiag_wqueue;
- * __u32 idiag_uid;
- * __u32 idiag_inode;
- * };
- *
- * @hide
- */
-public class StructInetDiagMsg {
- public static final int STRUCT_SIZE = 4 + StructInetDiagSockId.STRUCT_SIZE + 20;
- private static final int IDIAG_UID_OFFSET = StructNlMsgHdr.STRUCT_SIZE + 4
- + StructInetDiagSockId.STRUCT_SIZE + 12;
- public int idiag_uid;
-
- /**
- * Parse inet diag netlink message from buffer.
- */
- public static StructInetDiagMsg parse(ByteBuffer byteBuffer) {
- StructInetDiagMsg struct = new StructInetDiagMsg();
- struct.idiag_uid = byteBuffer.getInt(IDIAG_UID_OFFSET);
- return struct;
- }
-
- @Override
- public String toString() {
- return "StructInetDiagMsg{ "
- + "idiag_uid{" + idiag_uid + "}, "
- + "}";
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/StructInetDiagReqV2.java b/common/device/com/android/net/module/util/netlink/StructInetDiagReqV2.java
deleted file mode 100644
index 6eef865..0000000
--- a/common/device/com/android/net/module/util/netlink/StructInetDiagReqV2.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import androidx.annotation.Nullable;
-
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-
-/**
- * struct inet_diag_req_v2
- *
- * see <linux_src>/include/uapi/linux/inet_diag.h
- *
- * struct inet_diag_req_v2 {
- * __u8 sdiag_family;
- * __u8 sdiag_protocol;
- * __u8 idiag_ext;
- * __u8 pad;
- * __u32 idiag_states;
- * struct inet_diag_sockid id;
- * };
- *
- * @hide
- */
-public class StructInetDiagReqV2 {
- public static final int STRUCT_SIZE = 8 + StructInetDiagSockId.STRUCT_SIZE;
-
- private final byte mSdiagFamily;
- private final byte mSdiagProtocol;
- private final byte mIdiagExt;
- private final byte mPad;
- private final StructInetDiagSockId mId;
- private final int mState;
- public static final int INET_DIAG_REQ_V2_ALL_STATES = (int) 0xffffffff;
-
- public StructInetDiagReqV2(int protocol, InetSocketAddress local, InetSocketAddress remote,
- int family) {
- this(protocol, local, remote, family, 0 /* pad */, 0 /* extension */,
- INET_DIAG_REQ_V2_ALL_STATES);
- }
-
- public StructInetDiagReqV2(int protocol, @Nullable InetSocketAddress local,
- @Nullable InetSocketAddress remote, int family, int pad, int extension, int state)
- throws NullPointerException {
- mSdiagFamily = (byte) family;
- mSdiagProtocol = (byte) protocol;
- // Request for all sockets if no specific socket is requested. Specify the local and remote
- // socket address information for target request socket.
- if ((local == null) != (remote == null)) {
- throw new NullPointerException("Local and remote must be both null or both non-null");
- }
- mId = ((local != null && remote != null) ? new StructInetDiagSockId(local, remote) : null);
- mPad = (byte) pad;
- mIdiagExt = (byte) extension;
- mState = state;
- }
-
- /**
- * Write the int diag request v2 message to ByteBuffer.
- */
- public void pack(ByteBuffer byteBuffer) {
- // The ByteOrder must have already been set by the caller.
- byteBuffer.put((byte) mSdiagFamily);
- byteBuffer.put((byte) mSdiagProtocol);
- byteBuffer.put((byte) mIdiagExt);
- byteBuffer.put((byte) mPad);
- byteBuffer.putInt(mState);
- if (mId != null) mId.pack(byteBuffer);
- }
-
- @Override
- public String toString() {
- final String familyStr = NetlinkConstants.stringForAddressFamily(mSdiagFamily);
- final String protocolStr = NetlinkConstants.stringForAddressFamily(mSdiagProtocol);
-
- return "StructInetDiagReqV2{ "
- + "sdiag_family{" + familyStr + "}, "
- + "sdiag_protocol{" + protocolStr + "}, "
- + "idiag_ext{" + mIdiagExt + ")}, "
- + "pad{" + mPad + "}, "
- + "idiag_states{" + Integer.toHexString(mState) + "}, "
- + ((mId != null) ? mId.toString() : "inet_diag_sockid=null")
- + "}";
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/StructInetDiagSockId.java b/common/device/com/android/net/module/util/netlink/StructInetDiagSockId.java
deleted file mode 100644
index 95d60e5..0000000
--- a/common/device/com/android/net/module/util/netlink/StructInetDiagSockId.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static java.nio.ByteOrder.BIG_ENDIAN;
-
-import java.net.Inet4Address;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * struct inet_diag_req_v2
- *
- * see <linux_src>/include/uapi/linux/inet_diag.h
- *
- * struct inet_diag_sockid {
- * __be16 idiag_sport;
- * __be16 idiag_dport;
- * __be32 idiag_src[4];
- * __be32 idiag_dst[4];
- * __u32 idiag_if;
- * __u32 idiag_cookie[2];
- * #define INET_DIAG_NOCOOKIE (~0U)
- * };
- *
- * @hide
- */
-public class StructInetDiagSockId {
- public static final int STRUCT_SIZE = 48;
-
- private static final byte[] INET_DIAG_NOCOOKIE = new byte[]{
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff};
- private static final byte[] IPV4_PADDING = new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-
- private final InetSocketAddress mLocSocketAddress;
- private final InetSocketAddress mRemSocketAddress;
-
- public StructInetDiagSockId(InetSocketAddress loc, InetSocketAddress rem) {
- mLocSocketAddress = loc;
- mRemSocketAddress = rem;
- }
-
- /**
- * Write inet diag socket id message to ByteBuffer in big endian.
- */
- public void pack(ByteBuffer byteBuffer) {
- byteBuffer.order(BIG_ENDIAN);
- byteBuffer.putShort((short) mLocSocketAddress.getPort());
- byteBuffer.putShort((short) mRemSocketAddress.getPort());
- byteBuffer.put(mLocSocketAddress.getAddress().getAddress());
- if (mLocSocketAddress.getAddress() instanceof Inet4Address) {
- byteBuffer.put(IPV4_PADDING);
- }
- byteBuffer.put(mRemSocketAddress.getAddress().getAddress());
- if (mRemSocketAddress.getAddress() instanceof Inet4Address) {
- byteBuffer.put(IPV4_PADDING);
- }
- byteBuffer.order(ByteOrder.nativeOrder());
- byteBuffer.putInt(0);
- byteBuffer.put(INET_DIAG_NOCOOKIE);
- }
-
- @Override
- public String toString() {
- return "StructInetDiagSockId{ "
- + "idiag_sport{" + mLocSocketAddress.getPort() + "}, "
- + "idiag_dport{" + mRemSocketAddress.getPort() + "}, "
- + "idiag_src{" + mLocSocketAddress.getAddress().getHostAddress() + "}, "
- + "idiag_dst{" + mRemSocketAddress.getAddress().getHostAddress() + "}, "
- + "idiag_if{" + 0 + "} "
- + "idiag_cookie{INET_DIAG_NOCOOKIE}"
- + "}";
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/StructNdMsg.java b/common/device/com/android/net/module/util/netlink/StructNdMsg.java
deleted file mode 100644
index 53ce899..0000000
--- a/common/device/com/android/net/module/util/netlink/StructNdMsg.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import android.system.OsConstants;
-
-import java.nio.ByteBuffer;
-
-/**
- * struct ndmsg
- *
- * see: <linux_src>/include/uapi/linux/neighbour.h
- *
- * @hide
- */
-public class StructNdMsg {
- // Already aligned.
- public static final int STRUCT_SIZE = 12;
-
- // Neighbor Cache Entry States
- public static final short NUD_NONE = 0x00;
- public static final short NUD_INCOMPLETE = 0x01;
- public static final short NUD_REACHABLE = 0x02;
- public static final short NUD_STALE = 0x04;
- public static final short NUD_DELAY = 0x08;
- public static final short NUD_PROBE = 0x10;
- public static final short NUD_FAILED = 0x20;
- public static final short NUD_NOARP = 0x40;
- public static final short NUD_PERMANENT = 0x80;
-
- /**
- * Convert neighbor cache entry state integer to string.
- */
- public static String stringForNudState(short nudState) {
- switch (nudState) {
- case NUD_NONE: return "NUD_NONE";
- case NUD_INCOMPLETE: return "NUD_INCOMPLETE";
- case NUD_REACHABLE: return "NUD_REACHABLE";
- case NUD_STALE: return "NUD_STALE";
- case NUD_DELAY: return "NUD_DELAY";
- case NUD_PROBE: return "NUD_PROBE";
- case NUD_FAILED: return "NUD_FAILED";
- case NUD_NOARP: return "NUD_NOARP";
- case NUD_PERMANENT: return "NUD_PERMANENT";
- default:
- return "unknown NUD state: " + String.valueOf(nudState);
- }
- }
-
- /**
- * Check whether a neighbor is connected or not.
- */
- public static boolean isNudStateConnected(short nudState) {
- return ((nudState & (NUD_PERMANENT | NUD_NOARP | NUD_REACHABLE)) != 0);
- }
-
- /**
- * Check whether a neighbor is in the valid NUD state or not.
- */
- public static boolean isNudStateValid(short nudState) {
- return (isNudStateConnected(nudState)
- || ((nudState & (NUD_PROBE | NUD_STALE | NUD_DELAY)) != 0));
- }
-
- // Neighbor Cache Entry Flags
- public static byte NTF_USE = (byte) 0x01;
- public static byte NTF_SELF = (byte) 0x02;
- public static byte NTF_MASTER = (byte) 0x04;
- public static byte NTF_PROXY = (byte) 0x08;
- public static byte NTF_ROUTER = (byte) 0x80;
-
- private static String stringForNudFlags(byte flags) {
- final StringBuilder sb = new StringBuilder();
- if ((flags & NTF_USE) != 0) {
- sb.append("NTF_USE");
- }
- if ((flags & NTF_SELF) != 0) {
- if (sb.length() > 0) {
- sb.append("|");
- }
- sb.append("NTF_SELF");
- }
- if ((flags & NTF_MASTER) != 0) {
- if (sb.length() > 0) {
- sb.append("|");
- }
- sb.append("NTF_MASTER");
- }
- if ((flags & NTF_PROXY) != 0) {
- if (sb.length() > 0) {
- sb.append("|");
- }
- sb.append("NTF_PROXY");
- }
- if ((flags & NTF_ROUTER) != 0) {
- if (sb.length() > 0) {
- sb.append("|");
- }
- sb.append("NTF_ROUTER");
- }
- return sb.toString();
- }
-
- private static boolean hasAvailableSpace(ByteBuffer byteBuffer) {
- return byteBuffer != null && byteBuffer.remaining() >= STRUCT_SIZE;
- }
-
- /**
- * Parse a neighbor discovery netlink message header from a {@link ByteBuffer}.
- *
- * @param byteBuffer The buffer from which to parse the nd netlink message header.
- * @return the parsed nd netlink message header, or {@code null} if the nd netlink message
- * header could not be parsed successfully (for example, if it was truncated).
- */
- public static StructNdMsg parse(ByteBuffer byteBuffer) {
- if (!hasAvailableSpace(byteBuffer)) return null;
-
- // The ByteOrder must have already been set by the caller. In most
- // cases ByteOrder.nativeOrder() is correct, with the possible
- // exception of usage within unittests.
- final StructNdMsg struct = new StructNdMsg();
- struct.ndm_family = byteBuffer.get();
- final byte pad1 = byteBuffer.get();
- final short pad2 = byteBuffer.getShort();
- struct.ndm_ifindex = byteBuffer.getInt();
- struct.ndm_state = byteBuffer.getShort();
- struct.ndm_flags = byteBuffer.get();
- struct.ndm_type = byteBuffer.get();
- return struct;
- }
-
- public byte ndm_family;
- public int ndm_ifindex;
- public short ndm_state;
- public byte ndm_flags;
- public byte ndm_type;
-
- public StructNdMsg() {
- ndm_family = (byte) OsConstants.AF_UNSPEC;
- }
-
- /**
- * Write the neighbor discovery message header to {@link ByteBuffer}.
- */
- public void pack(ByteBuffer byteBuffer) {
- // The ByteOrder must have already been set by the caller. In most
- // cases ByteOrder.nativeOrder() is correct, with the exception
- // of usage within unittests.
- byteBuffer.put(ndm_family);
- byteBuffer.put((byte) 0); // pad1
- byteBuffer.putShort((short) 0); // pad2
- byteBuffer.putInt(ndm_ifindex);
- byteBuffer.putShort(ndm_state);
- byteBuffer.put(ndm_flags);
- byteBuffer.put(ndm_type);
- }
-
- /**
- * Check whether a neighbor is connected or not.
- */
- public boolean nudConnected() {
- return isNudStateConnected(ndm_state);
- }
-
- /**
- * Check whether a neighbor is in the valid NUD state or not.
- */
- public boolean nudValid() {
- return isNudStateValid(ndm_state);
- }
-
- @Override
- public String toString() {
- final String stateStr = "" + ndm_state + " (" + stringForNudState(ndm_state) + ")";
- final String flagsStr = "" + ndm_flags + " (" + stringForNudFlags(ndm_flags) + ")";
- return "StructNdMsg{ "
- + "family{" + NetlinkConstants.stringForAddressFamily((int) ndm_family) + "}, "
- + "ifindex{" + ndm_ifindex + "}, "
- + "state{" + stateStr + "}, "
- + "flags{" + flagsStr + "}, "
- + "type{" + ndm_type + "} "
- + "}";
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/StructNdOptPref64.java b/common/device/com/android/net/module/util/netlink/StructNdOptPref64.java
deleted file mode 100644
index f6b2e0e..0000000
--- a/common/device/com/android/net/module/util/netlink/StructNdOptPref64.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import android.net.IpPrefix;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.ByteBuffer;
-import java.util.Objects;
-
-/**
- * The PREF64 router advertisement option. RFC 8781.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Type | Length | Scaled Lifetime | PLC |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * + +
- * | Highest 96 bits of the Prefix |
- * + +
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- */
-public class StructNdOptPref64 extends NdOption {
- public static final int STRUCT_SIZE = 16;
- public static final int TYPE = 38;
- public static final byte LENGTH = 2;
-
- private static final String TAG = StructNdOptPref64.class.getSimpleName();
-
- /**
- * How many seconds the prefix is expected to remain valid.
- * Valid values are from 0 to 65528 in multiples of 8.
- */
- public final int lifetime;
- /** The NAT64 prefix. */
- @NonNull public final IpPrefix prefix;
-
- static int plcToPrefixLength(int plc) {
- switch (plc) {
- case 0: return 96;
- case 1: return 64;
- case 2: return 56;
- case 3: return 48;
- case 4: return 40;
- case 5: return 32;
- default:
- throw new IllegalArgumentException("Invalid prefix length code " + plc);
- }
- }
-
- static int prefixLengthToPlc(int prefixLength) {
- switch (prefixLength) {
- case 96: return 0;
- case 64: return 1;
- case 56: return 2;
- case 48: return 3;
- case 40: return 4;
- case 32: return 5;
- default:
- throw new IllegalArgumentException("Invalid prefix length " + prefixLength);
- }
- }
-
- /**
- * Returns the 2-byte "scaled lifetime and prefix length code" field: 13-bit lifetime, 3-bit PLC
- */
- static short getScaledLifetimePlc(int lifetime, int prefixLengthCode) {
- return (short) ((lifetime & 0xfff8) | (prefixLengthCode & 0x7));
- }
-
- public StructNdOptPref64(@NonNull IpPrefix prefix, int lifetime) {
- super((byte) TYPE, LENGTH);
-
- Objects.requireNonNull(prefix, "prefix must not be null");
- if (!(prefix.getAddress() instanceof Inet6Address)) {
- throw new IllegalArgumentException("Must be an IPv6 prefix: " + prefix);
- }
- prefixLengthToPlc(prefix.getPrefixLength()); // Throw if the prefix length is invalid.
- this.prefix = prefix;
-
- if (lifetime < 0 || lifetime > 0xfff8) {
- throw new IllegalArgumentException("Invalid lifetime " + lifetime);
- }
- this.lifetime = lifetime & 0xfff8;
- }
-
- private StructNdOptPref64(@NonNull ByteBuffer buf) {
- super(buf.get(), Byte.toUnsignedInt(buf.get()));
- if (type != TYPE) throw new IllegalArgumentException("Invalid type " + type);
- if (length != LENGTH) throw new IllegalArgumentException("Invalid length " + length);
-
- int scaledLifetimePlc = Short.toUnsignedInt(buf.getShort());
- lifetime = scaledLifetimePlc & 0xfff8;
-
- byte[] addressBytes = new byte[16];
- buf.get(addressBytes, 0, 12);
- InetAddress addr;
- try {
- addr = InetAddress.getByAddress(addressBytes);
- } catch (UnknownHostException e) {
- throw new AssertionError("16-byte array not valid InetAddress?");
- }
- prefix = new IpPrefix(addr, plcToPrefixLength(scaledLifetimePlc & 7));
- }
-
- /**
- * Parses an option from a {@link ByteBuffer}.
- *
- * @param buf The buffer from which to parse the option. The buffer's byte order must be
- * {@link java.nio.ByteOrder#BIG_ENDIAN}.
- * @return the parsed option, or {@code null} if the option could not be parsed successfully
- * (for example, if it was truncated, or if the prefix length code was wrong).
- */
- public static StructNdOptPref64 parse(@NonNull ByteBuffer buf) {
- if (buf.remaining() < STRUCT_SIZE) return null;
- try {
- return new StructNdOptPref64(buf);
- } catch (IllegalArgumentException e) {
- // Not great, but better than throwing an exception that might crash the caller.
- // Convention in this package is that null indicates that the option was truncated, so
- // callers must already handle it.
- Log.d(TAG, "Invalid PREF64 option: " + e);
- return null;
- }
- }
-
- protected void writeToByteBuffer(ByteBuffer buf) {
- super.writeToByteBuffer(buf);
- buf.putShort(getScaledLifetimePlc(lifetime, prefixLengthToPlc(prefix.getPrefixLength())));
- buf.put(prefix.getRawAddress(), 0, 12);
- }
-
- /** Outputs the wire format of the option to a new big-endian ByteBuffer. */
- public ByteBuffer toByteBuffer() {
- ByteBuffer buf = ByteBuffer.allocate(STRUCT_SIZE);
- writeToByteBuffer(buf);
- buf.flip();
- return buf;
- }
-
- @Override
- @NonNull
- public String toString() {
- return String.format("NdOptPref64(%s, %d)", prefix, lifetime);
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/StructNdOptRdnss.java b/common/device/com/android/net/module/util/netlink/StructNdOptRdnss.java
deleted file mode 100644
index 6dee0c4..0000000
--- a/common/device/com/android/net/module/util/netlink/StructNdOptRdnss.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static com.android.net.module.util.NetworkStackConstants.IPV6_ADDR_LEN;
-
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.structs.RdnssOption;
-
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.BufferUnderflowException;
-import java.nio.ByteBuffer;
-import java.util.Objects;
-import java.util.StringJoiner;
-
-/**
- * The Recursive DNS Server Option. RFC 8106.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Type | Length | Reserved |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Lifetime |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * : Addresses of IPv6 Recursive DNS Servers :
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class StructNdOptRdnss extends NdOption {
- private static final String TAG = StructNdOptRdnss.class.getSimpleName();
- public static final int TYPE = 25;
- // Length in 8-byte units, only if one IPv6 address included.
- public static final byte MIN_OPTION_LEN = 3;
-
- public final RdnssOption header;
- @NonNull
- public final Inet6Address[] servers;
-
- public StructNdOptRdnss(@NonNull final Inet6Address[] servers, long lifetime) {
- super((byte) TYPE, servers.length * 2 + 1);
-
- Objects.requireNonNull(servers, "Recursive DNS Servers address array must not be null");
- if (servers.length == 0) {
- throw new IllegalArgumentException("DNS server address array must not be empty");
- }
-
- this.header = new RdnssOption((byte) TYPE, (byte) (servers.length * 2 + 1),
- (short) 0 /* reserved */, lifetime);
- this.servers = servers.clone();
- }
-
- /**
- * Parses an RDNSS option from a {@link ByteBuffer}.
- *
- * @param buf The buffer from which to parse the option. The buffer's byte order must be
- * {@link java.nio.ByteOrder#BIG_ENDIAN}.
- * @return the parsed option, or {@code null} if the option could not be parsed successfully.
- */
- public static StructNdOptRdnss parse(@NonNull ByteBuffer buf) {
- if (buf == null || buf.remaining() < MIN_OPTION_LEN * 8) return null;
- try {
- final RdnssOption header = Struct.parse(RdnssOption.class, buf);
- if (header.type != TYPE) {
- throw new IllegalArgumentException("Invalid type " + header.type);
- }
- if (header.length < MIN_OPTION_LEN || (header.length % 2 == 0)) {
- throw new IllegalArgumentException("Invalid length " + header.length);
- }
-
- final int numOfDnses = (header.length - 1) / 2;
- final Inet6Address[] servers = new Inet6Address[numOfDnses];
- for (int i = 0; i < numOfDnses; i++) {
- byte[] rawAddress = new byte[IPV6_ADDR_LEN];
- buf.get(rawAddress);
- servers[i] = (Inet6Address) InetAddress.getByAddress(rawAddress);
- }
- return new StructNdOptRdnss(servers, header.lifetime);
- } catch (IllegalArgumentException | BufferUnderflowException | UnknownHostException e) {
- // Not great, but better than throwing an exception that might crash the caller.
- // Convention in this package is that null indicates that the option was truncated
- // or malformed, so callers must already handle it.
- Log.d(TAG, "Invalid RDNSS option: " + e);
- return null;
- }
- }
-
- protected void writeToByteBuffer(ByteBuffer buf) {
- header.writeToByteBuffer(buf);
- for (int i = 0; i < servers.length; i++) {
- buf.put(servers[i].getAddress());
- }
- }
-
- /** Outputs the wire format of the option to a new big-endian ByteBuffer. */
- public ByteBuffer toByteBuffer() {
- final ByteBuffer buf = ByteBuffer.allocate(Struct.getSize(RdnssOption.class)
- + servers.length * IPV6_ADDR_LEN);
- writeToByteBuffer(buf);
- buf.flip();
- return buf;
- }
-
- @Override
- @NonNull
- public String toString() {
- final StringJoiner sj = new StringJoiner(",", "[", "]");
- for (int i = 0; i < servers.length; i++) {
- sj.add(servers[i].getHostAddress());
- }
- return String.format("NdOptRdnss(%s,servers:%s)", header.toString(), sj.toString());
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/StructNdaCacheInfo.java b/common/device/com/android/net/module/util/netlink/StructNdaCacheInfo.java
deleted file mode 100644
index 79d5ff4..0000000
--- a/common/device/com/android/net/module/util/netlink/StructNdaCacheInfo.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import android.system.Os;
-import android.system.OsConstants;
-
-import java.nio.ByteBuffer;
-
-/**
- * struct nda_cacheinfo
- *
- * see: <linux_src>/include/uapi/linux/neighbour.h
- *
- * @hide
- */
-public class StructNdaCacheInfo {
- // Already aligned.
- public static final int STRUCT_SIZE = 16;
-
- private static boolean hasAvailableSpace(ByteBuffer byteBuffer) {
- return byteBuffer != null && byteBuffer.remaining() >= STRUCT_SIZE;
- }
-
- /**
- * Parse a nd cacheinfo netlink attribute from a {@link ByteBuffer}.
- *
- * @param byteBuffer The buffer from which to parse the nd cacheinfo attribute.
- * @return the parsed nd cacheinfo attribute, or {@code null} if the nd cacheinfo attribute
- * could not be parsed successfully (for example, if it was truncated).
- */
- public static StructNdaCacheInfo parse(ByteBuffer byteBuffer) {
- if (!hasAvailableSpace(byteBuffer)) return null;
-
- // The ByteOrder must have already been set by the caller. In most
- // cases ByteOrder.nativeOrder() is correct, with the possible
- // exception of usage within unittests.
- final StructNdaCacheInfo struct = new StructNdaCacheInfo();
- struct.ndm_used = byteBuffer.getInt();
- struct.ndm_confirmed = byteBuffer.getInt();
- struct.ndm_updated = byteBuffer.getInt();
- struct.ndm_refcnt = byteBuffer.getInt();
- return struct;
- }
-
- // TODO: investigate whether this can change during device runtime and
- // decide what (if anything) should be done about that.
- private static final long CLOCK_TICKS_PER_SECOND = Os.sysconf(OsConstants._SC_CLK_TCK);
-
- private static long ticksToMilliSeconds(int intClockTicks) {
- final long longClockTicks = (long) intClockTicks & 0xffffffff;
- return (longClockTicks * 1000) / CLOCK_TICKS_PER_SECOND;
- }
-
- /**
- * Explanatory notes, for reference.
- *
- * Before being returned to user space, the neighbor entry times are
- * converted to clock_t's like so:
- *
- * ndm_used = jiffies_to_clock_t(now - neigh->used);
- * ndm_confirmed = jiffies_to_clock_t(now - neigh->confirmed);
- * ndm_updated = jiffies_to_clock_t(now - neigh->updated);
- *
- * meaning that these values are expressed as "clock ticks ago". To
- * convert these clock ticks to seconds divide by sysconf(_SC_CLK_TCK).
- * When _SC_CLK_TCK is 100, for example, the ndm_* times are expressed
- * in centiseconds.
- *
- * These values are unsigned, but fortunately being expressed as "some
- * clock ticks ago", these values are typically very small (and
- * 2^31 centiseconds = 248 days).
- *
- * By observation, it appears that:
- * ndm_used: the last time ARP/ND took place for this neighbor
- * ndm_confirmed: the last time ARP/ND succeeded for this neighbor OR
- * higher layer confirmation (TCP or MSG_CONFIRM)
- * was received
- * ndm_updated: the time when the current NUD state was entered
- */
- public int ndm_used;
- public int ndm_confirmed;
- public int ndm_updated;
- public int ndm_refcnt;
-
- public StructNdaCacheInfo() {}
-
- /**
- * The last time ARP/ND took place for this neighbor.
- */
- public long lastUsed() {
- return ticksToMilliSeconds(ndm_used);
- }
-
- /**
- * The last time ARP/ND succeeded for this neighbor or higher layer confirmation (TCP or
- * MSG_CONFIRM) was received.
- */
- public long lastConfirmed() {
- return ticksToMilliSeconds(ndm_confirmed);
- }
-
- /**
- * The time when the current NUD state was entered.
- */
- public long lastUpdated() {
- return ticksToMilliSeconds(ndm_updated);
- }
-
- @Override
- public String toString() {
- return "NdaCacheInfo{ "
- + "ndm_used{" + lastUsed() + "}, "
- + "ndm_confirmed{" + lastConfirmed() + "}, "
- + "ndm_updated{" + lastUpdated() + "}, "
- + "ndm_refcnt{" + ndm_refcnt + "} "
- + "}";
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/StructNfGenMsg.java b/common/device/com/android/net/module/util/netlink/StructNfGenMsg.java
deleted file mode 100644
index 2de5490..0000000
--- a/common/device/com/android/net/module/util/netlink/StructNfGenMsg.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Objects;
-
-/**
- * struct nfgenmsg
- *
- * see <linux_src>/include/uapi/linux/netfilter/nfnetlink.h
- *
- * @hide
- */
-public class StructNfGenMsg {
- public static final int STRUCT_SIZE = 2 + Short.BYTES;
-
- public static final int NFNETLINK_V0 = 0;
-
- public final byte nfgen_family;
- public final byte version;
- public final short res_id; // N.B.: this is big endian in the kernel
-
- /**
- * Parse a netfilter netlink header from a {@link ByteBuffer}.
- *
- * @param byteBuffer The buffer from which to parse the netfilter netlink header.
- * @return the parsed netfilter netlink header, or {@code null} if the netfilter netlink header
- * could not be parsed successfully (for example, if it was truncated).
- */
- @Nullable
- public static StructNfGenMsg parse(@NonNull ByteBuffer byteBuffer) {
- Objects.requireNonNull(byteBuffer);
-
- if (!hasAvailableSpace(byteBuffer)) return null;
-
- final byte nfgen_family = byteBuffer.get();
- final byte version = byteBuffer.get();
-
- final ByteOrder originalOrder = byteBuffer.order();
- byteBuffer.order(ByteOrder.BIG_ENDIAN);
- final short res_id = byteBuffer.getShort();
- byteBuffer.order(originalOrder);
-
- return new StructNfGenMsg(nfgen_family, version, res_id);
- }
-
- public StructNfGenMsg(byte family, byte ver, short id) {
- nfgen_family = family;
- version = ver;
- res_id = id;
- }
-
- public StructNfGenMsg(byte family) {
- nfgen_family = family;
- version = (byte) NFNETLINK_V0;
- res_id = (short) 0;
- }
-
- /**
- * Write a netfilter netlink header to a {@link ByteBuffer}.
- */
- public void pack(ByteBuffer byteBuffer) {
- byteBuffer.put(nfgen_family);
- byteBuffer.put(version);
-
- final ByteOrder originalOrder = byteBuffer.order();
- byteBuffer.order(ByteOrder.BIG_ENDIAN);
- byteBuffer.putShort(res_id);
- byteBuffer.order(originalOrder);
- }
-
- private static boolean hasAvailableSpace(@NonNull ByteBuffer byteBuffer) {
- return byteBuffer.remaining() >= STRUCT_SIZE;
- }
-
- @Override
- public String toString() {
- final String familyStr = NetlinkConstants.stringForAddressFamily(nfgen_family);
-
- return "NfGenMsg{ "
- + "nfgen_family{" + familyStr + "}, "
- + "version{" + Byte.toUnsignedInt(version) + "}, "
- + "res_id{" + Short.toUnsignedInt(res_id) + "} "
- + "}";
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/StructNlAttr.java b/common/device/com/android/net/module/util/netlink/StructNlAttr.java
deleted file mode 100644
index 80f0057..0000000
--- a/common/device/com/android/net/module/util/netlink/StructNlAttr.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import androidx.annotation.Nullable;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * struct nlattr
- *
- * see: <linux_src>/include/uapi/linux/netlink.h
- *
- * @hide
- */
-public class StructNlAttr {
- // Already aligned.
- public static final int NLA_HEADERLEN = 4;
- public static final int NLA_F_NESTED = (1 << 15);
-
- /**
- * Set carries nested attributes bit.
- */
- public static short makeNestedType(short type) {
- return (short) (type | NLA_F_NESTED);
- }
-
- /**
- * Peek and parse the netlink attribute from {@link ByteBuffer}.
- *
- * Return a (length, type) object only, without consuming any bytes in
- * |byteBuffer| and without copying or interpreting any value bytes.
- * This is used for scanning over a packed set of struct nlattr's,
- * looking for instances of a particular type.
- */
- public static StructNlAttr peek(ByteBuffer byteBuffer) {
- if (byteBuffer == null || byteBuffer.remaining() < NLA_HEADERLEN) {
- return null;
- }
- final int baseOffset = byteBuffer.position();
-
- final StructNlAttr struct = new StructNlAttr();
- final ByteOrder originalOrder = byteBuffer.order();
- byteBuffer.order(ByteOrder.nativeOrder());
- try {
- struct.nla_len = byteBuffer.getShort();
- struct.nla_type = byteBuffer.getShort();
- } finally {
- byteBuffer.order(originalOrder);
- }
-
- byteBuffer.position(baseOffset);
- if (struct.nla_len < NLA_HEADERLEN) {
- // Malformed.
- return null;
- }
- return struct;
- }
-
- /**
- * Parse a netlink attribute from a {@link ByteBuffer}.
- *
- * @param byteBuffer The buffer from which to parse the netlink attriute.
- * @return the parsed netlink attribute, or {@code null} if the netlink attribute
- * could not be parsed successfully (for example, if it was truncated).
- */
- public static StructNlAttr parse(ByteBuffer byteBuffer) {
- final StructNlAttr struct = peek(byteBuffer);
- if (struct == null || byteBuffer.remaining() < struct.getAlignedLength()) {
- return null;
- }
-
- final int baseOffset = byteBuffer.position();
- byteBuffer.position(baseOffset + NLA_HEADERLEN);
-
- int valueLen = ((int) struct.nla_len) & 0xffff;
- valueLen -= NLA_HEADERLEN;
- if (valueLen > 0) {
- struct.nla_value = new byte[valueLen];
- byteBuffer.get(struct.nla_value, 0, valueLen);
- byteBuffer.position(baseOffset + struct.getAlignedLength());
- }
- return struct;
- }
-
- /**
- * Find next netlink attribute with a given type from {@link ByteBuffer}.
- *
- * @param attrType The given netlink attribute type is requested for.
- * @param byteBuffer The buffer from which to find the netlink attribute.
- * @return the found netlink attribute, or {@code null} if the netlink attribute could not be
- * found or parsed successfully (for example, if it was truncated).
- */
- @Nullable
- public static StructNlAttr findNextAttrOfType(short attrType,
- @Nullable ByteBuffer byteBuffer) {
- while (byteBuffer != null && byteBuffer.remaining() > 0) {
- final StructNlAttr nlAttr = StructNlAttr.peek(byteBuffer);
- if (nlAttr == null) {
- break;
- }
- if (nlAttr.nla_type == attrType) {
- return StructNlAttr.parse(byteBuffer);
- }
- if (byteBuffer.remaining() < nlAttr.getAlignedLength()) {
- break;
- }
- byteBuffer.position(byteBuffer.position() + nlAttr.getAlignedLength());
- }
- return null;
- }
-
- public short nla_len = (short) NLA_HEADERLEN;
- public short nla_type;
- public byte[] nla_value;
-
- public StructNlAttr() {}
-
- public StructNlAttr(short type, byte value) {
- nla_type = type;
- setValue(new byte[1]);
- nla_value[0] = value;
- }
-
- public StructNlAttr(short type, short value) {
- this(type, value, ByteOrder.nativeOrder());
- }
-
- public StructNlAttr(short type, short value, ByteOrder order) {
- nla_type = type;
- setValue(new byte[Short.BYTES]);
- final ByteBuffer buf = getValueAsByteBuffer();
- final ByteOrder originalOrder = buf.order();
- try {
- buf.order(order);
- buf.putShort(value);
- } finally {
- buf.order(originalOrder);
- }
- }
-
- public StructNlAttr(short type, int value) {
- this(type, value, ByteOrder.nativeOrder());
- }
-
- public StructNlAttr(short type, int value, ByteOrder order) {
- nla_type = type;
- setValue(new byte[Integer.BYTES]);
- final ByteBuffer buf = getValueAsByteBuffer();
- final ByteOrder originalOrder = buf.order();
- try {
- buf.order(order);
- buf.putInt(value);
- } finally {
- buf.order(originalOrder);
- }
- }
-
- public StructNlAttr(short type, InetAddress ip) {
- nla_type = type;
- setValue(ip.getAddress());
- }
-
- public StructNlAttr(short type, StructNlAttr... nested) {
- this();
- nla_type = makeNestedType(type);
-
- int payloadLength = 0;
- for (StructNlAttr nla : nested) payloadLength += nla.getAlignedLength();
- setValue(new byte[payloadLength]);
-
- final ByteBuffer buf = getValueAsByteBuffer();
- for (StructNlAttr nla : nested) {
- nla.pack(buf);
- }
- }
-
- /**
- * Get aligned attribute length.
- */
- public int getAlignedLength() {
- return NetlinkConstants.alignedLengthOf(nla_len);
- }
-
- /**
- * Get attribute value as BE16.
- */
- public short getValueAsBe16(short defaultValue) {
- final ByteBuffer byteBuffer = getValueAsByteBuffer();
- if (byteBuffer == null || byteBuffer.remaining() != Short.BYTES) {
- return defaultValue;
- }
- final ByteOrder originalOrder = byteBuffer.order();
- try {
- byteBuffer.order(ByteOrder.BIG_ENDIAN);
- return byteBuffer.getShort();
- } finally {
- byteBuffer.order(originalOrder);
- }
- }
-
- /**
- * Get attribute value as BE32.
- */
- public int getValueAsBe32(int defaultValue) {
- final ByteBuffer byteBuffer = getValueAsByteBuffer();
- if (byteBuffer == null || byteBuffer.remaining() != Integer.BYTES) {
- return defaultValue;
- }
- final ByteOrder originalOrder = byteBuffer.order();
- try {
- byteBuffer.order(ByteOrder.BIG_ENDIAN);
- return byteBuffer.getInt();
- } finally {
- byteBuffer.order(originalOrder);
- }
- }
-
- /**
- * Get attribute value as ByteBuffer.
- */
- public ByteBuffer getValueAsByteBuffer() {
- if (nla_value == null) return null;
- final ByteBuffer byteBuffer = ByteBuffer.wrap(nla_value);
- // By convention, all buffers in this library are in native byte order because netlink is in
- // native byte order. It's the order that is used by NetlinkSocket.recvMessage and the only
- // order accepted by NetlinkMessage.parse.
- byteBuffer.order(ByteOrder.nativeOrder());
- return byteBuffer;
- }
-
- /**
- * Get attribute value as byte.
- */
- public byte getValueAsByte(byte defaultValue) {
- final ByteBuffer byteBuffer = getValueAsByteBuffer();
- if (byteBuffer == null || byteBuffer.remaining() != Byte.BYTES) {
- return defaultValue;
- }
- return getValueAsByteBuffer().get();
- }
-
- /**
- * Get attribute value as Integer.
- */
- public int getValueAsInt(int defaultValue) {
- final ByteBuffer byteBuffer = getValueAsByteBuffer();
- if (byteBuffer == null || byteBuffer.remaining() != Integer.BYTES) {
- return defaultValue;
- }
- return getValueAsByteBuffer().getInt();
- }
-
- /**
- * Get attribute value as InetAddress.
- */
- public InetAddress getValueAsInetAddress() {
- if (nla_value == null) return null;
-
- try {
- return InetAddress.getByAddress(nla_value);
- } catch (UnknownHostException ignored) {
- return null;
- }
- }
-
- /**
- * Write the netlink attribute to {@link ByteBuffer}.
- */
- public void pack(ByteBuffer byteBuffer) {
- final ByteOrder originalOrder = byteBuffer.order();
- final int originalPosition = byteBuffer.position();
-
- byteBuffer.order(ByteOrder.nativeOrder());
- try {
- byteBuffer.putShort(nla_len);
- byteBuffer.putShort(nla_type);
- if (nla_value != null) byteBuffer.put(nla_value);
- } finally {
- byteBuffer.order(originalOrder);
- }
- byteBuffer.position(originalPosition + getAlignedLength());
- }
-
- private void setValue(byte[] value) {
- nla_value = value;
- nla_len = (short) (NLA_HEADERLEN + ((nla_value != null) ? nla_value.length : 0));
- }
-
- @Override
- public String toString() {
- return "StructNlAttr{ "
- + "nla_len{" + nla_len + "}, "
- + "nla_type{" + nla_type + "}, "
- + "nla_value{" + NetlinkConstants.hexify(nla_value) + "}, "
- + "}";
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/StructNlMsgErr.java b/common/device/com/android/net/module/util/netlink/StructNlMsgErr.java
deleted file mode 100644
index b6620f3..0000000
--- a/common/device/com/android/net/module/util/netlink/StructNlMsgErr.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import java.nio.ByteBuffer;
-
-/**
- * struct nlmsgerr
- *
- * see <linux_src>/include/uapi/linux/netlink.h
- *
- * @hide
- */
-public class StructNlMsgErr {
- public static final int STRUCT_SIZE = Integer.BYTES + StructNlMsgHdr.STRUCT_SIZE;
-
- private static boolean hasAvailableSpace(ByteBuffer byteBuffer) {
- return byteBuffer != null && byteBuffer.remaining() >= STRUCT_SIZE;
- }
-
- /**
- * Parse a netlink error message payload from a {@link ByteBuffer}.
- *
- * @param byteBuffer The buffer from which to parse the netlink error message payload.
- * @return the parsed netlink error message payload, or {@code null} if the netlink error
- * message payload could not be parsed successfully (for example, if it was truncated).
- */
- public static StructNlMsgErr parse(ByteBuffer byteBuffer) {
- if (!hasAvailableSpace(byteBuffer)) return null;
-
- // The ByteOrder must have already been set by the caller. In most
- // cases ByteOrder.nativeOrder() is correct, with the exception
- // of usage within unittests.
- final StructNlMsgErr struct = new StructNlMsgErr();
- struct.error = byteBuffer.getInt();
- struct.msg = StructNlMsgHdr.parse(byteBuffer);
- return struct;
- }
-
- public int error;
- public StructNlMsgHdr msg;
-
- /**
- * Write the netlink error message payload to {@link ByteBuffer}.
- */
- public void pack(ByteBuffer byteBuffer) {
- // The ByteOrder must have already been set by the caller. In most
- // cases ByteOrder.nativeOrder() is correct, with the possible
- // exception of usage within unittests.
- byteBuffer.putInt(error);
- if (msg != null) {
- msg.pack(byteBuffer);
- }
- }
-
- @Override
- public String toString() {
- return "StructNlMsgErr{ "
- + "error{" + error + "}, "
- + "msg{" + (msg == null ? "" : msg.toString()) + "} "
- + "}";
- }
-}
diff --git a/common/device/com/android/net/module/util/netlink/StructNlMsgHdr.java b/common/device/com/android/net/module/util/netlink/StructNlMsgHdr.java
deleted file mode 100644
index 9567cce..0000000
--- a/common/device/com/android/net/module/util/netlink/StructNlMsgHdr.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import java.nio.ByteBuffer;
-
-/**
- * struct nlmsghdr
- *
- * see <linux_src>/include/uapi/linux/netlink.h
- *
- * @hide
- */
-public class StructNlMsgHdr {
- // Already aligned.
- public static final int STRUCT_SIZE = 16;
-
- public static final short NLM_F_REQUEST = 0x0001;
- public static final short NLM_F_MULTI = 0x0002;
- public static final short NLM_F_ACK = 0x0004;
- public static final short NLM_F_ECHO = 0x0008;
- // Flags for a GET request.
- public static final short NLM_F_ROOT = 0x0100;
- public static final short NLM_F_MATCH = 0x0200;
- public static final short NLM_F_DUMP = NLM_F_ROOT | NLM_F_MATCH;
- // Flags for a NEW request.
- public static final short NLM_F_REPLACE = 0x100;
- public static final short NLM_F_EXCL = 0x200;
- public static final short NLM_F_CREATE = 0x400;
- public static final short NLM_F_APPEND = 0x800;
-
- // TODO: Probably need to distinguish the flags which have the same value. For example,
- // NLM_F_MATCH (0x200) and NLM_F_EXCL (0x200).
- private static String stringForNlMsgFlags(short flags) {
- final StringBuilder sb = new StringBuilder();
- if ((flags & NLM_F_REQUEST) != 0) {
- sb.append("NLM_F_REQUEST");
- }
- if ((flags & NLM_F_MULTI) != 0) {
- if (sb.length() > 0) {
- sb.append("|");
- }
- sb.append("NLM_F_MULTI");
- }
- if ((flags & NLM_F_ACK) != 0) {
- if (sb.length() > 0) {
- sb.append("|");
- }
- sb.append("NLM_F_ACK");
- }
- if ((flags & NLM_F_ECHO) != 0) {
- if (sb.length() > 0) {
- sb.append("|");
- }
- sb.append("NLM_F_ECHO");
- }
- if ((flags & NLM_F_ROOT) != 0) {
- if (sb.length() > 0) {
- sb.append("|");
- }
- sb.append("NLM_F_ROOT");
- }
- if ((flags & NLM_F_MATCH) != 0) {
- if (sb.length() > 0) {
- sb.append("|");
- }
- sb.append("NLM_F_MATCH");
- }
- return sb.toString();
- }
-
- private static boolean hasAvailableSpace(ByteBuffer byteBuffer) {
- return byteBuffer != null && byteBuffer.remaining() >= STRUCT_SIZE;
- }
-
- /**
- * Parse netlink message header from buffer.
- */
- @Nullable
- public static StructNlMsgHdr parse(@NonNull ByteBuffer byteBuffer) {
- if (!hasAvailableSpace(byteBuffer)) return null;
-
- // The ByteOrder must have already been set by the caller. In most
- // cases ByteOrder.nativeOrder() is correct, with the exception
- // of usage within unittests.
- final StructNlMsgHdr struct = new StructNlMsgHdr();
- struct.nlmsg_len = byteBuffer.getInt();
- struct.nlmsg_type = byteBuffer.getShort();
- struct.nlmsg_flags = byteBuffer.getShort();
- struct.nlmsg_seq = byteBuffer.getInt();
- struct.nlmsg_pid = byteBuffer.getInt();
-
- if (struct.nlmsg_len < STRUCT_SIZE) {
- // Malformed.
- return null;
- }
- return struct;
- }
-
- public int nlmsg_len;
- public short nlmsg_type;
- public short nlmsg_flags;
- public int nlmsg_seq;
- public int nlmsg_pid;
-
- public StructNlMsgHdr() {
- nlmsg_len = 0;
- nlmsg_type = 0;
- nlmsg_flags = 0;
- nlmsg_seq = 0;
- nlmsg_pid = 0;
- }
-
- /**
- * Write netlink message header to ByteBuffer.
- */
- public void pack(ByteBuffer byteBuffer) {
- // The ByteOrder must have already been set by the caller. In most
- // cases ByteOrder.nativeOrder() is correct, with the possible
- // exception of usage within unittests.
- byteBuffer.putInt(nlmsg_len);
- byteBuffer.putShort(nlmsg_type);
- byteBuffer.putShort(nlmsg_flags);
- byteBuffer.putInt(nlmsg_seq);
- byteBuffer.putInt(nlmsg_pid);
- }
-
- @Override
- public String toString() {
- return toString(null /* unknown netlink family */);
- }
-
- /**
- * Transform a netlink header into a string. The netlink family is required for transforming
- * a netlink type integer into a string.
- * @param nlFamily netlink family. Using Integer will not incur autoboxing penalties because
- * family values are small, and all Integer objects between -128 and 127 are
- * statically cached. See Integer.IntegerCache.
- * @return A list of header elements.
- */
- @NonNull
- public String toString(@Nullable Integer nlFamily) {
- final String typeStr = "" + nlmsg_type
- + "(" + (nlFamily == null
- ? "" : NetlinkConstants.stringForNlMsgType(nlmsg_type, nlFamily))
- + ")";
- final String flagsStr = "" + nlmsg_flags
- + "(" + stringForNlMsgFlags(nlmsg_flags) + ")";
- return "StructNlMsgHdr{ "
- + "nlmsg_len{" + nlmsg_len + "}, "
- + "nlmsg_type{" + typeStr + "}, "
- + "nlmsg_flags{" + flagsStr + ")}, "
- + "nlmsg_seq{" + nlmsg_seq + "}, "
- + "nlmsg_pid{" + nlmsg_pid + "} "
- + "}";
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/NsHeader.java b/common/device/com/android/net/module/util/structs/NsHeader.java
index 2e8b77b..6e0aa50 100644
--- a/common/device/com/android/net/module/util/structs/NsHeader.java
+++ b/common/device/com/android/net/module/util/structs/NsHeader.java
@@ -50,12 +50,8 @@
@Field(order = 1, type = Type.Ipv6Address)
public Inet6Address target;
- NsHeader(int reserved, final Inet6Address target) {
- this.reserved = reserved;
- this.target = target;
- }
-
public NsHeader(final Inet6Address target) {
- this(0, target);
+ this.reserved = 0;
+ this.target = target;
}
}
diff --git a/common/device/com/android/net/module/util/structs/PrefixInformationOption.java b/common/device/com/android/net/module/util/structs/PrefixInformationOption.java
index 49d7654..1bdee29 100644
--- a/common/device/com/android/net/module/util/structs/PrefixInformationOption.java
+++ b/common/device/com/android/net/module/util/structs/PrefixInformationOption.java
@@ -18,10 +18,9 @@
import static com.android.net.module.util.NetworkStackConstants.ICMPV6_ND_OPTION_PIO;
+import android.annotation.NonNull;
import android.net.IpPrefix;
-import androidx.annotation.NonNull;
-
import com.android.net.module.util.Struct;
import com.android.net.module.util.Struct.Field;
import com.android.net.module.util.Struct.Type;
diff --git a/common/device/com/android/net/module/util/structs/RdnssOption.java b/common/device/com/android/net/module/util/structs/RdnssOption.java
index 4a5bd7e..b7c2b0c 100644
--- a/common/device/com/android/net/module/util/structs/RdnssOption.java
+++ b/common/device/com/android/net/module/util/structs/RdnssOption.java
@@ -53,8 +53,7 @@
@Field(order = 3, type = Type.U32)
public final long lifetime;
- public RdnssOption(final byte type, final byte length, final short reserved,
- final long lifetime) {
+ RdnssOption(final byte type, final byte length, final short reserved, final long lifetime) {
this.type = type;
this.length = length;
this.reserved = reserved;
diff --git a/common/framework/com/android/net/module/util/CollectionUtils.java b/common/framework/com/android/net/module/util/CollectionUtils.java
index 6e1af55..4fce8f5 100644
--- a/common/framework/com/android/net/module/util/CollectionUtils.java
+++ b/common/framework/com/android/net/module/util/CollectionUtils.java
@@ -27,7 +27,6 @@
/**
* Utilities for {@link Collection} and arrays.
- * @hide
*/
public final class CollectionUtils {
private CollectionUtils() {}
@@ -123,19 +122,6 @@
/**
* @return true if the array contains the specified value.
*/
- public static boolean contains(@Nullable short[] array, short value) {
- if (array == null) return false;
- for (int element : array) {
- if (element == value) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @return true if the array contains the specified value.
- */
public static boolean contains(@Nullable int[] array, int value) {
if (array == null) return false;
for (int element : array) {
diff --git a/common/framework/com/android/net/module/util/ConnectivitySettingsUtils.java b/common/framework/com/android/net/module/util/ConnectivitySettingsUtils.java
deleted file mode 100644
index b7eb70b..0000000
--- a/common/framework/com/android/net/module/util/ConnectivitySettingsUtils.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.provider.Settings;
-import android.text.TextUtils;
-
-/**
- * Collection of connectivity settings utilities.
- *
- * @hide
- */
-public class ConnectivitySettingsUtils {
- public static final int PRIVATE_DNS_MODE_OFF = 1;
- public static final int PRIVATE_DNS_MODE_OPPORTUNISTIC = 2;
- public static final int PRIVATE_DNS_MODE_PROVIDER_HOSTNAME = 3;
-
- public static final String PRIVATE_DNS_DEFAULT_MODE = "private_dns_default_mode";
- public static final String PRIVATE_DNS_MODE = "private_dns_mode";
- public static final String PRIVATE_DNS_MODE_OFF_STRING = "off";
- public static final String PRIVATE_DNS_MODE_OPPORTUNISTIC_STRING = "opportunistic";
- public static final String PRIVATE_DNS_MODE_PROVIDER_HOSTNAME_STRING = "hostname";
- public static final String PRIVATE_DNS_SPECIFIER = "private_dns_specifier";
-
- /**
- * Get private DNS mode as string.
- *
- * @param mode One of the private DNS values.
- * @return A string of private DNS mode.
- */
- public static String getPrivateDnsModeAsString(int mode) {
- switch (mode) {
- case PRIVATE_DNS_MODE_OFF:
- return PRIVATE_DNS_MODE_OFF_STRING;
- case PRIVATE_DNS_MODE_OPPORTUNISTIC:
- return PRIVATE_DNS_MODE_OPPORTUNISTIC_STRING;
- case PRIVATE_DNS_MODE_PROVIDER_HOSTNAME:
- return PRIVATE_DNS_MODE_PROVIDER_HOSTNAME_STRING;
- default:
- throw new IllegalArgumentException("Invalid private dns mode: " + mode);
- }
- }
-
- private static int getPrivateDnsModeAsInt(String mode) {
- switch (mode) {
- case "off":
- return PRIVATE_DNS_MODE_OFF;
- case "hostname":
- return PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
- case "opportunistic":
- return PRIVATE_DNS_MODE_OPPORTUNISTIC;
- default:
- throw new IllegalArgumentException("Invalid private dns mode: " + mode);
- }
- }
-
- /**
- * Get private DNS mode from settings.
- *
- * @param context The Context to query the private DNS mode from settings.
- * @return An integer of private DNS mode.
- */
- public static int getPrivateDnsMode(@NonNull Context context) {
- final ContentResolver cr = context.getContentResolver();
- String mode = Settings.Global.getString(cr, PRIVATE_DNS_MODE);
- if (TextUtils.isEmpty(mode)) mode = Settings.Global.getString(cr, PRIVATE_DNS_DEFAULT_MODE);
- // If both PRIVATE_DNS_MODE and PRIVATE_DNS_DEFAULT_MODE are not set, choose
- // PRIVATE_DNS_MODE_OPPORTUNISTIC as default mode.
- if (TextUtils.isEmpty(mode)) return PRIVATE_DNS_MODE_OPPORTUNISTIC;
- return getPrivateDnsModeAsInt(mode);
- }
-
- /**
- * Set private DNS mode to settings.
- *
- * @param context The {@link Context} to set the private DNS mode.
- * @param mode The private dns mode. This should be one of the PRIVATE_DNS_MODE_* constants.
- */
- public static void setPrivateDnsMode(@NonNull Context context, int mode) {
- if (!(mode == PRIVATE_DNS_MODE_OFF
- || mode == PRIVATE_DNS_MODE_OPPORTUNISTIC
- || mode == PRIVATE_DNS_MODE_PROVIDER_HOSTNAME)) {
- throw new IllegalArgumentException("Invalid private dns mode: " + mode);
- }
- Settings.Global.putString(context.getContentResolver(), PRIVATE_DNS_MODE,
- getPrivateDnsModeAsString(mode));
- }
-
- /**
- * Get specific private dns provider name from {@link Settings}.
- *
- * @param context The {@link Context} to query the setting.
- * @return The specific private dns provider name, or null if no setting value.
- */
- @Nullable
- public static String getPrivateDnsHostname(@NonNull Context context) {
- return Settings.Global.getString(context.getContentResolver(), PRIVATE_DNS_SPECIFIER);
- }
-
- /**
- * Set specific private dns provider name to {@link Settings}.
- *
- * @param context The {@link Context} to set the setting.
- * @param specifier The specific private dns provider name.
- */
- public static void setPrivateDnsHostname(@NonNull Context context, @Nullable String specifier) {
- Settings.Global.putString(context.getContentResolver(), PRIVATE_DNS_SPECIFIER, specifier);
- }
-}
diff --git a/common/framework/com/android/net/module/util/ConnectivityUtils.java b/common/framework/com/android/net/module/util/ConnectivityUtils.java
index c135e46..382912b 100644
--- a/common/framework/com/android/net/module/util/ConnectivityUtils.java
+++ b/common/framework/com/android/net/module/util/ConnectivityUtils.java
@@ -24,7 +24,6 @@
/**
* Various utilities used in connectivity code.
- * @hide
*/
public final class ConnectivityUtils {
private ConnectivityUtils() {}
diff --git a/common/framework/com/android/net/module/util/MacAddressUtils.java b/common/framework/com/android/net/module/util/MacAddressUtils.java
index ab0040c..bc11fa2 100644
--- a/common/framework/com/android/net/module/util/MacAddressUtils.java
+++ b/common/framework/com/android/net/module/util/MacAddressUtils.java
@@ -41,8 +41,7 @@
private static final long NIC_MASK = longAddrFromByteAddr(
MacAddress.fromString("0:0:0:ff:ff:ff").toByteArray());
// Matches WifiInfo.DEFAULT_MAC_ADDRESS
- private static final MacAddress DEFAULT_MAC_ADDRESS =
- MacAddress.fromString("02:00:00:00:00:00");
+ private static final String DEFAULT_MAC_ADDRESS = "02:00:00:00:00:00";
private static final int ETHER_ADDR_LEN = 6;
/**
diff --git a/common/framework/com/android/net/module/util/NetworkCapabilitiesUtils.java b/common/framework/com/android/net/module/util/NetworkCapabilitiesUtils.java
index 903214e..4c7d675 100644
--- a/common/framework/com/android/net/module/util/NetworkCapabilitiesUtils.java
+++ b/common/framework/com/android/net/module/util/NetworkCapabilitiesUtils.java
@@ -33,7 +33,6 @@
import static android.net.NetworkCapabilities.TRANSPORT_BLUETOOTH;
import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
import static android.net.NetworkCapabilities.TRANSPORT_ETHERNET;
-import static android.net.NetworkCapabilities.TRANSPORT_USB;
import static android.net.NetworkCapabilities.TRANSPORT_VPN;
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
import static android.net.NetworkCapabilities.TRANSPORT_WIFI_AWARE;
@@ -45,7 +44,6 @@
/**
* Utilities to examine {@link android.net.NetworkCapabilities}.
- * @hide
*/
public final class NetworkCapabilitiesUtils {
// Transports considered to classify networks in UI, in order of which transport should be
@@ -65,8 +63,7 @@
TRANSPORT_WIFI_AWARE,
TRANSPORT_BLUETOOTH,
TRANSPORT_WIFI,
- TRANSPORT_ETHERNET,
- TRANSPORT_USB
+ TRANSPORT_ETHERNET
// Notably, TRANSPORT_TEST is not in this list as any network that has TRANSPORT_TEST and
// one of the above transports should be counted as that transport, to keep tests as
@@ -136,8 +133,7 @@
* See {@code NetworkCapabilities#maybeMarkCapabilitiesRestricted}.
*/
private static final long FORCE_RESTRICTED_CAPABILITIES =
- (1 << NET_CAPABILITY_ENTERPRISE)
- | (1 << NET_CAPABILITY_OEM_PAID)
+ (1 << NET_CAPABILITY_OEM_PAID)
| (1 << NET_CAPABILITY_OEM_PRIVATE);
/**
diff --git a/common/framework/com/android/net/module/util/NetworkIdentityUtils.java b/common/framework/com/android/net/module/util/NetworkIdentityUtils.java
index b641753..94e6017 100644
--- a/common/framework/com/android/net/module/util/NetworkIdentityUtils.java
+++ b/common/framework/com/android/net/module/util/NetworkIdentityUtils.java
@@ -21,7 +21,6 @@
/**
* Utilities to examine {@link android.net.NetworkIdentity}.
- * @hide
*/
public class NetworkIdentityUtils {
/**
diff --git a/common/framework/com/android/net/module/util/NetworkStackConstants.java b/common/framework/com/android/net/module/util/NetworkStackConstants.java
index f7151d7..b7062e7 100644
--- a/common/framework/com/android/net/module/util/NetworkStackConstants.java
+++ b/common/framework/com/android/net/module/util/NetworkStackConstants.java
@@ -148,10 +148,7 @@
public static final int ICMPV6_ND_OPTION_RDNSS = 25;
public static final int ICMPV6_ND_OPTION_PREF64 = 38;
- public static final int ICMPV6_RS_HEADER_LEN = 8;
public static final int ICMPV6_RA_HEADER_LEN = 16;
- public static final int ICMPV6_NS_HEADER_LEN = 24;
- public static final int ICMPV6_NA_HEADER_LEN = 24;
public static final int NEIGHBOR_ADVERTISEMENT_FLAG_ROUTER = 1 << 31;
public static final int NEIGHBOR_ADVERTISEMENT_FLAG_SOLICITED = 1 << 30;
diff --git a/common/jarjar-rules-shared.txt b/common/jarjar-rules-shared.txt
index e26999d..a7fda7c 100644
--- a/common/jarjar-rules-shared.txt
+++ b/common/jarjar-rules-shared.txt
@@ -1,3 +1,2 @@
rule android.annotation.** com.android.net.module.annotation.@1
rule com.android.internal.annotations.** com.android.net.module.annotation.@1
-rule com.android.modules.utils.build.** com.android.net.module.util.build.$1
diff --git a/common/lint-baseline.xml b/common/lint-baseline.xml
new file mode 100644
index 0000000..4c54e9f
--- /dev/null
+++ b/common/lint-baseline.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
+
+ <issue
+ id="NewApi"
+ message="Call requires API level R (current min is 29): `android.net.NetworkRequest#canBeSatisfiedBy`"
+ errorLine1=" && n.request.canBeSatisfiedBy(mCapabilityFilter)"
+ errorLine2=" ~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/device/android/net/NetworkFactory.java"
+ line="307"
+ column="26"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level R (current min is 29): `android.net.NetworkRequest#canBeSatisfiedBy`"
+ errorLine1=" || !n.request.canBeSatisfiedBy(mCapabilityFilter)"
+ errorLine2=" ~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/device/android/net/NetworkFactory.java"
+ line="323"
+ column="35"/>
+ </issue>
+
+</issues>
diff --git a/common/native/bpf_syscall_wrappers/Android.bp b/common/native/bpf_syscall_wrappers/Android.bp
index befb9f8..fa90655 100644
--- a/common/native/bpf_syscall_wrappers/Android.bp
+++ b/common/native/bpf_syscall_wrappers/Android.bp
@@ -35,6 +35,5 @@
visibility: [
"//packages/modules/Connectivity/Tethering",
"//system/bpf/libbpf_android",
- "//system/memory/lmkd",
],
}
diff --git a/common/netd/Android.bp b/common/netd/Android.bp
deleted file mode 100644
index c93c2fc..0000000
--- a/common/netd/Android.bp
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright (C) 2021 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-java_library {
- name: "netd_aidl_interface-lateststable-java",
- sdk_version: "system_current",
- min_sdk_version: "29",
- static_libs: [
- "netd_aidl_interface-V7-java",
- ],
- apex_available: [
- "//apex_available:platform", // used from services.net
- "com.android.bluetooth.updatable",
- "com.android.tethering",
- "com.android.wifi",
- ],
-}
-
-cc_library_static {
- name: "netd_event_listener_interface-lateststable-ndk",
- whole_static_libs: [
- "netd_event_listener_interface-V1-ndk",
- ],
- apex_available: [
- "com.android.resolv",
- ],
- min_sdk_version: "29",
-}
-
-cc_library_static {
- name: "netd_aidl_interface-lateststable-ndk",
- whole_static_libs: [
- "netd_aidl_interface-V7-ndk",
- ],
- apex_available: [
- "com.android.resolv",
- ],
- min_sdk_version: "29",
-}
-
-cc_library_static {
- name: "netd_aidl_interface-lateststable-cpp",
- whole_static_libs: [
- "netd_aidl_interface-V7-cpp",
- ],
-}
-
-aidl_interface {
- name: "netd_aidl_interface",
- local_include_dir: "binder",
- srcs: [
- "binder/android/net/INetd.aidl",
- // AIDL interface that callers can implement to receive networking events from netd.
- "binder/android/net/INetdUnsolicitedEventListener.aidl",
- "binder/android/net/InterfaceConfigurationParcel.aidl",
- "binder/android/net/MarkMaskParcel.aidl",
- "binder/android/net/NativeNetworkConfig.aidl",
- "binder/android/net/NativeNetworkType.aidl",
- "binder/android/net/NativeVpnType.aidl",
- "binder/android/net/RouteInfoParcel.aidl",
- "binder/android/net/TetherConfigParcel.aidl",
- "binder/android/net/TetherOffloadRuleParcel.aidl",
- "binder/android/net/TetherStatsParcel.aidl",
- "binder/android/net/UidRangeParcel.aidl",
- // Add new AIDL classes in android.net.netd.aidl to consist with other network modules.
- "binder/android/net/netd/aidl/**/*.aidl",
- ],
- backend: {
- cpp: {
- gen_log: true,
- },
- java: {
- // TODO: Remove apex_available and restrict visibility to only mainline modules that are
- // either outside the system server or use jarjar to rename the generated AIDL classes.
- apex_available: [
- "//apex_available:platform", // used from services.net
- "com.android.bluetooth.updatable",
- "com.android.tethering",
- "com.android.wifi",
- ],
- // this is part of updatable modules(NetworkStack) which targets 29(Q)
- min_sdk_version: "29",
- },
- ndk: {
- apex_available: [
- "//apex_available:platform",
- ],
- // This is necessary for the DnsResovler tests to run in Android Q.
- // Soong would recognize this value and produce the Q compatible aidl library.
- min_sdk_version: "29",
- },
- },
- versions: [
- "1",
- "2",
- "3",
- "4",
- "5",
- "6",
- "7",
- ],
-}
-
-java_library {
- name: "netd_event_listener_interface-lateststable-java",
- sdk_version: "system_current",
- min_sdk_version: "29",
- static_libs: [
- "netd_event_listener_interface-V1-java",
- ],
- apex_available: [
- "//apex_available:platform",
- "com.android.bluetooth.updatable",
- "com.android.wifi",
- "com.android.tethering",
- ],
-}
-
-aidl_interface {
- name: "netd_event_listener_interface",
- local_include_dir: "binder",
- srcs: [
- "binder/android/net/metrics/INetdEventListener.aidl",
- ],
- versions: ["1"],
- backend: {
- ndk: {
- apex_available: [
- "//apex_available:platform",
- "com.android.resolv",
- ],
- min_sdk_version: "29",
- },
- java: {
- apex_available: [
- "//apex_available:platform",
- "com.android.bluetooth.updatable",
- "com.android.wifi",
- "com.android.tethering",
- ],
- min_sdk_version: "29",
- },
- },
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/1/.hash b/common/netd/aidl_api/netd_aidl_interface/1/.hash
deleted file mode 100644
index d33e903..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/1/.hash
+++ /dev/null
@@ -1 +0,0 @@
-69c2ac134efbb31e9591d7e5c3640fb839e23bdb
diff --git a/common/netd/aidl_api/netd_aidl_interface/1/android/net/INetd.aidl b/common/netd/aidl_api/netd_aidl_interface/1/android/net/INetd.aidl
deleted file mode 100644
index 664c643..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/1/android/net/INetd.aidl
+++ /dev/null
@@ -1,132 +0,0 @@
-package android.net;
-interface INetd {
- boolean isAlive();
- boolean firewallReplaceUidChain(in @utf8InCpp String chainName, boolean isWhitelist, in int[] uids);
- boolean bandwidthEnableDataSaver(boolean enable);
- void networkCreatePhysical(int netId, int permission);
- void networkCreateVpn(int netId, boolean secure);
- void networkDestroy(int netId);
- void networkAddInterface(int netId, in @utf8InCpp String iface);
- void networkRemoveInterface(int netId, in @utf8InCpp String iface);
- void networkAddUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRemoveUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRejectNonSecureVpn(boolean add, in android.net.UidRangeParcel[] uidRanges);
- void socketDestroy(in android.net.UidRangeParcel[] uidRanges, in int[] exemptUids);
- boolean tetherApplyDnsInterfaces();
- android.net.TetherStatsParcel[] tetherGetStats();
- void interfaceAddAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- void interfaceDelAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- @utf8InCpp String getProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter);
- void setProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter, in @utf8InCpp String value);
- void ipSecSetEncapSocketOwner(in ParcelFileDescriptor socket, int newUid);
- int ipSecAllocateSpi(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecAddSecurityAssociation(int transformId, int mode, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int underlyingNetId, int spi, int markValue, int markMask, in @utf8InCpp String authAlgo, in byte[] authKey, in int authTruncBits, in @utf8InCpp String cryptAlgo, in byte[] cryptKey, in int cryptTruncBits, in @utf8InCpp String aeadAlgo, in byte[] aeadKey, in int aeadIcvBits, int encapType, int encapLocalPort, int encapRemotePort, int interfaceId);
- void ipSecDeleteSecurityAssociation(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecApplyTransportModeTransform(in ParcelFileDescriptor socket, int transformId, int direction, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecRemoveTransportModeTransform(in ParcelFileDescriptor socket);
- void ipSecAddSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecUpdateSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecDeleteSecurityPolicy(int transformId, int selAddrFamily, int direction, int markValue, int markMask, int interfaceId);
- void ipSecAddTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecUpdateTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecRemoveTunnelInterface(in @utf8InCpp String deviceName);
- void wakeupAddInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void wakeupDelInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void setIPv6AddrGenMode(in @utf8InCpp String ifName, int mode);
- void idletimerAddInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void idletimerRemoveInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void strictUidCleartextPenalty(int uid, int policyPenalty);
- @utf8InCpp String clatdStart(in @utf8InCpp String ifName, in @utf8InCpp String nat64Prefix);
- void clatdStop(in @utf8InCpp String ifName);
- boolean ipfwdEnabled();
- @utf8InCpp String[] ipfwdGetRequesterList();
- void ipfwdEnableForwarding(in @utf8InCpp String requester);
- void ipfwdDisableForwarding(in @utf8InCpp String requester);
- void ipfwdAddInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void ipfwdRemoveInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void bandwidthSetInterfaceQuota(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceQuota(in @utf8InCpp String ifName);
- void bandwidthSetInterfaceAlert(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceAlert(in @utf8InCpp String ifName);
- void bandwidthSetGlobalAlert(long bytes);
- void bandwidthAddNaughtyApp(int uid);
- void bandwidthRemoveNaughtyApp(int uid);
- void bandwidthAddNiceApp(int uid);
- void bandwidthRemoveNiceApp(int uid);
- void tetherStart(in @utf8InCpp String[] dhcpRanges);
- void tetherStop();
- boolean tetherIsEnabled();
- void tetherInterfaceAdd(in @utf8InCpp String ifName);
- void tetherInterfaceRemove(in @utf8InCpp String ifName);
- @utf8InCpp String[] tetherInterfaceList();
- void tetherDnsSet(int netId, in @utf8InCpp String[] dnsAddrs);
- @utf8InCpp String[] tetherDnsList();
- void networkAddRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkRemoveRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkAddLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- void networkRemoveLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- int networkGetDefault();
- void networkSetDefault(int netId);
- void networkClearDefault();
- void networkSetPermissionForNetwork(int netId, int permission);
- void networkSetPermissionForUser(int permission, in int[] uids);
- void networkClearPermissionForUser(in int[] uids);
- void trafficSetNetPermForUids(int permission, in int[] uids);
- void networkSetProtectAllow(int uid);
- void networkSetProtectDeny(int uid);
- boolean networkCanProtect(int uid);
- void firewallSetFirewallType(int firewalltype);
- void firewallSetInterfaceRule(in @utf8InCpp String ifName, int firewallRule);
- void firewallSetUidRule(int childChain, int uid, int firewallRule);
- void firewallEnableChildChain(int childChain, boolean enable);
- @utf8InCpp String[] interfaceGetList();
- android.net.InterfaceConfigurationParcel interfaceGetCfg(in @utf8InCpp String ifName);
- void interfaceSetCfg(in android.net.InterfaceConfigurationParcel cfg);
- void interfaceSetIPv6PrivacyExtensions(in @utf8InCpp String ifName, boolean enable);
- void interfaceClearAddrs(in @utf8InCpp String ifName);
- void interfaceSetEnableIPv6(in @utf8InCpp String ifName, boolean enable);
- void interfaceSetMtu(in @utf8InCpp String ifName, int mtu);
- void tetherAddForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void tetherRemoveForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void setTcpRWmemorySize(in @utf8InCpp String rmemValues, in @utf8InCpp String wmemValues);
- void registerUnsolicitedEventListener(android.net.INetdUnsolicitedEventListener listener);
- const int IPV4 = 4;
- const int IPV6 = 6;
- const int CONF = 1;
- const int NEIGH = 2;
- const String IPSEC_INTERFACE_PREFIX = "ipsec";
- const int IPV6_ADDR_GEN_MODE_EUI64 = 0;
- const int IPV6_ADDR_GEN_MODE_NONE = 1;
- const int IPV6_ADDR_GEN_MODE_STABLE_PRIVACY = 2;
- const int IPV6_ADDR_GEN_MODE_RANDOM = 3;
- const int IPV6_ADDR_GEN_MODE_DEFAULT = 0;
- const int PENALTY_POLICY_ACCEPT = 1;
- const int PENALTY_POLICY_LOG = 2;
- const int PENALTY_POLICY_REJECT = 3;
- const int LOCAL_NET_ID = 99;
- const String NEXTHOP_NONE = "";
- const String NEXTHOP_UNREACHABLE = "unreachable";
- const String NEXTHOP_THROW = "throw";
- const int PERMISSION_NONE = 0;
- const int PERMISSION_NETWORK = 1;
- const int PERMISSION_SYSTEM = 2;
- const int NO_PERMISSIONS = 0;
- const int PERMISSION_INTERNET = 4;
- const int PERMISSION_UPDATE_DEVICE_STATS = 8;
- const int PERMISSION_UNINSTALLED = -1;
- const int FIREWALL_WHITELIST = 0;
- const int FIREWALL_BLACKLIST = 1;
- const int FIREWALL_RULE_ALLOW = 1;
- const int FIREWALL_RULE_DENY = 2;
- const int FIREWALL_CHAIN_NONE = 0;
- const int FIREWALL_CHAIN_DOZABLE = 1;
- const int FIREWALL_CHAIN_STANDBY = 2;
- const int FIREWALL_CHAIN_POWERSAVE = 3;
- const String IF_STATE_UP = "up";
- const String IF_STATE_DOWN = "down";
- const String IF_FLAG_BROADCAST = "broadcast";
- const String IF_FLAG_LOOPBACK = "loopback";
- const String IF_FLAG_POINTOPOINT = "point-to-point";
- const String IF_FLAG_RUNNING = "running";
- const String IF_FLAG_MULTICAST = "multicast";
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/1/android/net/INetdUnsolicitedEventListener.aidl b/common/netd/aidl_api/netd_aidl_interface/1/android/net/INetdUnsolicitedEventListener.aidl
deleted file mode 100644
index 18631ff..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/1/android/net/INetdUnsolicitedEventListener.aidl
+++ /dev/null
@@ -1,14 +0,0 @@
-package android.net;
-interface INetdUnsolicitedEventListener {
- oneway void onInterfaceClassActivityChanged(boolean isActive, int timerLabel, long timestampNs, int uid);
- oneway void onQuotaLimitReached(@utf8InCpp String alertName, @utf8InCpp String ifName);
- oneway void onInterfaceDnsServerInfo(@utf8InCpp String ifName, long lifetimeS, in @utf8InCpp String[] servers);
- oneway void onInterfaceAddressUpdated(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAddressRemoved(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAdded(@utf8InCpp String ifName);
- oneway void onInterfaceRemoved(@utf8InCpp String ifName);
- oneway void onInterfaceChanged(@utf8InCpp String ifName, boolean up);
- oneway void onInterfaceLinkStateChanged(@utf8InCpp String ifName, boolean up);
- oneway void onRouteChanged(boolean updated, @utf8InCpp String route, @utf8InCpp String gateway, @utf8InCpp String ifName);
- oneway void onStrictCleartextDetected(int uid, @utf8InCpp String hex);
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/1/android/net/InterfaceConfigurationParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/1/android/net/InterfaceConfigurationParcel.aidl
deleted file mode 100644
index 93407dc..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/1/android/net/InterfaceConfigurationParcel.aidl
+++ /dev/null
@@ -1,8 +0,0 @@
-package android.net;
-parcelable InterfaceConfigurationParcel {
- @utf8InCpp String ifName;
- @utf8InCpp String hwAddr;
- @utf8InCpp String ipv4Addr;
- int prefixLength;
- @utf8InCpp String[] flags;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/1/android/net/TetherStatsParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/1/android/net/TetherStatsParcel.aidl
deleted file mode 100644
index d1782bb..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/1/android/net/TetherStatsParcel.aidl
+++ /dev/null
@@ -1,8 +0,0 @@
-package android.net;
-parcelable TetherStatsParcel {
- @utf8InCpp String iface;
- long rxBytes;
- long rxPackets;
- long txBytes;
- long txPackets;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/1/android/net/UidRangeParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/1/android/net/UidRangeParcel.aidl
deleted file mode 100644
index d3bc7ed..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/1/android/net/UidRangeParcel.aidl
+++ /dev/null
@@ -1,5 +0,0 @@
-package android.net;
-parcelable UidRangeParcel {
- int start;
- int stop;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/2/.hash b/common/netd/aidl_api/netd_aidl_interface/2/.hash
deleted file mode 100644
index 5fc5b2d..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/2/.hash
+++ /dev/null
@@ -1 +0,0 @@
-e395d63302c47e7d2dac0d503045779029ff598b
diff --git a/common/netd/aidl_api/netd_aidl_interface/2/android/net/INetd.aidl b/common/netd/aidl_api/netd_aidl_interface/2/android/net/INetd.aidl
deleted file mode 100644
index 0e2d5f4..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/2/android/net/INetd.aidl
+++ /dev/null
@@ -1,153 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a frozen snapshot of an AIDL interface (or parcelable). Do not
-// try to edit this file. It looks like you are doing that because you have
-// modified an AIDL interface in a backward-incompatible way, e.g., deleting a
-// function from an interface or a field from a parcelable and it broke the
-// build. That breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-interface INetd {
- boolean isAlive();
- boolean firewallReplaceUidChain(in @utf8InCpp String chainName, boolean isWhitelist, in int[] uids);
- boolean bandwidthEnableDataSaver(boolean enable);
- void networkCreatePhysical(int netId, int permission);
- void networkCreateVpn(int netId, boolean secure);
- void networkDestroy(int netId);
- void networkAddInterface(int netId, in @utf8InCpp String iface);
- void networkRemoveInterface(int netId, in @utf8InCpp String iface);
- void networkAddUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRemoveUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRejectNonSecureVpn(boolean add, in android.net.UidRangeParcel[] uidRanges);
- void socketDestroy(in android.net.UidRangeParcel[] uidRanges, in int[] exemptUids);
- boolean tetherApplyDnsInterfaces();
- android.net.TetherStatsParcel[] tetherGetStats();
- void interfaceAddAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- void interfaceDelAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- @utf8InCpp String getProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter);
- void setProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter, in @utf8InCpp String value);
- void ipSecSetEncapSocketOwner(in ParcelFileDescriptor socket, int newUid);
- int ipSecAllocateSpi(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecAddSecurityAssociation(int transformId, int mode, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int underlyingNetId, int spi, int markValue, int markMask, in @utf8InCpp String authAlgo, in byte[] authKey, in int authTruncBits, in @utf8InCpp String cryptAlgo, in byte[] cryptKey, in int cryptTruncBits, in @utf8InCpp String aeadAlgo, in byte[] aeadKey, in int aeadIcvBits, int encapType, int encapLocalPort, int encapRemotePort, int interfaceId);
- void ipSecDeleteSecurityAssociation(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecApplyTransportModeTransform(in ParcelFileDescriptor socket, int transformId, int direction, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecRemoveTransportModeTransform(in ParcelFileDescriptor socket);
- void ipSecAddSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecUpdateSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecDeleteSecurityPolicy(int transformId, int selAddrFamily, int direction, int markValue, int markMask, int interfaceId);
- void ipSecAddTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecUpdateTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecRemoveTunnelInterface(in @utf8InCpp String deviceName);
- void wakeupAddInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void wakeupDelInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void setIPv6AddrGenMode(in @utf8InCpp String ifName, int mode);
- void idletimerAddInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void idletimerRemoveInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void strictUidCleartextPenalty(int uid, int policyPenalty);
- @utf8InCpp String clatdStart(in @utf8InCpp String ifName, in @utf8InCpp String nat64Prefix);
- void clatdStop(in @utf8InCpp String ifName);
- boolean ipfwdEnabled();
- @utf8InCpp String[] ipfwdGetRequesterList();
- void ipfwdEnableForwarding(in @utf8InCpp String requester);
- void ipfwdDisableForwarding(in @utf8InCpp String requester);
- void ipfwdAddInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void ipfwdRemoveInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void bandwidthSetInterfaceQuota(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceQuota(in @utf8InCpp String ifName);
- void bandwidthSetInterfaceAlert(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceAlert(in @utf8InCpp String ifName);
- void bandwidthSetGlobalAlert(long bytes);
- void bandwidthAddNaughtyApp(int uid);
- void bandwidthRemoveNaughtyApp(int uid);
- void bandwidthAddNiceApp(int uid);
- void bandwidthRemoveNiceApp(int uid);
- void tetherStart(in @utf8InCpp String[] dhcpRanges);
- void tetherStop();
- boolean tetherIsEnabled();
- void tetherInterfaceAdd(in @utf8InCpp String ifName);
- void tetherInterfaceRemove(in @utf8InCpp String ifName);
- @utf8InCpp String[] tetherInterfaceList();
- void tetherDnsSet(int netId, in @utf8InCpp String[] dnsAddrs);
- @utf8InCpp String[] tetherDnsList();
- void networkAddRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkRemoveRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkAddLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- void networkRemoveLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- int networkGetDefault();
- void networkSetDefault(int netId);
- void networkClearDefault();
- void networkSetPermissionForNetwork(int netId, int permission);
- void networkSetPermissionForUser(int permission, in int[] uids);
- void networkClearPermissionForUser(in int[] uids);
- void trafficSetNetPermForUids(int permission, in int[] uids);
- void networkSetProtectAllow(int uid);
- void networkSetProtectDeny(int uid);
- boolean networkCanProtect(int uid);
- void firewallSetFirewallType(int firewalltype);
- void firewallSetInterfaceRule(in @utf8InCpp String ifName, int firewallRule);
- void firewallSetUidRule(int childChain, int uid, int firewallRule);
- void firewallEnableChildChain(int childChain, boolean enable);
- @utf8InCpp String[] interfaceGetList();
- android.net.InterfaceConfigurationParcel interfaceGetCfg(in @utf8InCpp String ifName);
- void interfaceSetCfg(in android.net.InterfaceConfigurationParcel cfg);
- void interfaceSetIPv6PrivacyExtensions(in @utf8InCpp String ifName, boolean enable);
- void interfaceClearAddrs(in @utf8InCpp String ifName);
- void interfaceSetEnableIPv6(in @utf8InCpp String ifName, boolean enable);
- void interfaceSetMtu(in @utf8InCpp String ifName, int mtu);
- void tetherAddForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void tetherRemoveForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void setTcpRWmemorySize(in @utf8InCpp String rmemValues, in @utf8InCpp String wmemValues);
- void registerUnsolicitedEventListener(android.net.INetdUnsolicitedEventListener listener);
- void firewallAddUidInterfaceRules(in @utf8InCpp String ifName, in int[] uids);
- void firewallRemoveUidInterfaceRules(in int[] uids);
- void trafficSwapActiveStatsMap();
- IBinder getOemNetd();
- const int IPV4 = 4;
- const int IPV6 = 6;
- const int CONF = 1;
- const int NEIGH = 2;
- const String IPSEC_INTERFACE_PREFIX = "ipsec";
- const int IPV6_ADDR_GEN_MODE_EUI64 = 0;
- const int IPV6_ADDR_GEN_MODE_NONE = 1;
- const int IPV6_ADDR_GEN_MODE_STABLE_PRIVACY = 2;
- const int IPV6_ADDR_GEN_MODE_RANDOM = 3;
- const int IPV6_ADDR_GEN_MODE_DEFAULT = 0;
- const int PENALTY_POLICY_ACCEPT = 1;
- const int PENALTY_POLICY_LOG = 2;
- const int PENALTY_POLICY_REJECT = 3;
- const int LOCAL_NET_ID = 99;
- const String NEXTHOP_NONE = "";
- const String NEXTHOP_UNREACHABLE = "unreachable";
- const String NEXTHOP_THROW = "throw";
- const int PERMISSION_NONE = 0;
- const int PERMISSION_NETWORK = 1;
- const int PERMISSION_SYSTEM = 2;
- const int NO_PERMISSIONS = 0;
- const int PERMISSION_INTERNET = 4;
- const int PERMISSION_UPDATE_DEVICE_STATS = 8;
- const int PERMISSION_UNINSTALLED = -1;
- const int FIREWALL_WHITELIST = 0;
- const int FIREWALL_BLACKLIST = 1;
- const int FIREWALL_RULE_ALLOW = 1;
- const int FIREWALL_RULE_DENY = 2;
- const int FIREWALL_CHAIN_NONE = 0;
- const int FIREWALL_CHAIN_DOZABLE = 1;
- const int FIREWALL_CHAIN_STANDBY = 2;
- const int FIREWALL_CHAIN_POWERSAVE = 3;
- const String IF_STATE_UP = "up";
- const String IF_STATE_DOWN = "down";
- const String IF_FLAG_BROADCAST = "broadcast";
- const String IF_FLAG_LOOPBACK = "loopback";
- const String IF_FLAG_POINTOPOINT = "point-to-point";
- const String IF_FLAG_RUNNING = "running";
- const String IF_FLAG_MULTICAST = "multicast";
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/2/android/net/INetdUnsolicitedEventListener.aidl b/common/netd/aidl_api/netd_aidl_interface/2/android/net/INetdUnsolicitedEventListener.aidl
deleted file mode 100644
index 621f1cf..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/2/android/net/INetdUnsolicitedEventListener.aidl
+++ /dev/null
@@ -1,31 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a frozen snapshot of an AIDL interface (or parcelable). Do not
-// try to edit this file. It looks like you are doing that because you have
-// modified an AIDL interface in a backward-incompatible way, e.g., deleting a
-// function from an interface or a field from a parcelable and it broke the
-// build. That breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-interface INetdUnsolicitedEventListener {
- oneway void onInterfaceClassActivityChanged(boolean isActive, int timerLabel, long timestampNs, int uid);
- oneway void onQuotaLimitReached(@utf8InCpp String alertName, @utf8InCpp String ifName);
- oneway void onInterfaceDnsServerInfo(@utf8InCpp String ifName, long lifetimeS, in @utf8InCpp String[] servers);
- oneway void onInterfaceAddressUpdated(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAddressRemoved(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAdded(@utf8InCpp String ifName);
- oneway void onInterfaceRemoved(@utf8InCpp String ifName);
- oneway void onInterfaceChanged(@utf8InCpp String ifName, boolean up);
- oneway void onInterfaceLinkStateChanged(@utf8InCpp String ifName, boolean up);
- oneway void onRouteChanged(boolean updated, @utf8InCpp String route, @utf8InCpp String gateway, @utf8InCpp String ifName);
- oneway void onStrictCleartextDetected(int uid, @utf8InCpp String hex);
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/2/android/net/InterfaceConfigurationParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/2/android/net/InterfaceConfigurationParcel.aidl
deleted file mode 100644
index 18de61f..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/2/android/net/InterfaceConfigurationParcel.aidl
+++ /dev/null
@@ -1,25 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a frozen snapshot of an AIDL interface (or parcelable). Do not
-// try to edit this file. It looks like you are doing that because you have
-// modified an AIDL interface in a backward-incompatible way, e.g., deleting a
-// function from an interface or a field from a parcelable and it broke the
-// build. That breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-parcelable InterfaceConfigurationParcel {
- @utf8InCpp String ifName;
- @utf8InCpp String hwAddr;
- @utf8InCpp String ipv4Addr;
- int prefixLength;
- @utf8InCpp String[] flags;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/2/android/net/TetherStatsParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/2/android/net/TetherStatsParcel.aidl
deleted file mode 100644
index c0ba676..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/2/android/net/TetherStatsParcel.aidl
+++ /dev/null
@@ -1,25 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a frozen snapshot of an AIDL interface (or parcelable). Do not
-// try to edit this file. It looks like you are doing that because you have
-// modified an AIDL interface in a backward-incompatible way, e.g., deleting a
-// function from an interface or a field from a parcelable and it broke the
-// build. That breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-parcelable TetherStatsParcel {
- @utf8InCpp String iface;
- long rxBytes;
- long rxPackets;
- long txBytes;
- long txPackets;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/2/android/net/UidRangeParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/2/android/net/UidRangeParcel.aidl
deleted file mode 100644
index c2c35db..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/2/android/net/UidRangeParcel.aidl
+++ /dev/null
@@ -1,22 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a frozen snapshot of an AIDL interface (or parcelable). Do not
-// try to edit this file. It looks like you are doing that because you have
-// modified an AIDL interface in a backward-incompatible way, e.g., deleting a
-// function from an interface or a field from a parcelable and it broke the
-// build. That breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-parcelable UidRangeParcel {
- int start;
- int stop;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/3/.hash b/common/netd/aidl_api/netd_aidl_interface/3/.hash
deleted file mode 100644
index 59cf708..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/3/.hash
+++ /dev/null
@@ -1 +0,0 @@
-e17c1f9b2068b539b22e3a4a447edea3c80aee4b
diff --git a/common/netd/aidl_api/netd_aidl_interface/3/android/net/INetd.aidl b/common/netd/aidl_api/netd_aidl_interface/3/android/net/INetd.aidl
deleted file mode 100644
index 135b738..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/3/android/net/INetd.aidl
+++ /dev/null
@@ -1,161 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-interface INetd {
- boolean isAlive();
- boolean firewallReplaceUidChain(in @utf8InCpp String chainName, boolean isWhitelist, in int[] uids);
- boolean bandwidthEnableDataSaver(boolean enable);
- void networkCreatePhysical(int netId, int permission);
- void networkCreateVpn(int netId, boolean secure);
- void networkDestroy(int netId);
- void networkAddInterface(int netId, in @utf8InCpp String iface);
- void networkRemoveInterface(int netId, in @utf8InCpp String iface);
- void networkAddUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRemoveUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRejectNonSecureVpn(boolean add, in android.net.UidRangeParcel[] uidRanges);
- void socketDestroy(in android.net.UidRangeParcel[] uidRanges, in int[] exemptUids);
- boolean tetherApplyDnsInterfaces();
- android.net.TetherStatsParcel[] tetherGetStats();
- void interfaceAddAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- void interfaceDelAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- @utf8InCpp String getProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter);
- void setProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter, in @utf8InCpp String value);
- void ipSecSetEncapSocketOwner(in ParcelFileDescriptor socket, int newUid);
- int ipSecAllocateSpi(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecAddSecurityAssociation(int transformId, int mode, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int underlyingNetId, int spi, int markValue, int markMask, in @utf8InCpp String authAlgo, in byte[] authKey, in int authTruncBits, in @utf8InCpp String cryptAlgo, in byte[] cryptKey, in int cryptTruncBits, in @utf8InCpp String aeadAlgo, in byte[] aeadKey, in int aeadIcvBits, int encapType, int encapLocalPort, int encapRemotePort, int interfaceId);
- void ipSecDeleteSecurityAssociation(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecApplyTransportModeTransform(in ParcelFileDescriptor socket, int transformId, int direction, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecRemoveTransportModeTransform(in ParcelFileDescriptor socket);
- void ipSecAddSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecUpdateSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecDeleteSecurityPolicy(int transformId, int selAddrFamily, int direction, int markValue, int markMask, int interfaceId);
- void ipSecAddTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecUpdateTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecRemoveTunnelInterface(in @utf8InCpp String deviceName);
- void wakeupAddInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void wakeupDelInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void setIPv6AddrGenMode(in @utf8InCpp String ifName, int mode);
- void idletimerAddInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void idletimerRemoveInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void strictUidCleartextPenalty(int uid, int policyPenalty);
- @utf8InCpp String clatdStart(in @utf8InCpp String ifName, in @utf8InCpp String nat64Prefix);
- void clatdStop(in @utf8InCpp String ifName);
- boolean ipfwdEnabled();
- @utf8InCpp String[] ipfwdGetRequesterList();
- void ipfwdEnableForwarding(in @utf8InCpp String requester);
- void ipfwdDisableForwarding(in @utf8InCpp String requester);
- void ipfwdAddInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void ipfwdRemoveInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void bandwidthSetInterfaceQuota(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceQuota(in @utf8InCpp String ifName);
- void bandwidthSetInterfaceAlert(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceAlert(in @utf8InCpp String ifName);
- void bandwidthSetGlobalAlert(long bytes);
- void bandwidthAddNaughtyApp(int uid);
- void bandwidthRemoveNaughtyApp(int uid);
- void bandwidthAddNiceApp(int uid);
- void bandwidthRemoveNiceApp(int uid);
- void tetherStart(in @utf8InCpp String[] dhcpRanges);
- void tetherStop();
- boolean tetherIsEnabled();
- void tetherInterfaceAdd(in @utf8InCpp String ifName);
- void tetherInterfaceRemove(in @utf8InCpp String ifName);
- @utf8InCpp String[] tetherInterfaceList();
- void tetherDnsSet(int netId, in @utf8InCpp String[] dnsAddrs);
- @utf8InCpp String[] tetherDnsList();
- void networkAddRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkRemoveRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkAddLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- void networkRemoveLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- int networkGetDefault();
- void networkSetDefault(int netId);
- void networkClearDefault();
- void networkSetPermissionForNetwork(int netId, int permission);
- void networkSetPermissionForUser(int permission, in int[] uids);
- void networkClearPermissionForUser(in int[] uids);
- void trafficSetNetPermForUids(int permission, in int[] uids);
- void networkSetProtectAllow(int uid);
- void networkSetProtectDeny(int uid);
- boolean networkCanProtect(int uid);
- void firewallSetFirewallType(int firewalltype);
- void firewallSetInterfaceRule(in @utf8InCpp String ifName, int firewallRule);
- void firewallSetUidRule(int childChain, int uid, int firewallRule);
- void firewallEnableChildChain(int childChain, boolean enable);
- @utf8InCpp String[] interfaceGetList();
- android.net.InterfaceConfigurationParcel interfaceGetCfg(in @utf8InCpp String ifName);
- void interfaceSetCfg(in android.net.InterfaceConfigurationParcel cfg);
- void interfaceSetIPv6PrivacyExtensions(in @utf8InCpp String ifName, boolean enable);
- void interfaceClearAddrs(in @utf8InCpp String ifName);
- void interfaceSetEnableIPv6(in @utf8InCpp String ifName, boolean enable);
- void interfaceSetMtu(in @utf8InCpp String ifName, int mtu);
- void tetherAddForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void tetherRemoveForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void setTcpRWmemorySize(in @utf8InCpp String rmemValues, in @utf8InCpp String wmemValues);
- void registerUnsolicitedEventListener(android.net.INetdUnsolicitedEventListener listener);
- void firewallAddUidInterfaceRules(in @utf8InCpp String ifName, in int[] uids);
- void firewallRemoveUidInterfaceRules(in int[] uids);
- void trafficSwapActiveStatsMap();
- IBinder getOemNetd();
- void tetherStartWithConfiguration(in android.net.TetherConfigParcel config);
- android.net.MarkMaskParcel getFwmarkForNetwork(int netId);
- void networkAddRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void networkUpdateRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void networkRemoveRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void tetherOffloadRuleAdd(in android.net.TetherOffloadRuleParcel rule);
- void tetherOffloadRuleRemove(in android.net.TetherOffloadRuleParcel rule);
- const int IPV4 = 4;
- const int IPV6 = 6;
- const int CONF = 1;
- const int NEIGH = 2;
- const String IPSEC_INTERFACE_PREFIX = "ipsec";
- const int IPV6_ADDR_GEN_MODE_EUI64 = 0;
- const int IPV6_ADDR_GEN_MODE_NONE = 1;
- const int IPV6_ADDR_GEN_MODE_STABLE_PRIVACY = 2;
- const int IPV6_ADDR_GEN_MODE_RANDOM = 3;
- const int IPV6_ADDR_GEN_MODE_DEFAULT = 0;
- const int PENALTY_POLICY_ACCEPT = 1;
- const int PENALTY_POLICY_LOG = 2;
- const int PENALTY_POLICY_REJECT = 3;
- const int LOCAL_NET_ID = 99;
- const String NEXTHOP_NONE = "";
- const String NEXTHOP_UNREACHABLE = "unreachable";
- const String NEXTHOP_THROW = "throw";
- const int PERMISSION_NONE = 0;
- const int PERMISSION_NETWORK = 1;
- const int PERMISSION_SYSTEM = 2;
- const int NO_PERMISSIONS = 0;
- const int PERMISSION_INTERNET = 4;
- const int PERMISSION_UPDATE_DEVICE_STATS = 8;
- const int PERMISSION_UNINSTALLED = -1;
- const int FIREWALL_WHITELIST = 0;
- const int FIREWALL_BLACKLIST = 1;
- const int FIREWALL_RULE_ALLOW = 1;
- const int FIREWALL_RULE_DENY = 2;
- const int FIREWALL_CHAIN_NONE = 0;
- const int FIREWALL_CHAIN_DOZABLE = 1;
- const int FIREWALL_CHAIN_STANDBY = 2;
- const int FIREWALL_CHAIN_POWERSAVE = 3;
- const String IF_STATE_UP = "up";
- const String IF_STATE_DOWN = "down";
- const String IF_FLAG_BROADCAST = "broadcast";
- const String IF_FLAG_LOOPBACK = "loopback";
- const String IF_FLAG_POINTOPOINT = "point-to-point";
- const String IF_FLAG_RUNNING = "running";
- const String IF_FLAG_MULTICAST = "multicast";
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/3/android/net/INetdUnsolicitedEventListener.aidl b/common/netd/aidl_api/netd_aidl_interface/3/android/net/INetdUnsolicitedEventListener.aidl
deleted file mode 100644
index 4459363..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/3/android/net/INetdUnsolicitedEventListener.aidl
+++ /dev/null
@@ -1,32 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-interface INetdUnsolicitedEventListener {
- oneway void onInterfaceClassActivityChanged(boolean isActive, int timerLabel, long timestampNs, int uid);
- oneway void onQuotaLimitReached(@utf8InCpp String alertName, @utf8InCpp String ifName);
- oneway void onInterfaceDnsServerInfo(@utf8InCpp String ifName, long lifetimeS, in @utf8InCpp String[] servers);
- oneway void onInterfaceAddressUpdated(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAddressRemoved(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAdded(@utf8InCpp String ifName);
- oneway void onInterfaceRemoved(@utf8InCpp String ifName);
- oneway void onInterfaceChanged(@utf8InCpp String ifName, boolean up);
- oneway void onInterfaceLinkStateChanged(@utf8InCpp String ifName, boolean up);
- oneway void onRouteChanged(boolean updated, @utf8InCpp String route, @utf8InCpp String gateway, @utf8InCpp String ifName);
- oneway void onStrictCleartextDetected(int uid, @utf8InCpp String hex);
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/3/android/net/InterfaceConfigurationParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/3/android/net/InterfaceConfigurationParcel.aidl
deleted file mode 100644
index 01e0f95..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/3/android/net/InterfaceConfigurationParcel.aidl
+++ /dev/null
@@ -1,26 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable InterfaceConfigurationParcel {
- @utf8InCpp String ifName;
- @utf8InCpp String hwAddr;
- @utf8InCpp String ipv4Addr;
- int prefixLength;
- @utf8InCpp String[] flags;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/3/android/net/MarkMaskParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/3/android/net/MarkMaskParcel.aidl
deleted file mode 100644
index 62be838..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/3/android/net/MarkMaskParcel.aidl
+++ /dev/null
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable MarkMaskParcel {
- int mark;
- int mask;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/3/android/net/RouteInfoParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/3/android/net/RouteInfoParcel.aidl
deleted file mode 100644
index 5e0ee62..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/3/android/net/RouteInfoParcel.aidl
+++ /dev/null
@@ -1,24 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-parcelable RouteInfoParcel {
- @utf8InCpp String destination;
- @utf8InCpp String ifName;
- @utf8InCpp String nextHop;
- int mtu;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/3/android/net/TetherConfigParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/3/android/net/TetherConfigParcel.aidl
deleted file mode 100644
index b136454..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/3/android/net/TetherConfigParcel.aidl
+++ /dev/null
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherConfigParcel {
- boolean usingLegacyDnsProxy;
- @utf8InCpp String[] dhcpRanges;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/3/android/net/TetherOffloadRuleParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/3/android/net/TetherOffloadRuleParcel.aidl
deleted file mode 100644
index 3abf0f8..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/3/android/net/TetherOffloadRuleParcel.aidl
+++ /dev/null
@@ -1,27 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherOffloadRuleParcel {
- int inputInterfaceIndex;
- int outputInterfaceIndex;
- byte[] destination;
- int prefixLength;
- byte[] srcL2Address;
- byte[] dstL2Address;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/3/android/net/TetherStatsParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/3/android/net/TetherStatsParcel.aidl
deleted file mode 100644
index 71ffb9b..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/3/android/net/TetherStatsParcel.aidl
+++ /dev/null
@@ -1,26 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherStatsParcel {
- @utf8InCpp String iface;
- long rxBytes;
- long rxPackets;
- long txBytes;
- long txPackets;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/3/android/net/UidRangeParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/3/android/net/UidRangeParcel.aidl
deleted file mode 100644
index 84ff457..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/3/android/net/UidRangeParcel.aidl
+++ /dev/null
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable UidRangeParcel {
- int start;
- int stop;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/4/.hash b/common/netd/aidl_api/netd_aidl_interface/4/.hash
deleted file mode 100644
index 0c3f810..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/4/.hash
+++ /dev/null
@@ -1 +0,0 @@
-63adaa5098e4d8621e90c5a84f7cb93505c79311
diff --git a/common/netd/aidl_api/netd_aidl_interface/4/android/net/INetd.aidl b/common/netd/aidl_api/netd_aidl_interface/4/android/net/INetd.aidl
deleted file mode 100644
index 47e2931..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/4/android/net/INetd.aidl
+++ /dev/null
@@ -1,164 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-interface INetd {
- boolean isAlive();
- boolean firewallReplaceUidChain(in @utf8InCpp String chainName, boolean isWhitelist, in int[] uids);
- boolean bandwidthEnableDataSaver(boolean enable);
- void networkCreatePhysical(int netId, int permission);
- void networkCreateVpn(int netId, boolean secure);
- void networkDestroy(int netId);
- void networkAddInterface(int netId, in @utf8InCpp String iface);
- void networkRemoveInterface(int netId, in @utf8InCpp String iface);
- void networkAddUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRemoveUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRejectNonSecureVpn(boolean add, in android.net.UidRangeParcel[] uidRanges);
- void socketDestroy(in android.net.UidRangeParcel[] uidRanges, in int[] exemptUids);
- boolean tetherApplyDnsInterfaces();
- android.net.TetherStatsParcel[] tetherGetStats();
- void interfaceAddAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- void interfaceDelAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- @utf8InCpp String getProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter);
- void setProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter, in @utf8InCpp String value);
- void ipSecSetEncapSocketOwner(in ParcelFileDescriptor socket, int newUid);
- int ipSecAllocateSpi(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecAddSecurityAssociation(int transformId, int mode, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int underlyingNetId, int spi, int markValue, int markMask, in @utf8InCpp String authAlgo, in byte[] authKey, in int authTruncBits, in @utf8InCpp String cryptAlgo, in byte[] cryptKey, in int cryptTruncBits, in @utf8InCpp String aeadAlgo, in byte[] aeadKey, in int aeadIcvBits, int encapType, int encapLocalPort, int encapRemotePort, int interfaceId);
- void ipSecDeleteSecurityAssociation(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecApplyTransportModeTransform(in ParcelFileDescriptor socket, int transformId, int direction, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecRemoveTransportModeTransform(in ParcelFileDescriptor socket);
- void ipSecAddSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecUpdateSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecDeleteSecurityPolicy(int transformId, int selAddrFamily, int direction, int markValue, int markMask, int interfaceId);
- void ipSecAddTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecUpdateTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecRemoveTunnelInterface(in @utf8InCpp String deviceName);
- void wakeupAddInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void wakeupDelInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void setIPv6AddrGenMode(in @utf8InCpp String ifName, int mode);
- void idletimerAddInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void idletimerRemoveInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void strictUidCleartextPenalty(int uid, int policyPenalty);
- @utf8InCpp String clatdStart(in @utf8InCpp String ifName, in @utf8InCpp String nat64Prefix);
- void clatdStop(in @utf8InCpp String ifName);
- boolean ipfwdEnabled();
- @utf8InCpp String[] ipfwdGetRequesterList();
- void ipfwdEnableForwarding(in @utf8InCpp String requester);
- void ipfwdDisableForwarding(in @utf8InCpp String requester);
- void ipfwdAddInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void ipfwdRemoveInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void bandwidthSetInterfaceQuota(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceQuota(in @utf8InCpp String ifName);
- void bandwidthSetInterfaceAlert(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceAlert(in @utf8InCpp String ifName);
- void bandwidthSetGlobalAlert(long bytes);
- void bandwidthAddNaughtyApp(int uid);
- void bandwidthRemoveNaughtyApp(int uid);
- void bandwidthAddNiceApp(int uid);
- void bandwidthRemoveNiceApp(int uid);
- void tetherStart(in @utf8InCpp String[] dhcpRanges);
- void tetherStop();
- boolean tetherIsEnabled();
- void tetherInterfaceAdd(in @utf8InCpp String ifName);
- void tetherInterfaceRemove(in @utf8InCpp String ifName);
- @utf8InCpp String[] tetherInterfaceList();
- void tetherDnsSet(int netId, in @utf8InCpp String[] dnsAddrs);
- @utf8InCpp String[] tetherDnsList();
- void networkAddRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkRemoveRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkAddLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- void networkRemoveLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- int networkGetDefault();
- void networkSetDefault(int netId);
- void networkClearDefault();
- void networkSetPermissionForNetwork(int netId, int permission);
- void networkSetPermissionForUser(int permission, in int[] uids);
- void networkClearPermissionForUser(in int[] uids);
- void trafficSetNetPermForUids(int permission, in int[] uids);
- void networkSetProtectAllow(int uid);
- void networkSetProtectDeny(int uid);
- boolean networkCanProtect(int uid);
- void firewallSetFirewallType(int firewalltype);
- void firewallSetInterfaceRule(in @utf8InCpp String ifName, int firewallRule);
- void firewallSetUidRule(int childChain, int uid, int firewallRule);
- void firewallEnableChildChain(int childChain, boolean enable);
- @utf8InCpp String[] interfaceGetList();
- android.net.InterfaceConfigurationParcel interfaceGetCfg(in @utf8InCpp String ifName);
- void interfaceSetCfg(in android.net.InterfaceConfigurationParcel cfg);
- void interfaceSetIPv6PrivacyExtensions(in @utf8InCpp String ifName, boolean enable);
- void interfaceClearAddrs(in @utf8InCpp String ifName);
- void interfaceSetEnableIPv6(in @utf8InCpp String ifName, boolean enable);
- void interfaceSetMtu(in @utf8InCpp String ifName, int mtu);
- void tetherAddForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void tetherRemoveForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void setTcpRWmemorySize(in @utf8InCpp String rmemValues, in @utf8InCpp String wmemValues);
- void registerUnsolicitedEventListener(android.net.INetdUnsolicitedEventListener listener);
- void firewallAddUidInterfaceRules(in @utf8InCpp String ifName, in int[] uids);
- void firewallRemoveUidInterfaceRules(in int[] uids);
- void trafficSwapActiveStatsMap();
- IBinder getOemNetd();
- void tetherStartWithConfiguration(in android.net.TetherConfigParcel config);
- android.net.MarkMaskParcel getFwmarkForNetwork(int netId);
- void networkAddRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void networkUpdateRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void networkRemoveRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void tetherOffloadRuleAdd(in android.net.TetherOffloadRuleParcel rule);
- void tetherOffloadRuleRemove(in android.net.TetherOffloadRuleParcel rule);
- android.net.TetherStatsParcel[] tetherOffloadGetStats();
- void tetherOffloadSetInterfaceQuota(int ifIndex, long quotaBytes);
- android.net.TetherStatsParcel tetherOffloadGetAndClearStats(int ifIndex);
- const int IPV4 = 4;
- const int IPV6 = 6;
- const int CONF = 1;
- const int NEIGH = 2;
- const String IPSEC_INTERFACE_PREFIX = "ipsec";
- const int IPV6_ADDR_GEN_MODE_EUI64 = 0;
- const int IPV6_ADDR_GEN_MODE_NONE = 1;
- const int IPV6_ADDR_GEN_MODE_STABLE_PRIVACY = 2;
- const int IPV6_ADDR_GEN_MODE_RANDOM = 3;
- const int IPV6_ADDR_GEN_MODE_DEFAULT = 0;
- const int PENALTY_POLICY_ACCEPT = 1;
- const int PENALTY_POLICY_LOG = 2;
- const int PENALTY_POLICY_REJECT = 3;
- const int LOCAL_NET_ID = 99;
- const String NEXTHOP_NONE = "";
- const String NEXTHOP_UNREACHABLE = "unreachable";
- const String NEXTHOP_THROW = "throw";
- const int PERMISSION_NONE = 0;
- const int PERMISSION_NETWORK = 1;
- const int PERMISSION_SYSTEM = 2;
- const int NO_PERMISSIONS = 0;
- const int PERMISSION_INTERNET = 4;
- const int PERMISSION_UPDATE_DEVICE_STATS = 8;
- const int PERMISSION_UNINSTALLED = -1;
- const int FIREWALL_WHITELIST = 0;
- const int FIREWALL_BLACKLIST = 1;
- const int FIREWALL_RULE_ALLOW = 1;
- const int FIREWALL_RULE_DENY = 2;
- const int FIREWALL_CHAIN_NONE = 0;
- const int FIREWALL_CHAIN_DOZABLE = 1;
- const int FIREWALL_CHAIN_STANDBY = 2;
- const int FIREWALL_CHAIN_POWERSAVE = 3;
- const String IF_STATE_UP = "up";
- const String IF_STATE_DOWN = "down";
- const String IF_FLAG_BROADCAST = "broadcast";
- const String IF_FLAG_LOOPBACK = "loopback";
- const String IF_FLAG_POINTOPOINT = "point-to-point";
- const String IF_FLAG_RUNNING = "running";
- const String IF_FLAG_MULTICAST = "multicast";
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/4/android/net/INetdUnsolicitedEventListener.aidl b/common/netd/aidl_api/netd_aidl_interface/4/android/net/INetdUnsolicitedEventListener.aidl
deleted file mode 100644
index 4459363..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/4/android/net/INetdUnsolicitedEventListener.aidl
+++ /dev/null
@@ -1,32 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-interface INetdUnsolicitedEventListener {
- oneway void onInterfaceClassActivityChanged(boolean isActive, int timerLabel, long timestampNs, int uid);
- oneway void onQuotaLimitReached(@utf8InCpp String alertName, @utf8InCpp String ifName);
- oneway void onInterfaceDnsServerInfo(@utf8InCpp String ifName, long lifetimeS, in @utf8InCpp String[] servers);
- oneway void onInterfaceAddressUpdated(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAddressRemoved(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAdded(@utf8InCpp String ifName);
- oneway void onInterfaceRemoved(@utf8InCpp String ifName);
- oneway void onInterfaceChanged(@utf8InCpp String ifName, boolean up);
- oneway void onInterfaceLinkStateChanged(@utf8InCpp String ifName, boolean up);
- oneway void onRouteChanged(boolean updated, @utf8InCpp String route, @utf8InCpp String gateway, @utf8InCpp String ifName);
- oneway void onStrictCleartextDetected(int uid, @utf8InCpp String hex);
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/4/android/net/InterfaceConfigurationParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/4/android/net/InterfaceConfigurationParcel.aidl
deleted file mode 100644
index 01e0f95..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/4/android/net/InterfaceConfigurationParcel.aidl
+++ /dev/null
@@ -1,26 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable InterfaceConfigurationParcel {
- @utf8InCpp String ifName;
- @utf8InCpp String hwAddr;
- @utf8InCpp String ipv4Addr;
- int prefixLength;
- @utf8InCpp String[] flags;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/4/android/net/MarkMaskParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/4/android/net/MarkMaskParcel.aidl
deleted file mode 100644
index 62be838..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/4/android/net/MarkMaskParcel.aidl
+++ /dev/null
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable MarkMaskParcel {
- int mark;
- int mask;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/4/android/net/RouteInfoParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/4/android/net/RouteInfoParcel.aidl
deleted file mode 100644
index 5e0ee62..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/4/android/net/RouteInfoParcel.aidl
+++ /dev/null
@@ -1,24 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-parcelable RouteInfoParcel {
- @utf8InCpp String destination;
- @utf8InCpp String ifName;
- @utf8InCpp String nextHop;
- int mtu;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/4/android/net/TetherConfigParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/4/android/net/TetherConfigParcel.aidl
deleted file mode 100644
index b136454..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/4/android/net/TetherConfigParcel.aidl
+++ /dev/null
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherConfigParcel {
- boolean usingLegacyDnsProxy;
- @utf8InCpp String[] dhcpRanges;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/4/android/net/TetherOffloadRuleParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/4/android/net/TetherOffloadRuleParcel.aidl
deleted file mode 100644
index c9d8458..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/4/android/net/TetherOffloadRuleParcel.aidl
+++ /dev/null
@@ -1,28 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherOffloadRuleParcel {
- int inputInterfaceIndex;
- int outputInterfaceIndex;
- byte[] destination;
- int prefixLength;
- byte[] srcL2Address;
- byte[] dstL2Address;
- int pmtu = 1500;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/4/android/net/TetherStatsParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/4/android/net/TetherStatsParcel.aidl
deleted file mode 100644
index 0b0960e..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/4/android/net/TetherStatsParcel.aidl
+++ /dev/null
@@ -1,27 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherStatsParcel {
- @utf8InCpp String iface;
- long rxBytes;
- long rxPackets;
- long txBytes;
- long txPackets;
- int ifIndex = 0;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/4/android/net/UidRangeParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/4/android/net/UidRangeParcel.aidl
deleted file mode 100644
index 84ff457..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/4/android/net/UidRangeParcel.aidl
+++ /dev/null
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable UidRangeParcel {
- int start;
- int stop;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/5/.hash b/common/netd/aidl_api/netd_aidl_interface/5/.hash
deleted file mode 100644
index a6ced45..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/5/.hash
+++ /dev/null
@@ -1 +0,0 @@
-d97c56dd789cee9eeb5cdcec43a99df0a01873a5
diff --git a/common/netd/aidl_api/netd_aidl_interface/5/android/net/INetd.aidl b/common/netd/aidl_api/netd_aidl_interface/5/android/net/INetd.aidl
deleted file mode 100644
index b30748a..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/5/android/net/INetd.aidl
+++ /dev/null
@@ -1,167 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-interface INetd {
- boolean isAlive();
- boolean firewallReplaceUidChain(in @utf8InCpp String chainName, boolean isAllowlist, in int[] uids);
- boolean bandwidthEnableDataSaver(boolean enable);
- void networkCreatePhysical(int netId, int permission);
- void networkCreateVpn(int netId, boolean secure);
- void networkDestroy(int netId);
- void networkAddInterface(int netId, in @utf8InCpp String iface);
- void networkRemoveInterface(int netId, in @utf8InCpp String iface);
- void networkAddUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRemoveUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRejectNonSecureVpn(boolean add, in android.net.UidRangeParcel[] uidRanges);
- void socketDestroy(in android.net.UidRangeParcel[] uidRanges, in int[] exemptUids);
- boolean tetherApplyDnsInterfaces();
- android.net.TetherStatsParcel[] tetherGetStats();
- void interfaceAddAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- void interfaceDelAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- @utf8InCpp String getProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter);
- void setProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter, in @utf8InCpp String value);
- void ipSecSetEncapSocketOwner(in ParcelFileDescriptor socket, int newUid);
- int ipSecAllocateSpi(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecAddSecurityAssociation(int transformId, int mode, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int underlyingNetId, int spi, int markValue, int markMask, in @utf8InCpp String authAlgo, in byte[] authKey, in int authTruncBits, in @utf8InCpp String cryptAlgo, in byte[] cryptKey, in int cryptTruncBits, in @utf8InCpp String aeadAlgo, in byte[] aeadKey, in int aeadIcvBits, int encapType, int encapLocalPort, int encapRemotePort, int interfaceId);
- void ipSecDeleteSecurityAssociation(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecApplyTransportModeTransform(in ParcelFileDescriptor socket, int transformId, int direction, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecRemoveTransportModeTransform(in ParcelFileDescriptor socket);
- void ipSecAddSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecUpdateSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecDeleteSecurityPolicy(int transformId, int selAddrFamily, int direction, int markValue, int markMask, int interfaceId);
- void ipSecAddTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecUpdateTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecRemoveTunnelInterface(in @utf8InCpp String deviceName);
- void wakeupAddInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void wakeupDelInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void setIPv6AddrGenMode(in @utf8InCpp String ifName, int mode);
- void idletimerAddInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void idletimerRemoveInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void strictUidCleartextPenalty(int uid, int policyPenalty);
- @utf8InCpp String clatdStart(in @utf8InCpp String ifName, in @utf8InCpp String nat64Prefix);
- void clatdStop(in @utf8InCpp String ifName);
- boolean ipfwdEnabled();
- @utf8InCpp String[] ipfwdGetRequesterList();
- void ipfwdEnableForwarding(in @utf8InCpp String requester);
- void ipfwdDisableForwarding(in @utf8InCpp String requester);
- void ipfwdAddInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void ipfwdRemoveInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void bandwidthSetInterfaceQuota(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceQuota(in @utf8InCpp String ifName);
- void bandwidthSetInterfaceAlert(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceAlert(in @utf8InCpp String ifName);
- void bandwidthSetGlobalAlert(long bytes);
- void bandwidthAddNaughtyApp(int uid);
- void bandwidthRemoveNaughtyApp(int uid);
- void bandwidthAddNiceApp(int uid);
- void bandwidthRemoveNiceApp(int uid);
- void tetherStart(in @utf8InCpp String[] dhcpRanges);
- void tetherStop();
- boolean tetherIsEnabled();
- void tetherInterfaceAdd(in @utf8InCpp String ifName);
- void tetherInterfaceRemove(in @utf8InCpp String ifName);
- @utf8InCpp String[] tetherInterfaceList();
- void tetherDnsSet(int netId, in @utf8InCpp String[] dnsAddrs);
- @utf8InCpp String[] tetherDnsList();
- void networkAddRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkRemoveRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkAddLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- void networkRemoveLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- int networkGetDefault();
- void networkSetDefault(int netId);
- void networkClearDefault();
- void networkSetPermissionForNetwork(int netId, int permission);
- void networkSetPermissionForUser(int permission, in int[] uids);
- void networkClearPermissionForUser(in int[] uids);
- void trafficSetNetPermForUids(int permission, in int[] uids);
- void networkSetProtectAllow(int uid);
- void networkSetProtectDeny(int uid);
- boolean networkCanProtect(int uid);
- void firewallSetFirewallType(int firewalltype);
- void firewallSetInterfaceRule(in @utf8InCpp String ifName, int firewallRule);
- void firewallSetUidRule(int childChain, int uid, int firewallRule);
- void firewallEnableChildChain(int childChain, boolean enable);
- @utf8InCpp String[] interfaceGetList();
- android.net.InterfaceConfigurationParcel interfaceGetCfg(in @utf8InCpp String ifName);
- void interfaceSetCfg(in android.net.InterfaceConfigurationParcel cfg);
- void interfaceSetIPv6PrivacyExtensions(in @utf8InCpp String ifName, boolean enable);
- void interfaceClearAddrs(in @utf8InCpp String ifName);
- void interfaceSetEnableIPv6(in @utf8InCpp String ifName, boolean enable);
- void interfaceSetMtu(in @utf8InCpp String ifName, int mtu);
- void tetherAddForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void tetherRemoveForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void setTcpRWmemorySize(in @utf8InCpp String rmemValues, in @utf8InCpp String wmemValues);
- void registerUnsolicitedEventListener(android.net.INetdUnsolicitedEventListener listener);
- void firewallAddUidInterfaceRules(in @utf8InCpp String ifName, in int[] uids);
- void firewallRemoveUidInterfaceRules(in int[] uids);
- void trafficSwapActiveStatsMap();
- IBinder getOemNetd();
- void tetherStartWithConfiguration(in android.net.TetherConfigParcel config);
- android.net.MarkMaskParcel getFwmarkForNetwork(int netId);
- void networkAddRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void networkUpdateRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void networkRemoveRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void tetherOffloadRuleAdd(in android.net.TetherOffloadRuleParcel rule);
- void tetherOffloadRuleRemove(in android.net.TetherOffloadRuleParcel rule);
- android.net.TetherStatsParcel[] tetherOffloadGetStats();
- void tetherOffloadSetInterfaceQuota(int ifIndex, long quotaBytes);
- android.net.TetherStatsParcel tetherOffloadGetAndClearStats(int ifIndex);
- const int IPV4 = 4;
- const int IPV6 = 6;
- const int CONF = 1;
- const int NEIGH = 2;
- const String IPSEC_INTERFACE_PREFIX = "ipsec";
- const int IPV6_ADDR_GEN_MODE_EUI64 = 0;
- const int IPV6_ADDR_GEN_MODE_NONE = 1;
- const int IPV6_ADDR_GEN_MODE_STABLE_PRIVACY = 2;
- const int IPV6_ADDR_GEN_MODE_RANDOM = 3;
- const int IPV6_ADDR_GEN_MODE_DEFAULT = 0;
- const int PENALTY_POLICY_ACCEPT = 1;
- const int PENALTY_POLICY_LOG = 2;
- const int PENALTY_POLICY_REJECT = 3;
- const int LOCAL_NET_ID = 99;
- const String NEXTHOP_NONE = "";
- const String NEXTHOP_UNREACHABLE = "unreachable";
- const String NEXTHOP_THROW = "throw";
- const int PERMISSION_NONE = 0;
- const int PERMISSION_NETWORK = 1;
- const int PERMISSION_SYSTEM = 2;
- const int NO_PERMISSIONS = 0;
- const int PERMISSION_INTERNET = 4;
- const int PERMISSION_UPDATE_DEVICE_STATS = 8;
- const int PERMISSION_UNINSTALLED = -1;
- const @JavaPassthrough(annotation="@Deprecated") int FIREWALL_WHITELIST = 0;
- const int FIREWALL_ALLOWLIST = 0;
- const @JavaPassthrough(annotation="@Deprecated") int FIREWALL_BLACKLIST = 1;
- const int FIREWALL_DENYLIST = 1;
- const int FIREWALL_RULE_ALLOW = 1;
- const int FIREWALL_RULE_DENY = 2;
- const int FIREWALL_CHAIN_NONE = 0;
- const int FIREWALL_CHAIN_DOZABLE = 1;
- const int FIREWALL_CHAIN_STANDBY = 2;
- const int FIREWALL_CHAIN_POWERSAVE = 3;
- const int FIREWALL_CHAIN_RESTRICTED = 4;
- const String IF_STATE_UP = "up";
- const String IF_STATE_DOWN = "down";
- const String IF_FLAG_BROADCAST = "broadcast";
- const String IF_FLAG_LOOPBACK = "loopback";
- const String IF_FLAG_POINTOPOINT = "point-to-point";
- const String IF_FLAG_RUNNING = "running";
- const String IF_FLAG_MULTICAST = "multicast";
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/5/android/net/INetdUnsolicitedEventListener.aidl b/common/netd/aidl_api/netd_aidl_interface/5/android/net/INetdUnsolicitedEventListener.aidl
deleted file mode 100644
index 4459363..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/5/android/net/INetdUnsolicitedEventListener.aidl
+++ /dev/null
@@ -1,32 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-interface INetdUnsolicitedEventListener {
- oneway void onInterfaceClassActivityChanged(boolean isActive, int timerLabel, long timestampNs, int uid);
- oneway void onQuotaLimitReached(@utf8InCpp String alertName, @utf8InCpp String ifName);
- oneway void onInterfaceDnsServerInfo(@utf8InCpp String ifName, long lifetimeS, in @utf8InCpp String[] servers);
- oneway void onInterfaceAddressUpdated(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAddressRemoved(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAdded(@utf8InCpp String ifName);
- oneway void onInterfaceRemoved(@utf8InCpp String ifName);
- oneway void onInterfaceChanged(@utf8InCpp String ifName, boolean up);
- oneway void onInterfaceLinkStateChanged(@utf8InCpp String ifName, boolean up);
- oneway void onRouteChanged(boolean updated, @utf8InCpp String route, @utf8InCpp String gateway, @utf8InCpp String ifName);
- oneway void onStrictCleartextDetected(int uid, @utf8InCpp String hex);
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/5/android/net/InterfaceConfigurationParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/5/android/net/InterfaceConfigurationParcel.aidl
deleted file mode 100644
index 01e0f95..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/5/android/net/InterfaceConfigurationParcel.aidl
+++ /dev/null
@@ -1,26 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable InterfaceConfigurationParcel {
- @utf8InCpp String ifName;
- @utf8InCpp String hwAddr;
- @utf8InCpp String ipv4Addr;
- int prefixLength;
- @utf8InCpp String[] flags;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/5/android/net/MarkMaskParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/5/android/net/MarkMaskParcel.aidl
deleted file mode 100644
index 62be838..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/5/android/net/MarkMaskParcel.aidl
+++ /dev/null
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable MarkMaskParcel {
- int mark;
- int mask;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/5/android/net/RouteInfoParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/5/android/net/RouteInfoParcel.aidl
deleted file mode 100644
index 5e0ee62..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/5/android/net/RouteInfoParcel.aidl
+++ /dev/null
@@ -1,24 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-parcelable RouteInfoParcel {
- @utf8InCpp String destination;
- @utf8InCpp String ifName;
- @utf8InCpp String nextHop;
- int mtu;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/5/android/net/TetherConfigParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/5/android/net/TetherConfigParcel.aidl
deleted file mode 100644
index b136454..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/5/android/net/TetherConfigParcel.aidl
+++ /dev/null
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherConfigParcel {
- boolean usingLegacyDnsProxy;
- @utf8InCpp String[] dhcpRanges;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/5/android/net/TetherOffloadRuleParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/5/android/net/TetherOffloadRuleParcel.aidl
deleted file mode 100644
index c9d8458..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/5/android/net/TetherOffloadRuleParcel.aidl
+++ /dev/null
@@ -1,28 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherOffloadRuleParcel {
- int inputInterfaceIndex;
- int outputInterfaceIndex;
- byte[] destination;
- int prefixLength;
- byte[] srcL2Address;
- byte[] dstL2Address;
- int pmtu = 1500;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/5/android/net/TetherStatsParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/5/android/net/TetherStatsParcel.aidl
deleted file mode 100644
index 0b0960e..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/5/android/net/TetherStatsParcel.aidl
+++ /dev/null
@@ -1,27 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherStatsParcel {
- @utf8InCpp String iface;
- long rxBytes;
- long rxPackets;
- long txBytes;
- long txPackets;
- int ifIndex = 0;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/5/android/net/UidRangeParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/5/android/net/UidRangeParcel.aidl
deleted file mode 100644
index debc6be..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/5/android/net/UidRangeParcel.aidl
+++ /dev/null
@@ -1,24 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
-parcelable UidRangeParcel {
- int start;
- int stop;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/6/.hash b/common/netd/aidl_api/netd_aidl_interface/6/.hash
deleted file mode 100644
index f5acf5d..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/6/.hash
+++ /dev/null
@@ -1 +0,0 @@
-b08451d9673b09cba84f1fd8740e1fdac64ff7be
diff --git a/common/netd/aidl_api/netd_aidl_interface/6/android/net/INetd.aidl b/common/netd/aidl_api/netd_aidl_interface/6/android/net/INetd.aidl
deleted file mode 100644
index a7952f2..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/6/android/net/INetd.aidl
+++ /dev/null
@@ -1,198 +0,0 @@
-/**
- * Copyright (c) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-interface INetd {
- boolean isAlive();
- boolean firewallReplaceUidChain(in @utf8InCpp String chainName, boolean isAllowlist, in int[] uids);
- boolean bandwidthEnableDataSaver(boolean enable);
- /**
- * @deprecated use networkCreate() instead.
- */
- void networkCreatePhysical(int netId, int permission);
- /**
- * @deprecated use networkCreate() instead.
- */
- void networkCreateVpn(int netId, boolean secure);
- void networkDestroy(int netId);
- void networkAddInterface(int netId, in @utf8InCpp String iface);
- void networkRemoveInterface(int netId, in @utf8InCpp String iface);
- void networkAddUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRemoveUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRejectNonSecureVpn(boolean add, in android.net.UidRangeParcel[] uidRanges);
- void socketDestroy(in android.net.UidRangeParcel[] uidRanges, in int[] exemptUids);
- boolean tetherApplyDnsInterfaces();
- android.net.TetherStatsParcel[] tetherGetStats();
- void interfaceAddAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- void interfaceDelAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- @utf8InCpp String getProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter);
- void setProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter, in @utf8InCpp String value);
- void ipSecSetEncapSocketOwner(in ParcelFileDescriptor socket, int newUid);
- int ipSecAllocateSpi(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecAddSecurityAssociation(int transformId, int mode, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int underlyingNetId, int spi, int markValue, int markMask, in @utf8InCpp String authAlgo, in byte[] authKey, in int authTruncBits, in @utf8InCpp String cryptAlgo, in byte[] cryptKey, in int cryptTruncBits, in @utf8InCpp String aeadAlgo, in byte[] aeadKey, in int aeadIcvBits, int encapType, int encapLocalPort, int encapRemotePort, int interfaceId);
- void ipSecDeleteSecurityAssociation(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecApplyTransportModeTransform(in ParcelFileDescriptor socket, int transformId, int direction, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecRemoveTransportModeTransform(in ParcelFileDescriptor socket);
- void ipSecAddSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecUpdateSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecDeleteSecurityPolicy(int transformId, int selAddrFamily, int direction, int markValue, int markMask, int interfaceId);
- void ipSecAddTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecUpdateTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecRemoveTunnelInterface(in @utf8InCpp String deviceName);
- void wakeupAddInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void wakeupDelInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void setIPv6AddrGenMode(in @utf8InCpp String ifName, int mode);
- void idletimerAddInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void idletimerRemoveInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void strictUidCleartextPenalty(int uid, int policyPenalty);
- @utf8InCpp String clatdStart(in @utf8InCpp String ifName, in @utf8InCpp String nat64Prefix);
- void clatdStop(in @utf8InCpp String ifName);
- boolean ipfwdEnabled();
- @utf8InCpp String[] ipfwdGetRequesterList();
- void ipfwdEnableForwarding(in @utf8InCpp String requester);
- void ipfwdDisableForwarding(in @utf8InCpp String requester);
- void ipfwdAddInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void ipfwdRemoveInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void bandwidthSetInterfaceQuota(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceQuota(in @utf8InCpp String ifName);
- void bandwidthSetInterfaceAlert(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceAlert(in @utf8InCpp String ifName);
- void bandwidthSetGlobalAlert(long bytes);
- void bandwidthAddNaughtyApp(int uid);
- void bandwidthRemoveNaughtyApp(int uid);
- void bandwidthAddNiceApp(int uid);
- void bandwidthRemoveNiceApp(int uid);
- void tetherStart(in @utf8InCpp String[] dhcpRanges);
- void tetherStop();
- boolean tetherIsEnabled();
- void tetherInterfaceAdd(in @utf8InCpp String ifName);
- void tetherInterfaceRemove(in @utf8InCpp String ifName);
- @utf8InCpp String[] tetherInterfaceList();
- void tetherDnsSet(int netId, in @utf8InCpp String[] dnsAddrs);
- @utf8InCpp String[] tetherDnsList();
- void networkAddRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkRemoveRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkAddLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- void networkRemoveLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- int networkGetDefault();
- void networkSetDefault(int netId);
- void networkClearDefault();
- void networkSetPermissionForNetwork(int netId, int permission);
- void networkSetPermissionForUser(int permission, in int[] uids);
- void networkClearPermissionForUser(in int[] uids);
- void trafficSetNetPermForUids(int permission, in int[] uids);
- void networkSetProtectAllow(int uid);
- void networkSetProtectDeny(int uid);
- boolean networkCanProtect(int uid);
- void firewallSetFirewallType(int firewalltype);
- void firewallSetInterfaceRule(in @utf8InCpp String ifName, int firewallRule);
- void firewallSetUidRule(int childChain, int uid, int firewallRule);
- void firewallEnableChildChain(int childChain, boolean enable);
- @utf8InCpp String[] interfaceGetList();
- android.net.InterfaceConfigurationParcel interfaceGetCfg(in @utf8InCpp String ifName);
- void interfaceSetCfg(in android.net.InterfaceConfigurationParcel cfg);
- void interfaceSetIPv6PrivacyExtensions(in @utf8InCpp String ifName, boolean enable);
- void interfaceClearAddrs(in @utf8InCpp String ifName);
- void interfaceSetEnableIPv6(in @utf8InCpp String ifName, boolean enable);
- void interfaceSetMtu(in @utf8InCpp String ifName, int mtu);
- void tetherAddForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void tetherRemoveForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void setTcpRWmemorySize(in @utf8InCpp String rmemValues, in @utf8InCpp String wmemValues);
- void registerUnsolicitedEventListener(android.net.INetdUnsolicitedEventListener listener);
- void firewallAddUidInterfaceRules(in @utf8InCpp String ifName, in int[] uids);
- void firewallRemoveUidInterfaceRules(in int[] uids);
- void trafficSwapActiveStatsMap();
- IBinder getOemNetd();
- void tetherStartWithConfiguration(in android.net.TetherConfigParcel config);
- android.net.MarkMaskParcel getFwmarkForNetwork(int netId);
- void networkAddRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void networkUpdateRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void networkRemoveRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void tetherOffloadRuleAdd(in android.net.TetherOffloadRuleParcel rule);
- void tetherOffloadRuleRemove(in android.net.TetherOffloadRuleParcel rule);
- android.net.TetherStatsParcel[] tetherOffloadGetStats();
- void tetherOffloadSetInterfaceQuota(int ifIndex, long quotaBytes);
- android.net.TetherStatsParcel tetherOffloadGetAndClearStats(int ifIndex);
- void networkCreate(in android.net.NativeNetworkConfig config);
- const int IPV4 = 4;
- const int IPV6 = 6;
- const int CONF = 1;
- const int NEIGH = 2;
- const String IPSEC_INTERFACE_PREFIX = "ipsec";
- const int IPV6_ADDR_GEN_MODE_EUI64 = 0;
- const int IPV6_ADDR_GEN_MODE_NONE = 1;
- const int IPV6_ADDR_GEN_MODE_STABLE_PRIVACY = 2;
- const int IPV6_ADDR_GEN_MODE_RANDOM = 3;
- const int IPV6_ADDR_GEN_MODE_DEFAULT = 0;
- const int PENALTY_POLICY_ACCEPT = 1;
- const int PENALTY_POLICY_LOG = 2;
- const int PENALTY_POLICY_REJECT = 3;
- const int LOCAL_NET_ID = 99;
- const int DUMMY_NET_ID = 51;
- const int UNREACHABLE_NET_ID = 52;
- const String NEXTHOP_NONE = "";
- const String NEXTHOP_UNREACHABLE = "unreachable";
- const String NEXTHOP_THROW = "throw";
- const int PERMISSION_NONE = 0;
- const int PERMISSION_NETWORK = 1;
- const int PERMISSION_SYSTEM = 2;
- const int NO_PERMISSIONS = 0;
- const int PERMISSION_INTERNET = 4;
- const int PERMISSION_UPDATE_DEVICE_STATS = 8;
- const int PERMISSION_UNINSTALLED = -1;
- /**
- * @deprecated use FIREWALL_ALLOWLIST.
- */
- const int FIREWALL_WHITELIST = 0;
- const int FIREWALL_ALLOWLIST = 0;
- /**
- * @deprecated use FIREWALL_DENYLIST.
- */
- const int FIREWALL_BLACKLIST = 1;
- const int FIREWALL_DENYLIST = 1;
- const int FIREWALL_RULE_ALLOW = 1;
- const int FIREWALL_RULE_DENY = 2;
- const int FIREWALL_CHAIN_NONE = 0;
- const int FIREWALL_CHAIN_DOZABLE = 1;
- const int FIREWALL_CHAIN_STANDBY = 2;
- const int FIREWALL_CHAIN_POWERSAVE = 3;
- const int FIREWALL_CHAIN_RESTRICTED = 4;
- const String IF_STATE_UP = "up";
- const String IF_STATE_DOWN = "down";
- const String IF_FLAG_BROADCAST = "broadcast";
- const String IF_FLAG_LOOPBACK = "loopback";
- const String IF_FLAG_POINTOPOINT = "point-to-point";
- const String IF_FLAG_RUNNING = "running";
- const String IF_FLAG_MULTICAST = "multicast";
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/6/android/net/INetdUnsolicitedEventListener.aidl b/common/netd/aidl_api/netd_aidl_interface/6/android/net/INetdUnsolicitedEventListener.aidl
deleted file mode 100644
index 31775df..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/6/android/net/INetdUnsolicitedEventListener.aidl
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright (c) 2018, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-interface INetdUnsolicitedEventListener {
- oneway void onInterfaceClassActivityChanged(boolean isActive, int timerLabel, long timestampNs, int uid);
- oneway void onQuotaLimitReached(@utf8InCpp String alertName, @utf8InCpp String ifName);
- oneway void onInterfaceDnsServerInfo(@utf8InCpp String ifName, long lifetimeS, in @utf8InCpp String[] servers);
- oneway void onInterfaceAddressUpdated(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAddressRemoved(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAdded(@utf8InCpp String ifName);
- oneway void onInterfaceRemoved(@utf8InCpp String ifName);
- oneway void onInterfaceChanged(@utf8InCpp String ifName, boolean up);
- oneway void onInterfaceLinkStateChanged(@utf8InCpp String ifName, boolean up);
- oneway void onRouteChanged(boolean updated, @utf8InCpp String route, @utf8InCpp String gateway, @utf8InCpp String ifName);
- oneway void onStrictCleartextDetected(int uid, @utf8InCpp String hex);
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/6/android/net/InterfaceConfigurationParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/6/android/net/InterfaceConfigurationParcel.aidl
deleted file mode 100644
index 1869d8d..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/6/android/net/InterfaceConfigurationParcel.aidl
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable InterfaceConfigurationParcel {
- @utf8InCpp String ifName;
- @utf8InCpp String hwAddr;
- @utf8InCpp String ipv4Addr;
- int prefixLength;
- @utf8InCpp String[] flags;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/6/android/net/MarkMaskParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/6/android/net/MarkMaskParcel.aidl
deleted file mode 100644
index 8ea20d1..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/6/android/net/MarkMaskParcel.aidl
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable MarkMaskParcel {
- int mark;
- int mask;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/6/android/net/NativeNetworkConfig.aidl b/common/netd/aidl_api/netd_aidl_interface/6/android/net/NativeNetworkConfig.aidl
deleted file mode 100644
index 76562b2..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/6/android/net/NativeNetworkConfig.aidl
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
-parcelable NativeNetworkConfig {
- int netId;
- android.net.NativeNetworkType networkType = android.net.NativeNetworkType.PHYSICAL;
- int permission;
- boolean secure;
- android.net.NativeVpnType vpnType = android.net.NativeVpnType.PLATFORM;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/6/android/net/NativeNetworkType.aidl b/common/netd/aidl_api/netd_aidl_interface/6/android/net/NativeNetworkType.aidl
deleted file mode 100644
index 06c8979..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/6/android/net/NativeNetworkType.aidl
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-@Backing(type="int")
-enum NativeNetworkType {
- PHYSICAL = 0,
- VIRTUAL = 1,
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/6/android/net/NativeVpnType.aidl b/common/netd/aidl_api/netd_aidl_interface/6/android/net/NativeVpnType.aidl
deleted file mode 100644
index 8a8be83..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/6/android/net/NativeVpnType.aidl
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-@Backing(type="int")
-enum NativeVpnType {
- SERVICE = 1,
- PLATFORM = 2,
- LEGACY = 3,
- OEM = 4,
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/6/android/net/RouteInfoParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/6/android/net/RouteInfoParcel.aidl
deleted file mode 100644
index 5ef95e6..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/6/android/net/RouteInfoParcel.aidl
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright (c) 2020, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-parcelable RouteInfoParcel {
- @utf8InCpp String destination;
- @utf8InCpp String ifName;
- @utf8InCpp String nextHop;
- int mtu;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/6/android/net/TetherConfigParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/6/android/net/TetherConfigParcel.aidl
deleted file mode 100644
index 7b39c22..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/6/android/net/TetherConfigParcel.aidl
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherConfigParcel {
- boolean usingLegacyDnsProxy;
- @utf8InCpp String[] dhcpRanges;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/6/android/net/TetherOffloadRuleParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/6/android/net/TetherOffloadRuleParcel.aidl
deleted file mode 100644
index 983e986..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/6/android/net/TetherOffloadRuleParcel.aidl
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherOffloadRuleParcel {
- int inputInterfaceIndex;
- int outputInterfaceIndex;
- byte[] destination;
- int prefixLength;
- byte[] srcL2Address;
- byte[] dstL2Address;
- int pmtu = 1500;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/6/android/net/TetherStatsParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/6/android/net/TetherStatsParcel.aidl
deleted file mode 100644
index 5f1b722..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/6/android/net/TetherStatsParcel.aidl
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherStatsParcel {
- @utf8InCpp String iface;
- long rxBytes;
- long rxPackets;
- long txBytes;
- long txPackets;
- int ifIndex = 0;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/6/android/net/UidRangeParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/6/android/net/UidRangeParcel.aidl
deleted file mode 100644
index 72e987a..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/6/android/net/UidRangeParcel.aidl
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
-parcelable UidRangeParcel {
- int start;
- int stop;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/.hash b/common/netd/aidl_api/netd_aidl_interface/7/.hash
deleted file mode 100644
index cad59df..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/.hash
+++ /dev/null
@@ -1 +0,0 @@
-850353de5d19a0dd718f8fd20791f0532e6a34c7
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/android/net/INetd.aidl b/common/netd/aidl_api/netd_aidl_interface/7/android/net/INetd.aidl
deleted file mode 100644
index ec03d86..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/android/net/INetd.aidl
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
- * Copyright (c) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-interface INetd {
- boolean isAlive();
- boolean firewallReplaceUidChain(in @utf8InCpp String chainName, boolean isAllowlist, in int[] uids);
- boolean bandwidthEnableDataSaver(boolean enable);
- /**
- * @deprecated use networkCreate() instead.
- */
- void networkCreatePhysical(int netId, int permission);
- /**
- * @deprecated use networkCreate() instead.
- */
- void networkCreateVpn(int netId, boolean secure);
- void networkDestroy(int netId);
- void networkAddInterface(int netId, in @utf8InCpp String iface);
- void networkRemoveInterface(int netId, in @utf8InCpp String iface);
- void networkAddUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRemoveUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRejectNonSecureVpn(boolean add, in android.net.UidRangeParcel[] uidRanges);
- void socketDestroy(in android.net.UidRangeParcel[] uidRanges, in int[] exemptUids);
- boolean tetherApplyDnsInterfaces();
- android.net.TetherStatsParcel[] tetherGetStats();
- void interfaceAddAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- void interfaceDelAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- @utf8InCpp String getProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter);
- void setProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter, in @utf8InCpp String value);
- void ipSecSetEncapSocketOwner(in ParcelFileDescriptor socket, int newUid);
- int ipSecAllocateSpi(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecAddSecurityAssociation(int transformId, int mode, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int underlyingNetId, int spi, int markValue, int markMask, in @utf8InCpp String authAlgo, in byte[] authKey, in int authTruncBits, in @utf8InCpp String cryptAlgo, in byte[] cryptKey, in int cryptTruncBits, in @utf8InCpp String aeadAlgo, in byte[] aeadKey, in int aeadIcvBits, int encapType, int encapLocalPort, int encapRemotePort, int interfaceId);
- void ipSecDeleteSecurityAssociation(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecApplyTransportModeTransform(in ParcelFileDescriptor socket, int transformId, int direction, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecRemoveTransportModeTransform(in ParcelFileDescriptor socket);
- void ipSecAddSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecUpdateSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecDeleteSecurityPolicy(int transformId, int selAddrFamily, int direction, int markValue, int markMask, int interfaceId);
- void ipSecAddTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecUpdateTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecRemoveTunnelInterface(in @utf8InCpp String deviceName);
- void wakeupAddInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void wakeupDelInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void setIPv6AddrGenMode(in @utf8InCpp String ifName, int mode);
- void idletimerAddInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void idletimerRemoveInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void strictUidCleartextPenalty(int uid, int policyPenalty);
- @utf8InCpp String clatdStart(in @utf8InCpp String ifName, in @utf8InCpp String nat64Prefix);
- void clatdStop(in @utf8InCpp String ifName);
- boolean ipfwdEnabled();
- @utf8InCpp String[] ipfwdGetRequesterList();
- void ipfwdEnableForwarding(in @utf8InCpp String requester);
- void ipfwdDisableForwarding(in @utf8InCpp String requester);
- void ipfwdAddInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void ipfwdRemoveInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void bandwidthSetInterfaceQuota(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceQuota(in @utf8InCpp String ifName);
- void bandwidthSetInterfaceAlert(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceAlert(in @utf8InCpp String ifName);
- void bandwidthSetGlobalAlert(long bytes);
- void bandwidthAddNaughtyApp(int uid);
- void bandwidthRemoveNaughtyApp(int uid);
- void bandwidthAddNiceApp(int uid);
- void bandwidthRemoveNiceApp(int uid);
- void tetherStart(in @utf8InCpp String[] dhcpRanges);
- void tetherStop();
- boolean tetherIsEnabled();
- void tetherInterfaceAdd(in @utf8InCpp String ifName);
- void tetherInterfaceRemove(in @utf8InCpp String ifName);
- @utf8InCpp String[] tetherInterfaceList();
- void tetherDnsSet(int netId, in @utf8InCpp String[] dnsAddrs);
- @utf8InCpp String[] tetherDnsList();
- void networkAddRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkRemoveRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkAddLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- void networkRemoveLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- int networkGetDefault();
- void networkSetDefault(int netId);
- void networkClearDefault();
- void networkSetPermissionForNetwork(int netId, int permission);
- void networkSetPermissionForUser(int permission, in int[] uids);
- void networkClearPermissionForUser(in int[] uids);
- void trafficSetNetPermForUids(int permission, in int[] uids);
- void networkSetProtectAllow(int uid);
- void networkSetProtectDeny(int uid);
- boolean networkCanProtect(int uid);
- void firewallSetFirewallType(int firewalltype);
- void firewallSetInterfaceRule(in @utf8InCpp String ifName, int firewallRule);
- void firewallSetUidRule(int childChain, int uid, int firewallRule);
- void firewallEnableChildChain(int childChain, boolean enable);
- @utf8InCpp String[] interfaceGetList();
- android.net.InterfaceConfigurationParcel interfaceGetCfg(in @utf8InCpp String ifName);
- void interfaceSetCfg(in android.net.InterfaceConfigurationParcel cfg);
- void interfaceSetIPv6PrivacyExtensions(in @utf8InCpp String ifName, boolean enable);
- void interfaceClearAddrs(in @utf8InCpp String ifName);
- void interfaceSetEnableIPv6(in @utf8InCpp String ifName, boolean enable);
- void interfaceSetMtu(in @utf8InCpp String ifName, int mtu);
- void tetherAddForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void tetherRemoveForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void setTcpRWmemorySize(in @utf8InCpp String rmemValues, in @utf8InCpp String wmemValues);
- void registerUnsolicitedEventListener(android.net.INetdUnsolicitedEventListener listener);
- void firewallAddUidInterfaceRules(in @utf8InCpp String ifName, in int[] uids);
- void firewallRemoveUidInterfaceRules(in int[] uids);
- void trafficSwapActiveStatsMap();
- IBinder getOemNetd();
- void tetherStartWithConfiguration(in android.net.TetherConfigParcel config);
- android.net.MarkMaskParcel getFwmarkForNetwork(int netId);
- void networkAddRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void networkUpdateRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void networkRemoveRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void tetherOffloadRuleAdd(in android.net.TetherOffloadRuleParcel rule);
- void tetherOffloadRuleRemove(in android.net.TetherOffloadRuleParcel rule);
- android.net.TetherStatsParcel[] tetherOffloadGetStats();
- void tetherOffloadSetInterfaceQuota(int ifIndex, long quotaBytes);
- android.net.TetherStatsParcel tetherOffloadGetAndClearStats(int ifIndex);
- void networkCreate(in android.net.NativeNetworkConfig config);
- void networkAddUidRangesParcel(in android.net.netd.aidl.NativeUidRangeConfig uidRangesConfig);
- void networkRemoveUidRangesParcel(in android.net.netd.aidl.NativeUidRangeConfig uidRangesConfig);
- const int IPV4 = 4;
- const int IPV6 = 6;
- const int CONF = 1;
- const int NEIGH = 2;
- const String IPSEC_INTERFACE_PREFIX = "ipsec";
- const int IPV6_ADDR_GEN_MODE_EUI64 = 0;
- const int IPV6_ADDR_GEN_MODE_NONE = 1;
- const int IPV6_ADDR_GEN_MODE_STABLE_PRIVACY = 2;
- const int IPV6_ADDR_GEN_MODE_RANDOM = 3;
- const int IPV6_ADDR_GEN_MODE_DEFAULT = 0;
- const int PENALTY_POLICY_ACCEPT = 1;
- const int PENALTY_POLICY_LOG = 2;
- const int PENALTY_POLICY_REJECT = 3;
- const int LOCAL_NET_ID = 99;
- const int DUMMY_NET_ID = 51;
- const int UNREACHABLE_NET_ID = 52;
- const String NEXTHOP_NONE = "";
- const String NEXTHOP_UNREACHABLE = "unreachable";
- const String NEXTHOP_THROW = "throw";
- const int PERMISSION_NONE = 0;
- const int PERMISSION_NETWORK = 1;
- const int PERMISSION_SYSTEM = 2;
- const int NO_PERMISSIONS = 0;
- const int PERMISSION_INTERNET = 4;
- const int PERMISSION_UPDATE_DEVICE_STATS = 8;
- const int PERMISSION_UNINSTALLED = -1;
- /**
- * @deprecated use FIREWALL_ALLOWLIST.
- */
- const int FIREWALL_WHITELIST = 0;
- const int FIREWALL_ALLOWLIST = 0;
- /**
- * @deprecated use FIREWALL_DENYLIST.
- */
- const int FIREWALL_BLACKLIST = 1;
- const int FIREWALL_DENYLIST = 1;
- const int FIREWALL_RULE_ALLOW = 1;
- const int FIREWALL_RULE_DENY = 2;
- const int FIREWALL_CHAIN_NONE = 0;
- const int FIREWALL_CHAIN_DOZABLE = 1;
- const int FIREWALL_CHAIN_STANDBY = 2;
- const int FIREWALL_CHAIN_POWERSAVE = 3;
- const int FIREWALL_CHAIN_RESTRICTED = 4;
- const String IF_STATE_UP = "up";
- const String IF_STATE_DOWN = "down";
- const String IF_FLAG_BROADCAST = "broadcast";
- const String IF_FLAG_LOOPBACK = "loopback";
- const String IF_FLAG_POINTOPOINT = "point-to-point";
- const String IF_FLAG_RUNNING = "running";
- const String IF_FLAG_MULTICAST = "multicast";
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/android/net/INetdUnsolicitedEventListener.aidl b/common/netd/aidl_api/netd_aidl_interface/7/android/net/INetdUnsolicitedEventListener.aidl
deleted file mode 100644
index 31775df..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/android/net/INetdUnsolicitedEventListener.aidl
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright (c) 2018, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-interface INetdUnsolicitedEventListener {
- oneway void onInterfaceClassActivityChanged(boolean isActive, int timerLabel, long timestampNs, int uid);
- oneway void onQuotaLimitReached(@utf8InCpp String alertName, @utf8InCpp String ifName);
- oneway void onInterfaceDnsServerInfo(@utf8InCpp String ifName, long lifetimeS, in @utf8InCpp String[] servers);
- oneway void onInterfaceAddressUpdated(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAddressRemoved(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAdded(@utf8InCpp String ifName);
- oneway void onInterfaceRemoved(@utf8InCpp String ifName);
- oneway void onInterfaceChanged(@utf8InCpp String ifName, boolean up);
- oneway void onInterfaceLinkStateChanged(@utf8InCpp String ifName, boolean up);
- oneway void onRouteChanged(boolean updated, @utf8InCpp String route, @utf8InCpp String gateway, @utf8InCpp String ifName);
- oneway void onStrictCleartextDetected(int uid, @utf8InCpp String hex);
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/android/net/InterfaceConfigurationParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/7/android/net/InterfaceConfigurationParcel.aidl
deleted file mode 100644
index 1869d8d..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/android/net/InterfaceConfigurationParcel.aidl
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable InterfaceConfigurationParcel {
- @utf8InCpp String ifName;
- @utf8InCpp String hwAddr;
- @utf8InCpp String ipv4Addr;
- int prefixLength;
- @utf8InCpp String[] flags;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/android/net/MarkMaskParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/7/android/net/MarkMaskParcel.aidl
deleted file mode 100644
index 8ea20d1..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/android/net/MarkMaskParcel.aidl
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable MarkMaskParcel {
- int mark;
- int mask;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/android/net/NativeNetworkConfig.aidl b/common/netd/aidl_api/netd_aidl_interface/7/android/net/NativeNetworkConfig.aidl
deleted file mode 100644
index 76562b2..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/android/net/NativeNetworkConfig.aidl
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
-parcelable NativeNetworkConfig {
- int netId;
- android.net.NativeNetworkType networkType = android.net.NativeNetworkType.PHYSICAL;
- int permission;
- boolean secure;
- android.net.NativeVpnType vpnType = android.net.NativeVpnType.PLATFORM;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/android/net/NativeNetworkType.aidl b/common/netd/aidl_api/netd_aidl_interface/7/android/net/NativeNetworkType.aidl
deleted file mode 100644
index 06c8979..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/android/net/NativeNetworkType.aidl
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-@Backing(type="int")
-enum NativeNetworkType {
- PHYSICAL = 0,
- VIRTUAL = 1,
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/android/net/NativeVpnType.aidl b/common/netd/aidl_api/netd_aidl_interface/7/android/net/NativeVpnType.aidl
deleted file mode 100644
index 8a8be83..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/android/net/NativeVpnType.aidl
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-@Backing(type="int")
-enum NativeVpnType {
- SERVICE = 1,
- PLATFORM = 2,
- LEGACY = 3,
- OEM = 4,
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/android/net/RouteInfoParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/7/android/net/RouteInfoParcel.aidl
deleted file mode 100644
index 5ef95e6..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/android/net/RouteInfoParcel.aidl
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright (c) 2020, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-parcelable RouteInfoParcel {
- @utf8InCpp String destination;
- @utf8InCpp String ifName;
- @utf8InCpp String nextHop;
- int mtu;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/android/net/TetherConfigParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/7/android/net/TetherConfigParcel.aidl
deleted file mode 100644
index 7b39c22..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/android/net/TetherConfigParcel.aidl
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherConfigParcel {
- boolean usingLegacyDnsProxy;
- @utf8InCpp String[] dhcpRanges;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/android/net/TetherOffloadRuleParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/7/android/net/TetherOffloadRuleParcel.aidl
deleted file mode 100644
index 983e986..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/android/net/TetherOffloadRuleParcel.aidl
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherOffloadRuleParcel {
- int inputInterfaceIndex;
- int outputInterfaceIndex;
- byte[] destination;
- int prefixLength;
- byte[] srcL2Address;
- byte[] dstL2Address;
- int pmtu = 1500;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/android/net/TetherStatsParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/7/android/net/TetherStatsParcel.aidl
deleted file mode 100644
index 5f1b722..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/android/net/TetherStatsParcel.aidl
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherStatsParcel {
- @utf8InCpp String iface;
- long rxBytes;
- long rxPackets;
- long txBytes;
- long txPackets;
- int ifIndex = 0;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/android/net/UidRangeParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/7/android/net/UidRangeParcel.aidl
deleted file mode 100644
index 72e987a..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/android/net/UidRangeParcel.aidl
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
-parcelable UidRangeParcel {
- int start;
- int stop;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/7/android/net/netd/aidl/NativeUidRangeConfig.aidl b/common/netd/aidl_api/netd_aidl_interface/7/android/net/netd/aidl/NativeUidRangeConfig.aidl
deleted file mode 100644
index 9bb679f..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/7/android/net/netd/aidl/NativeUidRangeConfig.aidl
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net.netd.aidl;
-/* @hide */
-@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
-parcelable NativeUidRangeConfig {
- int netId;
- android.net.UidRangeParcel[] uidRanges;
- int subPriority;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/current/android/net/INetd.aidl b/common/netd/aidl_api/netd_aidl_interface/current/android/net/INetd.aidl
deleted file mode 100644
index ec03d86..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/current/android/net/INetd.aidl
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
- * Copyright (c) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-interface INetd {
- boolean isAlive();
- boolean firewallReplaceUidChain(in @utf8InCpp String chainName, boolean isAllowlist, in int[] uids);
- boolean bandwidthEnableDataSaver(boolean enable);
- /**
- * @deprecated use networkCreate() instead.
- */
- void networkCreatePhysical(int netId, int permission);
- /**
- * @deprecated use networkCreate() instead.
- */
- void networkCreateVpn(int netId, boolean secure);
- void networkDestroy(int netId);
- void networkAddInterface(int netId, in @utf8InCpp String iface);
- void networkRemoveInterface(int netId, in @utf8InCpp String iface);
- void networkAddUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRemoveUidRanges(int netId, in android.net.UidRangeParcel[] uidRanges);
- void networkRejectNonSecureVpn(boolean add, in android.net.UidRangeParcel[] uidRanges);
- void socketDestroy(in android.net.UidRangeParcel[] uidRanges, in int[] exemptUids);
- boolean tetherApplyDnsInterfaces();
- android.net.TetherStatsParcel[] tetherGetStats();
- void interfaceAddAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- void interfaceDelAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString, int prefixLength);
- @utf8InCpp String getProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter);
- void setProcSysNet(int ipversion, int which, in @utf8InCpp String ifname, in @utf8InCpp String parameter, in @utf8InCpp String value);
- void ipSecSetEncapSocketOwner(in ParcelFileDescriptor socket, int newUid);
- int ipSecAllocateSpi(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecAddSecurityAssociation(int transformId, int mode, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int underlyingNetId, int spi, int markValue, int markMask, in @utf8InCpp String authAlgo, in byte[] authKey, in int authTruncBits, in @utf8InCpp String cryptAlgo, in byte[] cryptKey, in int cryptTruncBits, in @utf8InCpp String aeadAlgo, in byte[] aeadKey, in int aeadIcvBits, int encapType, int encapLocalPort, int encapRemotePort, int interfaceId);
- void ipSecDeleteSecurityAssociation(int transformId, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecApplyTransportModeTransform(in ParcelFileDescriptor socket, int transformId, int direction, in @utf8InCpp String sourceAddress, in @utf8InCpp String destinationAddress, int spi);
- void ipSecRemoveTransportModeTransform(in ParcelFileDescriptor socket);
- void ipSecAddSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecUpdateSecurityPolicy(int transformId, int selAddrFamily, int direction, in @utf8InCpp String tmplSrcAddress, in @utf8InCpp String tmplDstAddress, int spi, int markValue, int markMask, int interfaceId);
- void ipSecDeleteSecurityPolicy(int transformId, int selAddrFamily, int direction, int markValue, int markMask, int interfaceId);
- void ipSecAddTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecUpdateTunnelInterface(in @utf8InCpp String deviceName, in @utf8InCpp String localAddress, in @utf8InCpp String remoteAddress, int iKey, int oKey, int interfaceId);
- void ipSecRemoveTunnelInterface(in @utf8InCpp String deviceName);
- void wakeupAddInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void wakeupDelInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
- void setIPv6AddrGenMode(in @utf8InCpp String ifName, int mode);
- void idletimerAddInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void idletimerRemoveInterface(in @utf8InCpp String ifName, int timeout, in @utf8InCpp String classLabel);
- void strictUidCleartextPenalty(int uid, int policyPenalty);
- @utf8InCpp String clatdStart(in @utf8InCpp String ifName, in @utf8InCpp String nat64Prefix);
- void clatdStop(in @utf8InCpp String ifName);
- boolean ipfwdEnabled();
- @utf8InCpp String[] ipfwdGetRequesterList();
- void ipfwdEnableForwarding(in @utf8InCpp String requester);
- void ipfwdDisableForwarding(in @utf8InCpp String requester);
- void ipfwdAddInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void ipfwdRemoveInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
- void bandwidthSetInterfaceQuota(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceQuota(in @utf8InCpp String ifName);
- void bandwidthSetInterfaceAlert(in @utf8InCpp String ifName, long bytes);
- void bandwidthRemoveInterfaceAlert(in @utf8InCpp String ifName);
- void bandwidthSetGlobalAlert(long bytes);
- void bandwidthAddNaughtyApp(int uid);
- void bandwidthRemoveNaughtyApp(int uid);
- void bandwidthAddNiceApp(int uid);
- void bandwidthRemoveNiceApp(int uid);
- void tetherStart(in @utf8InCpp String[] dhcpRanges);
- void tetherStop();
- boolean tetherIsEnabled();
- void tetherInterfaceAdd(in @utf8InCpp String ifName);
- void tetherInterfaceRemove(in @utf8InCpp String ifName);
- @utf8InCpp String[] tetherInterfaceList();
- void tetherDnsSet(int netId, in @utf8InCpp String[] dnsAddrs);
- @utf8InCpp String[] tetherDnsList();
- void networkAddRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkRemoveRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop);
- void networkAddLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- void networkRemoveLegacyRoute(int netId, in @utf8InCpp String ifName, in @utf8InCpp String destination, in @utf8InCpp String nextHop, int uid);
- int networkGetDefault();
- void networkSetDefault(int netId);
- void networkClearDefault();
- void networkSetPermissionForNetwork(int netId, int permission);
- void networkSetPermissionForUser(int permission, in int[] uids);
- void networkClearPermissionForUser(in int[] uids);
- void trafficSetNetPermForUids(int permission, in int[] uids);
- void networkSetProtectAllow(int uid);
- void networkSetProtectDeny(int uid);
- boolean networkCanProtect(int uid);
- void firewallSetFirewallType(int firewalltype);
- void firewallSetInterfaceRule(in @utf8InCpp String ifName, int firewallRule);
- void firewallSetUidRule(int childChain, int uid, int firewallRule);
- void firewallEnableChildChain(int childChain, boolean enable);
- @utf8InCpp String[] interfaceGetList();
- android.net.InterfaceConfigurationParcel interfaceGetCfg(in @utf8InCpp String ifName);
- void interfaceSetCfg(in android.net.InterfaceConfigurationParcel cfg);
- void interfaceSetIPv6PrivacyExtensions(in @utf8InCpp String ifName, boolean enable);
- void interfaceClearAddrs(in @utf8InCpp String ifName);
- void interfaceSetEnableIPv6(in @utf8InCpp String ifName, boolean enable);
- void interfaceSetMtu(in @utf8InCpp String ifName, int mtu);
- void tetherAddForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void tetherRemoveForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
- void setTcpRWmemorySize(in @utf8InCpp String rmemValues, in @utf8InCpp String wmemValues);
- void registerUnsolicitedEventListener(android.net.INetdUnsolicitedEventListener listener);
- void firewallAddUidInterfaceRules(in @utf8InCpp String ifName, in int[] uids);
- void firewallRemoveUidInterfaceRules(in int[] uids);
- void trafficSwapActiveStatsMap();
- IBinder getOemNetd();
- void tetherStartWithConfiguration(in android.net.TetherConfigParcel config);
- android.net.MarkMaskParcel getFwmarkForNetwork(int netId);
- void networkAddRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void networkUpdateRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void networkRemoveRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
- void tetherOffloadRuleAdd(in android.net.TetherOffloadRuleParcel rule);
- void tetherOffloadRuleRemove(in android.net.TetherOffloadRuleParcel rule);
- android.net.TetherStatsParcel[] tetherOffloadGetStats();
- void tetherOffloadSetInterfaceQuota(int ifIndex, long quotaBytes);
- android.net.TetherStatsParcel tetherOffloadGetAndClearStats(int ifIndex);
- void networkCreate(in android.net.NativeNetworkConfig config);
- void networkAddUidRangesParcel(in android.net.netd.aidl.NativeUidRangeConfig uidRangesConfig);
- void networkRemoveUidRangesParcel(in android.net.netd.aidl.NativeUidRangeConfig uidRangesConfig);
- const int IPV4 = 4;
- const int IPV6 = 6;
- const int CONF = 1;
- const int NEIGH = 2;
- const String IPSEC_INTERFACE_PREFIX = "ipsec";
- const int IPV6_ADDR_GEN_MODE_EUI64 = 0;
- const int IPV6_ADDR_GEN_MODE_NONE = 1;
- const int IPV6_ADDR_GEN_MODE_STABLE_PRIVACY = 2;
- const int IPV6_ADDR_GEN_MODE_RANDOM = 3;
- const int IPV6_ADDR_GEN_MODE_DEFAULT = 0;
- const int PENALTY_POLICY_ACCEPT = 1;
- const int PENALTY_POLICY_LOG = 2;
- const int PENALTY_POLICY_REJECT = 3;
- const int LOCAL_NET_ID = 99;
- const int DUMMY_NET_ID = 51;
- const int UNREACHABLE_NET_ID = 52;
- const String NEXTHOP_NONE = "";
- const String NEXTHOP_UNREACHABLE = "unreachable";
- const String NEXTHOP_THROW = "throw";
- const int PERMISSION_NONE = 0;
- const int PERMISSION_NETWORK = 1;
- const int PERMISSION_SYSTEM = 2;
- const int NO_PERMISSIONS = 0;
- const int PERMISSION_INTERNET = 4;
- const int PERMISSION_UPDATE_DEVICE_STATS = 8;
- const int PERMISSION_UNINSTALLED = -1;
- /**
- * @deprecated use FIREWALL_ALLOWLIST.
- */
- const int FIREWALL_WHITELIST = 0;
- const int FIREWALL_ALLOWLIST = 0;
- /**
- * @deprecated use FIREWALL_DENYLIST.
- */
- const int FIREWALL_BLACKLIST = 1;
- const int FIREWALL_DENYLIST = 1;
- const int FIREWALL_RULE_ALLOW = 1;
- const int FIREWALL_RULE_DENY = 2;
- const int FIREWALL_CHAIN_NONE = 0;
- const int FIREWALL_CHAIN_DOZABLE = 1;
- const int FIREWALL_CHAIN_STANDBY = 2;
- const int FIREWALL_CHAIN_POWERSAVE = 3;
- const int FIREWALL_CHAIN_RESTRICTED = 4;
- const String IF_STATE_UP = "up";
- const String IF_STATE_DOWN = "down";
- const String IF_FLAG_BROADCAST = "broadcast";
- const String IF_FLAG_LOOPBACK = "loopback";
- const String IF_FLAG_POINTOPOINT = "point-to-point";
- const String IF_FLAG_RUNNING = "running";
- const String IF_FLAG_MULTICAST = "multicast";
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/current/android/net/INetdUnsolicitedEventListener.aidl b/common/netd/aidl_api/netd_aidl_interface/current/android/net/INetdUnsolicitedEventListener.aidl
deleted file mode 100644
index 31775df..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/current/android/net/INetdUnsolicitedEventListener.aidl
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright (c) 2018, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-interface INetdUnsolicitedEventListener {
- oneway void onInterfaceClassActivityChanged(boolean isActive, int timerLabel, long timestampNs, int uid);
- oneway void onQuotaLimitReached(@utf8InCpp String alertName, @utf8InCpp String ifName);
- oneway void onInterfaceDnsServerInfo(@utf8InCpp String ifName, long lifetimeS, in @utf8InCpp String[] servers);
- oneway void onInterfaceAddressUpdated(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAddressRemoved(@utf8InCpp String addr, @utf8InCpp String ifName, int flags, int scope);
- oneway void onInterfaceAdded(@utf8InCpp String ifName);
- oneway void onInterfaceRemoved(@utf8InCpp String ifName);
- oneway void onInterfaceChanged(@utf8InCpp String ifName, boolean up);
- oneway void onInterfaceLinkStateChanged(@utf8InCpp String ifName, boolean up);
- oneway void onRouteChanged(boolean updated, @utf8InCpp String route, @utf8InCpp String gateway, @utf8InCpp String ifName);
- oneway void onStrictCleartextDetected(int uid, @utf8InCpp String hex);
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/current/android/net/InterfaceConfigurationParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/current/android/net/InterfaceConfigurationParcel.aidl
deleted file mode 100644
index 1869d8d..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/current/android/net/InterfaceConfigurationParcel.aidl
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable InterfaceConfigurationParcel {
- @utf8InCpp String ifName;
- @utf8InCpp String hwAddr;
- @utf8InCpp String ipv4Addr;
- int prefixLength;
- @utf8InCpp String[] flags;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/current/android/net/MarkMaskParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/current/android/net/MarkMaskParcel.aidl
deleted file mode 100644
index 8ea20d1..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/current/android/net/MarkMaskParcel.aidl
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable MarkMaskParcel {
- int mark;
- int mask;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/current/android/net/NativeNetworkConfig.aidl b/common/netd/aidl_api/netd_aidl_interface/current/android/net/NativeNetworkConfig.aidl
deleted file mode 100644
index 76562b2..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/current/android/net/NativeNetworkConfig.aidl
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
-parcelable NativeNetworkConfig {
- int netId;
- android.net.NativeNetworkType networkType = android.net.NativeNetworkType.PHYSICAL;
- int permission;
- boolean secure;
- android.net.NativeVpnType vpnType = android.net.NativeVpnType.PLATFORM;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/current/android/net/NativeNetworkType.aidl b/common/netd/aidl_api/netd_aidl_interface/current/android/net/NativeNetworkType.aidl
deleted file mode 100644
index 06c8979..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/current/android/net/NativeNetworkType.aidl
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-@Backing(type="int")
-enum NativeNetworkType {
- PHYSICAL = 0,
- VIRTUAL = 1,
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/current/android/net/NativeVpnType.aidl b/common/netd/aidl_api/netd_aidl_interface/current/android/net/NativeVpnType.aidl
deleted file mode 100644
index 8a8be83..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/current/android/net/NativeVpnType.aidl
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-@Backing(type="int")
-enum NativeVpnType {
- SERVICE = 1,
- PLATFORM = 2,
- LEGACY = 3,
- OEM = 4,
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/current/android/net/RouteInfoParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/current/android/net/RouteInfoParcel.aidl
deleted file mode 100644
index 5ef95e6..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/current/android/net/RouteInfoParcel.aidl
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright (c) 2020, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-parcelable RouteInfoParcel {
- @utf8InCpp String destination;
- @utf8InCpp String ifName;
- @utf8InCpp String nextHop;
- int mtu;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/current/android/net/TetherConfigParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/current/android/net/TetherConfigParcel.aidl
deleted file mode 100644
index 7b39c22..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/current/android/net/TetherConfigParcel.aidl
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherConfigParcel {
- boolean usingLegacyDnsProxy;
- @utf8InCpp String[] dhcpRanges;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/current/android/net/TetherOffloadRuleParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/current/android/net/TetherOffloadRuleParcel.aidl
deleted file mode 100644
index 983e986..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/current/android/net/TetherOffloadRuleParcel.aidl
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherOffloadRuleParcel {
- int inputInterfaceIndex;
- int outputInterfaceIndex;
- byte[] destination;
- int prefixLength;
- byte[] srcL2Address;
- byte[] dstL2Address;
- int pmtu = 1500;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/current/android/net/TetherStatsParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/current/android/net/TetherStatsParcel.aidl
deleted file mode 100644
index 5f1b722..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/current/android/net/TetherStatsParcel.aidl
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-parcelable TetherStatsParcel {
- @utf8InCpp String iface;
- long rxBytes;
- long rxPackets;
- long txBytes;
- long txPackets;
- int ifIndex = 0;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/current/android/net/UidRangeParcel.aidl b/common/netd/aidl_api/netd_aidl_interface/current/android/net/UidRangeParcel.aidl
deleted file mode 100644
index 72e987a..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/current/android/net/UidRangeParcel.aidl
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net;
-/* @hide */
-@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
-parcelable UidRangeParcel {
- int start;
- int stop;
-}
diff --git a/common/netd/aidl_api/netd_aidl_interface/current/android/net/netd/aidl/NativeUidRangeConfig.aidl b/common/netd/aidl_api/netd_aidl_interface/current/android/net/netd/aidl/NativeUidRangeConfig.aidl
deleted file mode 100644
index 9bb679f..0000000
--- a/common/netd/aidl_api/netd_aidl_interface/current/android/net/netd/aidl/NativeUidRangeConfig.aidl
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-// the interface (from the latest frozen version), the build system will
-// prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net.netd.aidl;
-/* @hide */
-@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
-parcelable NativeUidRangeConfig {
- int netId;
- android.net.UidRangeParcel[] uidRanges;
- int subPriority;
-}
diff --git a/common/netd/aidl_api/netd_event_listener_interface/1/.hash b/common/netd/aidl_api/netd_event_listener_interface/1/.hash
deleted file mode 100644
index f39f730..0000000
--- a/common/netd/aidl_api/netd_event_listener_interface/1/.hash
+++ /dev/null
@@ -1 +0,0 @@
-8e27594d285ca7c567d87e8cf74766c27647e02b
diff --git a/common/netd/aidl_api/netd_event_listener_interface/1/android/net/metrics/INetdEventListener.aidl b/common/netd/aidl_api/netd_event_listener_interface/1/android/net/metrics/INetdEventListener.aidl
deleted file mode 100644
index 9898a67..0000000
--- a/common/netd/aidl_api/netd_event_listener_interface/1/android/net/metrics/INetdEventListener.aidl
+++ /dev/null
@@ -1,34 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a frozen snapshot of an AIDL interface (or parcelable). Do not
-// try to edit this file. It looks like you are doing that because you have
-// modified an AIDL interface in a backward-incompatible way, e.g., deleting a
-// function from an interface or a field from a parcelable and it broke the
-// build. That breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net.metrics;
-interface INetdEventListener {
- oneway void onDnsEvent(int netId, int eventType, int returnCode, int latencyMs, @utf8InCpp String hostname, in @utf8InCpp String[] ipAddresses, int ipAddressesCount, int uid);
- oneway void onPrivateDnsValidationEvent(int netId, String ipAddress, String hostname, boolean validated);
- oneway void onConnectEvent(int netId, int error, int latencyMs, String ipAddr, int port, int uid);
- oneway void onWakeupEvent(String prefix, int uid, int ethertype, int ipNextHeader, in byte[] dstHw, String srcIp, String dstIp, int srcPort, int dstPort, long timestampNs);
- oneway void onTcpSocketStatsEvent(in int[] networkIds, in int[] sentPackets, in int[] lostPackets, in int[] rttUs, in int[] sentAckDiffMs);
- oneway void onNat64PrefixEvent(int netId, boolean added, @utf8InCpp String prefixString, int prefixLength);
- const int EVENT_GETADDRINFO = 1;
- const int EVENT_GETHOSTBYNAME = 2;
- const int EVENT_GETHOSTBYADDR = 3;
- const int EVENT_RES_NSEND = 4;
- const int REPORTING_LEVEL_NONE = 0;
- const int REPORTING_LEVEL_METRICS = 1;
- const int REPORTING_LEVEL_FULL = 2;
- const int DNS_REPORTED_IP_ADDRESSES_LIMIT = 10;
-}
diff --git a/common/netd/aidl_api/netd_event_listener_interface/current/android/net/metrics/INetdEventListener.aidl b/common/netd/aidl_api/netd_event_listener_interface/current/android/net/metrics/INetdEventListener.aidl
deleted file mode 100644
index d71c3f2..0000000
--- a/common/netd/aidl_api/netd_event_listener_interface/current/android/net/metrics/INetdEventListener.aidl
+++ /dev/null
@@ -1,35 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.net.metrics;
-/* @hide */
-interface INetdEventListener {
- oneway void onDnsEvent(int netId, int eventType, int returnCode, int latencyMs, @utf8InCpp String hostname, in @utf8InCpp String[] ipAddresses, int ipAddressesCount, int uid);
- oneway void onPrivateDnsValidationEvent(int netId, String ipAddress, String hostname, boolean validated);
- oneway void onConnectEvent(int netId, int error, int latencyMs, String ipAddr, int port, int uid);
- oneway void onWakeupEvent(String prefix, int uid, int ethertype, int ipNextHeader, in byte[] dstHw, String srcIp, String dstIp, int srcPort, int dstPort, long timestampNs);
- oneway void onTcpSocketStatsEvent(in int[] networkIds, in int[] sentPackets, in int[] lostPackets, in int[] rttUs, in int[] sentAckDiffMs);
- oneway void onNat64PrefixEvent(int netId, boolean added, @utf8InCpp String prefixString, int prefixLength);
- const int EVENT_GETADDRINFO = 1;
- const int EVENT_GETHOSTBYNAME = 2;
- const int EVENT_GETHOSTBYADDR = 3;
- const int EVENT_RES_NSEND = 4;
- const int REPORTING_LEVEL_NONE = 0;
- const int REPORTING_LEVEL_METRICS = 1;
- const int REPORTING_LEVEL_FULL = 2;
- const int DNS_REPORTED_IP_ADDRESSES_LIMIT = 10;
-}
diff --git a/common/netd/binder/android/net/INetd.aidl b/common/netd/binder/android/net/INetd.aidl
deleted file mode 100644
index d6398c1..0000000
--- a/common/netd/binder/android/net/INetd.aidl
+++ /dev/null
@@ -1,1380 +0,0 @@
-/**
- * Copyright (c) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-import android.net.INetdUnsolicitedEventListener;
-import android.net.InterfaceConfigurationParcel;
-import android.net.MarkMaskParcel;
-import android.net.NativeNetworkConfig;
-import android.net.RouteInfoParcel;
-import android.net.TetherConfigParcel;
-import android.net.TetherOffloadRuleParcel;
-import android.net.TetherStatsParcel;
-import android.net.UidRangeParcel;
-import android.net.netd.aidl.NativeUidRangeConfig;
-
-/** {@hide} */
-interface INetd {
- /**
- * Returns true if the service is responding.
- */
- boolean isAlive();
-
- /**
- * Replaces the contents of the specified UID-based firewall chain.
- *
- * The chain may be an allowlist chain or a denylist chain. A denylist chain contains DROP
- * rules for the specified UIDs and a RETURN rule at the end. An allowlist chain contains RETURN
- * rules for the system UID range (0 to {@code UID_APP} - 1), RETURN rules for for the specified
- * UIDs, and a DROP rule at the end. The chain will be created if it does not exist.
- *
- * @param chainName The name of the chain to replace.
- * @param isAllowlist Whether this is an allowlist or denylist chain.
- * @param uids The list of UIDs to allow/deny.
- * @return true if the chain was successfully replaced, false otherwise.
- */
- boolean firewallReplaceUidChain(in @utf8InCpp String chainName,
- boolean isAllowlist,
- in int[] uids);
-
- /**
- * Enables or disables data saver mode on costly network interfaces.
- *
- * - When disabled, all packets to/from apps in the penalty box chain are rejected on costly
- * interfaces. Traffic to/from other apps or on other network interfaces is allowed.
- * - When enabled, only apps that are in the happy box chain and not in the penalty box chain
- * are allowed network connectivity on costly interfaces. All other packets on these
- * interfaces are rejected. The happy box chain always contains all system UIDs; to disallow
- * traffic from system UIDs, place them in the penalty box chain.
- *
- * By default, data saver mode is disabled. This command has no effect but might still return an
- * error) if {@code enable} is the same as the current value.
- *
- * @param enable whether to enable or disable data saver mode.
- * @return true if the if the operation was successful, false otherwise.
- */
- boolean bandwidthEnableDataSaver(boolean enable);
-
- /**
- * Creates a physical network (i.e., one containing physical interfaces.
- * @deprecated use networkCreate() instead.
- *
- * @param netId the networkId to create.
- * @param permission the permission necessary to use the network. Must be one of
- * PERMISSION_NONE/PERMISSION_NETWORK/PERMISSION_SYSTEM.
- *
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- void networkCreatePhysical(int netId, int permission);
-
- /**
- * Creates a VPN network.
- * @deprecated use networkCreate() instead.
- *
- * @param netId the network to create.
- * @param secure whether unprivileged apps are allowed to bypass the VPN.
- *
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- void networkCreateVpn(int netId, boolean secure);
-
- /**
- * Destroys a network. Any interfaces added to the network are removed, and the network ceases
- * to be the default network.
- *
- * @param netId the network to destroy.
- *
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- void networkDestroy(int netId);
-
- /**
- * Adds an interface to a network. The interface must not be assigned to any network, including
- * the specified network.
- *
- * @param netId the network to add the interface to.
- * @param interface the name of the interface to add.
- *
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- void networkAddInterface(int netId, in @utf8InCpp String iface);
-
- /**
- * Adds an interface to a network. The interface must be assigned to the specified network.
- *
- * @param netId the network to remove the interface from.
- * @param interface the name of the interface to remove.
- *
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- void networkRemoveInterface(int netId, in @utf8InCpp String iface);
-
- /**
- * Adds the specified UID ranges to the specified network. The network can be physical or
- * virtual. Traffic from the UID ranges will be routed to the network by default.
- *
- * @param netId the network ID of the network to add the ranges to.
- * @param uidRanges a set of non-overlapping ranges of UIDs to add. These exact ranges
- * must not overlap with existing ranges assigned to this network.
- *
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- void networkAddUidRanges(int netId, in UidRangeParcel[] uidRanges);
-
- /**
- * Remove the specified UID ranges from the specified network. The network can be physical or
- * virtual. Traffic from the UID ranges will no longer be routed to the network by default.
- *
- * @param netId the network ID of the network to remove the ranges from.
- * @param uidRanges a set of non-overlapping ranges of UIDs to remove. These exact ranges
- * must already be assigned to this network.
- *
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- void networkRemoveUidRanges(int netId, in UidRangeParcel[] uidRanges);
-
- /**
- * Adds or removes one rule for each supplied UID range to prohibit all network activity outside
- * of secure VPN.
- *
- * When a UID is covered by one of these rules, traffic sent through any socket that is not
- * protected or explicitly overriden by the system will be rejected. The kernel will respond
- * with an ICMP prohibit message.
- *
- * Initially, there are no such rules. Any rules that are added will only last until the next
- * restart of netd or the device.
- *
- * @param add {@code true} if the specified UID ranges should be denied access to any network
- * which is not secure VPN by adding rules, {@code false} to remove existing rules.
- * @param uidRanges a set of non-overlapping, contiguous ranges of UIDs to which to apply or
- * remove this restriction.
- * <p> Added rules should not overlap with existing rules. Likewise, removed rules should
- * each correspond to an existing rule.
- *
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- void networkRejectNonSecureVpn(boolean add, in UidRangeParcel[] uidRanges);
-
- /**
- * Administratively closes sockets belonging to the specified UIDs.
- */
- void socketDestroy(in UidRangeParcel[] uidRanges, in int[] exemptUids);
-
- /**
- * Instruct the tethering DNS server to reevaluated serving interfaces.
- * This is needed to for the DNS server to observe changes in the set
- * of potential listening IP addresses. (Listening on wildcard addresses
- * can turn the device into an open resolver; b/7530468)
- *
- * TODO: Return something richer than just a boolean.
- */
- boolean tetherApplyDnsInterfaces();
-
- /**
- * Return tethering statistics.
- *
- * @return an array of TetherStatsParcel, where each entry contains the upstream interface
- * name and its tethering statistics since netd startup.
- * There will only ever be one entry for a given interface.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- TetherStatsParcel[] tetherGetStats();
-
- /**
- * Add/Remove and IP address from an interface.
- *
- * @param ifName the interface name
- * @param addrString the IP address to add/remove as a string literal
- * @param prefixLength the prefix length associated with this IP address
- *
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- void interfaceAddAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString,
- int prefixLength);
- void interfaceDelAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString,
- int prefixLength);
-
- /**
- * Set and get /proc/sys/net interface configuration parameters.
- *
- * @param ipversion One of IPV4/IPV6 integers, indicating the desired IP version directory.
- * @param which One of CONF/NEIGH integers, indicating the desired parameter category directory.
- * @param ifname The interface name portion of the path; may also be "all" or "default".
- * @param parameter The parameter name portion of the path.
- * @param value The value string to be written into the assembled path.
- *
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
-
- const int IPV4 = 4;
- const int IPV6 = 6;
- const int CONF = 1;
- const int NEIGH = 2;
- @utf8InCpp String getProcSysNet(int ipversion, int which, in @utf8InCpp String ifname,
- in @utf8InCpp String parameter);
- void setProcSysNet(int ipversion, int which, in @utf8InCpp String ifname,
- in @utf8InCpp String parameter, in @utf8InCpp String value);
-
- /**
- * Sets owner of socket ParcelFileDescriptor to the new UID, checking to ensure that the caller's
- * uid is that of the old owner's, and that this is a UDP-encap socket
- *
- * @param ParcelFileDescriptor socket Socket file descriptor
- * @param int newUid UID of the new socket fd owner
- */
- void ipSecSetEncapSocketOwner(in ParcelFileDescriptor socket, int newUid);
-
- /**
- * Reserve an SPI from the kernel
- *
- * @param transformId a unique identifier for allocated resources
- * @param sourceAddress InetAddress as string for the sending endpoint
- * @param destinationAddress InetAddress as string for the receiving endpoint
- * @param spi a requested 32-bit unique ID or 0 to request random allocation
- * @return the SPI that was allocated or 0 if failed
- */
- int ipSecAllocateSpi(
- int transformId,
- in @utf8InCpp String sourceAddress,
- in @utf8InCpp String destinationAddress,
- int spi);
-
- /**
- * Create an IpSec Security Association describing how ip(v6) traffic will be encrypted
- * or decrypted.
- *
- * @param transformId a unique identifier for allocated resources
- * @param mode either Transport or Tunnel mode
- * @param sourceAddress InetAddress as string for the sending endpoint
- * @param destinationAddress InetAddress as string for the receiving endpoint
- * @param underlyingNetId the netId of the network to which the SA is applied. Only accepted for
- * tunnel mode SAs.
- * @param spi a 32-bit unique ID allocated to the user
- * @param markValue a 32-bit unique ID chosen by the user
- * @param markMask a 32-bit mask chosen by the user
- * @param authAlgo a string identifying the authentication algorithm to be used
- * @param authKey a byte array containing the authentication key
- * @param authTruncBits the truncation length of the MAC produced by the authentication algorithm
- * @param cryptAlgo a string identifying the encryption algorithm to be used
- * @param cryptKey a byte arrray containing the encryption key
- * @param cryptTruncBits unused parameter
- * @param aeadAlgo a string identifying the authenticated encryption algorithm to be used
- * @param aeadKey a byte arrray containing the key to be used in authenticated encryption
- * @param aeadIcvBits the truncation length of the ICV produced by the authentication algorithm
- * (similar to authTruncBits in function)
- * @param encapType encapsulation type used (if any) for the udp encap socket
- * @param encapLocalPort the port number on the host to be used in encap packets
- * @param encapRemotePort the port number of the remote to be used for encap packets
- * @param interfaceId the identifier for the IPsec tunnel interface.
- * Only accepted for tunnel mode SAs.
- */
- void ipSecAddSecurityAssociation(
- int transformId,
- int mode,
- in @utf8InCpp String sourceAddress,
- in @utf8InCpp String destinationAddress,
- int underlyingNetId,
- int spi,
- int markValue,
- int markMask,
- in @utf8InCpp String authAlgo, in byte[] authKey, in int authTruncBits,
- in @utf8InCpp String cryptAlgo, in byte[] cryptKey, in int cryptTruncBits,
- in @utf8InCpp String aeadAlgo, in byte[] aeadKey, in int aeadIcvBits,
- int encapType,
- int encapLocalPort,
- int encapRemotePort,
- int interfaceId);
-
- /**
- * Delete a previously created security association identified by the provided parameters
- *
- * @param transformId a unique identifier for allocated resources
- * @param sourceAddress InetAddress as string for the sending endpoint
- * @param destinationAddress InetAddress as string for the receiving endpoint
- * @param spi a requested 32-bit unique ID allocated to the user
- * @param markValue a 32-bit unique ID chosen by the user
- * @param markMask a 32-bit mask chosen by the user
- * @param interfaceId the identifier for the IPsec tunnel interface.
- */
- void ipSecDeleteSecurityAssociation(
- int transformId,
- in @utf8InCpp String sourceAddress,
- in @utf8InCpp String destinationAddress,
- int spi,
- int markValue,
- int markMask,
- int interfaceId);
-
- /**
- * Apply a previously created SA to a specified socket, starting IPsec on that socket
- *
- * @param socket a user-provided socket that will have IPsec applied
- * @param transformId a unique identifier for allocated resources
- * @param direction DIRECTION_IN or DIRECTION_OUT
- * @param sourceAddress InetAddress as string for the sending endpoint
- * @param destinationAddress InetAddress as string for the receiving endpoint
- * @param spi a 32-bit unique ID allocated to the user (socket owner)
- */
- void ipSecApplyTransportModeTransform(
- in ParcelFileDescriptor socket,
- int transformId,
- int direction,
- in @utf8InCpp String sourceAddress,
- in @utf8InCpp String destinationAddress,
- int spi);
-
- /**
- * Remove an IPsec SA from a given socket. This will allow unencrypted traffic to flow
- * on that socket if a transform had been previously applied.
- *
- * @param socket a user-provided socket from which to remove any IPsec configuration
- */
- void ipSecRemoveTransportModeTransform(
- in ParcelFileDescriptor socket);
-
- /**
- * Adds an IPsec global policy.
- *
- * @param transformId a unique identifier for allocated resources
- * @param selAddrFamily the address family identifier for the selector
- * @param direction DIRECTION_IN or DIRECTION_OUT
- * @param tmplSrcAddress InetAddress as string for the sending endpoint
- * @param tmplDstAddress InetAddress as string for the receiving endpoint
- * @param spi a 32-bit unique ID allocated to the user
- * @param markValue a 32-bit unique ID chosen by the user
- * @param markMask a 32-bit mask chosen by the user
- * @param interfaceId the identifier for the IPsec tunnel interface.
- */
- void ipSecAddSecurityPolicy(
- int transformId,
- int selAddrFamily,
- int direction,
- in @utf8InCpp String tmplSrcAddress,
- in @utf8InCpp String tmplDstAddress,
- int spi,
- int markValue,
- int markMask,
- int interfaceId);
-
- /**
- * Updates an IPsec global policy.
- *
- * @param transformId a unique identifier for allocated resources
- * @param selAddrFamily the address family identifier for the selector
- * @param direction DIRECTION_IN or DIRECTION_OUT
- * @param tmplSrcAddress InetAddress as string for the sending endpoint
- * @param tmplDstAddress InetAddress as string for the receiving endpoint
- * @param spi a 32-bit unique ID allocated to the user
- * @param markValue a 32-bit unique ID chosen by the user
- * @param markMask a 32-bit mask chosen by the user
- * @param interfaceId the identifier for the IPsec tunnel interface.
- */
- void ipSecUpdateSecurityPolicy(
- int transformId,
- int selAddrFamily,
- int direction,
- in @utf8InCpp String tmplSrcAddress,
- in @utf8InCpp String tmplDstAddress,
- int spi,
- int markValue,
- int markMask,
- int interfaceId);
-
- /**
- * Deletes an IPsec global policy.
- *
- * Deletion of global policies does not do any matching based on the templates, thus
- * template source/destination addresses are not needed (as opposed to add/update).
- *
- * @param transformId a unique identifier for allocated resources
- * @param selAddrFamily the address family identifier for the selector
- * @param direction DIRECTION_IN or DIRECTION_OUT
- * @param markValue a 32-bit unique ID chosen by the user
- * @param markMask a 32-bit mask chosen by the user
- * @param interfaceId the identifier for the IPsec tunnel interface.
- */
- void ipSecDeleteSecurityPolicy(
- int transformId,
- int selAddrFamily,
- int direction,
- int markValue,
- int markMask,
- int interfaceId);
-
- // This could not be declared as @uft8InCpp; thus, when used in native code it must be
- // converted from a UTF-16 string to an ASCII string.
- const String IPSEC_INTERFACE_PREFIX = "ipsec";
-
- /**
- * Add a IPsec Tunnel Interface.
- *
- * @param devName a unique identifier that represents the name of the device
- * @param localAddress InetAddress as string for the local endpoint
- * @param remoteAddress InetAddress as string for the remote endpoint
- * @param iKey, to match Policies and SAs for input packets.
- * @param oKey, to match Policies and SAs for output packets.
- * @param interfaceId the identifier for the IPsec tunnel interface.
- */
- void ipSecAddTunnelInterface(
- in @utf8InCpp String deviceName,
- in @utf8InCpp String localAddress,
- in @utf8InCpp String remoteAddress,
- int iKey,
- int oKey,
- int interfaceId);
-
- /**
- * Update a IPsec Tunnel Interface.
- *
- * @param devName a unique identifier that represents the name of the device
- * @param localAddress InetAddress as string for the local endpoint
- * @param remoteAddress InetAddress as string for the remote endpoint
- * @param iKey, to match Policies and SAs for input packets.
- * @param oKey, to match Policies and SAs for output packets.
- * @param interfaceId the identifier for the IPsec tunnel interface.
- */
- void ipSecUpdateTunnelInterface(
- in @utf8InCpp String deviceName,
- in @utf8InCpp String localAddress,
- in @utf8InCpp String remoteAddress,
- int iKey,
- int oKey,
- int interfaceId);
-
- /**
- * Removes a IPsec Tunnel Interface.
- *
- * @param devName a unique identifier that represents the name of the device
- */
- void ipSecRemoveTunnelInterface(in @utf8InCpp String deviceName);
-
- /**
- * Request notification of wakeup packets arriving on an interface. Notifications will be
- * delivered to INetdEventListener.onWakeupEvent().
- *
- * @param ifName the interface
- * @param prefix arbitrary string used to identify wakeup sources in onWakeupEvent
- */
- void wakeupAddInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
-
- /**
- * Stop notification of wakeup packets arriving on an interface.
- *
- * @param ifName the interface
- * @param prefix arbitrary string used to identify wakeup sources in onWakeupEvent
- */
- void wakeupDelInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
-
- const int IPV6_ADDR_GEN_MODE_EUI64 = 0;
- const int IPV6_ADDR_GEN_MODE_NONE = 1;
- const int IPV6_ADDR_GEN_MODE_STABLE_PRIVACY = 2;
- const int IPV6_ADDR_GEN_MODE_RANDOM = 3;
-
- const int IPV6_ADDR_GEN_MODE_DEFAULT = 0;
- /**
- * Set IPv6 address generation mode. IPv6 should be disabled before changing mode.
- *
- * @param mode SLAAC address generation mechanism to use
- */
- void setIPv6AddrGenMode(in @utf8InCpp String ifName, int mode);
-
- /**
- * Add idletimer for specific interface
- *
- * @param ifName Name of target interface
- * @param timeout The time in seconds that will trigger idletimer
- * @param classLabel The unique identifier for this idletimer
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void idletimerAddInterface(
- in @utf8InCpp String ifName,
- int timeout,
- in @utf8InCpp String classLabel);
-
- /**
- * Remove idletimer for specific interface
- *
- * @param ifName Name of target interface
- * @param timeout The time in seconds that will trigger idletimer
- * @param classLabel The unique identifier for this idletimer
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void idletimerRemoveInterface(
- in @utf8InCpp String ifName,
- int timeout,
- in @utf8InCpp String classLabel);
-
- const int PENALTY_POLICY_ACCEPT = 1;
- const int PENALTY_POLICY_LOG = 2;
- const int PENALTY_POLICY_REJECT = 3;
-
- /**
- * Offers to detect sockets sending data not wrapped inside a layer of SSL/TLS encryption.
- *
- * @param uid Uid of the app
- * @param policyPenalty The penalty policy of the app
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void strictUidCleartextPenalty(int uid, int policyPenalty);
-
- /**
- * Start clatd
- *
- * @param ifName interface name to start clatd
- * @param nat64Prefix the NAT64 prefix, e.g., "2001:db8:64::/96".
- * @return a string, the IPv6 address that will be used for 464xlat.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- @utf8InCpp String clatdStart(in @utf8InCpp String ifName, in @utf8InCpp String nat64Prefix);
-
- /**
- * Stop clatd
- *
- * @param ifName interface name to stop clatd
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void clatdStop(in @utf8InCpp String ifName);
-
- /**
- * Get status of IP forwarding
- *
- * @return true if IP forwarding is enabled, false otherwise.
- */
- boolean ipfwdEnabled();
-
- /**
- * Get requester list of IP forwarding
- *
- * @return An array of strings containing requester list of IP forwarding
- */
- @utf8InCpp String[] ipfwdGetRequesterList();
-
- /**
- * Enable IP forwarding for specific requester
- *
- * @param requester requester name to enable IP forwarding. It is a unique name which will be
- * stored in Netd to make sure if any requester needs IP forwarding.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void ipfwdEnableForwarding(in @utf8InCpp String requester);
-
- /**
- * Disable IP forwarding for specific requester
- *
- * @param requester requester name to disable IP forwarding. This name should match the
- * names which are set by ipfwdEnableForwarding.
- * IP forwarding would be disabled if it is the last requester.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void ipfwdDisableForwarding(in @utf8InCpp String requester);
-
- /**
- * Add forwarding ip rule
- *
- * @param fromIface interface name to add forwarding ip rule
- * @param toIface interface name to add forwarding ip rule
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void ipfwdAddInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
-
- /**
- * Remove forwarding ip rule
- *
- * @param fromIface interface name to remove forwarding ip rule
- * @param toIface interface name to remove forwarding ip rule
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void ipfwdRemoveInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
-
- /**
- * Set quota for interface
- *
- * @param ifName Name of target interface
- * @param bytes Quota value in bytes
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void bandwidthSetInterfaceQuota(in @utf8InCpp String ifName, long bytes);
-
- /**
- * Remove quota for interface
- *
- * @param ifName Name of target interface
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void bandwidthRemoveInterfaceQuota(in @utf8InCpp String ifName);
-
- /**
- * Set alert for interface
- *
- * @param ifName Name of target interface
- * @param bytes Alert value in bytes
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void bandwidthSetInterfaceAlert(in @utf8InCpp String ifName, long bytes);
-
- /**
- * Remove alert for interface
- *
- * @param ifName Name of target interface
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void bandwidthRemoveInterfaceAlert(in @utf8InCpp String ifName);
-
- /**
- * Set global alert
- *
- * @param bytes Alert value in bytes
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void bandwidthSetGlobalAlert(long bytes);
-
- /**
- * Add naughty app bandwidth rule for specific app
- *
- * @param uid uid of target app
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void bandwidthAddNaughtyApp(int uid);
-
- /**
- * Remove naughty app bandwidth rule for specific app
- *
- * @param uid uid of target app
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void bandwidthRemoveNaughtyApp(int uid);
-
- /**
- * Add nice app bandwidth rule for specific app
- *
- * @param uid uid of target app
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void bandwidthAddNiceApp(int uid);
-
- /**
- * Remove nice app bandwidth rule for specific app
- *
- * @param uid uid of target app
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void bandwidthRemoveNiceApp(int uid);
-
- /**
- * Start tethering
- *
- * @param dhcpRanges dhcp ranges to set.
- * dhcpRanges might contain many addresss {addr1, addr2, aadr3, addr4...}
- * Netd splits them into ranges: addr1-addr2, addr3-addr4, etc.
- * An odd number of addrs will fail.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void tetherStart(in @utf8InCpp String[] dhcpRanges);
-
- /**
- * Stop tethering
- *
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void tetherStop();
-
- /**
- * Get status of tethering
- *
- * @return true if tethering is enabled, false otherwise.
- */
- boolean tetherIsEnabled();
-
- /**
- * Setup interface for tethering
- *
- * @param ifName interface name to add
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void tetherInterfaceAdd(in @utf8InCpp String ifName);
-
- /**
- * Reset interface for tethering
- *
- * @param ifName interface name to remove
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void tetherInterfaceRemove(in @utf8InCpp String ifName);
-
- /**
- * Get the interface list which is stored in netd
- * The list contains the interfaces managed by tetherInterfaceAdd/tetherInterfaceRemove
- *
- * @return An array of strings containing interface list result
- */
- @utf8InCpp String[] tetherInterfaceList();
-
- /**
- * Set DNS forwarder server
- *
- * @param netId the upstream network to forward DNS queries to
- * @param dnsAddrs DNS server address to set
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void tetherDnsSet(int netId, in @utf8InCpp String[] dnsAddrs);
-
- /**
- * Return the DNS list set by tetherDnsSet
- *
- * @return An array of strings containing the list of DNS servers
- */
- @utf8InCpp String[] tetherDnsList();
-
- const int LOCAL_NET_ID = 99;
-
- /**
- * Constant net ID for the "dummy" network.
- *
- * The dummy network is used to blackhole or reject traffic. Any attempt to use it will
- * either drop the packets or fail with ENETUNREACH.
- */
- const int DUMMY_NET_ID = 51;
-
- /**
- * Constant net ID for the "unreachable" network.
- *
- * The unreachable network is used to reject traffic. Any attempt to use it will fail
- * with ENETUNREACH.
- */
- const int UNREACHABLE_NET_ID = 52;
-
- // Route does not specify a next hop
- const String NEXTHOP_NONE = "";
- // Route next hop is unreachable
- const String NEXTHOP_UNREACHABLE = "unreachable";
- // Route next hop is throw
- const String NEXTHOP_THROW = "throw";
-
- /**
- * Add a route for specific network
- *
- * @param netId the network to add the route to
- * @param ifName the name of interface of the route.
- * This interface should be assigned to the netID.
- * @param destination the destination of the route
- * @param nextHop The route's next hop address,
- * or it could be either NEXTHOP_NONE, NEXTHOP_UNREACHABLE, NEXTHOP_THROW.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void networkAddRoute(
- int netId,
- in @utf8InCpp String ifName,
- in @utf8InCpp String destination,
- in @utf8InCpp String nextHop);
-
- /**
- * Remove a route for specific network
- *
- * @param netId the network to remove the route from
- * @param ifName the name of interface of the route.
- * This interface should be assigned to the netID.
- * @param destination the destination of the route
- * @param nextHop The route's next hop address,
- * or it could be either NEXTHOP_NONE, NEXTHOP_UNREACHABLE, NEXTHOP_THROW.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void networkRemoveRoute(
- int netId,
- in @utf8InCpp String ifName,
- in @utf8InCpp String destination,
- in @utf8InCpp String nextHop);
-
- /**
- * Add a route to legacy routing table for specific network
- *
- * @param netId the network to add the route to
- * @param ifName the name of interface of the route.
- * This interface should be assigned to the netID.
- * @param destination the destination of the route
- * @param nextHop The route's next hop address,
- * or it could be either NEXTHOP_NONE, NEXTHOP_UNREACHABLE, NEXTHOP_THROW.
- * @param uid uid of the user
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void networkAddLegacyRoute(
- int netId,
- in @utf8InCpp String ifName,
- in @utf8InCpp String destination,
- in @utf8InCpp String nextHop,
- int uid);
-
- /**
- * Remove a route from legacy routing table for specific network
- *
- * @param netId the network to remove the route from
- * @param ifName the name of interface of the route.
- * This interface should be assigned to the netID.
- * @param destination the destination of the route
- * @param nextHop The route's next hop address,
- * or it could be either NEXTHOP_NONE, NEXTHOP_UNREACHABLE, NEXTHOP_THROW.
- * @param uid uid of the user
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void networkRemoveLegacyRoute(
- int netId,
- in @utf8InCpp String ifName,
- in @utf8InCpp String destination,
- in @utf8InCpp String nextHop,
- int uid);
-
- /**
- * Get default network
- *
- * @return netId of default network
- */
- int networkGetDefault();
-
- /**
- * Set network as default network
- *
- * @param netId the network to set as the default
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void networkSetDefault(int netId);
-
- /**
- * Clear default network
- *
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void networkClearDefault();
-
- /**
- * PERMISSION_NONE is used for regular networks and apps. TODO: use PERMISSION_INTERNET
- * for this instead, and use PERMISSION_NONE to indicate no network permissions at all.
- */
- const int PERMISSION_NONE = 0;
-
- /**
- * PERMISSION_NETWORK represents the CHANGE_NETWORK_STATE permission.
- */
- const int PERMISSION_NETWORK = 1;
-
- /**
- * PERMISSION_SYSTEM represents the ability to use restricted networks. This is mostly
- * equivalent to the CONNECTIVITY_USE_RESTRICTED_NETWORKS permission.
- */
- const int PERMISSION_SYSTEM = 2;
-
- /**
- * NO_PERMISSIONS indicates that this app is installed and doesn't have either
- * PERMISSION_INTERNET or PERMISSION_UPDATE_DEVICE_STATS.
- * TODO: use PERMISSION_NONE to represent this case
- */
- const int NO_PERMISSIONS = 0;
-
- /**
- * PERMISSION_INTERNET indicates that the app can create AF_INET and AF_INET6 sockets
- */
- const int PERMISSION_INTERNET = 4;
-
- /**
- * PERMISSION_UPDATE_DEVICE_STATS is used for system UIDs and privileged apps
- * that have the UPDATE_DEVICE_STATS permission
- */
- const int PERMISSION_UPDATE_DEVICE_STATS = 8;
-
- /**
- * PERMISSION_UNINSTALLED is used when an app is uninstalled from the device. All internet
- * related permissions need to be cleaned
- */
- const int PERMISSION_UNINSTALLED = -1;
-
-
- /**
- * Sets the permission required to access a specific network.
- *
- * @param netId the network to set
- * @param permission network permission to use
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void networkSetPermissionForNetwork(int netId, int permission);
-
- /**
- * Assigns network access permissions to the specified users.
- *
- * @param permission network permission to use
- * @param uids uid of users to set permission
- */
- void networkSetPermissionForUser(int permission, in int[] uids);
-
- /**
- * Clears network access permissions for the specified users.
- *
- * @param uids uid of users to clear permission
- */
- void networkClearPermissionForUser(in int[] uids);
-
- /**
- * Assigns android.permission.INTERNET and/or android.permission.UPDATE_DEVICE_STATS to the uids
- * specified. Or remove all permissions from the uids.
- *
- * @param permission The permission to grant, it could be either PERMISSION_INTERNET and/or
- * PERMISSION_UPDATE_DEVICE_STATS. If the permission is NO_PERMISSIONS, then
- * revoke all permissions for the uids.
- * @param uids uid of users to grant permission
- */
- void trafficSetNetPermForUids(int permission, in int[] uids);
-
- /**
- * Gives the specified user permission to protect sockets from VPNs.
- * Typically used by VPN apps themselves, to ensure that the sockets
- * they use to communicate with the VPN server aren't routed through
- * the VPN network.
- *
- * @param uid uid of user to set
- */
- void networkSetProtectAllow(int uid);
-
- /**
- * Removes the permission to protect sockets from VPN.
- *
- * @param uid uid of user to set
- */
- void networkSetProtectDeny(int uid);
-
- /**
- * Get the status of network protect for user
- *
- * @param uids uid of user
- * @return true if the user can protect sockets from VPN, false otherwise.
- */
- boolean networkCanProtect(int uid);
-
- /** Only allows packets from specific UID/Interface.
- @deprecated use FIREWALL_ALLOWLIST. */
- const int FIREWALL_WHITELIST = 0;
-
- /** Only allows packets from specific UID/Interface. */
- const int FIREWALL_ALLOWLIST = 0;
-
- /** Blocks packets from specific UID/Interface.
- @deprecated use FIREWALL_DENYLIST. */
- const int FIREWALL_BLACKLIST = 1;
-
- /** Blocks packets from specific UID/Interface. */
- const int FIREWALL_DENYLIST = 1;
-
- /**
- * Set type of firewall
- * Type allowlist only allows packets from specific UID/Interface
- * Type denylist blocks packets from specific UID/Interface
- *
- * @param firewalltype type of firewall, either FIREWALL_ALLOWLIST or FIREWALL_DENYLIST
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void firewallSetFirewallType(int firewalltype);
-
- // Specify allow Rule which allows packets
- const int FIREWALL_RULE_ALLOW = 1;
- // Specify deny Rule which drops packets
- const int FIREWALL_RULE_DENY = 2;
-
- // No specific chain is chosen, use general firewall chain(fw_input, fw_output)
- const int FIREWALL_CHAIN_NONE = 0;
- // Specify DOZABLE chain(fw_dozable) which is used in dozable mode
- const int FIREWALL_CHAIN_DOZABLE = 1;
- // Specify STANDBY chain(fw_standby) which is used in standby mode
- const int FIREWALL_CHAIN_STANDBY = 2;
- // Specify POWERSAVE chain(fw_powersave) which is used in power save mode
- const int FIREWALL_CHAIN_POWERSAVE = 3;
- // Specify RESTRICTED chain(fw_restricted) which is used in restricted
- // networking mode
- const int FIREWALL_CHAIN_RESTRICTED = 4;
-
- /**
- * Set firewall rule for interface
- *
- * @param ifName the interface to allow/deny
- * @param firewallRule either FIREWALL_RULE_ALLOW or FIREWALL_RULE_DENY
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void firewallSetInterfaceRule(in @utf8InCpp String ifName, int firewallRule);
-
- /**
- * Set firewall rule for uid
- *
- * @param childChain target chain
- * @param uid uid to allow/deny
- * @param firewallRule either FIREWALL_RULE_ALLOW or FIREWALL_RULE_DENY
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void firewallSetUidRule(int childChain, int uid, int firewallRule);
-
- /**
- * Enable/Disable target firewall child chain
- *
- * @param childChain target chain to enable
- * @param enable whether to enable or disable child chain.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void firewallEnableChildChain(int childChain, boolean enable);
-
- /**
- * Get interface list
- *
- * @return An array of strings containing all the interfaces on the system.
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- @utf8InCpp String[] interfaceGetList();
-
- // Must be kept in sync with constant in InterfaceConfiguration.java
- const String IF_STATE_UP = "up";
- const String IF_STATE_DOWN = "down";
-
- const String IF_FLAG_BROADCAST = "broadcast";
- const String IF_FLAG_LOOPBACK = "loopback";
- const String IF_FLAG_POINTOPOINT = "point-to-point";
- const String IF_FLAG_RUNNING = "running";
- const String IF_FLAG_MULTICAST = "multicast";
-
- /**
- * Get interface configuration
- *
- * @param ifName interface name
- * @return An InterfaceConfigurationParcel for the specified interface.
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- InterfaceConfigurationParcel interfaceGetCfg(in @utf8InCpp String ifName);
-
- /**
- * Set interface configuration
- *
- * @param cfg Interface configuration to set
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- void interfaceSetCfg(in InterfaceConfigurationParcel cfg);
-
- /**
- * Set interface IPv6 privacy extensions
- *
- * @param ifName interface name
- * @param enable whether to enable or disable this setting.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void interfaceSetIPv6PrivacyExtensions(in @utf8InCpp String ifName, boolean enable);
-
- /**
- * Clear all IP addresses on the given interface
- *
- * @param ifName interface name
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * POSIX errno.
- */
- void interfaceClearAddrs(in @utf8InCpp String ifName);
-
- /**
- * Enable or disable IPv6 on the given interface
- *
- * @param ifName interface name
- * @param enable whether to enable or disable this setting.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void interfaceSetEnableIPv6(in @utf8InCpp String ifName, boolean enable);
-
- /**
- * Set interface MTU
- *
- * @param ifName interface name
- * @param mtu MTU value
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void interfaceSetMtu(in @utf8InCpp String ifName, int mtu);
-
- /**
- * Add forwarding rule/stats on given interface.
- *
- * @param intIface downstream interface
- * @param extIface upstream interface
- */
- void tetherAddForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
-
- /**
- * Remove forwarding rule/stats on given interface.
- *
- * @param intIface downstream interface
- * @param extIface upstream interface
- */
- void tetherRemoveForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
-
- /**
- * Set the values of tcp_{rmem,wmem}.
- *
- * @param rmemValues the target values of tcp_rmem, each value is separated by spaces
- * @param wmemValues the target values of tcp_wmem, each value is separated by spaces
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void setTcpRWmemorySize(in @utf8InCpp String rmemValues, in @utf8InCpp String wmemValues);
-
- /**
- * Register unsolicited event listener
- * Netd supports multiple unsolicited event listeners.
- *
- * @param listener unsolicited event listener to register
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void registerUnsolicitedEventListener(INetdUnsolicitedEventListener listener);
-
- /**
- * Add ingress interface filtering rules to a list of UIDs
- *
- * For a given uid, once a filtering rule is added, the kernel will only allow packets from the
- * allowed interface and loopback to be sent to the list of UIDs.
- *
- * Calling this method on one or more UIDs with an existing filtering rule but a different
- * interface name will result in the filtering rule being updated to allow the new interface
- * instead. Otherwise calling this method will not affect existing rules set on other UIDs.
- *
- * @param ifName the name of the interface on which the filtering rules will allow packets to
- be received.
- * @param uids an array of UIDs which the filtering rules will be set
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void firewallAddUidInterfaceRules(in @utf8InCpp String ifName, in int[] uids);
-
- /**
- * Remove ingress interface filtering rules from a list of UIDs
- *
- * Clear the ingress interface filtering rules from the list of UIDs which were previously set
- * by firewallAddUidInterfaceRules(). Ignore any uid which does not have filtering rule.
- *
- * @param uids an array of UIDs from which the filtering rules will be removed
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void firewallRemoveUidInterfaceRules(in int[] uids);
-
- /**
- * Request netd to change the current active network stats map.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void trafficSwapActiveStatsMap();
-
- /**
- * Retrieves OEM netd listener interface
- *
- * @return a IBinder object, it could be casted to oem specific interface.
- */
- IBinder getOemNetd();
-
- /**
- * Start tethering with given configuration
- *
- * @param config config to start tethering.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void tetherStartWithConfiguration(in TetherConfigParcel config);
-
-
- /**
- * Get the fwmark and its net id mask for the given network id.
- *
- * @param netId the network to get the fwmark and mask for.
- * @return A MarkMaskParcel of the given network id.
- */
- MarkMaskParcel getFwmarkForNetwork(int netId);
-
- /**
- * Add a route for specific network
- *
- * @param netId the network to add the route to
- * @param routeInfo parcelable with route information
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void networkAddRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
-
- /**
- * Update a route for specific network
- *
- * @param routeInfo parcelable with route information
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void networkUpdateRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
-
- /**
- * Remove a route for specific network
- *
- * @param routeInfo parcelable with route information
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void networkRemoveRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
-
- /**
- * Adds a tethering offload rule, or updates it if it already exists.
- *
- * Currently, only downstream /128 IPv6 entries are supported. An existing rule will be updated
- * if the input interface and destination prefix match. Otherwise, a new rule will be created.
- *
- * @param rule The rule to add or update.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void tetherOffloadRuleAdd(in TetherOffloadRuleParcel rule);
-
- /**
- * Deletes a tethering offload rule.
- *
- * Currently, only downstream /128 IPv6 entries are supported. An existing rule will be deleted
- * if the destination IP address and the source interface match. It is not an error if there is
- * no matching rule to delete.
- *
- * @param rule The rule to delete.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void tetherOffloadRuleRemove(in TetherOffloadRuleParcel rule);
-
- /**
- * Return BPF tethering offload statistics.
- *
- * @return an array of TetherStatsParcel's, where each entry contains the upstream interface
- * index and its tethering statistics since tethering was first started.
- * There will only ever be one entry for a given interface index.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- TetherStatsParcel[] tetherOffloadGetStats();
-
- /**
- * Set a per-interface quota for tethering offload.
- *
- * @param ifIndex Index of upstream interface
- * @param quotaBytes The quota defined as the number of bytes, starting from zero and counting
- * from *now*. A value of QUOTA_UNLIMITED (-1) indicates there is no limit.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- void tetherOffloadSetInterfaceQuota(int ifIndex, long quotaBytes);
-
- /**
- * Return BPF tethering offload statistics and clear the stats for a given upstream.
- *
- * Must only be called once all offload rules have already been deleted for the given upstream
- * interface. The existing stats will be fetched and returned. The stats and the limit for the
- * given upstream interface will be deleted as well.
- *
- * The stats and limit for a given upstream interface must be initialized (using
- * tetherOffloadSetInterfaceQuota) before any offload will occur on that interface.
- *
- * @param ifIndex Index of upstream interface.
- * @return TetherStatsParcel, which contains the given upstream interface index and its
- * tethering statistics since tethering was first started on that upstream interface.
- * @throws ServiceSpecificException in case of failure, with an error code indicating the
- * cause of the failure.
- */
- TetherStatsParcel tetherOffloadGetAndClearStats(int ifIndex);
-
- /**
- * Creates a network.
- *
- * @param config the configuration of network.
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- void networkCreate(in NativeNetworkConfig config);
-
- /**
- * Adds the specified UID ranges to the specified network. The network can be physical or
- * virtual. Traffic from the UID ranges will be routed to the network by default. The possible
- * value of subsidiary priority for physical and unreachable networks is 0-999. 0 is the highest
- * priority. 0 is also the default value. Virtual network supports only the default value.
- *
- * @param NativeUidRangeConfig a parcel contains netId, UID ranges, subsidiary priority, etc.
- *
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- void networkAddUidRangesParcel(in NativeUidRangeConfig uidRangesConfig);
-
- /**
- * Removes the specified UID ranges from the specified network. The network can be physical or
- * virtual. Traffic from the UID ranges will no longer be routed to the network by default. The
- * possible value of subsidiary priority for physical and unreachable networks is 0-999. 0 is
- * the highest priority. 0 is also the default value. Virtual network supports only the default
- * value.
- *
- * @param NativeUidRangeConfig a parcel contains netId, UID ranges, subsidiary priority, etc.
- *
- * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
- * unix errno.
- */
- void networkRemoveUidRangesParcel(in NativeUidRangeConfig uidRangesConfig);
-}
diff --git a/common/netd/binder/android/net/INetdUnsolicitedEventListener.aidl b/common/netd/binder/android/net/INetdUnsolicitedEventListener.aidl
deleted file mode 100644
index 652a79c..0000000
--- a/common/netd/binder/android/net/INetdUnsolicitedEventListener.aidl
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * Copyright (c) 2018, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-/**
- * Unsolicited netd events which are reported by the kernel via netlink.
- * This one-way interface groups asynchronous notifications sent
- * by netd to any process that registered itself via INetd.registerUnsolEventListener.
- *
- * {@hide}
- */
-oneway interface INetdUnsolicitedEventListener {
-
- /**
- * Notifies that an interface has been idle/active for a certain period of time.
- * It is the event for idletimer.
- *
- * @param isActive true for active status, false for idle
- * @param timerLabel unique identifier of the idletimer.
- * Since NMS only set the identifier as int, only report event with int label.
- * @param timestampNs kernel timestamp of this event, 0 for no timestamp
- * @param uid uid of this event, -1 for no uid.
- * It represents the uid that was responsible for waking the radio.
- */
- void onInterfaceClassActivityChanged(
- boolean isActive,
- int timerLabel,
- long timestampNs,
- int uid);
-
- /**
- * Notifies that a specific interface reached its quota limit.
- *
- * @param alertName alert name of the quota limit
- * @param ifName interface which reached the limit
- */
- void onQuotaLimitReached(@utf8InCpp String alertName, @utf8InCpp String ifName);
-
- /**
- * Provides information on IPv6 DNS servers on a specific interface.
- *
- * @param ifName interface name
- * @param lifetimeS lifetime for the DNS servers in seconds
- * @param servers the address of servers.
- * e.g. IpV6: "2001:4860:4860::6464"
- *
- */
- void onInterfaceDnsServerInfo(
- @utf8InCpp String ifName, long lifetimeS, in @utf8InCpp String[] servers);
-
- /**
- * Notifies that an address has updated on a specific interface.
- *
- * @param addr address that is being updated
- * @param ifName the name of the interface on which the address is configured
- * @param flags address flags, see ifa_flags in if_addr.h
- * @param scope current scope of the address
- */
- void onInterfaceAddressUpdated(
- @utf8InCpp String addr,
- @utf8InCpp String ifName,
- int flags,
- int scope);
-
- /**
- * Notifies that an address has been removed on a specific interface.
- *
- * @param addr address of this change
- * @param ifName the name of the interface that changed addresses
- * @param flags address flags, see ifa_flags in if_addr.h
- * @param scope address address scope
- */
- void onInterfaceAddressRemoved(
- @utf8InCpp String addr,
- @utf8InCpp String ifName,
- int flags,
- int scope);
-
- /**
- * Notifies that an interface has been added.
- *
- * @param ifName the name of the added interface
- */
- void onInterfaceAdded(@utf8InCpp String ifName);
-
- /**
- * Notifies that an interface has been removed.
- *
- * @param ifName the name of the removed interface
- */
- void onInterfaceRemoved(@utf8InCpp String ifName);
-
- /**
- * Notifies that the status of the specific interface has changed.
- *
- * @param ifName the name of the interface that changed status
- * @param up true for interface up, false for down
- */
- void onInterfaceChanged(@utf8InCpp String ifName, boolean up);
-
- /**
- * Notifies that the link state of the specific interface has changed.
- *
- * @param ifName the name of the interface whose link state has changed
- * @param up true for interface link state up, false for link state down
- */
- void onInterfaceLinkStateChanged(@utf8InCpp String ifName, boolean up);
-
- /**
- * Notifies that an IP route has changed.
- *
- * @param updated true for update, false for remove
- * @param route destination prefix of this route, e.g., "2001:db8::/64"
- * @param gateway address of gateway, empty string for no gateway
- * @param ifName interface name of this route, empty string for no interface
- */
- void onRouteChanged(
- boolean updated,
- @utf8InCpp String route,
- @utf8InCpp String gateway,
- @utf8InCpp String ifName);
-
- /**
- * Notifies that kernel has detected a socket sending data not wrapped
- * inside a layer of SSL/TLS encryption.
- *
- * @param uid uid of this event
- * @param hex packet content in hex format
- */
- void onStrictCleartextDetected(int uid, @utf8InCpp String hex);
-}
diff --git a/common/netd/binder/android/net/InterfaceConfigurationParcel.aidl b/common/netd/binder/android/net/InterfaceConfigurationParcel.aidl
deleted file mode 100644
index c20792c..0000000
--- a/common/netd/binder/android/net/InterfaceConfigurationParcel.aidl
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-/**
- * Configuration details for a network interface.
- *
- * {@hide}
- */
-parcelable InterfaceConfigurationParcel {
- @utf8InCpp String ifName;
- @utf8InCpp String hwAddr;
- @utf8InCpp String ipv4Addr;
- int prefixLength;
- /**
- * Interface flags, String versions of IFF_* defined in netd/if.h
- */
- @utf8InCpp String[] flags;
-}
diff --git a/common/netd/binder/android/net/MarkMaskParcel.aidl b/common/netd/binder/android/net/MarkMaskParcel.aidl
deleted file mode 100644
index 932b7bf..0000000
--- a/common/netd/binder/android/net/MarkMaskParcel.aidl
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-/**
- * Structure that stores a firewall mark and its mask.
- *
- * {@hide}
- */
-parcelable MarkMaskParcel {
- // The fwmark.
- int mark;
- // Net id mask of fwmark.
- int mask;
-}
diff --git a/common/netd/binder/android/net/NativeNetworkConfig.aidl b/common/netd/binder/android/net/NativeNetworkConfig.aidl
deleted file mode 100644
index 2c4f83a..0000000
--- a/common/netd/binder/android/net/NativeNetworkConfig.aidl
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-import android.net.NativeNetworkType;
-import android.net.NativeVpnType;
-
-/**
- * The configuration to create a network.
- *
- * {@hide}
- */
-@JavaDerive(toString=true, equals=true)
-@JavaOnlyImmutable
-parcelable NativeNetworkConfig {
- /** The networkId to create. */
- int netId;
-
- /**
- * The type of network, e.g. physical network or virtual network.
- */
- NativeNetworkType networkType = NativeNetworkType.PHYSICAL;
-
- /**
- * For physical networks. The permission necessary to use the network. Must be one of
- * PERMISSION_NONE/PERMISSION_NETWORK/PERMISSION_SYSTEM. Ignored for all other network types.
- */
- int permission;
-
- /**
- * For virtual networks. Whether unprivileged apps are allowed to bypass the VPN. Ignored for
- * all other network types.
- */
- boolean secure;
-
- /** For virtual networks. The type of VPN to create. Ignored for all other network types. */
- NativeVpnType vpnType = NativeVpnType.PLATFORM;
-}
diff --git a/common/netd/binder/android/net/NativeNetworkType.aidl b/common/netd/binder/android/net/NativeNetworkType.aidl
deleted file mode 100644
index d667029..0000000
--- a/common/netd/binder/android/net/NativeNetworkType.aidl
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-@Backing(type="int")
-enum NativeNetworkType {
- /**
- * Physical network type.
- */
- PHYSICAL = 0,
-
- /**
- * Virtual private network type.
- */
- VIRTUAL = 1,
-}
\ No newline at end of file
diff --git a/common/netd/binder/android/net/NativeVpnType.aidl b/common/netd/binder/android/net/NativeVpnType.aidl
deleted file mode 100644
index cd1b447..0000000
--- a/common/netd/binder/android/net/NativeVpnType.aidl
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-@Backing(type="int")
-enum NativeVpnType {
- /**
- * A VPN created by an app using the VpnService API.
- */
- SERVICE = 1,
-
- /**
- * A VPN created using a VpnManager API such as startProvisionedVpnProfile.
- */
- PLATFORM = 2,
-
- /**
- * An IPsec VPN created by the built-in LegacyVpnRunner.
- */
- LEGACY = 3,
-
- /**
- * An VPN created by OEM code through other means than VpnService or VpnManager.
- */
- OEM = 4,
-}
\ No newline at end of file
diff --git a/common/netd/binder/android/net/RouteInfoParcel.aidl b/common/netd/binder/android/net/RouteInfoParcel.aidl
deleted file mode 100644
index fcc86e3..0000000
--- a/common/netd/binder/android/net/RouteInfoParcel.aidl
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright (c) 2020, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-parcelable RouteInfoParcel {
- // The destination of the route.
- @utf8InCpp String destination;
- // The name of interface of the route. This interface should be assigned to the netID.
- @utf8InCpp String ifName;
- // The route's next hop address, or one of the NEXTHOP_* constants defined in INetd.aidl.
- @utf8InCpp String nextHop;
- // The MTU of the route.
- int mtu;
-}
diff --git a/common/netd/binder/android/net/TetherConfigParcel.aidl b/common/netd/binder/android/net/TetherConfigParcel.aidl
deleted file mode 100644
index 9f371ce..0000000
--- a/common/netd/binder/android/net/TetherConfigParcel.aidl
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-/**
- * The configuration to start tethering.
- *
- * {@hide}
- */
-parcelable TetherConfigParcel {
- // Whether to enable or disable legacy DNS proxy server.
- boolean usingLegacyDnsProxy;
- // DHCP ranges to set.
- // dhcpRanges might contain many addresss {addr1, addr2, addr3, addr4...}
- // Netd splits them into ranges: addr1-addr2, addr3-addr4, etc.
- // An odd number of addrs will fail.
- @utf8InCpp String[] dhcpRanges;
-}
diff --git a/common/netd/binder/android/net/TetherOffloadRuleParcel.aidl b/common/netd/binder/android/net/TetherOffloadRuleParcel.aidl
deleted file mode 100644
index c549e61..0000000
--- a/common/netd/binder/android/net/TetherOffloadRuleParcel.aidl
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-/**
- * Represents a forwarding rule for tethering offload.
- *
- * {@hide}
- */
-parcelable TetherOffloadRuleParcel {
- /** The interface index of the input interface. */
- int inputInterfaceIndex;
-
- /** The interface index of the output interface. */
- int outputInterfaceIndex;
-
- /** The base IP address of the destination prefix as a byte array. */
- byte[] destination;
-
- /** The destination prefix length. */
- int prefixLength;
-
- /** The source link-layer address. Currently, must be a 6-byte MAC address.*/
- byte[] srcL2Address;
-
- /** The destination link-layer address. Currently, must be a 6-byte MAC address. */
- byte[] dstL2Address;
-
- /** The outbound path mtu. */
- int pmtu = 1500;
-}
diff --git a/common/netd/binder/android/net/TetherStatsParcel.aidl b/common/netd/binder/android/net/TetherStatsParcel.aidl
deleted file mode 100644
index 6bf60a8..0000000
--- a/common/netd/binder/android/net/TetherStatsParcel.aidl
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-/**
- * The statistics of tethering interface
- *
- * {@hide}
- */
-parcelable TetherStatsParcel {
- /**
- * Parcel representing tethering interface statistics.
- *
- * This parcel is used by tetherGetStats, tetherOffloadGetStats and
- * tetherOffloadGetAndClearStats in INetd.aidl. tetherGetStats uses this parcel to return the
- * tethering statistics since netd startup and presents the interface via its interface name.
- * Both tetherOffloadGetStats and tetherOffloadGetAndClearStats use this parcel to return
- * the tethering statistics since tethering was first started. They present the interface via
- * its interface index. Note that the interface must be presented by either interface name
- * |iface| or interface index |ifIndex| in this parcel. The unused interface name is set to
- * an empty string "" by default and the unused interface index is set to 0 by default.
- */
-
- /** The interface name. */
- @utf8InCpp String iface;
-
- /** Total number of received bytes. */
- long rxBytes;
-
- /** Total number of received packets. */
- long rxPackets;
-
- /** Total number of transmitted bytes. */
- long txBytes;
-
- /** Total number of transmitted packets. */
- long txPackets;
-
- /** The interface index. */
- int ifIndex = 0;
-}
diff --git a/common/netd/binder/android/net/UidRangeParcel.aidl b/common/netd/binder/android/net/UidRangeParcel.aidl
deleted file mode 100644
index 8f1fef6..0000000
--- a/common/netd/binder/android/net/UidRangeParcel.aidl
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net;
-
-/**
- * An inclusive range of UIDs.
- *
- * {@hide}
- */
-@JavaOnlyImmutable @JavaDerive(toString=true, equals=true)
-parcelable UidRangeParcel {
- int start;
- int stop;
-}
diff --git a/common/netd/binder/android/net/metrics/INetdEventListener.aidl b/common/netd/binder/android/net/metrics/INetdEventListener.aidl
deleted file mode 100644
index ef1b2cb..0000000
--- a/common/netd/binder/android/net/metrics/INetdEventListener.aidl
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * Copyright (c) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.metrics;
-
-/**
- * Logs netd events.
- *
- * {@hide}
- */
-oneway interface INetdEventListener {
- const int EVENT_GETADDRINFO = 1;
- const int EVENT_GETHOSTBYNAME = 2;
- const int EVENT_GETHOSTBYADDR = 3;
- const int EVENT_RES_NSEND = 4;
-
- const int REPORTING_LEVEL_NONE = 0;
- const int REPORTING_LEVEL_METRICS = 1;
- const int REPORTING_LEVEL_FULL = 2;
-
- // Maximum number of IP addresses logged for DNS lookups before we truncate the full list.
- const int DNS_REPORTED_IP_ADDRESSES_LIMIT = 10;
-
- /**
- * Logs a DNS lookup function call (getaddrinfo and gethostbyname).
- *
- * @param netId the ID of the network the lookup was performed on.
- * @param eventType one of the EVENT_* constants in this interface.
- * @param returnCode the return value of the function call.
- * @param latencyMs the latency of the function call.
- * @param hostname the name that was looked up.
- * @param ipAddresses (possibly a subset of) the IP addresses returned.
- * At most {@link #DNS_REPORTED_IP_ADDRESSES_LIMIT} addresses are logged.
- * @param ipAddressesCount the number of IP addresses returned. May be different from the length
- * of ipAddresses if there were too many addresses to log.
- * @param uid the UID of the application that performed the query.
- */
- void onDnsEvent(int netId, int eventType, int returnCode, int latencyMs,
- @utf8InCpp String hostname, in @utf8InCpp String[] ipAddresses,
- int ipAddressesCount, int uid);
-
- /**
- * Represents a private DNS validation success or failure.
- *
- * @param netId the ID of the network the validation was performed on.
- * @param ipAddress the IP address for which validation was performed.
- * @param hostname the hostname for which validation was performed.
- * @param validated whether or not validation was successful.
- */
- void onPrivateDnsValidationEvent(int netId, String ipAddress, String hostname,
- boolean validated);
-
- /**
- * Logs a single connect library call.
- *
- * @param netId the ID of the network the connect was performed on.
- * @param error 0 if the connect call succeeded, otherwise errno if it failed.
- * @param latencyMs the latency of the connect call.
- * @param ipAddr destination IP address.
- * @param port destination port number.
- * @param uid the UID of the application that performed the connection.
- */
- void onConnectEvent(int netId, int error, int latencyMs, String ipAddr, int port, int uid);
-
- /**
- * Logs a single RX packet which caused the main CPU to exit sleep state.
- * @param prefix arbitrary string provided via wakeupAddInterface()
- * @param uid UID of the destination process or -1 if no UID is available.
- * @param ethertype of the RX packet encoded in an int in native order, or -1 if not available.
- * @param ipNextHeader ip protocol of the RX packet as IPPROTO_* number,
- or -1 if the packet was not IPv4 or IPv6.
- * @param dstHw destination hardware address, or 0 if not available.
- * @param srcIp source IP address, or null if not available.
- * @param dstIp destination IP address, or null if not available.
- * @param srcPort src port of RX packet in native order, or -1 if the packet was not UDP or TCP.
- * @param dstPort dst port of RX packet in native order, or -1 if the packet was not UDP or TCP.
- * @param timestampNs receive timestamp for the offending packet. In units of nanoseconds and
- * synchronized to CLOCK_MONOTONIC.
- */
- void onWakeupEvent(String prefix, int uid, int ethertype, int ipNextHeader, in byte[] dstHw,
- String srcIp, String dstIp, int srcPort, int dstPort, long timestampNs);
-
- /**
- * An event sent after every Netlink sock_diag poll performed by Netd. This reported batch
- * groups TCP socket stats aggregated by network id. Per-network data are stored in a
- * structure-of-arrays style where networkIds, sentPackets, lostPackets, rttUs, and
- * sentAckDiffMs have the same length. Stats for the i-th network is spread across all these
- * arrays at index i.
- * @param networkIds an array of network ids for which there was tcp socket stats to collect in
- * the last sock_diag poll.
- * @param sentPackets an array of packet sent across all TCP sockets still alive and new
- TCP sockets since the last sock_diag poll, summed per network id.
- * @param lostPackets, an array of packet lost across all TCP sockets still alive and new
- TCP sockets since the last sock_diag poll, summed per network id.
- * @param rttUs an array of smoothed round trip times in microseconds, averaged across all TCP
- sockets since the last sock_diag poll for a given network id.
- * @param sentAckDiffMs an array of milliseconds duration between the last packet sent and the
- last ack received for a socket, averaged across all TCP sockets for a network id.
- */
- void onTcpSocketStatsEvent(in int[] networkIds, in int[] sentPackets,
- in int[] lostPackets, in int[] rttUs, in int[] sentAckDiffMs);
-
- /**
- * Represents adding or removing a NAT64 prefix.
- *
- * @param netId the ID of the network the prefix was discovered on.
- * @param added true if the NAT64 prefix was added, or false if the NAT64 prefix was removed.
- * There is only one prefix at a time for each netId. If a prefix is added, it replaces
- * the previous-added prefix.
- * @param prefixString the detected NAT64 prefix as a string literal.
- * @param prefixLength the prefix length associated with this NAT64 prefix.
- */
- void onNat64PrefixEvent(int netId, boolean added, @utf8InCpp String prefixString,
- int prefixLength);
-}
diff --git a/common/netd/binder/android/net/netd/aidl/NativeUidRangeConfig.aidl b/common/netd/binder/android/net/netd/aidl/NativeUidRangeConfig.aidl
deleted file mode 100644
index 99497a8..0000000
--- a/common/netd/binder/android/net/netd/aidl/NativeUidRangeConfig.aidl
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.netd.aidl;
-
-import android.net.UidRangeParcel;
-
-/**
- * The configuration to add or remove UID ranges.
- *
- * {@hide}
- */
-@JavaDerive(toString=true, equals=true)
-@JavaOnlyImmutable
-parcelable NativeUidRangeConfig {
- /** The network ID of the network to add/remove the ranges to/from. */
- int netId;
-
- /** A set of non-overlapping ranges of UIDs. */
- UidRangeParcel[] uidRanges;
-
- /**
- * The priority of this UID range config. 0 is the highest priority; 999 is the lowest priority.
- * The function of this parameter is to adjust the priority when the same UID is set to
- * different networks for different features.
- */
- int subPriority;
-}
\ No newline at end of file
diff --git a/common/tests/unit/Android.bp b/common/tests/unit/Android.bp
index 23835fe..45a89b0 100644
--- a/common/tests/unit/Android.bp
+++ b/common/tests/unit/Android.bp
@@ -10,7 +10,6 @@
name: "NetworkStaticLibTestsLib",
srcs: ["src/**/*.java","src/**/*.kt"],
min_sdk_version: "29",
- defaults: ["framework-connectivity-test-defaults"],
static_libs: [
"net-utils-framework-common",
"androidx.test.rules",
@@ -24,8 +23,7 @@
],
visibility: [
"//frameworks/base/packages/Tethering/tests/integration",
- "//packages/modules/Connectivity/tests:__subpackages__",
- "//packages/modules/Connectivity/Tethering/tests:__subpackages__",
+ "//packages/modules/Connectivity/Tethering/tests/integration",
"//packages/modules/NetworkStack/tests/integration",
]
}
diff --git a/common/tests/unit/lint-baseline.xml b/common/tests/unit/lint-baseline.xml
index e3a6c1e..0990916 100644
--- a/common/tests/unit/lint-baseline.xml
+++ b/common/tests/unit/lint-baseline.xml
@@ -3,6 +3,325 @@
<issue
id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#any`"
+ errorLine1=" assertTrue(CollectionUtils.any(listOf("A", "B", "C", "D", "E")) { it == "E" })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="32"
+ column="36"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#any`"
+ errorLine1=" assertFalse(CollectionUtils.any(listOf("A", "B", "C", "D", "E")) { it == "F" })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="33"
+ column="37"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#any`"
+ errorLine1=" assertTrue(CollectionUtils.any(listOf("AA", "BBB")) { it.length >= 3 })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="34"
+ column="36"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#any`"
+ errorLine1=" assertFalse(CollectionUtils.any(listOf("A", "BB", "CCC")) { it.length >= 4 })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="35"
+ column="37"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#any`"
+ errorLine1=" assertFalse(CollectionUtils.any(listOf("A", "BB", "CCC")) { it.length < 0 })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="36"
+ column="37"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#any`"
+ errorLine1=" assertFalse(CollectionUtils.any(listOf<String>()) { true })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="37"
+ column="37"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#any`"
+ errorLine1=" assertFalse(CollectionUtils.any(listOf<String>()) { false })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="38"
+ column="37"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#any`"
+ errorLine1=" assertTrue(CollectionUtils.any(listOf("A")) { true })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="39"
+ column="36"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#any`"
+ errorLine1=" assertFalse(CollectionUtils.any(listOf("A")) { false })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="40"
+ column="37"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#indexOf`"
+ errorLine1=" assertEquals(4, CollectionUtils.indexOf(listOf("A", "B", "C", "D", "E")) { it == "E" })"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="45"
+ column="41"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#indexOf`"
+ errorLine1=" assertEquals(0, CollectionUtils.indexOf(listOf("A", "B", "C", "D", "E")) { it == "A" })"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="46"
+ column="41"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#indexOf`"
+ errorLine1=" assertEquals(1, CollectionUtils.indexOf(listOf("AA", "BBB", "CCCC")) { it.length >= 3 })"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="47"
+ column="41"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#indexOf`"
+ errorLine1=" assertEquals(1, CollectionUtils.indexOf(listOf("AA", null, "CCCC")) { it == null })"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="48"
+ column="41"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#indexOf`"
+ errorLine1=" assertEquals(1, CollectionUtils.indexOf(listOf(null, "CCCC")) { it != null })"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="49"
+ column="41"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#all`"
+ errorLine1=" assertFalse(CollectionUtils.all(listOf("A", "B", "C", "D", "E")) { it != "E" })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="54"
+ column="37"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#all`"
+ errorLine1=" assertTrue(CollectionUtils.all(listOf("A", "B", "C", "D", "E")) { it != "F" })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="55"
+ column="36"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#all`"
+ errorLine1=" assertFalse(CollectionUtils.all(listOf("A", "BB", "CCC")) { it.length > 2 })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="56"
+ column="37"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#all`"
+ errorLine1=" assertTrue(CollectionUtils.all(listOf("A", "BB", "CCC")) { it.length >= 1 })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="57"
+ column="36"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#all`"
+ errorLine1=" assertTrue(CollectionUtils.all(listOf("A", "BB", "CCC")) { it.length < 4 })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="58"
+ column="36"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#all`"
+ errorLine1=" assertTrue(CollectionUtils.all(listOf<String>()) { true })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="59"
+ column="36"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#all`"
+ errorLine1=" assertTrue(CollectionUtils.all(listOf<String>()) { false })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="60"
+ column="36"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#all`"
+ errorLine1=" assertTrue(CollectionUtils.all(listOf(1)) { true })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="61"
+ column="36"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.CollectionUtils#all`"
+ errorLine1=" assertFalse(CollectionUtils.all(listOf(1)) { false })"
+ errorLine2=" ~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt"
+ line="62"
+ column="37"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.ConnectivityUtils#isIPv6ULA`"
+ errorLine1=" assertTrue(isIPv6ULA(parseNumericAddress("fc00::")));"
+ errorLine2=" ~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/ConnectivityUtilsTest.java"
+ line="38"
+ column="20"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.ConnectivityUtils#isIPv6ULA`"
+ errorLine1=" assertTrue(isIPv6ULA(parseNumericAddress("fc00::1")));"
+ errorLine2=" ~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/ConnectivityUtilsTest.java"
+ line="39"
+ column="20"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.ConnectivityUtils#isIPv6ULA`"
+ errorLine1=" assertTrue(isIPv6ULA(parseNumericAddress("fc00:1234::5678")));"
+ errorLine2=" ~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/ConnectivityUtilsTest.java"
+ line="40"
+ column="20"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.ConnectivityUtils#isIPv6ULA`"
+ errorLine1=" assertTrue(isIPv6ULA(parseNumericAddress("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")));"
+ errorLine2=" ~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/ConnectivityUtilsTest.java"
+ line="41"
+ column="20"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.ConnectivityUtils#isIPv6ULA`"
+ errorLine1=" assertFalse(isIPv6ULA(parseNumericAddress("fe00::")));"
+ errorLine2=" ~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/ConnectivityUtilsTest.java"
+ line="43"
+ column="21"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.ConnectivityUtils#isIPv6ULA`"
+ errorLine1=" assertFalse(isIPv6ULA(parseNumericAddress("2480:1248::123:456")));"
+ errorLine2=" ~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/ConnectivityUtilsTest.java"
+ line="44"
+ column="21"/>
+ </issue>
+
+ <issue
+ id="NewApi"
message="Call requires API level R (current min is 29): `android.app.AppOpsManager#noteOp`"
errorLine1=" when(mMockAppOps.noteOp(AppOpsManager.OPSTR_WIFI_SCAN, mUid, TEST_PKG_NAME,"
errorLine2=" ~~~~~~">
@@ -36,6 +355,138 @@
<issue
id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#getDisplayTransport`"
+ errorLine1=" assertEquals(TRANSPORT_WIFI, getDisplayTransport(intArrayOf(TRANSPORT_WIFI)))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="53"
+ column="38"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#getDisplayTransport`"
+ errorLine1=" assertEquals(TRANSPORT_CELLULAR, getDisplayTransport(intArrayOf(TRANSPORT_CELLULAR)))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="54"
+ column="42"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#getDisplayTransport`"
+ errorLine1=" assertEquals(TRANSPORT_BLUETOOTH, getDisplayTransport(intArrayOf(TRANSPORT_BLUETOOTH)))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="55"
+ column="43"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#getDisplayTransport`"
+ errorLine1=" assertEquals(TRANSPORT_ETHERNET, getDisplayTransport(intArrayOf(TRANSPORT_ETHERNET)))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="56"
+ column="42"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#getDisplayTransport`"
+ errorLine1=" assertEquals(TRANSPORT_WIFI_AWARE, getDisplayTransport(intArrayOf(TRANSPORT_WIFI_AWARE)))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="57"
+ column="44"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#getDisplayTransport`"
+ errorLine1=" assertEquals(TRANSPORT_VPN, getDisplayTransport("
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="59"
+ column="37"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#getDisplayTransport`"
+ errorLine1=" assertEquals(TRANSPORT_VPN, getDisplayTransport("
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="61"
+ column="37"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#getDisplayTransport`"
+ errorLine1=" assertEquals(TRANSPORT_WIFI, getDisplayTransport("
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="64"
+ column="38"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#getDisplayTransport`"
+ errorLine1=" assertEquals(TRANSPORT_ETHERNET, getDisplayTransport("
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="66"
+ column="42"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#getDisplayTransport`"
+ errorLine1=" getDisplayTransport(intArrayOf())"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="70"
+ column="13"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#packBits`"
+ errorLine1=" assertEquals(packedBits, packBits(bits))"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="87"
+ column="34"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#unpackBits`"
+ errorLine1=" assertTrue(bits contentEquals unpackBits(packedBits))"
+ errorLine2=" ~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="88"
+ column="39"/>
+ </issue>
+
+ <issue
+ id="NewApi"
message="Call requires API level R (current min is 29): `android.net.NetworkCapabilities()`"
errorLine1=" val nc = NetworkCapabilities()"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
@@ -45,4 +496,147 @@
column="18"/>
</issue>
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#inferRestrictedCapability`"
+ errorLine1=" assertFalse(NetworkCapabilitiesUtils.inferRestrictedCapability(nc))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="95"
+ column="46"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#inferRestrictedCapability`"
+ errorLine1=" assertTrue(NetworkCapabilitiesUtils.inferRestrictedCapability(nc))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="99"
+ column="45"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#inferRestrictedCapability`"
+ errorLine1=" assertFalse(NetworkCapabilitiesUtils.inferRestrictedCapability(nc))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="104"
+ column="46"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkCapabilitiesUtils#inferRestrictedCapability`"
+ errorLine1=" assertTrue(NetworkCapabilitiesUtils.inferRestrictedCapability(nc))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkCapabilitiesUtilsTest.kt"
+ line="108"
+ column="45"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkIdentityUtils#scrubSubscriberId`"
+ errorLine1=" assertEquals("123456...", scrubSubscriberId("1234567890123"))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkIdentityUtilsTest.kt"
+ line="34"
+ column="35"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkIdentityUtils#scrubSubscriberId`"
+ errorLine1=" assertEquals("123456...", scrubSubscriberId("1234567"))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkIdentityUtilsTest.kt"
+ line="35"
+ column="35"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkIdentityUtils#scrubSubscriberId`"
+ errorLine1=" assertEquals("123...", scrubSubscriberId("123"))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkIdentityUtilsTest.kt"
+ line="36"
+ column="32"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkIdentityUtils#scrubSubscriberId`"
+ errorLine1=" assertEquals("...", scrubSubscriberId(""))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkIdentityUtilsTest.kt"
+ line="37"
+ column="29"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkIdentityUtils#scrubSubscriberId`"
+ errorLine1=" assertEquals("null", scrubSubscriberId(null))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkIdentityUtilsTest.kt"
+ line="38"
+ column="30"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkIdentityUtils#scrubSubscriberIds`"
+ errorLine1=" assertContainsStringsExactly(scrubSubscriberIds(arrayOf("1234567", "", null))!!,"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkIdentityUtilsTest.kt"
+ line="43"
+ column="38"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkIdentityUtils#scrubSubscriberIds`"
+ errorLine1=" assertContainsStringsExactly(scrubSubscriberIds(arrayOf("12345"))!!, "12345...")"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkIdentityUtilsTest.kt"
+ line="45"
+ column="38"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkIdentityUtils#scrubSubscriberIds`"
+ errorLine1=" assertContainsStringsExactly(scrubSubscriberIds(arrayOf())!!)"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkIdentityUtilsTest.kt"
+ line="46"
+ column="38"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 29): `com.android.net.module.util.NetworkIdentityUtils#scrubSubscriberIds`"
+ errorLine1=" assertNull(scrubSubscriberIds(null))"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/libs/net/common/tests/unit/src/com/android/net/module/util/NetworkIdentityUtilsTest.kt"
+ line="47"
+ column="20"/>
+ </issue>
+
</issues>
diff --git a/common/tests/unit/src/android/net/util/MacAddressUtilsTest.java b/common/tests/unit/src/android/net/util/MacAddressUtilsTest.java
index 8988571..66d89ff 100644
--- a/common/tests/unit/src/android/net/util/MacAddressUtilsTest.java
+++ b/common/tests/unit/src/android/net/util/MacAddressUtilsTest.java
@@ -33,8 +33,7 @@
public final class MacAddressUtilsTest {
// Matches WifiInfo.DEFAULT_MAC_ADDRESS
- private static final MacAddress DEFAULT_MAC_ADDRESS =
- MacAddress.fromString("02:00:00:00:00:00");
+ private static final String DEFAULT_MAC_ADDRESS = "02:00:00:00:00:00";
@Test
public void testIsMulticastAddress() {
diff --git a/common/tests/unit/src/android/net/util/NetUtilsTest.java b/common/tests/unit/src/android/net/util/NetUtilsTest.java
index d523e14..338d1c8 100644
--- a/common/tests/unit/src/android/net/util/NetUtilsTest.java
+++ b/common/tests/unit/src/android/net/util/NetUtilsTest.java
@@ -71,18 +71,18 @@
route = NetUtils.selectBestRoute(routes, v4_dest);
assertEquals(null, route);
- final RouteInfo v4_expected = new RouteInfo(new IpPrefix("75.208.8.0/24"),
+ final RouteInfo v4_expected = new RouteInfo(new IpPrefix("75.208.8.10/24"),
V4_GATEWAY, "wlan0");
routes.add(v4_expected);
- // "75.208.0.0/16" is not an expected result since it is not the longest prefix.
- routes.add(new RouteInfo(new IpPrefix("75.208.0.0/16"), V4_GATEWAY, "wlan0"));
- routes.add(new RouteInfo(new IpPrefix("75.208.7.0/24"), V4_GATEWAY, "wlan0"));
+ // "75.208.8.10/16" is not an expected result since it is not the longest prefix.
+ routes.add(new RouteInfo(new IpPrefix("75.208.8.10/16"), V4_GATEWAY, "wlan0"));
+ routes.add(new RouteInfo(new IpPrefix("75.208.7.32/24"), V4_GATEWAY, "wlan0"));
final RouteInfo v6_expected = new RouteInfo(new IpPrefix("2001:db8:cafe::/64"),
V6_GATEWAY, "wlan0");
routes.add(v6_expected);
- // "2001:db8::/32" is not an expected result since it is not the longest prefix.
- routes.add(new RouteInfo(new IpPrefix("2001:db8::/32"), V6_GATEWAY, "wlan0"));
+ // "2001:db8:cafe::123/32" is not an expected result since it is not the longest prefix.
+ routes.add(new RouteInfo(new IpPrefix("2001:db8:cafe::123/32"), V6_GATEWAY, "wlan0"));
routes.add(new RouteInfo(new IpPrefix("2001:db8:beef::/64"), V6_GATEWAY, "wlan0"));
// Verify expected v4 route is selected
diff --git a/common/tests/unit/src/com/android/net/module/util/CleanupTest.kt b/common/tests/unit/src/com/android/net/module/util/CleanupTest.kt
deleted file mode 100644
index f4a7d10..0000000
--- a/common/tests/unit/src/com/android/net/module/util/CleanupTest.kt
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util
-
-import android.util.Log
-import com.android.testutils.tryTest
-import kotlin.test.assertFailsWith
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
-import kotlin.test.fail
-
-private val TAG = CleanupTest::class.toString()
-
-@RunWith(JUnit4::class)
-class CleanupTest {
- class TestException1 : Exception()
- class TestException2 : Exception()
-
- @Test
- fun testNotThrow() {
- var x = 1
- tryTest {
- x = 2
- Log.e(TAG, "Do nothing")
- } cleanup {
- assert(x == 2)
- x = 3
- Log.e(TAG, "Do nothing")
- }
- assert(x == 3)
- }
-
- @Test
- fun testThrowTry() {
- var x = 1
- assertFailsWith<TestException1> {
- tryTest {
- x = 2
- throw TestException1()
- x = 4
- } cleanup {
- assert(x == 2)
- x = 3
- Log.e(TAG, "Do nothing")
- }
- }
- assert(x == 3)
- }
-
- @Test
- fun testThrowCleanup() {
- var x = 1
- assertFailsWith<TestException2> {
- tryTest {
- x = 2
- Log.e(TAG, "Do nothing")
- } cleanup {
- assert(x == 2)
- x = 3
- throw TestException2()
- x = 4
- }
- }
- assert(x == 3)
- }
-
- @Test
- fun testThrowBoth() {
- var x = 1
- try {
- tryTest {
- x = 2
- throw TestException1()
- x = 3
- } cleanup {
- assert(x == 2)
- x = 4
- throw TestException2()
- x = 5
- }
- fail("Expected failure with TestException1")
- } catch (e: TestException1) {
- assert(e.suppressedExceptions[0] is TestException2)
- }
- assert(x == 4)
- }
-}
diff --git a/common/tests/unit/src/com/android/net/module/util/CleanupTestJava.java b/common/tests/unit/src/com/android/net/module/util/CleanupTestJava.java
deleted file mode 100644
index ba4e679..0000000
--- a/common/tests/unit/src/com/android/net/module/util/CleanupTestJava.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util;
-
-import static com.android.testutils.Cleanup.testAndCleanup;
-import static com.android.testutils.MiscAsserts.assertThrows;
-
-import static org.junit.Assert.assertEquals;
-
-import android.util.Log;
-
-import org.junit.Test;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class CleanupTestJava {
- private static final String TAG = CleanupTestJava.class.getSimpleName();
- private static final class TestException1 extends Exception {}
- private static final class TestException2 extends Exception {}
-
- @Test
- public void testNotThrow() {
- final AtomicInteger x = new AtomicInteger(1);
- testAndCleanup(() -> {
- x.compareAndSet(1, 2);
- Log.e(TAG, "Do nothing");
- }, () -> {
- x.compareAndSet(2, 3);
- Log.e(TAG, "Do nothing");
- });
- assertEquals(3, x.get());
- }
-
- @Test
- public void testThrowTry() {
- final AtomicInteger x = new AtomicInteger(1);
- assertThrows(TestException1.class, () ->
- testAndCleanup(() -> {
- x.compareAndSet(1, 2);
- throw new TestException1();
- // Java refuses to call x.set(3) here because this line is unreachable
- }, () -> {
- x.compareAndSet(2, 3);
- Log.e(TAG, "Do nothing");
- })
- );
- assertEquals(3, x.get());
- }
-
- @Test
- public void testThrowCleanup() {
- final AtomicInteger x = new AtomicInteger(1);
- assertThrows(TestException2.class, () ->
- testAndCleanup(() -> {
- x.compareAndSet(1, 2);
- Log.e(TAG, "Do nothing");
- }, () -> {
- x.compareAndSet(2, 3);
- throw new TestException2();
- // Java refuses to call x.set(4) here because this line is unreachable
- })
- );
- assertEquals(3, x.get());
- }
-
- @Test
- public void testThrowBoth() {
- final AtomicInteger x = new AtomicInteger(1);
- assertThrows(TestException1.class, () ->
- testAndCleanup(() -> {
- x.compareAndSet(1, 2);
- throw new TestException1();
- }, () -> {
- x.compareAndSet(2, 3);
- throw new TestException2();
- })
- );
- assertEquals(3, x.get());
- }
-}
diff --git a/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt b/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt
index 96648a5..0886426 100644
--- a/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt
+++ b/common/tests/unit/src/com/android/net/module/util/CollectionUtilsTest.kt
@@ -61,20 +61,4 @@
assertTrue(CollectionUtils.all(listOf(1)) { true })
assertFalse(CollectionUtils.all(listOf(1)) { false })
}
-
- @Test
- fun testContains() {
- assertTrue(CollectionUtils.contains(shortArrayOf(10, 20, 30), 10))
- assertTrue(CollectionUtils.contains(shortArrayOf(10, 20, 30), 30))
- assertFalse(CollectionUtils.contains(shortArrayOf(10, 20, 30), 40))
- assertFalse(CollectionUtils.contains(null, 10.toShort()))
- assertTrue(CollectionUtils.contains(intArrayOf(10, 20, 30), 10))
- assertTrue(CollectionUtils.contains(intArrayOf(10, 20, 30), 30))
- assertFalse(CollectionUtils.contains(intArrayOf(10, 20, 30), 40))
- assertFalse(CollectionUtils.contains(null, 10.toInt()))
- assertTrue(CollectionUtils.contains(arrayOf("A", "B", "C"), "A"))
- assertTrue(CollectionUtils.contains(arrayOf("A", "B", "C"), "C"))
- assertFalse(CollectionUtils.contains(arrayOf("A", "B", "C"), "D"))
- assertFalse(CollectionUtils.contains(null, "A"))
- }
}
diff --git a/common/tests/unit/src/com/android/net/module/util/StructTest.java b/common/tests/unit/src/com/android/net/module/util/StructTest.java
index eabc14b..df74398 100644
--- a/common/tests/unit/src/com/android/net/module/util/StructTest.java
+++ b/common/tests/unit/src/com/android/net/module/util/StructTest.java
@@ -31,6 +31,7 @@
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
+import com.android.internal.util.HexDump;
import com.android.net.module.util.Struct.Field;
import com.android.net.module.util.Struct.Type;
diff --git a/common/tests/unit/src/com/android/net/module/util/netlink/ConntrackMessageTest.java b/common/tests/unit/src/com/android/net/module/util/netlink/ConntrackMessageTest.java
deleted file mode 100644
index cea763c..0000000
--- a/common/tests/unit/src/com/android/net/module/util/netlink/ConntrackMessageTest.java
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static com.android.net.module.util.netlink.NetlinkConstants.IPCTNL_MSG_CT_NEW;
-import static com.android.net.module.util.netlink.NetlinkConstants.NFNL_SUBSYS_CTNETLINK;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
-
-import android.system.OsConstants;
-
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import libcore.util.HexEncoding;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Arrays;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class ConntrackMessageTest {
- private static final boolean USING_LE = (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN);
-
- private short makeCtType(short msgType) {
- return (short) (NFNL_SUBSYS_CTNETLINK << 8 | (byte) msgType);
- }
-
- // Example 1: TCP (192.168.43.209, 44333) -> (23.211.13.26, 443)
- public static final String CT_V4UPDATE_TCP_HEX =
- // struct nlmsghdr
- "50000000" + // length = 80
- "0001" + // type = (1 << 8) | 0
- "0501" + // flags
- "01000000" + // seqno = 1
- "00000000" + // pid = 0
- // struct nfgenmsg
- "02" + // nfgen_family = AF_INET
- "00" + // version = NFNETLINK_V0
- "0000" + // res_id
- // struct nlattr
- "3400" + // nla_len = 52
- "0180" + // nla_type = nested CTA_TUPLE_ORIG
- // struct nlattr
- "1400" + // nla_len = 20
- "0180" + // nla_type = nested CTA_TUPLE_IP
- "0800 0100 C0A82BD1" + // nla_type=CTA_IP_V4_SRC, ip=192.168.43.209
- "0800 0200 17D30D1A" + // nla_type=CTA_IP_V4_DST, ip=23.211.13.26
- // struct nlattr
- "1C00" + // nla_len = 28
- "0280" + // nla_type = nested CTA_TUPLE_PROTO
- "0500 0100 06 000000" + // nla_type=CTA_PROTO_NUM, proto=6
- "0600 0200 AD2D 0000" + // nla_type=CTA_PROTO_SRC_PORT, port=44333 (big endian)
- "0600 0300 01BB 0000" + // nla_type=CTA_PROTO_DST_PORT, port=443 (big endian)
- // struct nlattr
- "0800" + // nla_len = 8
- "0700" + // nla_type = CTA_TIMEOUT
- "00069780"; // nla_value = 432000 (big endian)
- public static final byte[] CT_V4UPDATE_TCP_BYTES =
- HexEncoding.decode(CT_V4UPDATE_TCP_HEX.replaceAll(" ", "").toCharArray(), false);
-
- private byte[] makeIPv4TimeoutUpdateRequestTcp() throws Exception {
- return ConntrackMessage.newIPv4TimeoutUpdateRequest(
- OsConstants.IPPROTO_TCP,
- (Inet4Address) InetAddress.getByName("192.168.43.209"), 44333,
- (Inet4Address) InetAddress.getByName("23.211.13.26"), 443,
- 432000);
- }
-
- // Example 2: UDP (100.96.167.146, 37069) -> (216.58.197.10, 443)
- public static final String CT_V4UPDATE_UDP_HEX =
- // struct nlmsghdr
- "50000000" + // length = 80
- "0001" + // type = (1 << 8) | 0
- "0501" + // flags
- "01000000" + // seqno = 1
- "00000000" + // pid = 0
- // struct nfgenmsg
- "02" + // nfgen_family = AF_INET
- "00" + // version = NFNETLINK_V0
- "0000" + // res_id
- // struct nlattr
- "3400" + // nla_len = 52
- "0180" + // nla_type = nested CTA_TUPLE_ORIG
- // struct nlattr
- "1400" + // nla_len = 20
- "0180" + // nla_type = nested CTA_TUPLE_IP
- "0800 0100 6460A792" + // nla_type=CTA_IP_V4_SRC, ip=100.96.167.146
- "0800 0200 D83AC50A" + // nla_type=CTA_IP_V4_DST, ip=216.58.197.10
- // struct nlattr
- "1C00" + // nla_len = 28
- "0280" + // nla_type = nested CTA_TUPLE_PROTO
- "0500 0100 11 000000" + // nla_type=CTA_PROTO_NUM, proto=17
- "0600 0200 90CD 0000" + // nla_type=CTA_PROTO_SRC_PORT, port=37069 (big endian)
- "0600 0300 01BB 0000" + // nla_type=CTA_PROTO_DST_PORT, port=443 (big endian)
- // struct nlattr
- "0800" + // nla_len = 8
- "0700" + // nla_type = CTA_TIMEOUT
- "000000B4"; // nla_value = 180 (big endian)
- public static final byte[] CT_V4UPDATE_UDP_BYTES =
- HexEncoding.decode(CT_V4UPDATE_UDP_HEX.replaceAll(" ", "").toCharArray(), false);
-
- private byte[] makeIPv4TimeoutUpdateRequestUdp() throws Exception {
- return ConntrackMessage.newIPv4TimeoutUpdateRequest(
- OsConstants.IPPROTO_UDP,
- (Inet4Address) InetAddress.getByName("100.96.167.146"), 37069,
- (Inet4Address) InetAddress.getByName("216.58.197.10"), 443,
- 180);
- }
-
- @Test
- public void testConntrackMakeIPv4TcpTimeoutUpdate() throws Exception {
- assumeTrue(USING_LE);
-
- final byte[] tcp = makeIPv4TimeoutUpdateRequestTcp();
- assertArrayEquals(CT_V4UPDATE_TCP_BYTES, tcp);
- }
-
- @Test
- public void testConntrackParseIPv4TcpTimeoutUpdate() throws Exception {
- assumeTrue(USING_LE);
-
- final byte[] tcp = makeIPv4TimeoutUpdateRequestTcp();
- final ByteBuffer byteBuffer = ByteBuffer.wrap(tcp);
- byteBuffer.order(ByteOrder.nativeOrder());
- final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer, OsConstants.NETLINK_NETFILTER);
- assertNotNull(msg);
- assertTrue(msg instanceof ConntrackMessage);
- final ConntrackMessage conntrackMessage = (ConntrackMessage) msg;
-
- final StructNlMsgHdr hdr = conntrackMessage.getHeader();
- assertNotNull(hdr);
- assertEquals(80, hdr.nlmsg_len);
- assertEquals(makeCtType(IPCTNL_MSG_CT_NEW), hdr.nlmsg_type);
- assertEquals((short) (StructNlMsgHdr.NLM_F_REPLACE | StructNlMsgHdr.NLM_F_REQUEST
- | StructNlMsgHdr.NLM_F_ACK), hdr.nlmsg_flags);
- assertEquals(1, hdr.nlmsg_seq);
- assertEquals(0, hdr.nlmsg_pid);
-
- final StructNfGenMsg nfmsgHdr = conntrackMessage.nfGenMsg;
- assertNotNull(nfmsgHdr);
- assertEquals((byte) OsConstants.AF_INET, nfmsgHdr.nfgen_family);
- assertEquals((byte) StructNfGenMsg.NFNETLINK_V0, nfmsgHdr.version);
- assertEquals((short) 0, nfmsgHdr.res_id);
-
- assertEquals(InetAddress.parseNumericAddress("192.168.43.209"),
- conntrackMessage.tupleOrig.srcIp);
- assertEquals(InetAddress.parseNumericAddress("23.211.13.26"),
- conntrackMessage.tupleOrig.dstIp);
- assertEquals((byte) OsConstants.IPPROTO_TCP, conntrackMessage.tupleOrig.protoNum);
- assertEquals((short) 44333, conntrackMessage.tupleOrig.srcPort);
- assertEquals((short) 443, conntrackMessage.tupleOrig.dstPort);
-
- assertNull(conntrackMessage.tupleReply);
-
- assertEquals(0 /* absent */, conntrackMessage.status);
- assertEquals(432000, conntrackMessage.timeoutSec);
- }
-
- @Test
- public void testConntrackMakeIPv4UdpTimeoutUpdate() throws Exception {
- assumeTrue(USING_LE);
-
- final byte[] udp = makeIPv4TimeoutUpdateRequestUdp();
- assertArrayEquals(CT_V4UPDATE_UDP_BYTES, udp);
- }
-
- @Test
- public void testConntrackParseIPv4UdpTimeoutUpdate() throws Exception {
- assumeTrue(USING_LE);
-
- final byte[] udp = makeIPv4TimeoutUpdateRequestUdp();
- final ByteBuffer byteBuffer = ByteBuffer.wrap(udp);
- byteBuffer.order(ByteOrder.nativeOrder());
- final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer, OsConstants.NETLINK_NETFILTER);
- assertNotNull(msg);
- assertTrue(msg instanceof ConntrackMessage);
- final ConntrackMessage conntrackMessage = (ConntrackMessage) msg;
-
- final StructNlMsgHdr hdr = conntrackMessage.getHeader();
- assertNotNull(hdr);
- assertEquals(80, hdr.nlmsg_len);
- assertEquals(makeCtType(IPCTNL_MSG_CT_NEW), hdr.nlmsg_type);
- assertEquals((short) (StructNlMsgHdr.NLM_F_REPLACE | StructNlMsgHdr.NLM_F_REQUEST
- | StructNlMsgHdr.NLM_F_ACK), hdr.nlmsg_flags);
- assertEquals(1, hdr.nlmsg_seq);
- assertEquals(0, hdr.nlmsg_pid);
-
- final StructNfGenMsg nfmsgHdr = conntrackMessage.nfGenMsg;
- assertNotNull(nfmsgHdr);
- assertEquals((byte) OsConstants.AF_INET, nfmsgHdr.nfgen_family);
- assertEquals((byte) StructNfGenMsg.NFNETLINK_V0, nfmsgHdr.version);
- assertEquals((short) 0, nfmsgHdr.res_id);
-
- assertEquals(InetAddress.parseNumericAddress("100.96.167.146"),
- conntrackMessage.tupleOrig.srcIp);
- assertEquals(InetAddress.parseNumericAddress("216.58.197.10"),
- conntrackMessage.tupleOrig.dstIp);
- assertEquals((byte) OsConstants.IPPROTO_UDP, conntrackMessage.tupleOrig.protoNum);
- assertEquals((short) 37069, conntrackMessage.tupleOrig.srcPort);
- assertEquals((short) 443, conntrackMessage.tupleOrig.dstPort);
-
- assertNull(conntrackMessage.tupleReply);
-
- assertEquals(0 /* absent */, conntrackMessage.status);
- assertEquals(180, conntrackMessage.timeoutSec);
- }
-
- public static final String CT_V4NEW_TCP_HEX =
- // CHECKSTYLE:OFF IndentationCheck
- // struct nlmsghdr
- "8C000000" + // length = 140
- "0001" + // type = NFNL_SUBSYS_CTNETLINK (1) << 8 | IPCTNL_MSG_CT_NEW (0)
- "0006" + // flags = NLM_F_CREATE (1 << 10) | NLM_F_EXCL (1 << 9)
- "00000000" + // seqno = 0
- "00000000" + // pid = 0
- // struct nfgenmsg
- "02" + // nfgen_family = AF_INET
- "00" + // version = NFNETLINK_V0
- "1234" + // res_id = 0x1234 (big endian)
- // struct nlattr
- "3400" + // nla_len = 52
- "0180" + // nla_type = nested CTA_TUPLE_ORIG
- // struct nlattr
- "1400" + // nla_len = 20
- "0180" + // nla_type = nested CTA_TUPLE_IP
- "0800 0100 C0A8500C" + // nla_type=CTA_IP_V4_SRC, ip=192.168.80.12
- "0800 0200 8C700874" + // nla_type=CTA_IP_V4_DST, ip=140.112.8.116
- // struct nlattr
- "1C00" + // nla_len = 28
- "0280" + // nla_type = nested CTA_TUPLE_PROTO
- "0500 0100 06 000000" + // nla_type=CTA_PROTO_NUM, proto=IPPROTO_TCP (6)
- "0600 0200 F3F1 0000" + // nla_type=CTA_PROTO_SRC_PORT, port=62449 (big endian)
- "0600 0300 01BB 0000" + // nla_type=CTA_PROTO_DST_PORT, port=443 (big endian)
- // struct nlattr
- "3400" + // nla_len = 52
- "0280" + // nla_type = nested CTA_TUPLE_REPLY
- // struct nlattr
- "1400" + // nla_len = 20
- "0180" + // nla_type = nested CTA_TUPLE_IP
- "0800 0100 8C700874" + // nla_type=CTA_IP_V4_SRC, ip=140.112.8.116
- "0800 0200 6451B301" + // nla_type=CTA_IP_V4_DST, ip=100.81.179.1
- // struct nlattr
- "1C00" + // nla_len = 28
- "0280" + // nla_type = nested CTA_TUPLE_PROTO
- "0500 0100 06 000000" + // nla_type=CTA_PROTO_NUM, proto=IPPROTO_TCP (6)
- "0600 0200 01BB 0000" + // nla_type=CTA_PROTO_SRC_PORT, port=443 (big endian)
- "0600 0300 F3F1 0000" + // nla_type=CTA_PROTO_DST_PORT, port=62449 (big endian)
- // struct nlattr
- "0800" + // nla_len = 8
- "0300" + // nla_type = CTA_STATUS
- "00000198" + // nla_value = 0b110011000 (big endian)
- // IPS_CONFIRMED (1 << 3) | IPS_SRC_NAT (1 << 4) |
- // IPS_SRC_NAT_DONE (1 << 7) | IPS_DST_NAT_DONE (1 << 8)
- // struct nlattr
- "0800" + // nla_len = 8
- "0700" + // nla_type = CTA_TIMEOUT
- "00000078"; // nla_value = 120 (big endian)
- // CHECKSTYLE:ON IndentationCheck
- public static final byte[] CT_V4NEW_TCP_BYTES =
- HexEncoding.decode(CT_V4NEW_TCP_HEX.replaceAll(" ", "").toCharArray(), false);
-
- @Test
- public void testParseCtNew() {
- assumeTrue(USING_LE);
-
- final ByteBuffer byteBuffer = ByteBuffer.wrap(CT_V4NEW_TCP_BYTES);
- byteBuffer.order(ByteOrder.nativeOrder());
- final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer, OsConstants.NETLINK_NETFILTER);
- assertNotNull(msg);
- assertTrue(msg instanceof ConntrackMessage);
- final ConntrackMessage conntrackMessage = (ConntrackMessage) msg;
-
- final StructNlMsgHdr hdr = conntrackMessage.getHeader();
- assertNotNull(hdr);
- assertEquals(140, hdr.nlmsg_len);
- assertEquals(makeCtType(IPCTNL_MSG_CT_NEW), hdr.nlmsg_type);
- assertEquals((short) (StructNlMsgHdr.NLM_F_CREATE | StructNlMsgHdr.NLM_F_EXCL),
- hdr.nlmsg_flags);
- assertEquals(0, hdr.nlmsg_seq);
- assertEquals(0, hdr.nlmsg_pid);
-
- final StructNfGenMsg nfmsgHdr = conntrackMessage.nfGenMsg;
- assertNotNull(nfmsgHdr);
- assertEquals((byte) OsConstants.AF_INET, nfmsgHdr.nfgen_family);
- assertEquals((byte) StructNfGenMsg.NFNETLINK_V0, nfmsgHdr.version);
- assertEquals((short) 0x1234, nfmsgHdr.res_id);
-
- assertEquals(InetAddress.parseNumericAddress("192.168.80.12"),
- conntrackMessage.tupleOrig.srcIp);
- assertEquals(InetAddress.parseNumericAddress("140.112.8.116"),
- conntrackMessage.tupleOrig.dstIp);
- assertEquals((byte) OsConstants.IPPROTO_TCP, conntrackMessage.tupleOrig.protoNum);
- assertEquals((short) 62449, conntrackMessage.tupleOrig.srcPort);
- assertEquals((short) 443, conntrackMessage.tupleOrig.dstPort);
-
- assertEquals(InetAddress.parseNumericAddress("140.112.8.116"),
- conntrackMessage.tupleReply.srcIp);
- assertEquals(InetAddress.parseNumericAddress("100.81.179.1"),
- conntrackMessage.tupleReply.dstIp);
- assertEquals((byte) OsConstants.IPPROTO_TCP, conntrackMessage.tupleReply.protoNum);
- assertEquals((short) 443, conntrackMessage.tupleReply.srcPort);
- assertEquals((short) 62449, conntrackMessage.tupleReply.dstPort);
-
- assertEquals(0x198, conntrackMessage.status);
- assertEquals(120, conntrackMessage.timeoutSec);
- }
-
- @Test
- public void testParseTruncation() {
- assumeTrue(USING_LE);
-
- // Expect no crash while parsing the truncated message which has been truncated to every
- // length between 0 and its full length - 1.
- for (int len = 0; len < CT_V4NEW_TCP_BYTES.length; len++) {
- final byte[] truncated = Arrays.copyOfRange(CT_V4NEW_TCP_BYTES, 0, len);
-
- final ByteBuffer byteBuffer = ByteBuffer.wrap(truncated);
- byteBuffer.order(ByteOrder.nativeOrder());
- final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer,
- OsConstants.NETLINK_NETFILTER);
- }
- }
-
- @Test
- public void testParseTruncationWithInvalidByte() {
- assumeTrue(USING_LE);
-
- // Expect no crash while parsing the message which is truncated by invalid bytes. The
- // message has been truncated to every length between 0 and its full length - 1.
- for (byte invalid : new byte[]{(byte) 0x00, (byte) 0xff}) {
- for (int len = 0; len < CT_V4NEW_TCP_BYTES.length; len++) {
- final byte[] truncated = new byte[CT_V4NEW_TCP_BYTES.length];
- Arrays.fill(truncated, (byte) invalid);
- System.arraycopy(CT_V4NEW_TCP_BYTES, 0, truncated, 0, len);
-
- final ByteBuffer byteBuffer = ByteBuffer.wrap(truncated);
- byteBuffer.order(ByteOrder.nativeOrder());
- final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer,
- OsConstants.NETLINK_NETFILTER);
- }
- }
- }
-
- // Malformed conntrack messages.
- public static final String CT_MALFORMED_HEX =
- // CHECKSTYLE:OFF IndentationCheck
- // <-- nlmsghr -->|<-nfgenmsg->|<-- CTA_TUPLE_ORIG -->|
- // CTA_TUPLE_ORIG has no nla_value.
- "18000000 0001 0006 00000000 00000000 02 00 0000 0400 0180"
- // nested CTA_TUPLE_IP has no nla_value.
- + "1C000000 0001 0006 00000000 00000000 02 00 0000 0800 0180 0400 0180"
- // nested CTA_IP_V4_SRC has no nla_value.
- + "20000000 0001 0006 00000000 00000000 02 00 0000 0C00 0180 0800 0180 0400 0100"
- // nested CTA_TUPLE_PROTO has no nla_value.
- // <-- nlmsghr -->|<-nfgenmsg->|<-- CTA_TUPLE_ORIG
- + "30000000 0001 0006 00000000 00000000 02 00 0000 1C00 0180 1400 0180 0800 0100"
- // -->|
- + "C0A8500C 0800 0200 8C700874 0400 0280";
- // CHECKSTYLE:ON IndentationCheck
- public static final byte[] CT_MALFORMED_BYTES =
- HexEncoding.decode(CT_MALFORMED_HEX.replaceAll(" ", "").toCharArray(), false);
-
- @Test
- public void testParseMalformation() {
- assumeTrue(USING_LE);
-
- final ByteBuffer byteBuffer = ByteBuffer.wrap(CT_MALFORMED_BYTES);
- byteBuffer.order(ByteOrder.nativeOrder());
-
- // Expect no crash while parsing the malformed message.
- int messageCount = 0;
- while (byteBuffer.remaining() > 0) {
- final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer,
- OsConstants.NETLINK_NETFILTER);
- messageCount++;
- }
- assertEquals(4, messageCount);
- }
-
- @Test
- public void testToString() {
- assumeTrue(USING_LE);
-
- final ByteBuffer byteBuffer = ByteBuffer.wrap(CT_V4NEW_TCP_BYTES);
- byteBuffer.order(ByteOrder.nativeOrder());
- final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer, OsConstants.NETLINK_NETFILTER);
- assertNotNull(msg);
- assertTrue(msg instanceof ConntrackMessage);
- final ConntrackMessage conntrackMessage = (ConntrackMessage) msg;
-
- // Bug: "nlmsg_flags{1536(NLM_F_MATCH))" is not correct because StructNlMsgHdr
- // #stringForNlMsgFlags can't convert all flags (ex: NLM_F_CREATE) and can't distinguish
- // the flags which have the same value (ex: NLM_F_MATCH <0x200> and NLM_F_EXCL <0x200>).
- // The flags output string should be "NLM_F_CREATE|NLM_F_EXCL" in this case.
- // TODO: correct the flag converted string once #stringForNlMsgFlags does.
- final String expected = ""
- + "ConntrackMessage{"
- + "nlmsghdr{StructNlMsgHdr{ nlmsg_len{140}, nlmsg_type{256(IPCTNL_MSG_CT_NEW)}, "
- + "nlmsg_flags{1536(NLM_F_MATCH))}, nlmsg_seq{0}, nlmsg_pid{0} }}, "
- + "nfgenmsg{NfGenMsg{ nfgen_family{AF_INET}, version{0}, res_id{4660} }}, "
- + "tuple_orig{Tuple{IPPROTO_TCP: 192.168.80.12:62449 -> 140.112.8.116:443}}, "
- + "tuple_reply{Tuple{IPPROTO_TCP: 140.112.8.116:443 -> 100.81.179.1:62449}}, "
- + "status{408(IPS_CONFIRMED|IPS_SRC_NAT|IPS_SRC_NAT_DONE|IPS_DST_NAT_DONE)}, "
- + "timeout_sec{120}}";
- assertEquals(expected, conntrackMessage.toString());
- }
-}
diff --git a/common/tests/unit/src/com/android/net/module/util/netlink/InetDiagSocketTest.java b/common/tests/unit/src/com/android/net/module/util/netlink/InetDiagSocketTest.java
deleted file mode 100644
index 6b1482d..0000000
--- a/common/tests/unit/src/com/android/net/module/util/netlink/InetDiagSocketTest.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static android.system.OsConstants.AF_INET;
-import static android.system.OsConstants.AF_INET6;
-import static android.system.OsConstants.IPPROTO_TCP;
-import static android.system.OsConstants.IPPROTO_UDP;
-import static android.system.OsConstants.NETLINK_INET_DIAG;
-
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_DUMP;
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REQUEST;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import libcore.util.HexEncoding;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class InetDiagSocketTest {
- // Hexadecimal representation of InetDiagReqV2 request.
- private static final String INET_DIAG_REQ_V2_UDP_INET4_HEX =
- // struct nlmsghdr
- "48000000" + // length = 72
- "1400" + // type = SOCK_DIAG_BY_FAMILY
- "0103" + // flags = NLM_F_REQUEST | NLM_F_DUMP
- "00000000" + // seqno
- "00000000" + // pid (0 == kernel)
- // struct inet_diag_req_v2
- "02" + // family = AF_INET
- "11" + // protcol = IPPROTO_UDP
- "00" + // idiag_ext
- "00" + // pad
- "ffffffff" + // idiag_states
- // inet_diag_sockid
- "a5de" + // idiag_sport = 42462
- "b971" + // idiag_dport = 47473
- "0a006402000000000000000000000000" + // idiag_src = 10.0.100.2
- "08080808000000000000000000000000" + // idiag_dst = 8.8.8.8
- "00000000" + // idiag_if
- "ffffffffffffffff"; // idiag_cookie = INET_DIAG_NOCOOKIE
- private static final byte[] INET_DIAG_REQ_V2_UDP_INET4_BYTES =
- HexEncoding.decode(INET_DIAG_REQ_V2_UDP_INET4_HEX.toCharArray(), false);
-
- @Test
- public void testInetDiagReqV2UdpInet4() throws Exception {
- InetSocketAddress local = new InetSocketAddress(InetAddress.getByName("10.0.100.2"),
- 42462);
- InetSocketAddress remote = new InetSocketAddress(InetAddress.getByName("8.8.8.8"),
- 47473);
- final byte[] msg = InetDiagMessage.inetDiagReqV2(IPPROTO_UDP, local, remote, AF_INET,
- (short) (NLM_F_REQUEST | NLM_F_DUMP));
- assertArrayEquals(INET_DIAG_REQ_V2_UDP_INET4_BYTES, msg);
- }
-
- // Hexadecimal representation of InetDiagReqV2 request.
- private static final String INET_DIAG_REQ_V2_TCP_INET6_HEX =
- // struct nlmsghdr
- "48000000" + // length = 72
- "1400" + // type = SOCK_DIAG_BY_FAMILY
- "0100" + // flags = NLM_F_REQUEST
- "00000000" + // seqno
- "00000000" + // pid (0 == kernel)
- // struct inet_diag_req_v2
- "0a" + // family = AF_INET6
- "06" + // protcol = IPPROTO_TCP
- "00" + // idiag_ext
- "00" + // pad
- "ffffffff" + // idiag_states
- // inet_diag_sockid
- "a5de" + // idiag_sport = 42462
- "b971" + // idiag_dport = 47473
- "fe8000000000000086c9b2fffe6aed4b" + // idiag_src = fe80::86c9:b2ff:fe6a:ed4b
- "08080808000000000000000000000000" + // idiag_dst = 8.8.8.8
- "00000000" + // idiag_if
- "ffffffffffffffff"; // idiag_cookie = INET_DIAG_NOCOOKIE
- private static final byte[] INET_DIAG_REQ_V2_TCP_INET6_BYTES =
- HexEncoding.decode(INET_DIAG_REQ_V2_TCP_INET6_HEX.toCharArray(), false);
-
- @Test
- public void testInetDiagReqV2TcpInet6() throws Exception {
- InetSocketAddress local = new InetSocketAddress(
- InetAddress.getByName("fe80::86c9:b2ff:fe6a:ed4b"), 42462);
- InetSocketAddress remote = new InetSocketAddress(InetAddress.getByName("8.8.8.8"),
- 47473);
- byte[] msg = InetDiagMessage.inetDiagReqV2(IPPROTO_TCP, local, remote, AF_INET6,
- NLM_F_REQUEST);
-
- assertArrayEquals(INET_DIAG_REQ_V2_TCP_INET6_BYTES, msg);
- }
-
- // Hexadecimal representation of InetDiagReqV2 request with extension, INET_DIAG_INFO.
- private static final String INET_DIAG_REQ_V2_TCP_INET_INET_DIAG_HEX =
- // struct nlmsghdr
- "48000000" + // length = 72
- "1400" + // type = SOCK_DIAG_BY_FAMILY
- "0100" + // flags = NLM_F_REQUEST
- "00000000" + // seqno
- "00000000" + // pid (0 == kernel)
- // struct inet_diag_req_v2
- "02" + // family = AF_INET
- "06" + // protcol = IPPROTO_TCP
- "02" + // idiag_ext = INET_DIAG_INFO
- "00" + // pad
- "ffffffff" + // idiag_states
- // inet_diag_sockid
- "3039" + // idiag_sport = 12345
- "d431" + // idiag_dport = 54321
- "01020304000000000000000000000000" + // idiag_src = 1.2.3.4
- "08080404000000000000000000000000" + // idiag_dst = 8.8.4.4
- "00000000" + // idiag_if
- "ffffffffffffffff"; // idiag_cookie = INET_DIAG_NOCOOKIE
-
- private static final byte[] INET_DIAG_REQ_V2_TCP_INET_INET_DIAG_BYTES =
- HexEncoding.decode(INET_DIAG_REQ_V2_TCP_INET_INET_DIAG_HEX.toCharArray(), false);
- private static final int TCP_ALL_STATES = 0xffffffff;
- @Test
- public void testInetDiagReqV2TcpInetWithExt() throws Exception {
- InetSocketAddress local = new InetSocketAddress(
- InetAddress.getByName("1.2.3.4"), 12345);
- InetSocketAddress remote = new InetSocketAddress(InetAddress.getByName("8.8.4.4"),
- 54321);
- byte[] msg = InetDiagMessage.inetDiagReqV2(IPPROTO_TCP, local, remote, AF_INET,
- NLM_F_REQUEST, 0 /* pad */, 2 /* idiagExt */, TCP_ALL_STATES);
-
- assertArrayEquals(INET_DIAG_REQ_V2_TCP_INET_INET_DIAG_BYTES, msg);
-
- local = new InetSocketAddress(
- InetAddress.getByName("fe80::86c9:b2ff:fe6a:ed4b"), 42462);
- remote = new InetSocketAddress(InetAddress.getByName("8.8.8.8"),
- 47473);
- msg = InetDiagMessage.inetDiagReqV2(IPPROTO_TCP, local, remote, AF_INET6,
- NLM_F_REQUEST, 0 /* pad */, 0 /* idiagExt */, TCP_ALL_STATES);
-
- assertArrayEquals(INET_DIAG_REQ_V2_TCP_INET6_BYTES, msg);
- }
-
- // Hexadecimal representation of InetDiagReqV2 request with no socket specified.
- private static final String INET_DIAG_REQ_V2_TCP_INET6_NO_ID_SPECIFIED_HEX =
- // struct nlmsghdr
- "48000000" + // length = 72
- "1400" + // type = SOCK_DIAG_BY_FAMILY
- "0100" + // flags = NLM_F_REQUEST
- "00000000" + // seqno
- "00000000" + // pid (0 == kernel)
- // struct inet_diag_req_v2
- "0a" + // family = AF_INET6
- "06" + // protcol = IPPROTO_TCP
- "00" + // idiag_ext
- "00" + // pad
- "ffffffff" + // idiag_states
- // inet_diag_sockid
- "0000" + // idiag_sport
- "0000" + // idiag_dport
- "00000000000000000000000000000000" + // idiag_src
- "00000000000000000000000000000000" + // idiag_dst
- "00000000" + // idiag_if
- "0000000000000000"; // idiag_cookie
-
- private static final byte[] INET_DIAG_REQ_V2_TCP_INET6_NO_ID_SPECIFIED_BYTES =
- HexEncoding.decode(INET_DIAG_REQ_V2_TCP_INET6_NO_ID_SPECIFIED_HEX.toCharArray(), false);
-
- @Test
- public void testInetDiagReqV2TcpInet6NoIdSpecified() throws Exception {
- InetSocketAddress local = new InetSocketAddress(
- InetAddress.getByName("fe80::fe6a:ed4b"), 12345);
- InetSocketAddress remote = new InetSocketAddress(InetAddress.getByName("8.8.4.4"),
- 54321);
- // Verify no socket specified if either local or remote socket address is null.
- byte[] msgExt = InetDiagMessage.inetDiagReqV2(IPPROTO_TCP, null, null, AF_INET6,
- NLM_F_REQUEST, 0 /* pad */, 0 /* idiagExt */, TCP_ALL_STATES);
- byte[] msg;
- try {
- msg = InetDiagMessage.inetDiagReqV2(IPPROTO_TCP, null, remote, AF_INET6,
- NLM_F_REQUEST);
- fail("Both remote and local should be null, expected UnknownHostException");
- } catch (NullPointerException e) {
- }
-
- try {
- msg = InetDiagMessage.inetDiagReqV2(IPPROTO_TCP, local, null, AF_INET6,
- NLM_F_REQUEST, 0 /* pad */, 0 /* idiagExt */, TCP_ALL_STATES);
- fail("Both remote and local should be null, expected UnknownHostException");
- } catch (NullPointerException e) {
- }
-
- msg = InetDiagMessage.inetDiagReqV2(IPPROTO_TCP, null, null, AF_INET6,
- NLM_F_REQUEST, 0 /* pad */, 0 /* idiagExt */, TCP_ALL_STATES);
- assertArrayEquals(INET_DIAG_REQ_V2_TCP_INET6_NO_ID_SPECIFIED_BYTES, msg);
- assertArrayEquals(INET_DIAG_REQ_V2_TCP_INET6_NO_ID_SPECIFIED_BYTES, msgExt);
- }
-
- // Hexadecimal representation of InetDiagReqV2 request.
- private static final String INET_DIAG_MSG_HEX =
- // struct nlmsghdr
- "58000000" + // length = 88
- "1400" + // type = SOCK_DIAG_BY_FAMILY
- "0200" + // flags = NLM_F_MULTI
- "00000000" + // seqno
- "f5220000" + // pid (0 == kernel)
- // struct inet_diag_msg
- "0a" + // family = AF_INET6
- "01" + // idiag_state
- "00" + // idiag_timer
- "00" + // idiag_retrans
- // inet_diag_sockid
- "a817" + // idiag_sport = 43031
- "960f" + // idiag_dport = 38415
- "fe8000000000000086c9b2fffe6aed4b" + // idiag_src = fe80::86c9:b2ff:fe6a:ed4b
- "00000000000000000000ffff08080808" + // idiag_dst = 8.8.8.8
- "00000000" + // idiag_if
- "ffffffffffffffff" + // idiag_cookie = INET_DIAG_NOCOOKIE
- "00000000" + // idiag_expires
- "00000000" + // idiag_rqueue
- "00000000" + // idiag_wqueue
- "a3270000" + // idiag_uid
- "A57E1900"; // idiag_inode
- private static final byte[] INET_DIAG_MSG_BYTES =
- HexEncoding.decode(INET_DIAG_MSG_HEX.toCharArray(), false);
-
- @Test
- public void testParseInetDiagResponse() throws Exception {
- final ByteBuffer byteBuffer = ByteBuffer.wrap(INET_DIAG_MSG_BYTES);
- byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
- final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer, NETLINK_INET_DIAG);
- assertNotNull(msg);
-
- assertTrue(msg instanceof InetDiagMessage);
- final InetDiagMessage inetDiagMsg = (InetDiagMessage) msg;
- assertEquals(10147, inetDiagMsg.mStructInetDiagMsg.idiag_uid);
-
- final StructNlMsgHdr hdr = inetDiagMsg.getHeader();
- assertNotNull(hdr);
- assertEquals(NetlinkConstants.SOCK_DIAG_BY_FAMILY, hdr.nlmsg_type);
- assertEquals(StructNlMsgHdr.NLM_F_MULTI, hdr.nlmsg_flags);
- assertEquals(0, hdr.nlmsg_seq);
- assertEquals(8949, hdr.nlmsg_pid);
- }
-}
diff --git a/common/tests/unit/src/com/android/net/module/util/netlink/NduseroptMessageTest.java b/common/tests/unit/src/com/android/net/module/util/netlink/NduseroptMessageTest.java
deleted file mode 100644
index 4fc5ec2..0000000
--- a/common/tests/unit/src/com/android/net/module/util/netlink/NduseroptMessageTest.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static android.net.InetAddresses.parseNumericAddress;
-import static android.system.OsConstants.AF_INET6;
-import static android.system.OsConstants.NETLINK_ROUTE;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import android.net.InetAddresses;
-import android.net.IpPrefix;
-
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import libcore.util.HexEncoding;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class NduseroptMessageTest {
-
- private static final byte ICMP_TYPE_RA = (byte) 134;
-
- private static final int IFINDEX1 = 15715755;
- private static final int IFINDEX2 = 1431655765;
-
- // IPv6, 0 bytes of options, interface index 15715755, type 134 (RA), code 0, padding.
- private static final String HDR_EMPTY = "0a00" + "0000" + "abcdef00" + "8600000000000000";
-
- // IPv6, 16 bytes of options, interface index 1431655765, type 134 (RA), code 0, padding.
- private static final String HDR_16BYTE = "0a00" + "1000" + "55555555" + "8600000000000000";
-
- // IPv6, 32 bytes of options, interface index 1431655765, type 134 (RA), code 0, padding.
- private static final String HDR_32BYTE = "0a00" + "2000" + "55555555" + "8600000000000000";
-
- // PREF64 option, 2001:db8:3:4:5:6::/96, lifetime=10064
- private static final String OPT_PREF64 = "2602" + "2750" + "20010db80003000400050006";
-
- // Length 20, NDUSEROPT_SRCADDR, fe80:2:3:4:5:6:7:8
- private static final String NLA_SRCADDR = "1400" + "0100" + "fe800002000300040005000600070008";
-
- private static final InetAddress SADDR1 = parseNumericAddress("fe80:2:3:4:5:6:7:8%" + IFINDEX1);
- private static final InetAddress SADDR2 = parseNumericAddress("fe80:2:3:4:5:6:7:8%" + IFINDEX2);
-
- private static final String MSG_EMPTY = HDR_EMPTY + NLA_SRCADDR;
- private static final String MSG_PREF64 = HDR_16BYTE + OPT_PREF64 + NLA_SRCADDR;
-
- @Test
- public void testParsing() {
- NduseroptMessage msg = parseNduseroptMessage(toBuffer(MSG_EMPTY));
- assertMatches(AF_INET6, 0, IFINDEX1, ICMP_TYPE_RA, (byte) 0, SADDR1, msg);
- assertNull(msg.option);
-
- msg = parseNduseroptMessage(toBuffer(MSG_PREF64));
- assertMatches(AF_INET6, 16, IFINDEX2, ICMP_TYPE_RA, (byte) 0, SADDR2, msg);
- assertPref64Option("2001:db8:3:4:5:6::/96", msg.option);
- }
-
- @Test
- public void testParseWithinNetlinkMessage() throws Exception {
- // A NduseroptMessage inside a netlink message. Ensure that it parses the same way both by
- // parsing the netlink message via NetlinkMessage.parse() and by parsing the option itself
- // with NduseroptMessage.parse().
- final String hexBytes =
- "44000000440000000000000000000000" // len=68, RTM_NEWNDUSEROPT
- + "0A0010001E0000008600000000000000" // IPv6, opt_bytes=16, ifindex=30, RA
- + "260202580064FF9B0000000000000000" // pref64, prefix=64:ff9b::/96, 600
- + "14000100FE800000000000000250B6FFFEB7C499"; // srcaddr=fe80::250:b6ff:feb7:c499
-
- ByteBuffer buf = toBuffer(hexBytes);
- assertEquals(68, buf.limit());
- buf.order(ByteOrder.nativeOrder());
-
- NetlinkMessage nlMsg = NetlinkMessage.parse(buf, NETLINK_ROUTE);
- assertNotNull(nlMsg);
- assertTrue(nlMsg instanceof NduseroptMessage);
-
- NduseroptMessage msg = (NduseroptMessage) nlMsg;
- InetAddress srcaddr = InetAddress.getByName("fe80::250:b6ff:feb7:c499%30");
- assertMatches(AF_INET6, 16, 30, ICMP_TYPE_RA, (byte) 0, srcaddr, msg);
- assertPref64Option("64:ff9b::/96", msg.option);
-
- final String hexBytesWithoutHeader = hexBytes.substring(StructNlMsgHdr.STRUCT_SIZE * 2);
- ByteBuffer bufWithoutHeader = toBuffer(hexBytesWithoutHeader);
- assertEquals(52, bufWithoutHeader.limit());
- msg = parseNduseroptMessage(bufWithoutHeader);
- assertMatches(AF_INET6, 16, 30, ICMP_TYPE_RA, (byte) 0, srcaddr, msg);
- assertPref64Option("64:ff9b::/96", msg.option);
- }
-
- @Test
- public void testParseRdnssOptionWithinNetlinkMessage() throws Exception {
- final String hexBytes =
- "4C000000440000000000000000000000"
- + "0A0018001E0000008600000000000000"
- + "1903000000001770FD123456789000000000000000000001" // RDNSS option
- + "14000100FE800000000000000250B6FFFEB7C499";
-
- ByteBuffer buf = toBuffer(hexBytes);
- assertEquals(76, buf.limit());
- buf.order(ByteOrder.nativeOrder());
-
- NetlinkMessage nlMsg = NetlinkMessage.parse(buf, NETLINK_ROUTE);
- assertNotNull(nlMsg);
- assertTrue(nlMsg instanceof NduseroptMessage);
-
- NduseroptMessage msg = (NduseroptMessage) nlMsg;
- InetAddress srcaddr = InetAddress.getByName("fe80::250:b6ff:feb7:c499%30");
- assertMatches(AF_INET6, 24, 30, ICMP_TYPE_RA, (byte) 0, srcaddr, msg);
- assertRdnssOption(msg.option, 6000 /* lifetime */,
- (Inet6Address) InetAddresses.parseNumericAddress("fd12:3456:7890::1"));
- }
-
- @Test
- public void testParseTruncatedRdnssOptionWithinNetlinkMessage() throws Exception {
- final String truncatedHexBytes =
- "38000000440000000000000000000000"
- + "0A0018001E0000008600000000000000"
- + "1903000000001770FD123456789000000000000000000001"; // RDNSS option
-
- ByteBuffer buf = toBuffer(truncatedHexBytes);
- buf.order(ByteOrder.nativeOrder());
- NetlinkMessage nlMsg = NetlinkMessage.parse(buf, NETLINK_ROUTE);
- assertNull(nlMsg);
- }
-
- @Test
- public void testParseUnknownOptionWithinNetlinkMessage() throws Exception {
- final String hexBytes =
- "4C000000440000000000000000000000"
- + "0A0018001E0000008600000000000000"
- + "310300000000177006676F6F676C652E03636F6D00000000" // DNSSL option: "google.com"
- + "14000100FE800000000000000250B6FFFEB7C499";
-
- ByteBuffer buf = toBuffer(hexBytes);
- assertEquals(76, buf.limit());
- buf.order(ByteOrder.nativeOrder());
-
- NetlinkMessage nlMsg = NetlinkMessage.parse(buf, NETLINK_ROUTE);
- assertNotNull(nlMsg);
- assertTrue(nlMsg instanceof NduseroptMessage);
-
- NduseroptMessage msg = (NduseroptMessage) nlMsg;
- InetAddress srcaddr = InetAddress.getByName("fe80::250:b6ff:feb7:c499%30");
- assertMatches(AF_INET6, 24, 30, ICMP_TYPE_RA, (byte) 0, srcaddr, msg);
- assertEquals(NdOption.UNKNOWN, msg.option);
- }
-
- @Test
- public void testUnknownOption() {
- ByteBuffer buf = toBuffer(MSG_PREF64);
- // Replace the PREF64 option type (38) with an unknown option number.
- final int optionStart = NduseroptMessage.STRUCT_SIZE;
- assertEquals(38, buf.get(optionStart));
- buf.put(optionStart, (byte) 42);
-
- NduseroptMessage msg = parseNduseroptMessage(buf);
- assertMatches(AF_INET6, 16, IFINDEX2, ICMP_TYPE_RA, (byte) 0, SADDR2, msg);
- assertEquals(NdOption.UNKNOWN, msg.option);
-
- buf.flip();
- assertEquals(42, buf.get(optionStart));
- buf.put(optionStart, (byte) 38);
-
- msg = parseNduseroptMessage(buf);
- assertMatches(AF_INET6, 16, IFINDEX2, ICMP_TYPE_RA, (byte) 0, SADDR2, msg);
- assertPref64Option("2001:db8:3:4:5:6::/96", msg.option);
- }
-
- @Test
- public void testZeroLengthOption() {
- // Make sure an unknown option with a 0-byte length is ignored and parsing continues with
- // the address, which comes after it.
- final String hexString = HDR_16BYTE + "00000000000000000000000000000000" + NLA_SRCADDR;
- ByteBuffer buf = toBuffer(hexString);
- assertEquals(52, buf.limit());
- NduseroptMessage msg = parseNduseroptMessage(buf);
- assertMatches(AF_INET6, 16, IFINDEX2, ICMP_TYPE_RA, (byte) 0, SADDR2, msg);
- assertNull(msg.option);
- }
-
- @Test
- public void testTooLongOption() {
- // Make sure that if an option's length is too long, it's ignored and parsing continues with
- // the address, which comes after it.
- final String hexString = HDR_16BYTE + "26030000000000000000000000000000" + NLA_SRCADDR;
- ByteBuffer buf = toBuffer(hexString);
- assertEquals(52, buf.limit());
- NduseroptMessage msg = parseNduseroptMessage(buf);
- assertMatches(AF_INET6, 16, IFINDEX2, ICMP_TYPE_RA, (byte) 0, SADDR2, msg);
- assertNull(msg.option);
- }
-
- @Test
- public void testOptionsTooLong() {
- // Header claims 32 bytes of options. Buffer ends before options end.
- String hexString = HDR_32BYTE + OPT_PREF64;
- ByteBuffer buf = toBuffer(hexString);
- assertEquals(32, buf.limit());
- assertNull(NduseroptMessage.parse(toBuffer(hexString), NETLINK_ROUTE));
-
- // Header claims 32 bytes of options. Buffer ends at end of options with no source address.
- hexString = HDR_32BYTE + OPT_PREF64 + OPT_PREF64;
- buf = toBuffer(hexString);
- assertEquals(48, buf.limit());
- assertNull(NduseroptMessage.parse(toBuffer(hexString), NETLINK_ROUTE));
- }
-
- @Test
- public void testTruncation() {
- final int optLen = MSG_PREF64.length() / 2; // 1 byte = 2 hex chars
- for (int len = 0; len < optLen; len++) {
- ByteBuffer buf = toBuffer(MSG_PREF64.substring(0, len * 2));
- NduseroptMessage msg = parseNduseroptMessage(buf);
- if (len < optLen) {
- assertNull(msg);
- } else {
- assertNotNull(msg);
- assertPref64Option("2001:db8:3:4:5:6::/96", msg.option);
- }
- }
- }
-
- @Test
- public void testToString() {
- NduseroptMessage msg = parseNduseroptMessage(toBuffer(MSG_PREF64));
- assertNotNull(msg);
- assertEquals("Nduseroptmsg(10, 16, 1431655765, 134, 0, fe80:2:3:4:5:6:7:8%1431655765)",
- msg.toString());
- }
-
- // Convenience method to parse a NduseroptMessage that's not part of a netlink message.
- private NduseroptMessage parseNduseroptMessage(ByteBuffer buf) {
- return NduseroptMessage.parse(null, buf);
- }
-
- private ByteBuffer toBuffer(String hexString) {
- return ByteBuffer.wrap(HexEncoding.decode(hexString));
- }
-
- private void assertMatches(int family, int optsLen, int ifindex, byte icmpType,
- byte icmpCode, InetAddress srcaddr, NduseroptMessage msg) {
- assertNotNull(msg);
- assertEquals(family, msg.family);
- assertEquals(ifindex, msg.ifindex);
- assertEquals(optsLen, msg.opts_len);
- assertEquals(icmpType, msg.icmp_type);
- assertEquals(icmpCode, msg.icmp_code);
- assertEquals(srcaddr, msg.srcaddr);
- }
-
- private void assertPref64Option(String prefix, NdOption opt) {
- assertNotNull(opt);
- assertTrue(opt instanceof StructNdOptPref64);
- StructNdOptPref64 pref64Opt = (StructNdOptPref64) opt;
- assertEquals(new IpPrefix(prefix), pref64Opt.prefix);
- }
-
- private void assertRdnssOption(NdOption opt, long lifetime, Inet6Address... servers) {
- assertNotNull(opt);
- assertTrue(opt instanceof StructNdOptRdnss);
- StructNdOptRdnss rdnss = (StructNdOptRdnss) opt;
- assertEquals(StructNdOptRdnss.TYPE, rdnss.type);
- assertEquals((byte) (servers.length * 2 + 1), rdnss.header.length);
- assertEquals(lifetime, rdnss.header.lifetime);
- assertArrayEquals(servers, rdnss.servers);
- }
-}
diff --git a/common/tests/unit/src/com/android/net/module/util/netlink/NetlinkConstantsTest.java b/common/tests/unit/src/com/android/net/module/util/netlink/NetlinkConstantsTest.java
deleted file mode 100644
index 143e4d4..0000000
--- a/common/tests/unit/src/com/android/net/module/util/netlink/NetlinkConstantsTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static android.system.OsConstants.NETLINK_INET_DIAG;
-import static android.system.OsConstants.NETLINK_NETFILTER;
-import static android.system.OsConstants.NETLINK_ROUTE;
-
-import static com.android.net.module.util.netlink.NetlinkConstants.IPCTNL_MSG_CT_DELETE;
-import static com.android.net.module.util.netlink.NetlinkConstants.IPCTNL_MSG_CT_GET;
-import static com.android.net.module.util.netlink.NetlinkConstants.IPCTNL_MSG_CT_GET_CTRZERO;
-import static com.android.net.module.util.netlink.NetlinkConstants.IPCTNL_MSG_CT_GET_DYING;
-import static com.android.net.module.util.netlink.NetlinkConstants.IPCTNL_MSG_CT_GET_STATS;
-import static com.android.net.module.util.netlink.NetlinkConstants.IPCTNL_MSG_CT_GET_STATS_CPU;
-import static com.android.net.module.util.netlink.NetlinkConstants.IPCTNL_MSG_CT_GET_UNCONFIRMED;
-import static com.android.net.module.util.netlink.NetlinkConstants.IPCTNL_MSG_CT_NEW;
-import static com.android.net.module.util.netlink.NetlinkConstants.NFNL_SUBSYS_CTNETLINK;
-import static com.android.net.module.util.netlink.NetlinkConstants.NLMSG_DONE;
-import static com.android.net.module.util.netlink.NetlinkConstants.NLMSG_ERROR;
-import static com.android.net.module.util.netlink.NetlinkConstants.NLMSG_NOOP;
-import static com.android.net.module.util.netlink.NetlinkConstants.NLMSG_OVERRUN;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_DELADDR;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_DELLINK;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_DELNEIGH;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_DELROUTE;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_DELRULE;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_GETADDR;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_GETLINK;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_GETNEIGH;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_GETROUTE;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_GETRULE;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_NEWADDR;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_NEWLINK;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_NEWNDUSEROPT;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_NEWNEIGH;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_NEWROUTE;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_NEWRULE;
-import static com.android.net.module.util.netlink.NetlinkConstants.RTM_SETLINK;
-import static com.android.net.module.util.netlink.NetlinkConstants.SOCK_DIAG_BY_FAMILY;
-import static com.android.net.module.util.netlink.NetlinkConstants.stringForNlMsgType;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class NetlinkConstantsTest {
- private static final short UNKNOWN_FAMILY = 1234;
-
- private short makeCtType(short msgType) {
- return (short) (NFNL_SUBSYS_CTNETLINK << 8 | (byte) msgType);
- }
-
- @Test
- public void testStringForNlMsgType() {
- assertEquals("RTM_NEWLINK", stringForNlMsgType(RTM_NEWLINK, NETLINK_ROUTE));
- assertEquals("RTM_DELLINK", stringForNlMsgType(RTM_DELLINK, NETLINK_ROUTE));
- assertEquals("RTM_GETLINK", stringForNlMsgType(RTM_GETLINK, NETLINK_ROUTE));
- assertEquals("RTM_SETLINK", stringForNlMsgType(RTM_SETLINK, NETLINK_ROUTE));
- assertEquals("RTM_NEWADDR", stringForNlMsgType(RTM_NEWADDR, NETLINK_ROUTE));
- assertEquals("RTM_DELADDR", stringForNlMsgType(RTM_DELADDR, NETLINK_ROUTE));
- assertEquals("RTM_GETADDR", stringForNlMsgType(RTM_GETADDR, NETLINK_ROUTE));
- assertEquals("RTM_NEWROUTE", stringForNlMsgType(RTM_NEWROUTE, NETLINK_ROUTE));
- assertEquals("RTM_DELROUTE", stringForNlMsgType(RTM_DELROUTE, NETLINK_ROUTE));
- assertEquals("RTM_GETROUTE", stringForNlMsgType(RTM_GETROUTE, NETLINK_ROUTE));
- assertEquals("RTM_NEWNEIGH", stringForNlMsgType(RTM_NEWNEIGH, NETLINK_ROUTE));
- assertEquals("RTM_DELNEIGH", stringForNlMsgType(RTM_DELNEIGH, NETLINK_ROUTE));
- assertEquals("RTM_GETNEIGH", stringForNlMsgType(RTM_GETNEIGH, NETLINK_ROUTE));
- assertEquals("RTM_NEWRULE", stringForNlMsgType(RTM_NEWRULE, NETLINK_ROUTE));
- assertEquals("RTM_DELRULE", stringForNlMsgType(RTM_DELRULE, NETLINK_ROUTE));
- assertEquals("RTM_GETRULE", stringForNlMsgType(RTM_GETRULE, NETLINK_ROUTE));
- assertEquals("RTM_NEWNDUSEROPT", stringForNlMsgType(RTM_NEWNDUSEROPT, NETLINK_ROUTE));
-
- assertEquals("SOCK_DIAG_BY_FAMILY",
- stringForNlMsgType(SOCK_DIAG_BY_FAMILY, NETLINK_INET_DIAG));
-
- assertEquals("IPCTNL_MSG_CT_NEW",
- stringForNlMsgType(makeCtType(IPCTNL_MSG_CT_NEW), NETLINK_NETFILTER));
- assertEquals("IPCTNL_MSG_CT_GET",
- stringForNlMsgType(makeCtType(IPCTNL_MSG_CT_GET), NETLINK_NETFILTER));
- assertEquals("IPCTNL_MSG_CT_DELETE",
- stringForNlMsgType(makeCtType(IPCTNL_MSG_CT_DELETE), NETLINK_NETFILTER));
- assertEquals("IPCTNL_MSG_CT_GET_CTRZERO",
- stringForNlMsgType(makeCtType(IPCTNL_MSG_CT_GET_CTRZERO), NETLINK_NETFILTER));
- assertEquals("IPCTNL_MSG_CT_GET_STATS_CPU",
- stringForNlMsgType(makeCtType(IPCTNL_MSG_CT_GET_STATS_CPU), NETLINK_NETFILTER));
- assertEquals("IPCTNL_MSG_CT_GET_STATS",
- stringForNlMsgType(makeCtType(IPCTNL_MSG_CT_GET_STATS), NETLINK_NETFILTER));
- assertEquals("IPCTNL_MSG_CT_GET_DYING",
- stringForNlMsgType(makeCtType(IPCTNL_MSG_CT_GET_DYING), NETLINK_NETFILTER));
- assertEquals("IPCTNL_MSG_CT_GET_UNCONFIRMED",
- stringForNlMsgType(makeCtType(IPCTNL_MSG_CT_GET_UNCONFIRMED), NETLINK_NETFILTER));
- }
-
- @Test
- public void testStringForNlMsgType_ControlMessage() {
- for (int family : new int[]{NETLINK_ROUTE, NETLINK_INET_DIAG, NETLINK_NETFILTER}) {
- assertEquals("NLMSG_NOOP", stringForNlMsgType(NLMSG_NOOP, family));
- assertEquals("NLMSG_ERROR", stringForNlMsgType(NLMSG_ERROR, family));
- assertEquals("NLMSG_DONE", stringForNlMsgType(NLMSG_DONE, family));
- assertEquals("NLMSG_OVERRUN", stringForNlMsgType(NLMSG_OVERRUN, family));
- }
- }
-
- @Test
- public void testStringForNlMsgType_UnknownFamily() {
- assertTrue(stringForNlMsgType(RTM_NEWLINK, UNKNOWN_FAMILY).startsWith("unknown"));
- assertTrue(stringForNlMsgType(SOCK_DIAG_BY_FAMILY, UNKNOWN_FAMILY).startsWith("unknown"));
- assertTrue(stringForNlMsgType(makeCtType(IPCTNL_MSG_CT_NEW), UNKNOWN_FAMILY)
- .startsWith("unknown"));
- }
-}
diff --git a/common/tests/unit/src/com/android/net/module/util/netlink/NetlinkErrorMessageTest.java b/common/tests/unit/src/com/android/net/module/util/netlink/NetlinkErrorMessageTest.java
deleted file mode 100644
index ab7d9cf..0000000
--- a/common/tests/unit/src/com/android/net/module/util/netlink/NetlinkErrorMessageTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static android.system.OsConstants.NETLINK_ROUTE;
-
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_ACK;
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REPLACE;
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REQUEST;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import libcore.util.HexEncoding;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class NetlinkErrorMessageTest {
- private static final String TAG = "NetlinkErrorMessageTest";
-
- // Hexadecimal representation of packet capture.
- public static final String NLM_ERROR_OK_HEX =
- // struct nlmsghdr
- "24000000" + // length = 36
- "0200" + // type = 2 (NLMSG_ERROR)
- "0000" + // flags
- "26350000" + // seqno
- "64100000" + // pid = userspace process
- // error integer
- "00000000" + // "errno" (0 == OK)
- // struct nlmsghdr
- "30000000" + // length (48) of original request
- "1C00" + // type = 28 (RTM_NEWNEIGH)
- "0501" + // flags (NLM_F_REQUEST | NLM_F_ACK | NLM_F_REPLACE)
- "26350000" + // seqno
- "00000000"; // pid = kernel
- public static final byte[] NLM_ERROR_OK =
- HexEncoding.decode(NLM_ERROR_OK_HEX.toCharArray(), false);
-
- @Test
- public void testParseNlmErrorOk() {
- final ByteBuffer byteBuffer = ByteBuffer.wrap(NLM_ERROR_OK);
- byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing.
- final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer, NETLINK_ROUTE);
- assertNotNull(msg);
- assertTrue(msg instanceof NetlinkErrorMessage);
- final NetlinkErrorMessage errorMsg = (NetlinkErrorMessage) msg;
-
- final StructNlMsgHdr hdr = errorMsg.getHeader();
- assertNotNull(hdr);
- assertEquals(36, hdr.nlmsg_len);
- assertEquals(NetlinkConstants.NLMSG_ERROR, hdr.nlmsg_type);
- assertEquals(0, hdr.nlmsg_flags);
- assertEquals(13606, hdr.nlmsg_seq);
- assertEquals(4196, hdr.nlmsg_pid);
-
- final StructNlMsgErr err = errorMsg.getNlMsgError();
- assertNotNull(err);
- assertEquals(0, err.error);
- assertNotNull(err.msg);
- assertEquals(48, err.msg.nlmsg_len);
- assertEquals(NetlinkConstants.RTM_NEWNEIGH, err.msg.nlmsg_type);
- assertEquals((NLM_F_REQUEST | NLM_F_ACK | NLM_F_REPLACE), err.msg.nlmsg_flags);
- assertEquals(13606, err.msg.nlmsg_seq);
- assertEquals(0, err.msg.nlmsg_pid);
- }
-}
diff --git a/common/tests/unit/src/com/android/net/module/util/netlink/NetlinkSocketTest.java b/common/tests/unit/src/com/android/net/module/util/netlink/NetlinkSocketTest.java
deleted file mode 100644
index 33ea602..0000000
--- a/common/tests/unit/src/com/android/net/module/util/netlink/NetlinkSocketTest.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static android.system.OsConstants.AF_INET;
-import static android.system.OsConstants.AF_INET6;
-import static android.system.OsConstants.AF_UNSPEC;
-import static android.system.OsConstants.EACCES;
-import static android.system.OsConstants.NETLINK_ROUTE;
-
-import static com.android.net.module.util.netlink.NetlinkSocket.DEFAULT_RECV_BUFSIZE;
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_DUMP;
-import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REQUEST;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import android.content.Context;
-import android.system.ErrnoException;
-import android.system.NetlinkSocketAddress;
-import android.system.Os;
-
-import androidx.test.filters.SmallTest;
-import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import com.android.modules.utils.build.SdkLevel;
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import libcore.io.IoUtils;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.io.FileDescriptor;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class NetlinkSocketTest {
- private static final String TAG = "NetlinkSocketTest";
- private static final int TEST_SEQNO = 5;
- private static final int TEST_TIMEOUT_MS = 500;
-
- @Test
- public void testGetNeighborsQuery() throws Exception {
- final FileDescriptor fd = NetlinkSocket.forProto(NETLINK_ROUTE);
- assertNotNull(fd);
-
- NetlinkSocket.connectToKernel(fd);
-
- final NetlinkSocketAddress localAddr = (NetlinkSocketAddress) Os.getsockname(fd);
- assertNotNull(localAddr);
- assertEquals(0, localAddr.getGroupsMask());
- assertTrue(0 != localAddr.getPortId());
-
- final byte[] req = RtNetlinkNeighborMessage.newGetNeighborsRequest(TEST_SEQNO);
- assertNotNull(req);
-
- final Context ctx = InstrumentationRegistry.getInstrumentation().getContext();
- final int targetSdk =
- ctx.getPackageManager()
- .getApplicationInfo(ctx.getPackageName(), 0)
- .targetSdkVersion;
-
- // Apps targeting an SDK version > S are not allowed to send RTM_GETNEIGH{TBL} messages
- if (SdkLevel.isAtLeastT() && targetSdk > 31) {
- try {
- NetlinkSocket.sendMessage(fd, req, 0, req.length, TEST_TIMEOUT_MS);
- fail("RTM_GETNEIGH is not allowed for apps targeting SDK > 31 on T+ platforms,"
- + " target SDK version: " + targetSdk);
- } catch (ErrnoException e) {
- // Expected
- assertEquals(e.errno, EACCES);
- return;
- }
- }
-
- // Check that apps targeting lower API levels / running on older platforms succeed
- assertEquals(req.length,
- NetlinkSocket.sendMessage(fd, req, 0, req.length, TEST_TIMEOUT_MS));
-
- int neighMessageCount = 0;
- int doneMessageCount = 0;
-
- while (doneMessageCount == 0) {
- ByteBuffer response =
- NetlinkSocket.recvMessage(fd, DEFAULT_RECV_BUFSIZE, TEST_TIMEOUT_MS);
- assertNotNull(response);
- assertTrue(StructNlMsgHdr.STRUCT_SIZE <= response.limit());
- assertEquals(0, response.position());
- assertEquals(ByteOrder.nativeOrder(), response.order());
-
- // Verify the messages at least appears minimally reasonable.
- while (response.remaining() > 0) {
- final NetlinkMessage msg = NetlinkMessage.parse(response, NETLINK_ROUTE);
- assertNotNull(msg);
- final StructNlMsgHdr hdr = msg.getHeader();
- assertNotNull(hdr);
-
- if (hdr.nlmsg_type == NetlinkConstants.NLMSG_DONE) {
- doneMessageCount++;
- continue;
- }
-
- assertEquals(NetlinkConstants.RTM_NEWNEIGH, hdr.nlmsg_type);
- assertTrue(msg instanceof RtNetlinkNeighborMessage);
- assertTrue((hdr.nlmsg_flags & StructNlMsgHdr.NLM_F_MULTI) != 0);
- assertEquals(TEST_SEQNO, hdr.nlmsg_seq);
- assertEquals(localAddr.getPortId(), hdr.nlmsg_pid);
-
- neighMessageCount++;
- }
- }
-
- assertEquals(1, doneMessageCount);
- // TODO: make sure this test passes sanely in airplane mode.
- assertTrue(neighMessageCount > 0);
-
- IoUtils.closeQuietly(fd);
- }
-
- @Test
- public void testBasicWorkingGetAddrQuery() throws Exception {
- final FileDescriptor fd = NetlinkSocket.forProto(NETLINK_ROUTE);
- assertNotNull(fd);
-
- NetlinkSocket.connectToKernel(fd);
-
- final NetlinkSocketAddress localAddr = (NetlinkSocketAddress) Os.getsockname(fd);
- assertNotNull(localAddr);
- assertEquals(0, localAddr.getGroupsMask());
- assertTrue(0 != localAddr.getPortId());
-
- final int testSeqno = 8;
- final byte[] req = newGetAddrRequest(testSeqno);
- assertNotNull(req);
-
- final long timeout = 500;
- assertEquals(req.length, NetlinkSocket.sendMessage(fd, req, 0, req.length, timeout));
-
- int addrMessageCount = 0;
-
- while (true) {
- ByteBuffer response = NetlinkSocket.recvMessage(fd, DEFAULT_RECV_BUFSIZE, timeout);
- assertNotNull(response);
- assertTrue(StructNlMsgHdr.STRUCT_SIZE <= response.limit());
- assertEquals(0, response.position());
- assertEquals(ByteOrder.nativeOrder(), response.order());
-
- final StructNlMsgHdr nlmsghdr = StructNlMsgHdr.parse(response);
- assertNotNull(nlmsghdr);
-
- if (nlmsghdr.nlmsg_type == NetlinkConstants.NLMSG_DONE) {
- break;
- }
-
- assertEquals(NetlinkConstants.RTM_NEWADDR, nlmsghdr.nlmsg_type);
- assertTrue((nlmsghdr.nlmsg_flags & StructNlMsgHdr.NLM_F_MULTI) != 0);
- assertEquals(testSeqno, nlmsghdr.nlmsg_seq);
- assertEquals(localAddr.getPortId(), nlmsghdr.nlmsg_pid);
- addrMessageCount++;
-
- final IfaddrMsg ifaMsg = Struct.parse(IfaddrMsg.class, response);
- assertTrue(
- "Non-IP address family: " + ifaMsg.family,
- ifaMsg.family == AF_INET || ifaMsg.family == AF_INET6);
- }
-
- assertTrue(addrMessageCount > 0);
-
- IoUtils.closeQuietly(fd);
- }
-
- /** A convenience method to create an RTM_GETADDR request message. */
- private static byte[] newGetAddrRequest(int seqNo) {
- final int length = StructNlMsgHdr.STRUCT_SIZE + Struct.getSize(RtgenMsg.class);
- final byte[] bytes = new byte[length];
- final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
- byteBuffer.order(ByteOrder.nativeOrder());
-
- final StructNlMsgHdr nlmsghdr = new StructNlMsgHdr();
- nlmsghdr.nlmsg_len = length;
- nlmsghdr.nlmsg_type = NetlinkConstants.RTM_GETADDR;
- nlmsghdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
- nlmsghdr.nlmsg_seq = seqNo;
- nlmsghdr.pack(byteBuffer);
-
- final RtgenMsg rtgenMsg = new RtgenMsg();
- rtgenMsg.family = (byte) AF_UNSPEC;
- rtgenMsg.writeToByteBuffer(byteBuffer);
-
- return bytes;
- }
-
- /** From uapi/linux/rtnetlink.h */
- private static class RtgenMsg extends Struct {
- @Field(order = 0, type = Type.U8)
- public short family;
- }
-
- /**
- * From uapi/linux/ifaddr.h
- *
- * Public ensures visibility to Struct class
- */
- public static class IfaddrMsg extends Struct {
- @Field(order = 0, type = Type.U8)
- public short family;
-
- @Field(order = 1, type = Type.U8)
- public short prefixlen;
-
- @Field(order = 2, type = Type.U8)
- public short flags;
-
- @Field(order = 3, type = Type.U8)
- public short scope;
-
- @Field(order = 4, type = Type.U32)
- public long index;
- }
-}
diff --git a/common/tests/unit/src/com/android/net/module/util/netlink/RtNetlinkNeighborMessageTest.java b/common/tests/unit/src/com/android/net/module/util/netlink/RtNetlinkNeighborMessageTest.java
deleted file mode 100644
index 4d8900c..0000000
--- a/common/tests/unit/src/com/android/net/module/util/netlink/RtNetlinkNeighborMessageTest.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static android.system.OsConstants.NETLINK_ROUTE;
-
-import static com.android.net.module.util.netlink.StructNdMsg.NUD_STALE;
-import static com.android.testutils.NetlinkTestUtils.makeDelNeighMessage;
-import static com.android.testutils.NetlinkTestUtils.makeNewNeighMessage;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import android.net.InetAddresses;
-import android.system.OsConstants;
-
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import libcore.util.HexEncoding;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Arrays;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class RtNetlinkNeighborMessageTest {
- private static final String TAG = "RtNetlinkNeighborMessageTest";
-
- public static final byte[] RTM_DELNEIGH = makeDelNeighMessage(
- InetAddresses.parseNumericAddress("192.168.159.254"), NUD_STALE);
-
- public static final byte[] RTM_NEWNEIGH = makeNewNeighMessage(
- InetAddresses.parseNumericAddress("fe80::86c9:b2ff:fe6a:ed4b"), NUD_STALE);
-
- // An example of the full response from an RTM_GETNEIGH query.
- private static final String RTM_GETNEIGH_RESPONSE_HEX =
- // <-- struct nlmsghr -->|<-- struct ndmsg -->|<-- struct nlattr: NDA_DST -->|<-- NDA_LLADDR -->|<-- NDA_PROBES -->|<-- NDA_CACHEINFO -->|
- "58000000 1c00 0200 00000000 3e2b0000 0a 00 0000 15000000 4000 00 05 1400 0100 ff020000000000000000000000000001 0a00 0200 333300000001 0000 0800 0400 00000000 1400 0300 a2280000 32110000 32110000 01000000" +
- "58000000 1c00 0200 00000000 3e2b0000 0a 00 0000 15000000 4000 00 05 1400 0100 ff0200000000000000000001ff000001 0a00 0200 3333ff000001 0000 0800 0400 00000000 1400 0300 0d280000 9d100000 9d100000 00000000" +
- "58000000 1c00 0200 00000000 3e2b0000 0a 00 0000 15000000 0400 80 01 1400 0100 20010db800040ca00000000000000001 0a00 0200 84c9b26aed4b 0000 0800 0400 04000000 1400 0300 90100000 90100000 90080000 01000000" +
- "58000000 1c00 0200 00000000 3e2b0000 0a 00 0000 15000000 4000 00 05 1400 0100 ff0200000000000000000001ff47da19 0a00 0200 3333ff47da19 0000 0800 0400 00000000 1400 0300 a1280000 31110000 31110000 01000000" +
- "58000000 1c00 0200 00000000 3e2b0000 0a 00 0000 14000000 4000 00 05 1400 0100 ff020000000000000000000000000016 0a00 0200 333300000016 0000 0800 0400 00000000 1400 0300 912a0000 21130000 21130000 00000000" +
- "58000000 1c00 0200 00000000 3e2b0000 0a 00 0000 14000000 4000 00 05 1400 0100 ff0200000000000000000001ffeace3b 0a00 0200 3333ffeace3b 0000 0800 0400 00000000 1400 0300 922a0000 22130000 22130000 00000000" +
- "58000000 1c00 0200 00000000 3e2b0000 0a 00 0000 15000000 4000 00 05 1400 0100 ff0200000000000000000001ff5c2a83 0a00 0200 3333ff5c2a83 0000 0800 0400 00000000 1400 0300 391c0000 c9040000 c9040000 01000000" +
- "58000000 1c00 0200 00000000 3e2b0000 0a 00 0000 01000000 4000 00 02 1400 0100 00000000000000000000000000000000 0a00 0200 000000000000 0000 0800 0400 00000000 1400 0300 cd180200 5d010200 5d010200 08000000" +
- "58000000 1c00 0200 00000000 3e2b0000 0a 00 0000 15000000 4000 00 05 1400 0100 ff020000000000000000000000000002 0a00 0200 333300000002 0000 0800 0400 00000000 1400 0300 352a0000 c5120000 c5120000 00000000" +
- "58000000 1c00 0200 00000000 3e2b0000 0a 00 0000 15000000 4000 00 05 1400 0100 ff020000000000000000000000000016 0a00 0200 333300000016 0000 0800 0400 00000000 1400 0300 982a0000 28130000 28130000 00000000" +
- "58000000 1c00 0200 00000000 3e2b0000 0a 00 0000 15000000 0800 80 01 1400 0100 fe8000000000000086c9b2fffe6aed4b 0a00 0200 84c9b26aed4b 0000 0800 0400 00000000 1400 0300 23000000 24000000 57000000 13000000" +
- "58000000 1c00 0200 00000000 3e2b0000 0a 00 0000 15000000 4000 00 05 1400 0100 ff0200000000000000000001ffeace3b 0a00 0200 3333ffeace3b 0000 0800 0400 00000000 1400 0300 992a0000 29130000 29130000 01000000" +
- "58000000 1c00 0200 00000000 3e2b0000 0a 00 0000 14000000 4000 00 05 1400 0100 ff020000000000000000000000000002 0a00 0200 333300000002 0000 0800 0400 00000000 1400 0300 2e2a0000 be120000 be120000 00000000" +
- "44000000 1c00 0200 00000000 3e2b0000 02 00 0000 18000000 4000 00 03 0800 0100 00000000 0400 0200 0800 0400 00000000 1400 0300 75280000 05110000 05110000 22000000";
- public static final byte[] RTM_GETNEIGH_RESPONSE =
- HexEncoding.decode(RTM_GETNEIGH_RESPONSE_HEX.replaceAll(" ", "").toCharArray(), false);
-
- @Test
- public void testParseRtmDelNeigh() {
- final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_DELNEIGH);
- byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing.
- final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer, NETLINK_ROUTE);
- assertNotNull(msg);
- assertTrue(msg instanceof RtNetlinkNeighborMessage);
- final RtNetlinkNeighborMessage neighMsg = (RtNetlinkNeighborMessage) msg;
-
- final StructNlMsgHdr hdr = neighMsg.getHeader();
- assertNotNull(hdr);
- assertEquals(76, hdr.nlmsg_len);
- assertEquals(NetlinkConstants.RTM_DELNEIGH, hdr.nlmsg_type);
- assertEquals(0, hdr.nlmsg_flags);
- assertEquals(0, hdr.nlmsg_seq);
- assertEquals(0, hdr.nlmsg_pid);
-
- final StructNdMsg ndmsgHdr = neighMsg.getNdHeader();
- assertNotNull(ndmsgHdr);
- assertEquals((byte) OsConstants.AF_INET, ndmsgHdr.ndm_family);
- assertEquals(21, ndmsgHdr.ndm_ifindex);
- assertEquals(NUD_STALE, ndmsgHdr.ndm_state);
- final InetAddress destination = neighMsg.getDestination();
- assertNotNull(destination);
- assertEquals(InetAddress.parseNumericAddress("192.168.159.254"), destination);
- }
-
- @Test
- public void testParseRtmNewNeigh() {
- final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_NEWNEIGH);
- byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing.
- final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer, NETLINK_ROUTE);
- assertNotNull(msg);
- assertTrue(msg instanceof RtNetlinkNeighborMessage);
- final RtNetlinkNeighborMessage neighMsg = (RtNetlinkNeighborMessage) msg;
-
- final StructNlMsgHdr hdr = neighMsg.getHeader();
- assertNotNull(hdr);
- assertEquals(88, hdr.nlmsg_len);
- assertEquals(NetlinkConstants.RTM_NEWNEIGH, hdr.nlmsg_type);
- assertEquals(0, hdr.nlmsg_flags);
- assertEquals(0, hdr.nlmsg_seq);
- assertEquals(0, hdr.nlmsg_pid);
-
- final StructNdMsg ndmsgHdr = neighMsg.getNdHeader();
- assertNotNull(ndmsgHdr);
- assertEquals((byte) OsConstants.AF_INET6, ndmsgHdr.ndm_family);
- assertEquals(21, ndmsgHdr.ndm_ifindex);
- assertEquals(NUD_STALE, ndmsgHdr.ndm_state);
- final InetAddress destination = neighMsg.getDestination();
- assertNotNull(destination);
- assertEquals(InetAddress.parseNumericAddress("fe80::86c9:b2ff:fe6a:ed4b"), destination);
- }
-
- @Test
- public void testParseRtmGetNeighResponse() {
- final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_GETNEIGH_RESPONSE);
- byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing.
-
- int messageCount = 0;
- while (byteBuffer.remaining() > 0) {
- final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer, NETLINK_ROUTE);
- assertNotNull(msg);
- assertTrue(msg instanceof RtNetlinkNeighborMessage);
- final RtNetlinkNeighborMessage neighMsg = (RtNetlinkNeighborMessage) msg;
-
- final StructNlMsgHdr hdr = neighMsg.getHeader();
- assertNotNull(hdr);
- assertEquals(NetlinkConstants.RTM_NEWNEIGH, hdr.nlmsg_type);
- assertEquals(StructNlMsgHdr.NLM_F_MULTI, hdr.nlmsg_flags);
- assertEquals(0, hdr.nlmsg_seq);
- assertEquals(11070, hdr.nlmsg_pid);
-
- final int probes = neighMsg.getProbes();
- assertTrue("Unexpected number of probes. Got " + probes + ", max=5",
- probes < 5);
- final int ndm_refcnt = neighMsg.getCacheInfo().ndm_refcnt;
- assertTrue("nda_cacheinfo has unexpectedly high ndm_refcnt: " + ndm_refcnt,
- ndm_refcnt < 0x100);
-
- messageCount++;
- }
- // TODO: add more detailed spot checks.
- assertEquals(14, messageCount);
- }
-
- @Test
- public void testCreateRtmNewNeighMessage() {
- final int seqNo = 2635;
- final int ifIndex = 14;
- final byte[] llAddr =
- new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5, (byte) 6 };
-
- // Hexadecimal representation of our created packet.
- final String expectedNewNeighHex =
- // struct nlmsghdr
- "30000000" + // length = 48
- "1c00" + // type = 28 (RTM_NEWNEIGH)
- "0501" + // flags (NLM_F_REQUEST | NLM_F_ACK | NLM_F_REPLACE)
- "4b0a0000" + // seqno
- "00000000" + // pid (0 == kernel)
- // struct ndmsg
- "02" + // family
- "00" + // pad1
- "0000" + // pad2
- "0e000000" + // interface index (14)
- "0800" + // NUD state (0x08 == NUD_DELAY)
- "00" + // flags
- "00" + // type
- // struct nlattr: NDA_DST
- "0800" + // length = 8
- "0100" + // type (1 == NDA_DST, for neighbor messages)
- "7f000001" + // IPv4 address (== 127.0.0.1)
- // struct nlattr: NDA_LLADDR
- "0a00" + // length = 10
- "0200" + // type (2 == NDA_LLADDR, for neighbor messages)
- "010203040506" + // MAC Address (== 01:02:03:04:05:06)
- "0000"; // padding, for 4 byte alignment
- final byte[] expectedNewNeigh =
- HexEncoding.decode(expectedNewNeighHex.toCharArray(), false);
-
- final byte[] bytes = RtNetlinkNeighborMessage.newNewNeighborMessage(
- seqNo, Inet4Address.LOOPBACK, StructNdMsg.NUD_DELAY, ifIndex, llAddr);
- if (!Arrays.equals(expectedNewNeigh, bytes)) {
- assertEquals(expectedNewNeigh.length, bytes.length);
- for (int i = 0; i < Math.min(expectedNewNeigh.length, bytes.length); i++) {
- assertEquals(expectedNewNeigh[i], bytes[i]);
- }
- }
- }
-}
diff --git a/common/tests/unit/src/com/android/net/module/util/netlink/StructNdOptPref64Test.java b/common/tests/unit/src/com/android/net/module/util/netlink/StructNdOptPref64Test.java
deleted file mode 100644
index 57248ea..0000000
--- a/common/tests/unit/src/com/android/net/module/util/netlink/StructNdOptPref64Test.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static com.android.net.module.util.netlink.StructNdOptPref64.getScaledLifetimePlc;
-import static com.android.net.module.util.netlink.StructNdOptPref64.plcToPrefixLength;
-import static com.android.net.module.util.netlink.StructNdOptPref64.prefixLengthToPlc;
-import static com.android.testutils.MiscAsserts.assertThrows;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import android.net.IpPrefix;
-
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import libcore.util.HexEncoding;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.net.InetAddress;
-import java.nio.ByteBuffer;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class StructNdOptPref64Test {
-
- private static final String PREFIX1 = "64:ff9b::";
- private static final String PREFIX2 = "2001:db8:1:2:3:64::";
-
- private static byte[] prefixBytes(String addrString) throws Exception {
- InetAddress addr = InetAddress.getByName(addrString);
- byte[] prefixBytes = new byte[12];
- System.arraycopy(addr.getAddress(), 0, prefixBytes, 0, 12);
- return prefixBytes;
- }
-
- private static IpPrefix prefix(String addrString, int prefixLength) throws Exception {
- return new IpPrefix(InetAddress.getByName(addrString), prefixLength);
- }
-
- private void assertPref64OptMatches(int lifetime, IpPrefix prefix, StructNdOptPref64 opt) {
- assertEquals(StructNdOptPref64.TYPE, opt.type);
- assertEquals(2, opt.length);
- assertEquals(lifetime, opt.lifetime);
- assertEquals(prefix, opt.prefix);
- }
-
- private void assertToByteBufferMatches(StructNdOptPref64 opt, String expected) {
- String actual = HexEncoding.encodeToString(opt.toByteBuffer().array());
- assertEquals(expected, actual);
- }
-
- private ByteBuffer makeNdOptPref64(int lifetime, byte[] prefix, int prefixLengthCode) {
- if (prefix.length != 12) throw new IllegalArgumentException("Prefix must be 12 bytes");
-
- ByteBuffer buf = ByteBuffer.allocate(16)
- .put((byte) StructNdOptPref64.TYPE)
- .put((byte) StructNdOptPref64.LENGTH)
- .putShort(getScaledLifetimePlc(lifetime, prefixLengthCode))
- .put(prefix, 0, 12);
-
- buf.flip();
- return buf;
- }
-
- @Test
- public void testParseCannedOption() throws Exception {
- String hexBytes = "2602" // type=38, len=2 (16 bytes)
- + "0088" // lifetime=136, PLC=0 (/96)
- + "20010DB80003000400050006"; // 2001:db8:3:4:5:6/96
- byte[] rawBytes = HexEncoding.decode(hexBytes);
- StructNdOptPref64 opt = StructNdOptPref64.parse(ByteBuffer.wrap(rawBytes));
- assertPref64OptMatches(136, prefix("2001:DB8:3:4:5:6::", 96), opt);
- assertToByteBufferMatches(opt, hexBytes);
-
- hexBytes = "2602" // type=38, len=2 (16 bytes)
- + "2752" // lifetime=10064, PLC=2 (/56)
- + "0064FF9B0000000000000000"; // 64:ff9b::/56
- rawBytes = HexEncoding.decode(hexBytes);
- opt = StructNdOptPref64.parse(ByteBuffer.wrap(rawBytes));
- assertPref64OptMatches(10064, prefix("64:FF9B::", 56), opt);
- assertToByteBufferMatches(opt, hexBytes);
- }
-
- @Test
- public void testParsing() throws Exception {
- // Valid.
- ByteBuffer buf = makeNdOptPref64(600, prefixBytes(PREFIX1), 0);
- StructNdOptPref64 opt = StructNdOptPref64.parse(buf);
- assertPref64OptMatches(600, prefix(PREFIX1, 96), opt);
-
- // Valid, zero lifetime, /64.
- buf = makeNdOptPref64(0, prefixBytes(PREFIX1), 1);
- opt = StructNdOptPref64.parse(buf);
- assertPref64OptMatches(0, prefix(PREFIX1, 64), opt);
-
- // Valid, low lifetime, /56.
- buf = makeNdOptPref64(8, prefixBytes(PREFIX2), 2);
- opt = StructNdOptPref64.parse(buf);
- assertPref64OptMatches(8, prefix(PREFIX2, 56), opt);
- assertEquals(new IpPrefix("2001:db8:1::/56"), opt.prefix); // Prefix is truncated.
-
- // Valid, maximum lifetime, /32.
- buf = makeNdOptPref64(65528, prefixBytes(PREFIX2), 5);
- opt = StructNdOptPref64.parse(buf);
- assertPref64OptMatches(65528, prefix(PREFIX2, 32), opt);
- assertEquals(new IpPrefix("2001:db8::/32"), opt.prefix); // Prefix is truncated.
-
- // Lifetime not divisible by 8.
- buf = makeNdOptPref64(300, prefixBytes(PREFIX2), 0);
- opt = StructNdOptPref64.parse(buf);
- assertPref64OptMatches(296, prefix(PREFIX2, 96), opt);
-
- // Invalid prefix length codes.
- buf = makeNdOptPref64(600, prefixBytes(PREFIX1), 6);
- assertNull(StructNdOptPref64.parse(buf));
- buf = makeNdOptPref64(600, prefixBytes(PREFIX1), 7);
- assertNull(StructNdOptPref64.parse(buf));
-
- // Truncated to varying lengths...
- buf = makeNdOptPref64(600, prefixBytes(PREFIX1), 3);
- final int len = buf.limit();
- for (int i = 0; i < buf.limit() - 1; i++) {
- buf.flip();
- buf.limit(i);
- assertNull("Option truncated to " + i + " bytes, should have returned null",
- StructNdOptPref64.parse(buf));
- }
- buf.flip();
- buf.limit(len);
- // ... but otherwise OK.
- opt = StructNdOptPref64.parse(buf);
- assertPref64OptMatches(600, prefix(PREFIX1, 48), opt);
- }
-
- @Test
- public void testToString() throws Exception {
- ByteBuffer buf = makeNdOptPref64(600, prefixBytes(PREFIX1), 4);
- StructNdOptPref64 opt = StructNdOptPref64.parse(buf);
- assertPref64OptMatches(600, prefix(PREFIX1, 40), opt);
- assertEquals("NdOptPref64(64:ff9b::/40, 600)", opt.toString());
- }
-
- private void assertInvalidPlc(int plc) {
- assertThrows(IllegalArgumentException.class, () -> plcToPrefixLength(plc));
- }
-
- @Test
- public void testPrefixLengthToPlc() {
- for (int i = 0; i < 6; i++) {
- assertEquals(i, prefixLengthToPlc(plcToPrefixLength(i)));
- }
- assertInvalidPlc(-1);
- assertInvalidPlc(6);
- assertInvalidPlc(7);
- assertEquals(0, prefixLengthToPlc(96));
- }
-
-
- private void assertInvalidParameters(IpPrefix prefix, int lifetime) {
- assertThrows(IllegalArgumentException.class, () -> new StructNdOptPref64(prefix, lifetime));
- }
-
- @Test
- public void testToByteBuffer() throws Exception {
- final IpPrefix prefix1 = prefix(PREFIX1, 56);
- final IpPrefix prefix2 = prefix(PREFIX2, 96);
-
- StructNdOptPref64 opt = new StructNdOptPref64(prefix1, 600);
- assertToByteBufferMatches(opt, "2602025A0064FF9B0000000000000000");
- assertEquals(new IpPrefix("64:ff9b::/56"), opt.prefix);
- assertEquals(600, opt.lifetime);
-
- opt = new StructNdOptPref64(prefix2, 65519);
- assertToByteBufferMatches(opt, "2602FFE820010DB80001000200030064");
- assertEquals(new IpPrefix("2001:db8:1:2:3:64::/96"), opt.prefix);
- assertEquals(65512, opt.lifetime);
-
- assertInvalidParameters(prefix1, 65535);
- assertInvalidParameters(prefix2, -1);
- assertInvalidParameters(prefix("1.2.3.4", 32), 600);
- }
-}
diff --git a/common/tests/unit/src/com/android/net/module/util/netlink/StructNdOptRdnssTest.java b/common/tests/unit/src/com/android/net/module/util/netlink/StructNdOptRdnssTest.java
deleted file mode 100644
index 1dcb9b5..0000000
--- a/common/tests/unit/src/com/android/net/module/util/netlink/StructNdOptRdnssTest.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static com.android.net.module.util.NetworkStackConstants.ICMPV6_ND_OPTION_RDNSS;
-import static com.android.testutils.MiscAsserts.assertThrows;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import android.net.InetAddresses;
-
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import com.android.net.module.util.structs.RdnssOption;
-
-import libcore.util.HexEncoding;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.net.Inet6Address;
-import java.nio.ByteBuffer;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class StructNdOptRdnssTest {
- private static final String DNS_SERVER1 = "2001:4860:4860::64";
- private static final String DNS_SERVER2 = "2001:4860:4860::6464";
-
- private static final Inet6Address[] DNS_SERVER_ADDRESSES = new Inet6Address[] {
- (Inet6Address) InetAddresses.parseNumericAddress(DNS_SERVER1),
- (Inet6Address) InetAddresses.parseNumericAddress(DNS_SERVER2),
- };
-
- private static final String RDNSS_OPTION_BYTES =
- "1905" // type=25, len=5 (40 bytes)
- + "0000" // reserved
- + "00000E10" // lifetime=3600
- + "20014860486000000000000000000064" // 2001:4860:4860::64
- + "20014860486000000000000000006464"; // 2001:4860:4860::6464
-
- private static final String RDNSS_INFINITY_LIFETIME_OPTION_BYTES =
- "1905" // type=25, len=3 (24 bytes)
- + "0000" // reserved
- + "FFFFFFFF" // lifetime=0xffffffff
- + "20014860486000000000000000000064" // 2001:4860:4860::64
- + "20014860486000000000000000006464"; // 2001:4860:4860::6464
-
- private void assertRdnssOptMatches(final StructNdOptRdnss opt, int length, long lifetime,
- final Inet6Address[] servers) {
- assertEquals(StructNdOptRdnss.TYPE, opt.type);
- assertEquals(length, opt.length);
- assertEquals(lifetime, opt.header.lifetime);
- assertEquals(servers, opt.servers);
- }
-
- private ByteBuffer makeRdnssOption(byte type, byte length, long lifetime, String... servers)
- throws Exception {
- final ByteBuffer buf = ByteBuffer.allocate(8 + servers.length * 16)
- .put(type)
- .put(length)
- .putShort((short) 0) // Reserved
- .putInt((int) (lifetime & 0xFFFFFFFFL));
- for (int i = 0; i < servers.length; i++) {
- final byte[] rawBytes =
- ((Inet6Address) InetAddresses.parseNumericAddress(servers[i])).getAddress();
- buf.put(rawBytes);
- }
- buf.flip();
- return buf;
- }
-
- private void assertToByteBufferMatches(StructNdOptRdnss opt, String expected) {
- String actual = HexEncoding.encodeToString(opt.toByteBuffer().array());
- assertEquals(expected, actual);
- }
-
- private void doRdnssOptionParsing(final String optionHexString, int length, long lifetime,
- final Inet6Address[] servers) {
- final byte[] rawBytes = HexEncoding.decode(optionHexString);
- final StructNdOptRdnss opt = StructNdOptRdnss.parse(ByteBuffer.wrap(rawBytes));
- assertRdnssOptMatches(opt, length, lifetime, servers);
- assertToByteBufferMatches(opt, optionHexString);
- }
-
- @Test
- public void testParsing() throws Exception {
- doRdnssOptionParsing(RDNSS_OPTION_BYTES, 5 /* length */, 3600 /* lifetime */,
- DNS_SERVER_ADDRESSES);
- }
-
- @Test
- public void testParsing_infinityLifetime() throws Exception {
- doRdnssOptionParsing(RDNSS_INFINITY_LIFETIME_OPTION_BYTES, 5 /* length */,
- 0xffffffffL /* lifetime */, DNS_SERVER_ADDRESSES);
- }
-
- @Test
- public void testToByteBuffer() {
- final StructNdOptRdnss rdnss = new StructNdOptRdnss(DNS_SERVER_ADDRESSES, 3600);
- assertToByteBufferMatches(rdnss, RDNSS_OPTION_BYTES);
- }
-
- @Test
- public void testToByteBuffer_infinityLifetime() {
- final StructNdOptRdnss rdnss = new StructNdOptRdnss(DNS_SERVER_ADDRESSES, 0xffffffffL);
- assertToByteBufferMatches(rdnss, RDNSS_INFINITY_LIFETIME_OPTION_BYTES);
- }
-
- @Test
- public void testParsing_invalidType() throws Exception {
- final ByteBuffer buf = makeRdnssOption((byte) 38, (byte) 5 /* length */,
- 3600 /* lifetime */, DNS_SERVER1, DNS_SERVER2);
- assertNull(StructNdOptRdnss.parse(buf));
- }
-
- @Test
- public void testParsing_smallOptionLength() throws Exception {
- final ByteBuffer buf = makeRdnssOption((byte) ICMPV6_ND_OPTION_RDNSS,
- (byte) 2 /* length */, 3600 /* lifetime */, DNS_SERVER1, DNS_SERVER2);
- assertNull(StructNdOptRdnss.parse(buf));
- }
-
- @Test
- public void testParsing_oddOptionLength() throws Exception {
- final ByteBuffer buf = makeRdnssOption((byte) ICMPV6_ND_OPTION_RDNSS,
- (byte) 6 /* length */, 3600 /* lifetime */, DNS_SERVER1, DNS_SERVER2);
- assertNull(StructNdOptRdnss.parse(buf));
- }
-
- @Test
- public void testParsing_truncatedByteBuffer() throws Exception {
- ByteBuffer buf = makeRdnssOption((byte) ICMPV6_ND_OPTION_RDNSS,
- (byte) 5 /* length */, 3600 /* lifetime */, DNS_SERVER1, DNS_SERVER2);
- final int len = buf.limit();
- for (int i = 0; i < buf.limit() - 1; i++) {
- buf.flip();
- buf.limit(i);
- assertNull("Option truncated to " + i + " bytes, should have returned null",
- StructNdOptRdnss.parse(buf));
- }
- buf.flip();
- buf.limit(len);
-
- final StructNdOptRdnss opt = StructNdOptRdnss.parse(buf);
- assertRdnssOptMatches(opt, 5 /* length */, 3600 /* lifetime */, DNS_SERVER_ADDRESSES);
- }
-
- @Test
- public void testParsing_invalidByteBufferLength() throws Exception {
- final ByteBuffer buf = makeRdnssOption((byte) ICMPV6_ND_OPTION_RDNSS,
- (byte) 5 /* length */, 3600 /* lifetime */, DNS_SERVER1, DNS_SERVER2);
- buf.limit(20); // less than MIN_OPT_LEN * 8
- assertNull(StructNdOptRdnss.parse(buf));
- }
-
- @Test
- public void testConstructor_nullDnsServerAddressArray() {
- assertThrows(NullPointerException.class,
- () -> new StructNdOptRdnss(null /* servers */, 3600 /* lifetime */));
- }
-
- @Test
- public void testConstructor_emptyDnsServerAddressArray() {
- assertThrows(IllegalArgumentException.class,
- () -> new StructNdOptRdnss(new Inet6Address[0] /* empty server array */,
- 3600 /* lifetime*/));
- }
-
- @Test
- public void testToString() {
- final ByteBuffer buf = RdnssOption.build(3600 /* lifetime */, DNS_SERVER1, DNS_SERVER2);
- final StructNdOptRdnss opt = StructNdOptRdnss.parse(buf);
- final String expected = "NdOptRdnss(type: 25, length: 5, reserved: 0, lifetime: 3600,"
- + "servers:[2001:4860:4860::64,2001:4860:4860::6464])";
- assertRdnssOptMatches(opt, 5 /* length */, 3600 /* lifetime */, DNS_SERVER_ADDRESSES);
- assertEquals(expected, opt.toString());
- }
-}
diff --git a/common/tests/unit/src/com/android/net/module/util/netlink/StructNlMsgHdrTest.java b/common/tests/unit/src/com/android/net/module/util/netlink/StructNlMsgHdrTest.java
deleted file mode 100644
index b7f68c6..0000000
--- a/common/tests/unit/src/com/android/net/module/util/netlink/StructNlMsgHdrTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.netlink;
-
-import static org.junit.Assert.fail;
-
-import android.system.OsConstants;
-
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class StructNlMsgHdrTest {
-
- public static final short TEST_NLMSG_LEN = 16;
- public static final short TEST_NLMSG_FLAGS = StructNlMsgHdr.NLM_F_REQUEST
- | StructNlMsgHdr.NLM_F_MULTI | StructNlMsgHdr.NLM_F_ACK | StructNlMsgHdr.NLM_F_ECHO;
- public static final short TEST_NLMSG_SEQ = 1234;
- public static final short TEST_NLMSG_PID = 5678;
-
- // Checking the header string nlmsg_{len, ..} of the number can make sure that the checking
- // number comes from the expected element.
- // TODO: Verify more flags once StructNlMsgHdr can distinguish the flags which have the same
- // value. For example, NLM_F_MATCH (0x200) and NLM_F_EXCL (0x200) can't be distinguished.
- // See StructNlMsgHdrTest#stringForNlMsgFlags.
- public static final String TEST_NLMSG_LEN_STR = "nlmsg_len{16}";
- public static final String TEST_NLMSG_FLAGS_STR =
- "NLM_F_REQUEST|NLM_F_MULTI|NLM_F_ACK|NLM_F_ECHO";
- public static final String TEST_NLMSG_SEQ_STR = "nlmsg_seq{1234}";
- public static final String TEST_NLMSG_PID_STR = "nlmsg_pid{5678}";
-
- private StructNlMsgHdr makeStructNlMsgHdr(short type) {
- final StructNlMsgHdr struct = new StructNlMsgHdr();
- struct.nlmsg_len = TEST_NLMSG_LEN;
- struct.nlmsg_type = type;
- struct.nlmsg_flags = TEST_NLMSG_FLAGS;
- struct.nlmsg_seq = TEST_NLMSG_SEQ;
- struct.nlmsg_pid = TEST_NLMSG_PID;
- return struct;
- }
-
- private static void assertContains(String actualValue, String expectedSubstring) {
- if (actualValue.contains(expectedSubstring)) return;
- fail("\"" + actualValue + "\" does not contain \"" + expectedSubstring + "\"");
- }
-
- @Test
- public void testToString() {
- StructNlMsgHdr struct = makeStructNlMsgHdr(NetlinkConstants.RTM_NEWADDR);
- String s = struct.toString();
- assertContains(s, TEST_NLMSG_LEN_STR);
- assertContains(s, TEST_NLMSG_FLAGS_STR);
- assertContains(s, TEST_NLMSG_SEQ_STR);
- assertContains(s, TEST_NLMSG_PID_STR);
- assertContains(s, "nlmsg_type{20()}");
-
- struct = makeStructNlMsgHdr(NetlinkConstants.SOCK_DIAG_BY_FAMILY);
- s = struct.toString();
- assertContains(s, TEST_NLMSG_LEN_STR);
- assertContains(s, TEST_NLMSG_FLAGS_STR);
- assertContains(s, TEST_NLMSG_SEQ_STR);
- assertContains(s, TEST_NLMSG_PID_STR);
- assertContains(s, "nlmsg_type{20()}");
- }
-
- @Test
- public void testToStringWithNetlinkFamily() {
- StructNlMsgHdr struct = makeStructNlMsgHdr(NetlinkConstants.RTM_NEWADDR);
- String s = struct.toString(OsConstants.NETLINK_ROUTE);
- assertContains(s, TEST_NLMSG_LEN_STR);
- assertContains(s, TEST_NLMSG_FLAGS_STR);
- assertContains(s, TEST_NLMSG_SEQ_STR);
- assertContains(s, TEST_NLMSG_PID_STR);
- assertContains(s, "nlmsg_type{20(RTM_NEWADDR)}");
-
- struct = makeStructNlMsgHdr(NetlinkConstants.SOCK_DIAG_BY_FAMILY);
- s = struct.toString(OsConstants.NETLINK_INET_DIAG);
- assertContains(s, TEST_NLMSG_LEN_STR);
- assertContains(s, TEST_NLMSG_FLAGS_STR);
- assertContains(s, TEST_NLMSG_SEQ_STR);
- assertContains(s, TEST_NLMSG_PID_STR);
- assertContains(s, "nlmsg_type{20(SOCK_DIAG_BY_FAMILY)}");
- }
-}
diff --git a/common/testutils/Android.bp b/common/testutils/Android.bp
index b7297bb..d4465dd 100644
--- a/common/testutils/Android.bp
+++ b/common/testutils/Android.bp
@@ -22,10 +22,7 @@
"devicetests/**/*.java",
"devicetests/**/*.kt",
],
- defaults: [
- "framework-connectivity-test-defaults",
- "lib_mockito_extended"
- ],
+ defaults: ["lib_mockito_extended"],
libs: [
"androidx.annotation_annotation",
],
@@ -35,8 +32,6 @@
"libnanohttpd",
"net-tests-utils-host-device-common",
"net-utils-device-common",
- "net-utils-device-common-netlink",
- "modules-utils-build_system",
],
}
@@ -54,9 +49,6 @@
"//frameworks/libs/net/common/tests:__subpackages__",
"//frameworks/libs/net/client-libs/tests:__subpackages__",
],
- libs: [
- "jsr305",
- ],
static_libs: [
"kotlin-test"
]
diff --git a/common/testutils/devicetests/com/android/testutils/DevSdkIgnoreRule.kt b/common/testutils/devicetests/com/android/testutils/DevSdkIgnoreRule.kt
index 201bf2d..4a83f6f 100644
--- a/common/testutils/devicetests/com/android/testutils/DevSdkIgnoreRule.kt
+++ b/common/testutils/devicetests/com/android/testutils/DevSdkIgnoreRule.kt
@@ -17,7 +17,6 @@
package com.android.testutils
import android.os.Build
-import com.android.modules.utils.build.SdkLevel
import org.junit.Assume.assumeTrue
import org.junit.rules.TestRule
import org.junit.runner.Description
@@ -30,32 +29,14 @@
* [Build.VERSION.SDK_INT].
*/
fun isDevSdkInRange(minExclusive: Int?, maxInclusive: Int?): Boolean {
- return (minExclusive == null || isDevSdkAfter(minExclusive)) &&
- (maxInclusive == null || isDevSdkUpTo(maxInclusive))
-}
+ // In-development API n+1 will have SDK_INT == n and CODENAME != REL.
+ // Stable API n has SDK_INT == n and CODENAME == REL.
+ val release = "REL" == Build.VERSION.CODENAME
+ val sdkInt = Build.VERSION.SDK_INT
+ val devApiLevel = sdkInt + if (release) 0 else 1
-private fun isDevSdkAfter(minExclusive: Int): Boolean {
- // A development build for T typically has SDK_INT = 30 (R) or SDK_INT = 31 (S), so SDK_INT
- // alone cannot be used to check the SDK version.
- // For recent SDKs that still have development builds used for testing, use SdkLevel utilities
- // instead of SDK_INT.
- return when (minExclusive) {
- // TODO: use Build.VERSION_CODES.S when it is not CURRENT_DEVELOPMENT
- 31 -> SdkLevel.isAtLeastT()
- Build.VERSION_CODES.R -> SdkLevel.isAtLeastS()
- // Development builds of SDK versions <= R are not used anymore
- else -> Build.VERSION.SDK_INT > minExclusive
- }
-}
-
-private fun isDevSdkUpTo(maxInclusive: Int): Boolean {
- return when (maxInclusive) {
- // TODO: use Build.VERSION_CODES.S when it is not CURRENT_DEVELOPMENT
- 31 -> !SdkLevel.isAtLeastT()
- Build.VERSION_CODES.R -> !SdkLevel.isAtLeastS()
- // Development builds of SDK versions <= R are not used anymore
- else -> Build.VERSION.SDK_INT <= maxInclusive
- }
+ return (minExclusive == null || devApiLevel > minExclusive) &&
+ (maxInclusive == null || devApiLevel <= maxInclusive)
}
/**
diff --git a/common/testutils/devicetests/com/android/testutils/DevSdkIgnoreRunner.kt b/common/testutils/devicetests/com/android/testutils/DevSdkIgnoreRunner.kt
index da7bf97..73b2843 100644
--- a/common/testutils/devicetests/com/android/testutils/DevSdkIgnoreRunner.kt
+++ b/common/testutils/devicetests/com/android/testutils/DevSdkIgnoreRunner.kt
@@ -21,13 +21,7 @@
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo
import org.junit.runner.Description
import org.junit.runner.Runner
-import org.junit.runner.manipulation.Filter
-import org.junit.runner.manipulation.Filterable
-import org.junit.runner.manipulation.NoTestsRemainException
-import org.junit.runner.manipulation.Sortable
-import org.junit.runner.manipulation.Sorter
import org.junit.runner.notification.RunNotifier
-import kotlin.jvm.Throws
/**
* A runner that can skip tests based on the development SDK as defined in [DevSdkIgnoreRule].
@@ -47,7 +41,7 @@
* @IgnoreUpTo(Build.VERSION_CODES.Q)
* class MyTestClass { ... }
*/
-class DevSdkIgnoreRunner(private val klass: Class<*>) : Runner(), Filterable, Sortable {
+class DevSdkIgnoreRunner(private val klass: Class<*>) : Runner() {
private val baseRunner = klass.let {
val ignoreAfter = it.getAnnotation(IgnoreAfter::class.java)
val ignoreUpTo = it.getAnnotation(IgnoreUpTo::class.java)
@@ -61,9 +55,8 @@
return
}
- // Report a single, skipped placeholder test for this class, as the class is expected to
- // report results when run. In practice runners that apply the Filterable implementation
- // would see a NoTestsRemainException and not call the run method.
+ // Report a single, skipped placeholder test for this class, so that the class is still
+ // visible as skipped in test results.
notifier.fireTestIgnored(
Description.createTestDescription(klass, "skippedClassForDevSdkMismatch"))
}
@@ -72,20 +65,8 @@
return baseRunner?.description ?: Description.createSuiteDescription(klass)
}
- /**
- * Get the test count before applying the [Filterable] implementation.
- */
override fun testCount(): Int {
// When ignoring the tests, a skipped placeholder test is reported, so test count is 1.
return baseRunner?.testCount() ?: 1
}
-
- @Throws(NoTestsRemainException::class)
- override fun filter(filter: Filter?) {
- baseRunner?.filter(filter) ?: throw NoTestsRemainException()
- }
-
- override fun sort(sorter: Sorter?) {
- baseRunner?.sort(sorter)
- }
}
\ No newline at end of file
diff --git a/common/testutils/devicetests/com/android/testutils/NetlinkTestUtils.kt b/common/testutils/devicetests/com/android/testutils/NetlinkTestUtils.kt
deleted file mode 100644
index 3f5460b..0000000
--- a/common/testutils/devicetests/com/android/testutils/NetlinkTestUtils.kt
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@file:JvmName("NetlinkTestUtils")
-
-package com.android.testutils
-
-import com.android.net.module.util.netlink.NetlinkConstants.RTM_DELNEIGH
-import com.android.net.module.util.netlink.NetlinkConstants.RTM_NEWNEIGH
-import libcore.util.HexEncoding
-import libcore.util.HexEncoding.encodeToString
-import java.net.Inet6Address
-import java.net.InetAddress
-
-private const val VRRP_MAC_ADDR = "00005e000164"
-
-/**
- * Make a RTM_NEWNEIGH netlink message.
- */
-@JvmOverloads
-fun makeNewNeighMessage(
- neighAddr: InetAddress,
- nudState: Short,
- linkLayerAddr: String = VRRP_MAC_ADDR
-) = makeNeighborMessage(
- neighAddr = neighAddr,
- type = RTM_NEWNEIGH,
- nudState = nudState,
- linkLayerAddr = linkLayerAddr
-)
-
-/**
- * Make a RTM_DELNEIGH netlink message.
- */
-fun makeDelNeighMessage(
- neighAddr: InetAddress,
- nudState: Short
-) = makeNeighborMessage(
- neighAddr = neighAddr,
- type = RTM_DELNEIGH,
- nudState = nudState
-)
-
-private fun makeNeighborMessage(
- neighAddr: InetAddress,
- type: Short,
- nudState: Short,
- linkLayerAddr: String = VRRP_MAC_ADDR
-) = HexEncoding.decode(
- /* ktlint-disable indent */
- // -- struct nlmsghdr --
- // length = 88 or 76:
- (if (neighAddr is Inet6Address) "58000000" else "4c000000") +
- type.toLEHex() + // type
- "0000" + // flags
- "00000000" + // seqno
- "00000000" + // pid (0 == kernel)
- // struct ndmsg
- // family (AF_INET6 or AF_INET)
- (if (neighAddr is Inet6Address) "0a" else "02") +
- "00" + // pad1
- "0000" + // pad2
- "15000000" + // interface index (21 == wlan0, on test device)
- nudState.toLEHex() + // NUD state
- "00" + // flags
- "01" + // type
- // -- struct nlattr: NDA_DST --
- // length = 20 or 8:
- (if (neighAddr is Inet6Address) "1400" else "0800") +
- "0100" + // type (1 == NDA_DST, for neighbor messages)
- // IP address:
- encodeToString(neighAddr.address) +
- // -- struct nlattr: NDA_LLADDR --
- "0a00" + // length = 10
- "0200" + // type (2 == NDA_LLADDR, for neighbor messages)
- linkLayerAddr + // MAC Address(default == 00:00:5e:00:01:64)
- "0000" + // padding, for 4 byte alignment
- // -- struct nlattr: NDA_PROBES --
- "0800" + // length = 8
- "0400" + // type (4 == NDA_PROBES, for neighbor messages)
- "01000000" + // number of probes
- // -- struct nlattr: NDA_CACHEINFO --
- "1400" + // length = 20
- "0300" + // type (3 == NDA_CACHEINFO, for neighbor messages)
- "05190000" + // ndm_used, as "clock ticks ago"
- "05190000" + // ndm_confirmed, as "clock ticks ago"
- "190d0000" + // ndm_updated, as "clock ticks ago"
- "00000000", // ndm_refcnt
- false /* allowSingleChar */)
- /* ktlint-enable indent */
-
-/**
- * Convert a [Short] to a little-endian hex string.
- */
-private fun Short.toLEHex() = String.format("%04x", java.lang.Short.reverseBytes(this))
diff --git a/common/testutils/devicetests/com/android/testutils/TestHttpServer.kt b/common/testutils/devicetests/com/android/testutils/TestHttpServer.kt
index 39ce487..7aae8e3 100644
--- a/common/testutils/devicetests/com/android/testutils/TestHttpServer.kt
+++ b/common/testutils/devicetests/com/android/testutils/TestHttpServer.kt
@@ -54,12 +54,12 @@
fun addResponse(
uri: Uri,
statusCode: Response.IStatus,
- headers: Map<String, String>? = null,
+ locationHeader: String? = null,
content: String = ""
) {
addResponse(Request(uri.path
?: "", Method.GET, uri.query ?: ""),
- statusCode, headers, content)
+ statusCode, locationHeader, content)
}
/**
@@ -68,13 +68,11 @@
fun addResponse(
request: Request,
statusCode: Response.IStatus,
- headers: Map<String, String>? = null,
+ locationHeader: String? = null,
content: String = ""
) {
val response = newFixedLengthResponse(statusCode, "text/plain", content)
- headers?.forEach {
- (key, value) -> response.addHeader(key, value)
- }
+ locationHeader?.let { response.addHeader("Location", it) }
responses[request] = response
}
diff --git a/common/testutils/devicetests/com/android/testutils/TestNetworkTracker.kt b/common/testutils/devicetests/com/android/testutils/TestNetworkTracker.kt
index 40731ea..5b97861 100644
--- a/common/testutils/devicetests/com/android/testutils/TestNetworkTracker.kt
+++ b/common/testutils/devicetests/com/android/testutils/TestNetworkTracker.kt
@@ -26,40 +26,20 @@
import android.net.TestNetworkInterface
import android.net.TestNetworkManager
import android.os.Binder
-import com.android.modules.utils.build.SdkLevel.isAtLeastS
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit
/**
- * Create a test network based on a TUN interface with a LinkAddress.
+ * Create a test network based on a TUN interface.
*
* This method will block until the test network is available. Requires
* [android.Manifest.permission.CHANGE_NETWORK_STATE] and
* [android.Manifest.permission.MANAGE_TEST_NETWORKS].
*/
-fun initTestNetwork(
- context: Context,
- interfaceAddr: LinkAddress,
- setupTimeoutMs: Long = 10_000L
-): TestNetworkTracker {
- return initTestNetwork(context, listOf(interfaceAddr), setupTimeoutMs)
-}
-
-/**
- * Create a test network based on a TUN interface with giving LinkAddress list.
- *
- * This method will block until the test network is available. Requires
- * [android.Manifest.permission.CHANGE_NETWORK_STATE] and
- * [android.Manifest.permission.MANAGE_TEST_NETWORKS].
- */
-fun initTestNetwork(
- context: Context,
- linkAddrs: List<LinkAddress>,
- setupTimeoutMs: Long = 10_000L
-): TestNetworkTracker {
+fun initTestNetwork(context: Context, interfaceAddr: LinkAddress, setupTimeoutMs: Long = 10_000L):
+ TestNetworkTracker {
val tnm = context.getSystemService(TestNetworkManager::class.java)
- val iface = if (isAtLeastS()) tnm.createTunInterface(linkAddrs)
- else tnm.createTunInterface(linkAddrs.toTypedArray())
+ val iface = tnm.createTunInterface(arrayOf(interfaceAddr))
return TestNetworkTracker(context, iface, tnm, setupTimeoutMs)
}
@@ -71,7 +51,7 @@
class TestNetworkTracker internal constructor(
val context: Context,
val iface: TestNetworkInterface,
- val tnm: TestNetworkManager,
+ tnm: TestNetworkManager,
setupTimeoutMs: Long
) {
private val cm = context.getSystemService(ConnectivityManager::class.java)
@@ -79,7 +59,6 @@
private val networkCallback: NetworkCallback
val network: Network
- val testIface: TestNetworkInterface
init {
val networkFuture = CompletableFuture<Network>()
@@ -104,12 +83,9 @@
teardown()
throw e
}
-
- testIface = iface
}
fun teardown() {
cm.unregisterNetworkCallback(networkCallback)
- tnm.teardownTestNetwork(network)
}
}
\ No newline at end of file
diff --git a/common/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt b/common/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt
index 7d851f1..1b3d0f6 100644
--- a/common/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt
+++ b/common/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt
@@ -116,7 +116,6 @@
val mark get() = history.mark
override fun onAvailable(network: Network) {
- Log.d(TAG, "onAvailable $network")
history.add(Available(network))
}
@@ -200,15 +199,6 @@
if (null != cb) fail("Expected no callback but got $cb")
}
- fun assertNoCallbackThat(
- timeoutMs: Long = defaultTimeoutMs,
- valid: (CallbackEntry) -> Boolean
- ) {
- val cb = history.poll(timeoutMs) { valid(it) }.let {
- if (null != it) fail("Expected no callback but got $it")
- }
- }
-
// Expects a callback of the specified type on the specified network within the timeout.
// If no callback arrives, or a different callback arrives, fail. Returns the callback.
inline fun <reified T : CallbackEntry> expectCallback(
diff --git a/common/testutils/devicetests/com/android/testutils/TestableNetworkOfferCallback.kt b/common/testutils/devicetests/com/android/testutils/TestableNetworkOfferCallback.kt
deleted file mode 100644
index 21bd60c..0000000
--- a/common/testutils/devicetests/com/android/testutils/TestableNetworkOfferCallback.kt
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.testutils
-
-import android.net.NetworkCapabilities
-import android.net.NetworkProvider
-import android.net.NetworkRequest
-import android.util.Log
-import com.android.net.module.util.ArrayTrackRecord
-import kotlin.test.fail
-
-class TestableNetworkOfferCallback(val timeoutMs: Long, private val noCallbackTimeoutMs: Long)
- : NetworkProvider.NetworkOfferCallback {
- private val TAG = this::class.simpleName
- val history = ArrayTrackRecord<CallbackEntry>().newReadHead()
-
- sealed class CallbackEntry {
- data class OnNetworkNeeded(val request: NetworkRequest) : CallbackEntry()
- data class OnNetworkUnneeded(val request: NetworkRequest) : CallbackEntry()
- }
-
- /**
- * Called by the system when a network for this offer is needed to satisfy some
- * networking request.
- */
- override fun onNetworkNeeded(request: NetworkRequest) {
- Log.d(TAG, "onNetworkNeeded $request")
- history.add(CallbackEntry.OnNetworkNeeded(request))
- }
-
- /**
- * Called by the system when this offer is no longer valuable for this request.
- */
- override fun onNetworkUnneeded(request: NetworkRequest) {
- Log.d(TAG, "onNetworkUnneeded $request")
- history.add(CallbackEntry.OnNetworkUnneeded(request))
- }
-
- inline fun <reified T : CallbackEntry> expectCallbackThat(
- crossinline predicate: (T) -> Boolean
- ) {
- val event = history.poll(timeoutMs)
- ?: fail("Did not receive callback after ${timeoutMs}ms")
- if (event !is T || !predicate(event)) fail("Received unexpected callback $event")
- }
-
- fun expectOnNetworkNeeded(capabilities: NetworkCapabilities) =
- expectCallbackThat<CallbackEntry.OnNetworkNeeded> {
- it.request.canBeSatisfiedBy(capabilities)
- }
-
- fun expectOnNetworkUnneeded(capabilities: NetworkCapabilities) =
- expectCallbackThat<CallbackEntry.OnNetworkUnneeded> {
- it.request.canBeSatisfiedBy(capabilities)
- }
-
- fun assertNoCallback() {
- val cb = history.poll(noCallbackTimeoutMs)
- if (null != cb) fail("Expected no callback but got $cb")
- }
-}
\ No newline at end of file
diff --git a/common/testutils/devicetests/com/android/testutils/TestableNetworkStatsProvider.kt b/common/testutils/devicetests/com/android/testutils/TestableNetworkStatsProvider.kt
index be5c9b2..d5c3a2a 100644
--- a/common/testutils/devicetests/com/android/testutils/TestableNetworkStatsProvider.kt
+++ b/common/testutils/devicetests/com/android/testutils/TestableNetworkStatsProvider.kt
@@ -23,23 +23,13 @@
import kotlin.test.fail
private const val DEFAULT_TIMEOUT_MS = 200L
-const val TOKEN_ANY = -1
open class TestableNetworkStatsProvider(
val defaultTimeoutMs: Long = DEFAULT_TIMEOUT_MS
) : NetworkStatsProvider() {
sealed class CallbackType {
data class OnRequestStatsUpdate(val token: Int) : CallbackType()
- data class OnSetWarningAndLimit(
- val iface: String,
- val warningBytes: Long,
- val limitBytes: Long
- ) : CallbackType()
- data class OnSetLimit(val iface: String, val limitBytes: Long) : CallbackType() {
- // Add getter for backward compatibility since old tests do not recognize limitBytes.
- val quotaBytes: Long
- get() = limitBytes
- }
+ data class OnSetLimit(val iface: String?, val quotaBytes: Long) : CallbackType()
data class OnSetAlert(val quotaBytes: Long) : CallbackType()
}
@@ -51,10 +41,6 @@
history.add(CallbackType.OnRequestStatsUpdate(token))
}
- override fun onSetWarningAndLimit(iface: String, warningBytes: Long, limitBytes: Long) {
- history.add(CallbackType.OnSetWarningAndLimit(iface, warningBytes, limitBytes))
- }
-
override fun onSetLimit(iface: String, quotaBytes: Long) {
history.add(CallbackType.OnSetLimit(iface, quotaBytes))
}
@@ -63,16 +49,11 @@
history.add(CallbackType.OnSetAlert(quotaBytes))
}
- fun expectOnRequestStatsUpdate(token: Int, timeout: Long = defaultTimeoutMs): Int {
- val event = history.poll(timeout)
- assertTrue(event is CallbackType.OnRequestStatsUpdate)
- if (token != TOKEN_ANY) {
- assertEquals(token, event.token)
- }
- return event.token
+ fun expectOnRequestStatsUpdate(token: Int, timeout: Long = defaultTimeoutMs) {
+ assertEquals(CallbackType.OnRequestStatsUpdate(token), history.poll(timeout))
}
- fun expectOnSetLimit(iface: String, quotaBytes: Long, timeout: Long = defaultTimeoutMs) {
+ fun expectOnSetLimit(iface: String?, quotaBytes: Long, timeout: Long = defaultTimeoutMs) {
assertEquals(CallbackType.OnSetLimit(iface, quotaBytes), history.poll(timeout))
}
diff --git a/common/testutils/devicetests/com/android/testutils/TestableNetworkStatsProviderCbBinder.kt b/common/testutils/devicetests/com/android/testutils/TestableNetworkStatsProviderCbBinder.kt
index c039cad..f15f610 100644
--- a/common/testutils/devicetests/com/android/testutils/TestableNetworkStatsProviderCbBinder.kt
+++ b/common/testutils/devicetests/com/android/testutils/TestableNetworkStatsProviderCbBinder.kt
@@ -32,7 +32,6 @@
val uidStats: NetworkStats
) : CallbackType()
object NotifyWarningOrLimitReached : CallbackType()
- object LegacyNotifyLimitReached : CallbackType()
object NotifyAlertReached : CallbackType()
object Unregister : CallbackType()
}
@@ -47,11 +46,6 @@
history.add(CallbackType.NotifyWarningOrLimitReached)
}
- override fun notifyLimitReached() {
- // Older callback renamed to notifyWarningOrLimitReached in S
- history.add(CallbackType.LegacyNotifyLimitReached)
- }
-
override fun notifyAlertReached() {
history.add(CallbackType.NotifyAlertReached)
}
@@ -78,9 +72,6 @@
fun expectNotifyWarningOrLimitReached() =
assertEquals(CallbackType.NotifyWarningOrLimitReached, history.poll(DEFAULT_TIMEOUT_MS))
- fun expectLegacyNotifyLimitReached() =
- assertEquals(CallbackType.LegacyNotifyLimitReached, history.poll(DEFAULT_TIMEOUT_MS))
-
fun expectNotifyAlertReached() =
assertEquals(CallbackType.NotifyAlertReached, history.poll(DEFAULT_TIMEOUT_MS))
diff --git a/common/testutils/hostdevice/com/android/testutils/Cleanup.kt b/common/testutils/hostdevice/com/android/testutils/Cleanup.kt
deleted file mode 100644
index 769d980..0000000
--- a/common/testutils/hostdevice/com/android/testutils/Cleanup.kt
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@file:JvmName("Cleanup")
-
-package com.android.testutils
-
-import com.android.testutils.ExceptionUtils.ThrowingRunnable
-import javax.annotation.CheckReturnValue
-
-/**
- * Utility to do cleanup in tests without replacing exceptions with those from a finally block.
- *
- * This utility is meant for tests that want to do cleanup after they execute their test
- * logic, whether the test fails (and throws) or not.
- *
- * The usual way of doing this is to have a try{}finally{} block and put cleanup in finally{}.
- * However, if any code in finally{} throws, the exception thrown in finally{} is thrown before
- * any thrown in try{} ; that means errors reported from tests are from finally{} even if they
- * have been caused by errors in try{}. This is unhelpful in tests, because it results in a
- * stacktrace for a symptom rather than a stacktrace for a cause.
- *
- * To alleviate this, tests are encouraged to make sure the code in finally{} can't throw, or
- * that the code in try{} can't cause it to fail. This is not always realistic ; not only does
- * it require the developer thinks about complex interactions of code, test code often relies
- * on bricks provided by other teams, not controlled by the team writing the test, which may
- * start throwing with an update (see b/198998862 for an example).
- *
- * This utility allows a different approach : it offers a new construct, tryTest{}cleanup{} similar
- * to try{}finally{}, but that will always throw the first exception that happens. In other words,
- * if only tryTest{} throws or only cleanup{} throws, that exception will be thrown, but contrary
- * to the standard try{}finally{}, if both throws, the construct throws the exception that happened
- * in tryTest{} rather than the one that happened in cleanup{}.
- *
- * Kotlin usage is as try{}finally{} :
- * tryTest {
- * testing code
- * } cleanup {
- * cleanup code
- * }
- *
- * Java doesn't allow this kind of syntax, so instead a function taking 2 lambdas is provided.
- * testAndCleanup(() -> {
- * testing code
- * }, () -> {
- * cleanup code
- * });
- */
-class ExceptionCleanupBlock(val originalException: Exception?) {
- inline infix fun cleanup(block: () -> Unit) {
- try {
- block()
- if (null != originalException) throw originalException
- } catch (e: Exception) {
- if (null == originalException) {
- throw e
- } else {
- originalException.addSuppressed(e)
- throw originalException
- }
- }
- }
-}
-
-@CheckReturnValue
-inline fun tryTest(block: () -> Unit): ExceptionCleanupBlock {
- try {
- block()
- } catch (e: Exception) {
- return ExceptionCleanupBlock(e)
- }
- return ExceptionCleanupBlock(null)
-}
-
-// Java support
-fun testAndCleanup(tryBlock: ThrowingRunnable, cleanupBlock: ThrowingRunnable) {
- tryTest {
- tryBlock.run()
- } cleanup {
- cleanupBlock.run()
- }
-}
diff --git a/common/testutils/hostdevice/com/android/testutils/ConnectivityModuleTest.kt b/common/testutils/hostdevice/com/android/testutils/ConnectivityModuleTest.kt
deleted file mode 100644
index ec485fe..0000000
--- a/common/testutils/hostdevice/com/android/testutils/ConnectivityModuleTest.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.testutils
-
-/**
- * Indicates that the test covers functionality that was rolled out in a connectivity module update.
- *
- * Annotated MTS tests will typically only be run in Connectivity/Tethering module MTS, and not when
- * only other modules (such as NetworkStack) have been updated.
- * Annotated CTS tests will always be run, as the Connectivity module should be at least newer than
- * the CTS suite.
- */
-annotation class ConnectivityModuleTest