diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-15 00:41:31 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-15 00:41:31 +0000 |
commit | 8d2a712a92e03a4e96d5382813abbfa8c1db45b7 (patch) | |
tree | 841265c0e0a1db2c4c044ba56b676c224fea28d4 | |
parent | 5b30bd114f404f2de3ed030755061442dd6a569c (diff) | |
parent | ba22e8166a51f623ba05b6bce5d5ceaa01814a33 (diff) | |
download | NetworkStack-android14-qpr2-s1-release.tar.gz |
Snap for 11220357 from ba22e8166a51f623ba05b6bce5d5ceaa01814a33 to 24Q1-releaseandroid-14.0.0_r33android-14.0.0_r32android-14.0.0_r31android-14.0.0_r30android-14.0.0_r29android14-qpr2-s3-releaseandroid14-qpr2-s2-releaseandroid14-qpr2-s1-releaseandroid14-qpr2-release
Change-Id: I0f431ba4ee1d63db0d5b3d17645614ae3361a09a
48 files changed, 1890 insertions, 318 deletions
@@ -320,7 +320,6 @@ java_defaults { "datastallprotosnano", "statsprotos", "captiveportal-lib", - "net-utils-device-common", "net-utils-device-common-ip", "net-utils-device-common-netlink", "net-utils-device-common-struct", @@ -389,6 +388,7 @@ java_library { "modules-utils-build", "net-utils-framework-common", "networkstack-client", + "net-utils-device-common", ], // If this library is ever used outside of tests, it should not use "Dhcp*Packet", and specify // its contents explicitly. diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 259a4038..a65d0d5c 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -45,6 +45,10 @@ <uses-permission android:name="android.permission.READ_DEVICE_CONFIG" /> <!-- Signature permission defined in NetworkStackStub --> <uses-permission android:name="android.permission.MAINLINE_NETWORK_STACK" /> + <!-- Crash while reading deviceownerName security exception --> + <uses-permission android:name="android.permission.MANAGE_USERS"/> + <!-- ends here --> + <application android:extractNativeLibs="false" android:persistent="true" diff --git a/common/networkstackclient/Android.bp b/common/networkstackclient/Android.bp index e056e3bf..07fd52e1 100644 --- a/common/networkstackclient/Android.bp +++ b/common/networkstackclient/Android.bp @@ -48,21 +48,54 @@ aidl_interface { enabled: false, }, }, - versions: [ - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "10", - ], + visibility: [ "//system/tools/aidl/build", ], + versions_with_info: [ + { + version: "1", + imports: [], + }, + { + version: "2", + imports: [], + }, + { + version: "3", + imports: [], + }, + { + version: "4", + imports: [], + }, + { + version: "5", + imports: [], + }, + { + version: "6", + imports: [], + }, + { + version: "7", + imports: [], + }, + { + version: "8", + imports: [], + }, + { + version: "9", + imports: [], + }, + { + version: "10", + imports: [], + }, + + ], + } aidl_interface { @@ -164,12 +197,13 @@ aidl_interface { version: "19", imports: ["ipmemorystore-aidl-interfaces-V10"], }, + { + version: "20", + imports: ["ipmemorystore-aidl-interfaces-V10"], + }, ], - - // "frozen: true" is removed manually after each freeze, this property cannot be unrecognized - // in some downstream branches and TH will get the build error, see b/262507066 for details. - + frozen: true, } java_library { @@ -178,7 +212,7 @@ java_library { min_sdk_version: "30", static_libs: [ "ipmemorystore-aidl-interfaces-V10-java", - "networkstack-aidl-interfaces-V19-java", + "networkstack-aidl-interfaces-V20-java", ], visibility: ["//packages/modules/NetworkStack:__subpackages__"], apex_available: [ diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/.hash b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/.hash new file mode 100644 index 00000000..e447bdd7 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/.hash @@ -0,0 +1 @@ +fdb37ac2749e155d9d5aa51541ec254dc36dc353 diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/DataStallReportParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/DataStallReportParcelable.aidl new file mode 100644 index 00000000..771deda4 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/DataStallReportParcelable.aidl @@ -0,0 +1,42 @@ +/** + * 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 perNmissions 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; +@JavaDerive(toString=true) +parcelable DataStallReportParcelable { + long timestampMillis = 0; + int detectionMethod = 1; + int tcpPacketFailRate = 2; + int tcpMetricsCollectionPeriodMillis = 3; + int dnsConsecutiveTimeouts = 4; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/DhcpResultsParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/DhcpResultsParcelable.aidl new file mode 100644 index 00000000..31f2194a --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/DhcpResultsParcelable.aidl @@ -0,0 +1,44 @@ +/** + * 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 perNmissions 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; +@JavaDerive(toString=true) +parcelable DhcpResultsParcelable { + android.net.StaticIpConfiguration baseConfiguration; + int leaseDuration; + int mtu; + String serverAddress; + String vendorInfo; + @nullable String serverHostName; + @nullable String captivePortalApiUrl; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/INetworkMonitor.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/INetworkMonitor.aidl new file mode 100644 index 00000000..fb13c0cb --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/INetworkMonitor.aidl @@ -0,0 +1,60 @@ +/** + * 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 perNmissions 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 INetworkMonitor { + oneway void start(); + oneway void launchCaptivePortalApp(); + oneway void notifyCaptivePortalAppFinished(int response); + oneway void setAcceptPartialConnectivity(); + oneway void forceReevaluation(int uid); + oneway void notifyPrivateDnsChanged(in android.net.PrivateDnsConfigParcel config); + oneway void notifyDnsResponse(int returnCode); + oneway void notifyNetworkConnected(in android.net.LinkProperties lp, in android.net.NetworkCapabilities nc); + oneway void notifyNetworkDisconnected(); + oneway void notifyLinkPropertiesChanged(in android.net.LinkProperties lp); + oneway void notifyNetworkCapabilitiesChanged(in android.net.NetworkCapabilities nc); + oneway void notifyNetworkConnectedParcel(in android.net.networkstack.aidl.NetworkMonitorParameters params); + const int NETWORK_TEST_RESULT_VALID = 0; + const int NETWORK_TEST_RESULT_INVALID = 1; + const int NETWORK_TEST_RESULT_PARTIAL_CONNECTIVITY = 2; + const int NETWORK_VALIDATION_RESULT_VALID = 0x01; + const int NETWORK_VALIDATION_RESULT_PARTIAL = 0x02; + const int NETWORK_VALIDATION_RESULT_SKIPPED = 0x04; + const int NETWORK_VALIDATION_PROBE_DNS = 0x04; + const int NETWORK_VALIDATION_PROBE_HTTP = 0x08; + const int NETWORK_VALIDATION_PROBE_HTTPS = 0x10; + const int NETWORK_VALIDATION_PROBE_FALLBACK = 0x20; + const int NETWORK_VALIDATION_PROBE_PRIVDNS = 0x40; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/INetworkMonitorCallbacks.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/INetworkMonitorCallbacks.aidl new file mode 100644 index 00000000..36eda8e7 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/INetworkMonitorCallbacks.aidl @@ -0,0 +1,46 @@ +/* + * 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 INetworkMonitorCallbacks { + oneway void onNetworkMonitorCreated(in android.net.INetworkMonitor networkMonitor) = 0; + oneway void notifyNetworkTested(int testResult, @nullable String redirectUrl) = 1; + oneway void notifyPrivateDnsConfigResolved(in android.net.PrivateDnsConfigParcel config) = 2; + oneway void showProvisioningNotification(String action, String packageName) = 3; + oneway void hideProvisioningNotification() = 4; + oneway void notifyProbeStatusChanged(int probesCompleted, int probesSucceeded) = 5; + oneway void notifyNetworkTestedWithExtras(in android.net.NetworkTestResultParcelable result) = 6; + oneway void notifyDataStallSuspected(in android.net.DataStallReportParcelable report) = 7; + oneway void notifyCaptivePortalDataChanged(in android.net.CaptivePortalData data) = 8; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/INetworkStackConnector.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/INetworkStackConnector.aidl new file mode 100644 index 00000000..8120ffc3 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/INetworkStackConnector.aidl @@ -0,0 +1,42 @@ +/** + * 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 perNmissions 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 INetworkStackConnector { + oneway void makeDhcpServer(in String ifName, in android.net.dhcp.DhcpServingParamsParcel params, in android.net.dhcp.IDhcpServerCallbacks cb); + oneway void makeNetworkMonitor(in android.net.Network network, String name, in android.net.INetworkMonitorCallbacks cb); + oneway void makeIpClient(in String ifName, in android.net.ip.IIpClientCallbacks callbacks); + oneway void fetchIpMemoryStore(in android.net.IIpMemoryStoreCallbacks cb); + oneway void allowTestUid(int uid, in android.net.INetworkStackStatusCallback cb); +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/INetworkStackStatusCallback.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/INetworkStackStatusCallback.aidl new file mode 100644 index 00000000..0b6b7788 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/INetworkStackStatusCallback.aidl @@ -0,0 +1,38 @@ +/* + * 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 INetworkStackStatusCallback { + oneway void onStatusAvailable(int statusCode); +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/InformationElementParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/InformationElementParcelable.aidl new file mode 100644 index 00000000..61037749 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/InformationElementParcelable.aidl @@ -0,0 +1,39 @@ +/* + * 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; +@JavaDerive(toString=true) +parcelable InformationElementParcelable { + int id; + byte[] payload; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/InitialConfigurationParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/InitialConfigurationParcelable.aidl new file mode 100644 index 00000000..6a597e65 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/InitialConfigurationParcelable.aidl @@ -0,0 +1,41 @@ +/* + * 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; +@JavaDerive(toString=true) +parcelable InitialConfigurationParcelable { + android.net.LinkAddress[] ipAddresses; + android.net.IpPrefix[] directlyConnectedRoutes; + String[] dnsServers; + String gateway; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/Layer2InformationParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/Layer2InformationParcelable.aidl new file mode 100644 index 00000000..83796ee8 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/Layer2InformationParcelable.aidl @@ -0,0 +1,40 @@ +/* + * 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; +@JavaDerive(toString=true) +parcelable Layer2InformationParcelable { + String l2Key; + String cluster; + android.net.MacAddress bssid; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/Layer2PacketParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/Layer2PacketParcelable.aidl new file mode 100644 index 00000000..4b3fff52 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/Layer2PacketParcelable.aidl @@ -0,0 +1,39 @@ +/** + * 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 perNmissions 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; +@JavaDerive(toString=true) +parcelable Layer2PacketParcelable { + android.net.MacAddress dstMacAddress; + byte[] payload; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/NattKeepalivePacketDataParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/NattKeepalivePacketDataParcelable.aidl new file mode 100644 index 00000000..18cf954a --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/NattKeepalivePacketDataParcelable.aidl @@ -0,0 +1,41 @@ +/* + * 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; +@JavaDerive(toString=true) +parcelable NattKeepalivePacketDataParcelable { + byte[] srcAddress; + int srcPort; + byte[] dstAddress; + int dstPort; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/NetworkTestResultParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/NetworkTestResultParcelable.aidl new file mode 100644 index 00000000..4d6d5a23 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/NetworkTestResultParcelable.aidl @@ -0,0 +1,42 @@ +/** + * 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 perNmissions 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; +@JavaDerive(toString=true) +parcelable NetworkTestResultParcelable { + long timestampMillis; + int result; + int probesSucceeded; + int probesAttempted; + String redirectUrl; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/PrivateDnsConfigParcel.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/PrivateDnsConfigParcel.aidl new file mode 100644 index 00000000..ab62fe77 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/PrivateDnsConfigParcel.aidl @@ -0,0 +1,44 @@ +/* + * 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; +@JavaDerive(equals=true, toString=true) +parcelable PrivateDnsConfigParcel { + String hostname; + String[] ips; + int privateDnsMode = (-1) /* -1 */; + String dohName = ""; + String[] dohIps = {}; + String dohPath = ""; + int dohPort = (-1) /* -1 */; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/ProvisioningConfigurationParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/ProvisioningConfigurationParcelable.aidl new file mode 100644 index 00000000..7061f1ea --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/ProvisioningConfigurationParcelable.aidl @@ -0,0 +1,64 @@ +/* +** +** 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; +@JavaDerive(toString=true) +parcelable ProvisioningConfigurationParcelable { + /** + * @deprecated use ipv4ProvisioningMode instead. + */ + boolean enableIPv4; + /** + * @deprecated use ipv6ProvisioningMode instead. + */ + boolean enableIPv6; + boolean usingMultinetworkPolicyTracker; + boolean usingIpReachabilityMonitor; + int requestedPreDhcpActionMs; + android.net.InitialConfigurationParcelable initialConfig; + android.net.StaticIpConfiguration staticIpConfig; + android.net.apf.ApfCapabilities apfCapabilities; + int provisioningTimeoutMs; + int ipv6AddrGenMode; + android.net.Network network; + String displayName; + boolean enablePreconnection; + @nullable android.net.ScanResultInfoParcelable scanResultInfo; + @nullable android.net.Layer2InformationParcelable layer2Info; + @nullable List<android.net.networkstack.aidl.dhcp.DhcpOption> options; + int ipv4ProvisioningMode; + int ipv6ProvisioningMode; + boolean uniqueEui64AddressesOnly; + int creatorUid; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/ScanResultInfoParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/ScanResultInfoParcelable.aidl new file mode 100644 index 00000000..94fc27ff --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/ScanResultInfoParcelable.aidl @@ -0,0 +1,40 @@ +/* + * 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; +@JavaDerive(toString=true) +parcelable ScanResultInfoParcelable { + String ssid; + String bssid; + android.net.InformationElementParcelable[] informationElements; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/TcpKeepalivePacketDataParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/TcpKeepalivePacketDataParcelable.aidl new file mode 100644 index 00000000..0e1c21c9 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/TcpKeepalivePacketDataParcelable.aidl @@ -0,0 +1,47 @@ +/* + * 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; +@JavaDerive(toString=true) +parcelable TcpKeepalivePacketDataParcelable { + byte[] srcAddress; + int srcPort; + byte[] dstAddress; + int dstPort; + int seq; + int ack; + int rcvWnd; + int rcvWndScale; + int tos; + int ttl; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/DhcpLeaseParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/DhcpLeaseParcelable.aidl new file mode 100644 index 00000000..3cd8860e --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/DhcpLeaseParcelable.aidl @@ -0,0 +1,43 @@ +/** + * 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 perNmissions 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.dhcp; +@JavaDerive(toString=true) +parcelable DhcpLeaseParcelable { + byte[] clientId; + byte[] hwAddr; + int netAddr; + int prefixLength; + long expTime; + String hostname; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/DhcpServingParamsParcel.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/DhcpServingParamsParcel.aidl new file mode 100644 index 00000000..7997936e --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/DhcpServingParamsParcel.aidl @@ -0,0 +1,49 @@ +/** + * + * 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.dhcp; +@JavaDerive(toString=true) +parcelable DhcpServingParamsParcel { + int serverAddr; + int serverAddrPrefixLength; + int[] defaultRouters; + int[] dnsServers; + int[] excludedAddrs; + long dhcpLeaseTimeSecs; + int linkMtu; + boolean metered; + int singleClientAddr = 0; + boolean changePrefixOnDecline = false; + int leasesSubnetPrefixLength = 0; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/IDhcpEventCallbacks.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/IDhcpEventCallbacks.aidl new file mode 100644 index 00000000..9312f47a --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/IDhcpEventCallbacks.aidl @@ -0,0 +1,38 @@ +/** + * 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 perNmissions 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.dhcp; +interface IDhcpEventCallbacks { + oneway void onLeasesChanged(in List<android.net.dhcp.DhcpLeaseParcelable> newLeases); + oneway void onNewPrefixRequest(in android.net.IpPrefix currentPrefix); +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/IDhcpServer.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/IDhcpServer.aidl new file mode 100644 index 00000000..1109f35f --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/IDhcpServer.aidl @@ -0,0 +1,45 @@ +/** + * 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 perNmissions 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.dhcp; +/* @hide */ +interface IDhcpServer { + oneway void start(in android.net.INetworkStackStatusCallback cb) = 0; + oneway void startWithCallbacks(in android.net.INetworkStackStatusCallback statusCb, in android.net.dhcp.IDhcpEventCallbacks eventCb) = 3; + oneway void updateParams(in android.net.dhcp.DhcpServingParamsParcel params, in android.net.INetworkStackStatusCallback cb) = 1; + oneway void stop(in android.net.INetworkStackStatusCallback cb) = 2; + const int STATUS_UNKNOWN = 0; + const int STATUS_SUCCESS = 1; + const int STATUS_INVALID_ARGUMENT = 2; + const int STATUS_UNKNOWN_ERROR = 3; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/IDhcpServerCallbacks.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/IDhcpServerCallbacks.aidl new file mode 100644 index 00000000..ab8577c6 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/dhcp/IDhcpServerCallbacks.aidl @@ -0,0 +1,38 @@ +/** + * 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 perNmissions 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.dhcp; +/* @hide */ +interface IDhcpServerCallbacks { + oneway void onDhcpServerCreated(int statusCode, in android.net.dhcp.IDhcpServer server); +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/ip/IIpClient.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/ip/IIpClient.aidl new file mode 100644 index 00000000..b81ec209 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/ip/IIpClient.aidl @@ -0,0 +1,59 @@ +/** + * 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 perNmissions 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.ip; +/* @hide */ +interface IIpClient { + oneway void completedPreDhcpAction(); + oneway void confirmConfiguration(); + oneway void readPacketFilterComplete(in byte[] data); + oneway void shutdown(); + oneway void startProvisioning(in android.net.ProvisioningConfigurationParcelable req); + oneway void stop(); + oneway void setTcpBufferSizes(in String tcpBufferSizes); + oneway void setHttpProxy(in android.net.ProxyInfo proxyInfo); + oneway void setMulticastFilter(boolean enabled); + oneway void addKeepalivePacketFilter(int slot, in android.net.TcpKeepalivePacketDataParcelable pkt); + oneway void removeKeepalivePacketFilter(int slot); + oneway void setL2KeyAndGroupHint(in String l2Key, in String cluster); + oneway void addNattKeepalivePacketFilter(int slot, in android.net.NattKeepalivePacketDataParcelable pkt); + oneway void notifyPreconnectionComplete(boolean success); + oneway void updateLayer2Information(in android.net.Layer2InformationParcelable info); + oneway void updateApfCapabilities(in android.net.apf.ApfCapabilities apfCapabilities); + const int PROV_IPV4_DISABLED = 0x00; + const int PROV_IPV4_STATIC = 0x01; + const int PROV_IPV4_DHCP = 0x02; + const int PROV_IPV6_DISABLED = 0x00; + const int PROV_IPV6_SLAAC = 0x01; + const int PROV_IPV6_LINKLOCAL = 0x02; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/ip/IIpClientCallbacks.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/ip/IIpClientCallbacks.aidl new file mode 100644 index 00000000..9d364195 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/ip/IIpClientCallbacks.aidl @@ -0,0 +1,54 @@ +/** + * 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 perNmissions 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.ip; +/* @hide */ +interface IIpClientCallbacks { + oneway void onIpClientCreated(in android.net.ip.IIpClient ipClient); + oneway void onPreDhcpAction(); + oneway void onPostDhcpAction(); + oneway void onNewDhcpResults(in android.net.DhcpResultsParcelable dhcpResults); + oneway void onProvisioningSuccess(in android.net.LinkProperties newLp); + oneway void onProvisioningFailure(in android.net.LinkProperties newLp); + oneway void onLinkPropertiesChange(in android.net.LinkProperties newLp); + oneway void onReachabilityLost(in String logMsg); + oneway void onQuit(); + oneway void installPacketFilter(in byte[] filter); + oneway void startReadPacketFilter(); + oneway void setFallbackMulticastFilter(boolean enabled); + oneway void setNeighborDiscoveryOffload(boolean enable); + oneway void onPreconnectionStart(in List<android.net.Layer2PacketParcelable> packets); + oneway void onReachabilityFailure(in android.net.networkstack.aidl.ip.ReachabilityLossInfoParcelable lossInfo); + oneway void setMaxDtimMultiplier(int multiplier); + const int DTIM_MULTIPLIER_RESET = 0; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/networkstack/aidl/NetworkMonitorParameters.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/networkstack/aidl/NetworkMonitorParameters.aidl new file mode 100644 index 00000000..2ab9db06 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/networkstack/aidl/NetworkMonitorParameters.aidl @@ -0,0 +1,41 @@ +/** + * + * Copyright (C) 2022 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.networkstack.aidl; +@JavaDerive(equals=true, toString=true) +parcelable NetworkMonitorParameters { + android.net.NetworkAgentConfig networkAgentConfig; + android.net.NetworkCapabilities networkCapabilities; + android.net.LinkProperties linkProperties; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/networkstack/aidl/dhcp/DhcpOption.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/networkstack/aidl/dhcp/DhcpOption.aidl new file mode 100644 index 00000000..eea3e0d6 --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/networkstack/aidl/dhcp/DhcpOption.aidl @@ -0,0 +1,39 @@ +/** + * 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 perNmissions 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.networkstack.aidl.dhcp; +@JavaDerive(toString=true) +parcelable DhcpOption { + byte type; + @nullable byte[] value; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/networkstack/aidl/ip/ReachabilityLossInfoParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/networkstack/aidl/ip/ReachabilityLossInfoParcelable.aidl new file mode 100644 index 00000000..bb88434b --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/networkstack/aidl/ip/ReachabilityLossInfoParcelable.aidl @@ -0,0 +1,39 @@ +/* + * 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.networkstack.aidl.ip; +@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable +parcelable ReachabilityLossInfoParcelable { + String message; + android.net.networkstack.aidl.ip.ReachabilityLossReason reason; +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/networkstack/aidl/ip/ReachabilityLossReason.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/networkstack/aidl/ip/ReachabilityLossReason.aidl new file mode 100644 index 00000000..f9bb3c4a --- /dev/null +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/20/android/net/networkstack/aidl/ip/ReachabilityLossReason.aidl @@ -0,0 +1,40 @@ +/* + * 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.networkstack.aidl.ip; +@Backing(type="int") +enum ReachabilityLossReason { + ROAM, + CONFIRM, + ORGANIC, +} diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/ProvisioningConfigurationParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/ProvisioningConfigurationParcelable.aidl index fba524b7..7061f1ea 100644 --- a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/ProvisioningConfigurationParcelable.aidl +++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/ProvisioningConfigurationParcelable.aidl @@ -60,4 +60,5 @@ parcelable ProvisioningConfigurationParcelable { int ipv4ProvisioningMode; int ipv6ProvisioningMode; boolean uniqueEui64AddressesOnly; + int creatorUid; } diff --git a/common/networkstackclient/src/android/net/ProvisioningConfigurationParcelable.aidl b/common/networkstackclient/src/android/net/ProvisioningConfigurationParcelable.aidl index c4d7866d..7ab612fe 100644 --- a/common/networkstackclient/src/android/net/ProvisioningConfigurationParcelable.aidl +++ b/common/networkstackclient/src/android/net/ProvisioningConfigurationParcelable.aidl @@ -50,4 +50,5 @@ parcelable ProvisioningConfigurationParcelable { int ipv4ProvisioningMode; int ipv6ProvisioningMode; boolean uniqueEui64AddressesOnly; + int creatorUid; } diff --git a/common/networkstackclient/src/android/net/shared/Layer2Information.java b/common/networkstackclient/src/android/net/shared/Layer2Information.java index 8cdd0189..f3845092 100644 --- a/common/networkstackclient/src/android/net/shared/Layer2Information.java +++ b/common/networkstackclient/src/android/net/shared/Layer2Information.java @@ -30,7 +30,6 @@ public class Layer2Information { public final String mCluster; @Nullable public final MacAddress mBssid; - /** * Create a Layer2Information with the specified configuration. */ diff --git a/common/networkstackclient/src/android/net/shared/ProvisioningConfiguration.java b/common/networkstackclient/src/android/net/shared/ProvisioningConfiguration.java index f3631f27..16ad2015 100644 --- a/common/networkstackclient/src/android/net/shared/ProvisioningConfiguration.java +++ b/common/networkstackclient/src/android/net/shared/ProvisioningConfiguration.java @@ -228,6 +228,14 @@ public class ProvisioningConfiguration { } /** + * Specify the UID of the remote entity that created this Network. + */ + public Builder withCreatorUid(int creatoruid) { + mConfig.mCreatorUid = creatoruid; + return this; + } + + /** * Specify the information elements included in wifi scan result that was obtained * prior to connecting to the access point, if this is a WiFi network. * @@ -492,6 +500,7 @@ public class ProvisioningConfiguration { public List<DhcpOption> mDhcpOptions; public int mIPv4ProvisioningMode = PROV_IPV4_DHCP; public int mIPv6ProvisioningMode = PROV_IPV6_SLAAC; + public int mCreatorUid; public ProvisioningConfiguration() {} // used by Builder @@ -510,6 +519,7 @@ public class ProvisioningConfiguration { mIPv6AddrGenMode = other.mIPv6AddrGenMode; mNetwork = other.mNetwork; mDisplayName = other.mDisplayName; + mCreatorUid = other.mCreatorUid; mScanResultInfo = other.mScanResultInfo; mLayer2Info = other.mLayer2Info; mDhcpOptions = other.mDhcpOptions; @@ -540,6 +550,7 @@ public class ProvisioningConfiguration { p.ipv6AddrGenMode = mIPv6AddrGenMode; p.network = mNetwork; p.displayName = mDisplayName; + p.creatorUid = mCreatorUid; p.scanResultInfo = (mScanResultInfo == null) ? null : mScanResultInfo.toStableParcelable(); p.layer2Info = (mLayer2Info == null) ? null : mLayer2Info.toStableParcelable(); p.options = (mDhcpOptions == null) ? null : new ArrayList<>(mDhcpOptions); @@ -572,6 +583,7 @@ public class ProvisioningConfiguration { config.mIPv6AddrGenMode = p.ipv6AddrGenMode; config.mNetwork = p.network; config.mDisplayName = p.displayName; + config.mCreatorUid = p.creatorUid; config.mScanResultInfo = ScanResultInfo.fromStableParcelable(p.scanResultInfo); config.mLayer2Info = Layer2Information.fromStableParcelable(p.layer2Info); config.mDhcpOptions = (p.options == null) ? null : new ArrayList<>(p.options); @@ -630,6 +642,7 @@ public class ProvisioningConfiguration { .add("mIPv6AddrGenMode: " + mIPv6AddrGenMode) .add("mNetwork: " + mNetwork) .add("mDisplayName: " + mDisplayName) + .add("mCreatorUid:" + mCreatorUid) .add("mScanResultInfo: " + mScanResultInfo) .add("mLayer2Info: " + mLayer2Info) .add("mDhcpOptions: " + mDhcpOptions) @@ -680,7 +693,8 @@ public class ProvisioningConfiguration { && Objects.equals(mLayer2Info, other.mLayer2Info) && dhcpOptionListEquals(mDhcpOptions, other.mDhcpOptions) && mIPv4ProvisioningMode == other.mIPv4ProvisioningMode - && mIPv6ProvisioningMode == other.mIPv6ProvisioningMode; + && mIPv6ProvisioningMode == other.mIPv6ProvisioningMode + && mCreatorUid == other.mCreatorUid; } public boolean isValid() { diff --git a/res/values/config.xml b/res/values/config.xml index 15152e34..aed375ce 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -125,4 +125,7 @@ <!-- Whether to validate DUN networks. This is unused and always true on U+. --> <bool name="config_validate_dun_networks">false</bool> + + <!-- Configuration for including DHCP domain search list option --> + <bool name="config_dhcp_client_domain_search_list">false</bool> </resources> diff --git a/res/values/overlayable.xml b/res/values/overlayable.xml index 20ee5933..9c2172aa 100644 --- a/res/values/overlayable.xml +++ b/res/values/overlayable.xml @@ -90,6 +90,8 @@ <item type="drawable" name="icon_wifi"/> <!-- Whether to validate DUN networks. This is unused and always true on U+. --> <item type="bool" name="config_validate_dun_networks"/> + <!-- Configuration for including DHCP client domain search list option. --> + <item type="bool" name="config_dhcp_client_domain_search_list"/> </policy> </overlayable> </resources> diff --git a/src/android/net/DhcpResults.java b/src/android/net/DhcpResults.java index 7c271c33..d590c07a 100644 --- a/src/android/net/DhcpResults.java +++ b/src/android/net/DhcpResults.java @@ -63,6 +63,8 @@ public final class DhcpResults implements Parcelable { @Nullable public String captivePortalApiUrl; + public ArrayList<String> dmnsrchList = new ArrayList<>(); + public DhcpResults() { super(); } @@ -100,6 +102,7 @@ public final class DhcpResults implements Parcelable { mtu = source.mtu; serverHostName = source.serverHostName; captivePortalApiUrl = source.captivePortalApiUrl; + dmnsrchList = source.dmnsrchList; } } @@ -135,6 +138,7 @@ public final class DhcpResults implements Parcelable { mtu = 0; serverHostName = null; captivePortalApiUrl = null; + dmnsrchList.clear(); } @Override @@ -167,13 +171,14 @@ public final class DhcpResults implements Parcelable { && Objects.equals(serverHostName, target.serverHostName) && leaseDuration == target.leaseDuration && mtu == target.mtu - && Objects.equals(captivePortalApiUrl, target.captivePortalApiUrl); + && Objects.equals(captivePortalApiUrl, target.captivePortalApiUrl) + && dmnsrchList.equals(target.dmnsrchList); } @Override public int hashCode() { return Objects.hash(ipAddress, gateway, dnsServers, domains, serverAddress, vendorInfo, - serverHostName, captivePortalApiUrl) + 43 * leaseDuration + 67 * mtu; + serverHostName, captivePortalApiUrl, dmnsrchList) + 43 * leaseDuration + 67 * mtu; } /** @@ -302,6 +307,15 @@ public final class DhcpResults implements Parcelable { return domains; } + /** + * Append the domain search list strings separated by space to domain string. + */ + public String appendDomainsSearchList() { + final String domainsPrefix = domains == null ? "" : domains; + final String separator = domains != null && dmnsrchList.size() > 0 ? " " : ""; + return domainsPrefix + separator + TextUtils.join(" ", dmnsrchList); + } + public void setDomains(String domains) { this.domains = domains; } diff --git a/src/android/net/apf/ApfGenerator.java b/src/android/net/apf/ApfGenerator.java index fe5628c5..0c4007bc 100644 --- a/src/android/net/apf/ApfGenerator.java +++ b/src/android/net/apf/ApfGenerator.java @@ -41,8 +41,15 @@ public class ApfGenerator { } private enum Opcodes { LABEL(-1), - PASS(0), // Unconditionally pass packet, requires R=0, LEN=0, e.g. "pass" - DROP(0), // Unconditionally drop packet, requires R=1, LEN=0, e.g. "drop" + // Unconditionally pass (if R=0) or drop (if R=1) packet. + // An optional unsigned immediate value can be provided to encode the counter number. + // If the value is non-zero, the instruction increments the counter. + // The counter is located (-4 * counter number) bytes from the end of the data region. + // It is a U32 big-endian value and is always incremented by 1. + // This is more or less equivalent to: lddw R0, -N4; add R0,1; stdw R0, -N4; {pass,drop} + // e.g. "pass", "pass 1", "drop", "drop 1" + PASS(0), + DROP(0), LDB(1), // Load 1 byte from immediate offset, e.g. "ldb R0, [5]" LDH(2), // Load 2 bytes from immediate offset, e.g. "ldh R0, [5]" LDW(3), // Load 4 bytes from immediate offset, e.g. "ldw R0, [5]" @@ -89,7 +96,12 @@ public class ApfGenerator { SWAP(34), // Swap, e.g. "swap R0,R1" MOVE(35), // Move, e.g. "move R0,R1" ALLOC(36), // Allocate buffer, "e.g. ALLOC R0" - TRANS(37), // Transmit buffer, "e.g. TRANS R0" + // Transmit and deallocate the buffer (transmission can be delayed until the program + // terminates). R=0 means discard the buffer, R=1 means transmit the buffer. + // "e.g. trans" + // "e.g. discard" + TRANSMIT(37), + DISCARD(37), EWRITE1(38), // Write 1 byte from register to the output buffer, e.g. "EWRITE1 R0" EWRITE2(39), // Write 2 bytes from register to the output buffer, e.g. "EWRITE2 R0" EWRITE4(40), // Write 4 bytes from register to the output buffer, e.g. "EWRITE4 R0" @@ -142,26 +154,19 @@ public class ApfGenerator { private class Instruction { private final byte mOpcode; // A "Opcode" value. private final byte mRegister; // A "Register" value. - private final int mMaxSupportedImms; public final List<Immediate> mImms = new ArrayList<>(); // When mOpcode is a jump: private byte mTargetLabelSize; private String mTargetLabel; // When mOpcode == Opcodes.LABEL: private String mLabel; - // When mOpcode == Opcodes.JNEBS: - private byte[] mCompareBytes; + private byte[] mBytesImm; // Offset in bytes from the beginning of this program. Set by {@link ApfGenerator#generate}. int offset; Instruction(Opcodes opcode, Register register) { - this(opcode, register, 1 /* maxSupportedImm */); - } - - Instruction(Opcodes opcode, Register register, int maxSupportedImms) { mOpcode = (byte) opcode.value; mRegister = (byte) register.value; - mMaxSupportedImms = maxSupportedImms; } Instruction(Opcodes opcode) { @@ -181,11 +186,6 @@ public class ApfGenerator { } void addImm(Immediate imm) { - if (mImms.size() == mMaxSupportedImms) { - throw new IllegalArgumentException( - String.format("Opcode: %d only support at max: %d imms", mOpcode, - mMaxSupportedImms)); - } mImms.add(imm); } @@ -205,11 +205,11 @@ public class ApfGenerator { mTargetLabelSize = 4; // May shrink later on in generate(). } - void setCompareBytes(byte[] bytes) { + void setBytesImm(byte[] bytes) { if (mOpcode != Opcodes.JNEBS.value) { throw new IllegalStateException("adding compare bytes to non-JNEBS instruction"); } - mCompareBytes = bytes; + mBytesImm = bytes; } /** @@ -222,21 +222,12 @@ public class ApfGenerator { int size = 1; byte maxImmSize = getMaxImmSize(); // For the copy opcode, the last imm is the length field is always 1 byte - if (isCopyOpCode()) { - if (mMaxSupportedImms != mImms.size()) { - throw new IllegalStateException( - "mImm size: " + mImms.size() + " doesn't match the mMaxSupportedImms: " - + mMaxSupportedImms); - } - size += (mImms.size() - 1) * maxImmSize + mImms.get(mImms.size() - 1).mImmSize; - } else { - size += mImms.size() * maxImmSize; - } + size += mImms.size() * maxImmSize; if (mTargetLabel != null) { size += maxImmSize; } - if (mCompareBytes != null) { - size += mCompareBytes.length; + if (mBytesImm != null) { + size += mBytesImm.length; } return size; } @@ -306,28 +297,12 @@ public class ApfGenerator { writingOffset = writeValue(calculateTargetLabelOffset(), bytecode, writingOffset, maxImmSize); } - // For the copy opcode, the last imm is the length field is always 1 byte - if (isCopyOpCode()) { - if (mMaxSupportedImms != mImms.size()) { - throw new IllegalStateException( - "mImm size: " + mImms.size() + " doesn't match the mMaxSupportedImms: " - + mMaxSupportedImms); - } - int i; - for (i = 0; i < mImms.size() - 1; ++i) { - writingOffset = writeValue(mImms.get(i).mValue, bytecode, writingOffset, - maxImmSize); - } - writingOffset = writeValue(mImms.get(i).mValue, bytecode, writingOffset, - mImms.get(i).mImmSize); - } else { - for (Immediate imm : mImms) { - writingOffset = writeValue(imm.mValue, bytecode, writingOffset, maxImmSize); - } + for (Immediate imm : mImms) { + writingOffset = writeValue(imm.mValue, bytecode, writingOffset, maxImmSize); } - if (mCompareBytes != null) { - System.arraycopy(mCompareBytes, 0, bytecode, writingOffset, mCompareBytes.length); - writingOffset += mCompareBytes.length; + if (mBytesImm != null) { + System.arraycopy(mBytesImm, 0, bytecode, writingOffset, mBytesImm.length); + writingOffset += mBytesImm.length; } if ((writingOffset - offset) != size()) { throw new IllegalStateException("wrote " + (writingOffset - offset) + @@ -335,20 +310,6 @@ public class ApfGenerator { } } - private boolean isCopyOpCode() { - if (mOpcode == Opcodes.MEMCOPY.value) { - return true; - } - if (mOpcode == Opcodes.EXT.value) { - int realOpcode = mImms.get(0).mValue; - if (realOpcode == ExtendedOpcodes.EPKTCOPY.value - || realOpcode == ExtendedOpcodes.EDATACOPY.value) { - return true; - } - } - return false; - } - /** * Calculate the size of either the immediate fields or the target label field, if either is * present. Most instructions have either immediates or a target label field, but for the @@ -846,7 +807,7 @@ public class ApfGenerator { Instruction instruction = new Instruction(Opcodes.JNEBS, register); instruction.addUnsignedImm(bytes.length); instruction.setTargetLabel(target); - instruction.setCompareBytes(bytes); + instruction.setBytesImm(bytes); addInstruction(instruction); return this; } @@ -932,188 +893,228 @@ public class ApfGenerator { } /** - * Add an instruction to the end of the program to let the program immediately return DROP. + * Add an instruction to the end of the program to increment the counter value and + * immediately return PASS. */ - public ApfGenerator addDrop() throws IllegalInstructionException { + public ApfGenerator addCountAndPass(int counterNumber) throws IllegalInstructionException { requireApfVersion(MIN_APF_VERSION_IN_DEV); - Instruction instruction = new Instruction(Opcodes.DROP, Register.R1); - addInstruction(instruction); - return this; - } - - /** - * Add an instruction to the end of the program to call the apf_allocate_buffer() function. - * - * @param register the register value contains the buffer size. - */ - public ApfGenerator addAlloc(Register register) throws IllegalInstructionException { - requireApfVersion(5); - Instruction instruction = new Instruction(Opcodes.EXT, register); - instruction.addUnsignedImm(ExtendedOpcodes.ALLOC.value); + checkCounterNumber(counterNumber); + Instruction instruction = new Instruction(Opcodes.PASS, Register.R0); + instruction.addUnsignedImm(counterNumber); addInstruction(instruction); return this; } /** - * Add an instruction to the end of the program to call the apf_transmit_buffer() function. - * - * @param register the register value contains the packet type. + * Add an instruction to the end of the program to let the program immediately return DROP. */ - public ApfGenerator addTrans(Register register) throws IllegalInstructionException { - requireApfVersion(5); - Instruction instruction = new Instruction(Opcodes.EXT, register); - instruction.addUnsignedImm(ExtendedOpcodes.TRANS.value); + public ApfGenerator addDrop() throws IllegalInstructionException { + requireApfVersion(MIN_APF_VERSION_IN_DEV); + Instruction instruction = new Instruction(Opcodes.DROP, Register.R1); addInstruction(instruction); return this; } /** - * Add an instruction to the end of the program to write 1, 2 or 4 bytes value to output buffer. - * - * @param value the value to write - * @param size the size of the value - * @return the ApfGenerator object - * @throws IllegalInstructionException throws when size is not 1, 2 or 4 + * Add an instruction to the end of the program to increment the counter value and + * immediately return DROP. */ - public ApfGenerator addWrite(int value, byte size) throws IllegalInstructionException { - requireApfVersion(5); - if (!(size == 1 || size == 2 || size == 4)) { - throw new IllegalInstructionException("length field must be 1, 2 or 4"); - } - if (size < calculateImmSize(value, false)) { - throw new IllegalInstructionException( - String.format("the value %d is unfit into size: %d", value, size)); - } - Instruction instruction = new Instruction(Opcodes.WRITE); - instruction.addUnsignedImm(value, size); + public ApfGenerator addCountAndDrop(int counterNumber) throws IllegalInstructionException { + requireApfVersion(MIN_APF_VERSION_IN_DEV); + checkCounterNumber(counterNumber); + Instruction instruction = new Instruction(Opcodes.DROP, Register.R1); + instruction.addUnsignedImm(counterNumber); addInstruction(instruction); return this; } /** - * Add an instruction to the end of the program to write 1, 2 or 4 bytes value from register - * to output buffer. + * Add an instruction to the end of the program to call the apf_allocate_buffer() function. * - * @param register the register contains the value to be written - * @param size the size of the value - * @return the ApfGenerator object - * @throws IllegalInstructionException throws when size is not 1, 2 or 4 + * @param register the register value contains the buffer size. */ - public ApfGenerator addWrite(Register register, byte size) - throws IllegalInstructionException { + public ApfGenerator addAlloc(Register register) throws IllegalInstructionException { requireApfVersion(5); - if (!(size == 1 || size == 2 || size == 4)) { - throw new IllegalInstructionException( - "length field must be 1, 2 or 4"); - } Instruction instruction = new Instruction(Opcodes.EXT, register); - if (size == 1) { - instruction.addUnsignedImm(ExtendedOpcodes.EWRITE1.value); - } else if (size == 2) { - instruction.addUnsignedImm(ExtendedOpcodes.EWRITE2.value); - } else { - instruction.addUnsignedImm(ExtendedOpcodes.EWRITE4.value); - } + instruction.addUnsignedImm(ExtendedOpcodes.ALLOC.value); addInstruction(instruction); return this; } /** - * Add an instruction to the end of the program to copy data from APF data region to output - * buffer. - * - * @param srcOffset the offset inside the APF data region for where to start copy - * @param length the length of bytes needed to be copied, only <= 255 bytes can be copied at - * one time. - * @return the ApfGenerator object - * @throws IllegalInstructionException throws when imm size is incorrectly set. - */ - public ApfGenerator addDataCopy(int srcOffset, int length) - throws IllegalInstructionException { - return addMemCopy(srcOffset, length, Register.R1); - } - - /** - * Add an instruction to the end of the program to copy data from input packet to output buffer. - * - * @param srcOffset the offset inside the input packet for where to start copy - * @param length the length of bytes needed to be copied, only <= 255 bytes can be copied at - * one time. - * @return the ApfGenerator object - * @throws IllegalInstructionException throws when imm size is incorrectly set. + * Add an instruction to the end of the program to transmit the allocated buffer. */ - public ApfGenerator addPacketCopy(int srcOffset, int length) - throws IllegalInstructionException { - return addMemCopy(srcOffset, length, Register.R0); - } - - private ApfGenerator addMemCopy(int srcOffset, int length, Register register) - throws IllegalInstructionException { - requireApfVersion(5); - checkCopyLength(length); - checkCopyOffset(srcOffset); - Instruction instruction = new Instruction(Opcodes.MEMCOPY, - register, 2 /* maxSupportedImms */); - // if the offset == 0, it should still be encoded with 1 byte size. - if (srcOffset == 0) { - instruction.addUnsignedImm(srcOffset, (byte) 1 /* size */); - } else { - instruction.addUnsignedImm(srcOffset); - } - instruction.addUnsignedImm(length, (byte) 1 /* size */); + public ApfGenerator addTransmit() throws IllegalInstructionException { + requireApfVersion(MIN_APF_VERSION_IN_DEV); + Instruction instruction = new Instruction(Opcodes.EXT, Register.R0); + instruction.addUnsignedImm(ExtendedOpcodes.TRANSMIT.value); addInstruction(instruction); return this; } /** - * Add an instruction to the end of the program to copy data from APF data region to output - * buffer. - * - * @param register the register that stored the base offset value. - * @param relativeOffset the offset inside the APF data region for where to start copy - * @param length the length of bytes needed to be copied, only <= 255 bytes can be copied at - * one time. - * @return the ApfGenerator object - * @throws IllegalInstructionException throws when imm size is incorrectly set. + * Add an instruction to the end of the program to discard the allocated buffer. */ - public ApfGenerator addDataCopy(Register register, int relativeOffset, int length) - throws IllegalInstructionException { - return addMemcopy(register, relativeOffset, length, ExtendedOpcodes.EDATACOPY.value); - } - - /** - * Add an instruction to the end of the program to copy data from input packet to output buffer. - * - * @param register the register that stored the base offset value. - * @param relativeOffset the offset inside the input packet for where to start copy - * @param length the length of bytes needed to be copied, only <= 255 bytes can be copied at - * one time. - * @return the ApfGenerator object - * @throws IllegalInstructionException throws when imm size is incorrectly set. - */ - public ApfGenerator addPacketCopy(Register register, int relativeOffset, int length) - throws IllegalInstructionException { - return addMemcopy(register, relativeOffset, length, ExtendedOpcodes.EPKTCOPY.value); - } - - private ApfGenerator addMemcopy(Register register, int relativeOffset, int length, int opcode) - throws IllegalInstructionException { - requireApfVersion(5); - checkCopyLength(length); - checkCopyOffset(relativeOffset); - Instruction instruction = new Instruction(Opcodes.EXT, register, 3 /* maxSupportedImms */); - instruction.addUnsignedImm(opcode); - // if the offset == 0, it should still be encoded with 1 byte size. - if (relativeOffset == 0) { - instruction.addUnsignedImm(relativeOffset, (byte) 1 /* size */); - } else { - instruction.addUnsignedImm(relativeOffset); - } - instruction.addUnsignedImm(length, (byte) 1 /* size */); + public ApfGenerator addDiscard() throws IllegalInstructionException { + requireApfVersion(MIN_APF_VERSION_IN_DEV); + Instruction instruction = new Instruction(Opcodes.EXT, Register.R1); + instruction.addUnsignedImm(ExtendedOpcodes.DISCARD.value); addInstruction(instruction); return this; } + // TODO: add back when support WRITE opcode +// /** +// * Add an instruction to the end of the program to write 1, 2 or 4 bytes value to output +// buffer. +// * +// * @param value the value to write +// * @param size the size of the value +// * @return the ApfGenerator object +// * @throws IllegalInstructionException throws when size is not 1, 2 or 4 +// */ +// public ApfGenerator addWrite(int value, byte size) throws IllegalInstructionException { +// requireApfVersion(5); +// if (!(size == 1 || size == 2 || size == 4)) { +// throw new IllegalInstructionException("length field must be 1, 2 or 4"); +// } +// if (size < calculateImmSize(value, false)) { +// throw new IllegalInstructionException( +// String.format("the value %d is unfit into size: %d", value, size)); +// } +// Instruction instruction = new Instruction(Opcodes.WRITE); +// instruction.addUnsignedImm(value, size); +// addInstruction(instruction); +// return this; +// } + + // TODO: add back when support EWRITE opcode +// /** +// * Add an instruction to the end of the program to write 1, 2 or 4 bytes value from register +// * to output buffer. +// * +// * @param register the register contains the value to be written +// * @param size the size of the value +// * @return the ApfGenerator object +// * @throws IllegalInstructionException throws when size is not 1, 2 or 4 +// */ +// public ApfGenerator addWrite(Register register, byte size) +// throws IllegalInstructionException { +// requireApfVersion(5); +// if (!(size == 1 || size == 2 || size == 4)) { +// throw new IllegalInstructionException( +// "length field must be 1, 2 or 4"); +// } +// Instruction instruction = new Instruction(Opcodes.EXT, register); +// if (size == 1) { +// instruction.addUnsignedImm(ExtendedOpcodes.EWRITE1.value); +// } else if (size == 2) { +// instruction.addUnsignedImm(ExtendedOpcodes.EWRITE2.value); +// } else { +// instruction.addUnsignedImm(ExtendedOpcodes.EWRITE4.value); +// } +// addInstruction(instruction); +// return this; +// } + + // TODO: add back when support PKTCOPY/DATACOPY opcode +// /** +// * Add an instruction to the end of the program to copy data from APF data region to output +// * buffer. +// * +// * @param srcOffset the offset inside the APF data region for where to start copy +// * @param length the length of bytes needed to be copied, only <= 255 bytes can be copied at +// * one time. +// * @return the ApfGenerator object +// * @throws IllegalInstructionException throws when imm size is incorrectly set. +// */ +// public ApfGenerator addDataCopy(int srcOffset, int length) +// throws IllegalInstructionException { +// return addMemCopy(srcOffset, length, Register.R1); +// } +// +// /** +// * Add an instruction to the end of the program to copy data from input packet to output +// buffer. +// * +// * @param srcOffset the offset inside the input packet for where to start copy +// * @param length the length of bytes needed to be copied, only <= 255 bytes can be copied at +// * one time. +// * @return the ApfGenerator object +// * @throws IllegalInstructionException throws when imm size is incorrectly set. +// */ +// public ApfGenerator addPacketCopy(int srcOffset, int length) +// throws IllegalInstructionException { +// return addMemCopy(srcOffset, length, Register.R0); +// } +// +// private ApfGenerator addMemCopy(int srcOffset, int length, Register register) +// throws IllegalInstructionException { +// requireApfVersion(5); +// checkCopyLength(length); +// checkCopyOffset(srcOffset); +// Instruction instruction = new Instruction(Opcodes.MEMCOPY, register); +// // if the offset == 0, it should still be encoded with 1 byte size. +// if (srcOffset == 0) { +// instruction.addUnsignedImm(srcOffset, (byte) 1 /* size */); +// } else { +// instruction.addUnsignedImm(srcOffset); +// } +// instruction.addUnsignedImm(length, (byte) 1 /* size */); +// addInstruction(instruction); +// return this; +// } +// TODO: add back when support EPKTCOPY/EDATACOPY opcode +// /** +// * Add an instruction to the end of the program to copy data from APF data region to output +// * buffer. +// * +// * @param register the register that stored the base offset value. +// * @param relativeOffset the offset inside the APF data region for where to start copy +// * @param length the length of bytes needed to be copied, only <= 255 bytes can be copied at +// * one time. +// * @return the ApfGenerator object +// * @throws IllegalInstructionException throws when imm size is incorrectly set. +// */ +// public ApfGenerator addDataCopy(Register register, int relativeOffset, int length) +// throws IllegalInstructionException { +// return addMemcopy(register, relativeOffset, length, ExtendedOpcodes.EDATACOPY.value); +// } +// +// /** +// * Add an instruction to the end of the program to copy data from input packet to output +// buffer. +// * +// * @param register the register that stored the base offset value. +// * @param relativeOffset the offset inside the input packet for where to start copy +// * @param length the length of bytes needed to be copied, only <= 255 bytes can be copied at +// * one time. +// * @return the ApfGenerator object +// * @throws IllegalInstructionException throws when imm size is incorrectly set. +// */ +// public ApfGenerator addPacketCopy(Register register, int relativeOffset, int length) +// throws IllegalInstructionException { +// return addMemcopy(register, relativeOffset, length, ExtendedOpcodes.EPKTCOPY.value); +// } +// +// private ApfGenerator addMemcopy(Register register, int relativeOffset, int length, int opcode) +// throws IllegalInstructionException { +// requireApfVersion(5); +// checkCopyLength(length); +// checkCopyOffset(relativeOffset); +// Instruction instruction = new Instruction(Opcodes.EXT, register); +// instruction.addUnsignedImm(opcode); +// // if the offset == 0, it should still be encoded with 1 byte size. +// if (relativeOffset == 0) { +// instruction.addUnsignedImm(relativeOffset, (byte) 1 /* size */); +// } else { +// instruction.addUnsignedImm(relativeOffset); +// } +// instruction.addUnsignedImm(length, (byte) 1 /* size */); +// addInstruction(instruction); +// return this; +// } + private void checkCopyLength(int length) { if (length < 0 || length > 255) { throw new IllegalArgumentException( @@ -1128,6 +1129,13 @@ public class ApfGenerator { } } + private void checkCounterNumber(int counterNumber) { + if (counterNumber < 1 || counterNumber > 1000) { + throw new IllegalArgumentException( + "Counter number must be in range (0, 1000], counterNumber: " + counterNumber); + } + } + /** * Add an instruction to the end of the program to load 32 bits from the data memory into * {@code register}. The source address is computed by adding the signed immediate diff --git a/src/android/net/dhcp/DhcpAckPacket.java b/src/android/net/dhcp/DhcpAckPacket.java index 225e4477..3d20bda7 100644 --- a/src/android/net/dhcp/DhcpAckPacket.java +++ b/src/android/net/dhcp/DhcpAckPacket.java @@ -50,6 +50,7 @@ public class DhcpAckPacket extends DhcpPacket { + ", netmask " + mSubnetMask + ", gateways " + mGateways + dnsServers + ", lease time " + mLeaseTime + + ", domain " + mDomainName + (mIpv6OnlyWaitTime != null ? ", V6ONLY_WAIT " + mIpv6OnlyWaitTime : ""); } diff --git a/src/android/net/dhcp/DhcpClient.java b/src/android/net/dhcp/DhcpClient.java index 43537465..b0bac047 100644 --- a/src/android/net/dhcp/DhcpClient.java +++ b/src/android/net/dhcp/DhcpClient.java @@ -20,6 +20,7 @@ import static android.net.dhcp.DhcpPacket.DHCP_BROADCAST_ADDRESS; import static android.net.dhcp.DhcpPacket.DHCP_CAPTIVE_PORTAL; import static android.net.dhcp.DhcpPacket.DHCP_DNS_SERVER; import static android.net.dhcp.DhcpPacket.DHCP_DOMAIN_NAME; +import static android.net.dhcp.DhcpPacket.DHCP_DOMAIN_SEARCHLIST; import static android.net.dhcp.DhcpPacket.DHCP_IPV6_ONLY_PREFERRED; import static android.net.dhcp.DhcpPacket.DHCP_LEASE_TIME; import static android.net.dhcp.DhcpPacket.DHCP_MTU; @@ -294,7 +295,14 @@ public class DhcpClient extends StateMachine { @NonNull private byte[] getRequestedParams() { // Set an initial size large enough for all optional parameters that we might request. - final int numOptionalParams = 2; + // mCreatorId + the size is changed + final int numOptionalParams; + if (mConfiguration.isWifiManagedProfile) { + numOptionalParams = 3 + mConfiguration.options.size(); + } else { + numOptionalParams = 2 + mConfiguration.options.size(); + } + final ByteArrayOutputStream params = new ByteArrayOutputStream(DEFAULT_REQUESTED_PARAMS.length + numOptionalParams); params.write(DEFAULT_REQUESTED_PARAMS, 0, DEFAULT_REQUESTED_PARAMS.length); @@ -306,6 +314,10 @@ public class DhcpClient extends StateMachine { for (DhcpOption option : mConfiguration.options) { if (option.value == null) params.write(option.type); } + // Check if the target network is managed by user. + if (mConfiguration.isWifiManagedProfile) { + params.write(DHCP_DOMAIN_SEARCHLIST); + } return params.toByteArray(); } @@ -635,6 +647,9 @@ public class DhcpClient extends StateMachine { private byte[] getOptionsToSkip() { final ByteArrayOutputStream optionsToSkip = new ByteArrayOutputStream(2); if (!isCapportApiEnabled()) optionsToSkip.write(DHCP_CAPTIVE_PORTAL); + if (!mConfiguration.isWifiManagedProfile) { + optionsToSkip.write(DHCP_DOMAIN_SEARCHLIST); + } return optionsToSkip.toByteArray(); } @@ -992,12 +1007,15 @@ public class DhcpClient extends StateMachine { public final boolean isPreconnectionEnabled; @NonNull public final List<DhcpOption> options; + public final boolean isWifiManagedProfile; public Configuration(@Nullable final String l2Key, final boolean isPreconnectionEnabled, - @NonNull final List<DhcpOption> options) { + @NonNull final List<DhcpOption> options, + final boolean isWifiManagedProfile) { this.l2Key = l2Key; this.isPreconnectionEnabled = isPreconnectionEnabled; this.options = options; + this.isWifiManagedProfile = isWifiManagedProfile; } } diff --git a/src/android/net/dhcp/DhcpOfferPacket.java b/src/android/net/dhcp/DhcpOfferPacket.java index e3e5d0f9..daf520d3 100644 --- a/src/android/net/dhcp/DhcpOfferPacket.java +++ b/src/android/net/dhcp/DhcpOfferPacket.java @@ -48,7 +48,7 @@ public class DhcpOfferPacket extends DhcpPacket { } return s + " OFFER, ip " + mYourIp - + ", mask " + mSubnetMask + dnsServers + + ", netmask " + mSubnetMask + dnsServers + ", gateways " + mGateways + ", lease time " + mLeaseTime + ", domain " + mDomainName diff --git a/src/android/net/dhcp/DhcpPacket.java b/src/android/net/dhcp/DhcpPacket.java index 770baac7..26498519 100644 --- a/src/android/net/dhcp/DhcpPacket.java +++ b/src/android/net/dhcp/DhcpPacket.java @@ -33,6 +33,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; +import com.android.net.module.util.DomainUtils; import com.android.net.module.util.Inet4AddressUtils; import java.io.UnsupportedEncodingException; @@ -338,6 +339,12 @@ public abstract class DhcpPacket { protected String mCaptivePortalUrl; /** + * DHCP Optional Type: Domain Search List, domain suffixes are space separated. + */ + public static final byte DHCP_DOMAIN_SEARCHLIST = (byte) 119; + protected List<String> mDmnSrchList; + + /** * DHCP zero-length option code: pad */ public static final byte DHCP_OPTION_PAD = 0x00; @@ -832,6 +839,7 @@ public abstract class DhcpPacket { } } + // The common server TLVs are corresponding to the parameter request list from client. protected void addCommonServerTlvs(ByteBuffer buf) { addTlv(buf, DHCP_LEASE_TIME, mLeaseTime); if (mLeaseTime != null && mLeaseTime != INFINITE_LEASE) { @@ -854,6 +862,15 @@ public abstract class DhcpPacket { if (mIpv6OnlyWaitTime != null) { addTlv(buf, DHCP_IPV6_ONLY_PREFERRED, (int) Integer.toUnsignedLong(mIpv6OnlyWaitTime)); } + if (mDmnSrchList != null && mDmnSrchList.size() > 0) { + // domain search list string is space separated. + String[] searchList = new String[mDmnSrchList.size()]; + for (int i = 0; i < mDmnSrchList.size(); i++) { + searchList[i] = mDmnSrchList.get(i); + } + final byte[] domains = DomainUtils.encode(searchList, true /* compression */); + addTlv(buf, DHCP_DOMAIN_SEARCHLIST, domains); + } addTlv(buf, DHCP_CAPTIVE_PORTAL, mCaptivePortalUrl); } @@ -987,6 +1004,7 @@ public abstract class DhcpPacket { byte[] clientId = null; List<Inet4Address> dnsServers = new ArrayList<>(); List<Inet4Address> gateways = new ArrayList<>(); // aka router + ArrayList<String> dmnSrchList = new ArrayList<>(); Inet4Address serverIdentifier = null; Inet4Address netMask = null; String message = null; @@ -1292,6 +1310,14 @@ public abstract class DhcpPacket { expectedLen = skipOption(packet, optionLen); } break; + case DHCP_DOMAIN_SEARCHLIST: + // TODO: should support multiple options(i.e. length > 255)? + expectedLen = optionLen; + final byte[] bytes = new byte[expectedLen]; + packet.get(bytes); + final ByteBuffer buf = ByteBuffer.wrap(bytes); + dmnSrchList = DomainUtils.decode(buf, true /* compression */); + break; default: expectedLen = skipOption(packet, optionLen); } @@ -1359,7 +1385,6 @@ public abstract class DhcpPacket { newPacket.mBroadcastAddress = bcAddr; newPacket.mClientId = clientId; newPacket.mDnsServers = dnsServers; - newPacket.mDomainName = domainName; newPacket.mGateways = gateways; newPacket.mHostName = hostName; newPacket.mLeaseTime = leaseTime; @@ -1382,6 +1407,10 @@ public abstract class DhcpPacket { } else { newPacket.mServerHostName = ""; } + // Domain suffixes in the search list are concatenated to domain name with space separated, + // which will be set to DnsResolver via LinkProperties. + newPacket.mDmnSrchList = dmnSrchList; + newPacket.mDomainName = domainName; return newPacket; } @@ -1451,7 +1480,10 @@ public abstract class DhcpPacket { results.mtu = (mMtu != null && MIN_MTU <= mMtu && mMtu <= MAX_MTU) ? mMtu : 0; results.serverHostName = mServerHostName; results.captivePortalApiUrl = mCaptivePortalUrl; - + // Add the check before setting it + if (mDmnSrchList != null && mDmnSrchList.size() > 0) { + results.dmnsrchList.addAll(mDmnSrchList); + } return results; } @@ -1512,7 +1544,8 @@ public abstract class DhcpPacket { Inet4Address yourIp, byte[] mac, Integer timeout, Inet4Address netMask, Inet4Address bcAddr, List<Inet4Address> gateways, List<Inet4Address> dnsServers, Inet4Address dhcpServerIdentifier, String domainName, String hostname, boolean metered, - short mtu, String captivePortalUrl, Integer ipv6OnlyWaitTime) { + short mtu, String captivePortalUrl, Integer ipv6OnlyWaitTime, + List<String> domainSearchList) { DhcpPacket pkt = new DhcpOfferPacket( transactionId, (short) 0, broadcast, serverIpAddr, relayIp, INADDR_ANY /* clientIp */, yourIp, mac); @@ -1526,6 +1559,9 @@ public abstract class DhcpPacket { pkt.mBroadcastAddress = bcAddr; pkt.mMtu = mtu; pkt.mCaptivePortalUrl = captivePortalUrl; + if (domainSearchList != null) { + pkt.mDmnSrchList = new ArrayList<>(domainSearchList); + } if (metered) { pkt.mVendorInfo = VENDOR_INFO_ANDROID_METERED; } @@ -1546,7 +1582,8 @@ public abstract class DhcpPacket { short mtu, String captivePortalUrl) { return buildOfferPacket(encap, transactionId, broadcast, serverIpAddr, relayIp, yourIp, mac, timeout, netMask, bcAddr, gateways, dnsServers, dhcpServerIdentifier, - domainName, hostname, metered, mtu, captivePortalUrl, null /* V6ONLY_WAIT */); + domainName, hostname, metered, mtu, captivePortalUrl, null /* V6ONLY_WAIT */, + null /* domainSearchList */); } /** @@ -1557,7 +1594,8 @@ public abstract class DhcpPacket { Inet4Address requestClientIp, byte[] mac, Integer timeout, Inet4Address netMask, Inet4Address bcAddr, List<Inet4Address> gateways, List<Inet4Address> dnsServers, Inet4Address dhcpServerIdentifier, String domainName, String hostname, boolean metered, - short mtu, boolean rapidCommit, String captivePortalUrl, Integer ipv6OnlyWaitTime) { + short mtu, boolean rapidCommit, String captivePortalUrl, Integer ipv6OnlyWaitTime, + List<String> domainSearchList) { DhcpPacket pkt = new DhcpAckPacket( transactionId, (short) 0, broadcast, serverIpAddr, relayIp, requestClientIp, yourIp, mac, rapidCommit); @@ -1571,6 +1609,9 @@ public abstract class DhcpPacket { pkt.mBroadcastAddress = bcAddr; pkt.mMtu = mtu; pkt.mCaptivePortalUrl = captivePortalUrl; + if (domainSearchList != null) { + pkt.mDmnSrchList = new ArrayList<>(domainSearchList); + } if (metered) { pkt.mVendorInfo = VENDOR_INFO_ANDROID_METERED; } @@ -1592,7 +1633,7 @@ public abstract class DhcpPacket { return buildAckPacket(encap, transactionId, broadcast, serverIpAddr, relayIp, yourIp, requestClientIp, mac, timeout, netMask, bcAddr, gateways, dnsServers, dhcpServerIdentifier, domainName, hostname, metered, mtu, rapidCommit, - captivePortalUrl, null /* V6ONLY_WAIT */); + captivePortalUrl, null /* V6ONLY_WAIT */, null /* domainSearchList */); } /** diff --git a/src/android/net/ip/IpClient.java b/src/android/net/ip/IpClient.java index 3f328bad..4f8eead7 100644 --- a/src/android/net/ip/IpClient.java +++ b/src/android/net/ip/IpClient.java @@ -51,7 +51,10 @@ import static com.android.networkstack.util.NetworkStackUtils.IPCLIENT_MULTICAST import static com.android.server.util.PermissionUtil.enforceNetworkStackCallingPermission; import android.annotation.SuppressLint; +import android.app.admin.DevicePolicyManager; +import android.content.ComponentName; import android.content.Context; +import android.content.pm.PackageManager; import android.content.res.Resources; import android.net.ConnectivityManager; import android.net.DhcpResults; @@ -94,6 +97,7 @@ import android.os.Message; import android.os.RemoteException; import android.os.ServiceSpecificException; import android.os.SystemClock; +import android.os.UserHandle; import android.stats.connectivity.DisconnectCode; import android.stats.connectivity.NetworkQuirkEvent; import android.stats.connectivity.NudEventType; @@ -673,6 +677,8 @@ public class IpClient extends StateMachine { private final Set<Inet6Address> mGratuitousNaTargetAddresses = new HashSet<>(); // Set of IPv6 addresses from which multicast NS packets have been sent. private final Set<Inet6Address> mMulticastNsSourceAddresses = new HashSet<>(); + @Nullable + private final DevicePolicyManager mDevicePolicyManager; // Ignore nonzero RDNSS option lifetimes below this value. 0 = disabled. private final int mMinRdnssLifetimeSec; @@ -706,6 +712,7 @@ public class IpClient extends StateMachine { private AndroidPacketFilter mApfFilter; private String mL2Key; // The L2 key for this network, for writing into the memory store private String mCluster; // The cluster for this network, for writing into the memory store + private int mCreatorUid; // Uid of app creating the wifi configuration private boolean mMulticastFiltering; private long mStartTimeMillis; private long mIPv6ProvisioningDtimGracePeriodMillis; @@ -861,6 +868,14 @@ public class IpClient extends StateMachine { final File sysctl = new File(path); return sysctl.exists(); } + /** + * Get the configuration from RRO to check whether or not to send domain search list + * option in DHCPDISCOVER/DHCPREQUEST message. + */ + public boolean getSendDomainSearchListOption(final Context context) { + return context.getResources().getBoolean(R.bool.config_dhcp_client_domain_search_list); + } + } public IpClient(Context context, String ifName, IIpClientCallbacks callback, @@ -878,6 +893,8 @@ public class IpClient extends StateMachine { mTag = getName(); + mDevicePolicyManager = (DevicePolicyManager) + context.getSystemService(Context.DEVICE_POLICY_SERVICE); mContext = context; mInterfaceName = ifName; mDependencies = deps; @@ -1172,6 +1189,7 @@ public class IpClient extends StateMachine { mCurrentBssid = getInitialBssid(req.mLayer2Info, req.mScanResultInfo, ShimUtils.isAtLeastS()); mCurrentApfCapabilities = req.mApfCapabilities; + mCreatorUid = req.mCreatorUid; if (req.mLayer2Info != null) { mL2Key = req.mLayer2Info.mL2Key; mCluster = req.mLayer2Info.mCluster; @@ -1734,7 +1752,12 @@ public class IpClient extends StateMachine { newLp.addRoute(route); } addAllReachableDnsServers(newLp, mDhcpResults.dnsServers); - newLp.setDomains(mDhcpResults.domains); + if (mDhcpResults.dmnsrchList.size() == 0) { + newLp.setDomains(mDhcpResults.domains); + } else { + final String domainsString = mDhcpResults.appendDomainsSearchList(); + newLp.setDomains(TextUtils.isEmpty(domainsString) ? null : domainsString); + } if (mDhcpResults.mtu != 0) { newLp.setMtu(mDhcpResults.mtu); @@ -2593,8 +2616,92 @@ public class IpClient extends StateMachine { // registerForPreDhcpNotification is called later when processing the CMD_*_PRECONNECTION // messages. if (!isUsingPreconnection()) mDhcpClient.registerForPreDhcpNotification(); + boolean isManagedWifiProfile = false; + if (mDependencies.getSendDomainSearchListOption(mContext) + && (mCreatorUid > 0) && (isDeviceOwnerNetwork(mCreatorUid) + || isProfileOwner(mCreatorUid))) { + isManagedWifiProfile = true; + } mDhcpClient.sendMessage(DhcpClient.CMD_START_DHCP, new DhcpClient.Configuration(mL2Key, - isUsingPreconnection(), options)); + isUsingPreconnection(), options, isManagedWifiProfile)); + } + + private boolean hasPermission(String permissionName) { + return (mContext.checkCallingOrSelfPermission(permissionName) + == PackageManager.PERMISSION_GRANTED); + } + + private boolean isDeviceOwnerNetwork(int creatorUid) { + if (mDevicePolicyManager == null) return false; + if (!hasPermission(android.Manifest.permission.MANAGE_USERS)) return false; + final ComponentName devicecmpName = mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser(); + if (devicecmpName == null) return false; + final String deviceOwnerPackageName = devicecmpName.getPackageName(); + if (deviceOwnerPackageName == null) return false; + + final String[] packages = mContext.getPackageManager().getPackagesForUid(creatorUid); + + for (String pkg : packages) { + if (pkg.equals(deviceOwnerPackageName)) { + return true; + } + } + return false; + } + + @Nullable + private Context createPackageContextAsUser(int uid) { + Context userContext = null; + try { + userContext = mContext.createPackageContextAsUser(mContext.getPackageName(), 0, + UserHandle.getUserHandleForUid(uid)); + } catch (PackageManager.NameNotFoundException e) { + Log.e(TAG, "Unknown package name"); + return null; + } + return userContext; + } + + /** + * Returns the DevicePolicyManager from context + */ + private DevicePolicyManager retrieveDevicePolicyManagerFromContext(Context context) { + DevicePolicyManager devicePolicyManager = + context.getSystemService(DevicePolicyManager.class); + if (devicePolicyManager == null + && context.getPackageManager().hasSystemFeature( + PackageManager.FEATURE_DEVICE_ADMIN)) { + Log.wtf(TAG, "Error retrieving DPM service"); + } + return devicePolicyManager; + } + + private DevicePolicyManager retrieveDevicePolicyManagerFromUserContext(int uid) { + Context userContext = createPackageContextAsUser(uid); + if (userContext == null) return null; + return retrieveDevicePolicyManagerFromContext(userContext); + } + + /** + * Returns {@code true} if the calling {@code uid} is the profile owner + * + */ + + private boolean isProfileOwner(int uid) { + DevicePolicyManager devicePolicyManager = retrieveDevicePolicyManagerFromUserContext(uid); + if (devicePolicyManager == null) return false; + String[] packages = mContext.getPackageManager().getPackagesForUid(uid); + if (packages == null) { + Log.w(TAG, "isProfileOwner: could not find packages for uid=" + + uid); + return false; + } + for (String packageName : packages) { + if (devicePolicyManager.isProfileOwnerApp(packageName)) { + return true; + } + } + return false; } class ClearingIpAddressesState extends State { diff --git a/tests/integration/common/android/net/ip/IpClientIntegrationTestCommon.java b/tests/integration/common/android/net/ip/IpClientIntegrationTestCommon.java index 40da4b7c..c733f9c9 100644 --- a/tests/integration/common/android/net/ip/IpClientIntegrationTestCommon.java +++ b/tests/integration/common/android/net/ip/IpClientIntegrationTestCommon.java @@ -122,8 +122,11 @@ import android.app.AlarmManager; import android.app.AlarmManager.OnAlarmListener; import android.app.Instrumentation; import android.app.UiAutomation; +import android.app.admin.DevicePolicyManager; +import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; +import android.content.pm.PackageManager; import android.content.res.Resources; import android.net.ConnectivityManager; import android.net.DhcpResultsParcelable; @@ -296,6 +299,8 @@ public abstract class IpClientIntegrationTestCommon { private static final int TEST_LOWER_IPV6_ONLY_WAIT_S = (int) (MIN_V6ONLY_WAIT_MS / 1000 - 1); private static final int TEST_ZERO_IPV6_ONLY_WAIT_S = 0; private static final long TEST_MAX_IPV6_ONLY_WAIT_S = 0xffffffffL; + private static final int TEST_DEVICE_OWNER_APP_UID = 14242; + private static final String TEST_DEVICE_OWNER_APP_PACKAGE = "com.example.deviceowner"; protected static final String TEST_L2KEY = "some l2key"; // TODO: move to NetlinkConstants, NetworkStackConstants, or OsConstants. @@ -356,7 +361,8 @@ public abstract class IpClientIntegrationTestCommon { @Mock protected NetworkStackIpMemoryStore mIpMemoryStore; @Mock private NetworkQuirkMetrics.Dependencies mNetworkQuirkMetricsDeps; @Mock private IpReachabilityMonitorMetrics mIpReachabilityMonitorMetrics; - + @Mock private DevicePolicyManager mDevicePolicyManager; + @Mock private PackageManager mPackageManager; @Spy private INetd mNetd; private NetworkObserverRegistry mNetworkObserverRegistry; @@ -794,8 +800,11 @@ public abstract class IpClientIntegrationTestCommon { MockitoAnnotations.initMocks(this); mDependencies = new Dependencies(); - when(mContext.getSystemService(eq(Context.ALARM_SERVICE))).thenReturn(mAlarm); - when(mContext.getSystemService(eq(ConnectivityManager.class))).thenReturn(mCm); + when(mContext.getSystemService(Context.ALARM_SERVICE)).thenReturn(mAlarm); + when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mCm); + when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE)) + .thenReturn(mDevicePolicyManager); + when(mContext.getPackageManager()).thenReturn(mPackageManager); when(mContext.getResources()).thenReturn(mResources); when(mResources.getInteger(eq(R.integer.config_nud_postroaming_solicit_num))).thenReturn(5); when(mResources.getInteger(eq(R.integer.config_nud_postroaming_solicit_interval))) @@ -815,6 +824,11 @@ public abstract class IpClientIntegrationTestCommon { // liftime. when(mCm.shouldAvoidBadWifi()).thenReturn(true); + when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn( + new ComponentName(TEST_DEVICE_OWNER_APP_PACKAGE, "com.example.SomeClass")); + when(mPackageManager.getPackagesForUid(TEST_DEVICE_OWNER_APP_UID)).thenReturn( + new String[] { TEST_DEVICE_OWNER_APP_PACKAGE }); + mDependencies.setDeviceConfigProperty(IpClient.CONFIG_MIN_RDNSS_LIFETIME, 67); mDependencies.setDeviceConfigProperty(DhcpClient.DHCP_RESTART_CONFIG_DELAY, 10); mDependencies.setDeviceConfigProperty(DhcpClient.ARP_FIRST_PROBE_DELAY_MS, 10); @@ -1114,43 +1128,47 @@ public abstract class IpClientIntegrationTestCommon { private static ByteBuffer buildDhcpOfferPacket(final DhcpPacket packet, final Inet4Address clientAddress, final Integer leaseTimeSec, final short mtu, - final String captivePortalUrl, final Integer ipv6OnlyWaitTime) { + final String captivePortalUrl, final Integer ipv6OnlyWaitTime, + final String domainName, final List<String> domainSearchList) { return DhcpPacket.buildOfferPacket(DhcpPacket.ENCAP_L2, packet.getTransactionId(), false /* broadcast */, SERVER_ADDR, INADDR_ANY /* relayIp */, clientAddress /* yourIp */, packet.getClientMac(), leaseTimeSec, NETMASK /* netMask */, BROADCAST_ADDR /* bcAddr */, Collections.singletonList(SERVER_ADDR) /* gateways */, Collections.singletonList(SERVER_ADDR) /* dnsServers */, - SERVER_ADDR /* dhcpServerIdentifier */, null /* domainName */, HOSTNAME, - false /* metered */, mtu, captivePortalUrl, ipv6OnlyWaitTime); + SERVER_ADDR /* dhcpServerIdentifier */, domainName, HOSTNAME, + false /* metered */, mtu, captivePortalUrl, ipv6OnlyWaitTime, domainSearchList); } private static ByteBuffer buildDhcpOfferPacket(final DhcpPacket packet, final Inet4Address clientAddress, final Integer leaseTimeSec, final short mtu, final String captivePortalUrl) { return buildDhcpOfferPacket(packet, clientAddress, leaseTimeSec, mtu, captivePortalUrl, - null /* ipv6OnlyWaitTime */); + null /* ipv6OnlyWaitTime */, null /* domainName */, null /* domainSearchList */); } private static ByteBuffer buildDhcpAckPacket(final DhcpPacket packet, final Inet4Address clientAddress, final Integer leaseTimeSec, final short mtu, final boolean rapidCommit, final String captivePortalApiUrl, - final Integer ipv6OnlyWaitTime) { + final Integer ipv6OnlyWaitTime, final String domainName, + final List<String> domainSearchList) { return DhcpPacket.buildAckPacket(DhcpPacket.ENCAP_L2, packet.getTransactionId(), false /* broadcast */, SERVER_ADDR, INADDR_ANY /* relayIp */, clientAddress /* yourIp */, CLIENT_ADDR /* requestIp */, packet.getClientMac(), leaseTimeSec, NETMASK /* netMask */, BROADCAST_ADDR /* bcAddr */, Collections.singletonList(SERVER_ADDR) /* gateways */, Collections.singletonList(SERVER_ADDR) /* dnsServers */, - SERVER_ADDR /* dhcpServerIdentifier */, null /* domainName */, HOSTNAME, - false /* metered */, mtu, rapidCommit, captivePortalApiUrl, ipv6OnlyWaitTime); + SERVER_ADDR /* dhcpServerIdentifier */, domainName, HOSTNAME, + false /* metered */, mtu, rapidCommit, captivePortalApiUrl, ipv6OnlyWaitTime, + domainSearchList); } private static ByteBuffer buildDhcpAckPacket(final DhcpPacket packet, final Inet4Address clientAddress, final Integer leaseTimeSec, final short mtu, final boolean rapidCommit, final String captivePortalApiUrl) { return buildDhcpAckPacket(packet, clientAddress, leaseTimeSec, mtu, rapidCommit, - captivePortalApiUrl, null /* ipv6OnlyWaitTime */); + captivePortalApiUrl, null /* ipv6OnlyWaitTime */, null /* domainName */, + null /* domainSearchList */); } private static ByteBuffer buildDhcpNakPacket(final DhcpPacket packet, final String message) { @@ -1306,6 +1324,15 @@ public abstract class IpClientIntegrationTestCommon { private List<DhcpPacket> handleDhcpPackets(final boolean isSuccessLease, final Integer leaseTimeSec, final boolean shouldReplyRapidCommitAck, final int mtu, final String captivePortalApiUrl) throws Exception { + return handleDhcpPackets(isSuccessLease, leaseTimeSec, shouldReplyRapidCommitAck, + mtu, captivePortalApiUrl, null /* ipv6OnlyWaitTime */, + null /* domainName */, null /* domainSearchList */); + } + + private List<DhcpPacket> handleDhcpPackets(final boolean isSuccessLease, + final Integer leaseTimeSec, final boolean shouldReplyRapidCommitAck, final int mtu, + final String captivePortalApiUrl, final Integer ipv6OnlyWaitTime, + final String domainName, final List<String> domainSearchList) throws Exception { final List<DhcpPacket> packetList = new ArrayList<>(); DhcpPacket packet; while ((packet = getNextDhcpPacket()) != null) { @@ -1313,15 +1340,18 @@ public abstract class IpClientIntegrationTestCommon { if (packet instanceof DhcpDiscoverPacket) { if (shouldReplyRapidCommitAck) { mPacketReader.sendResponse(buildDhcpAckPacket(packet, CLIENT_ADDR, leaseTimeSec, - (short) mtu, true /* rapidCommit */, captivePortalApiUrl)); + (short) mtu, true /* rapidCommit */, captivePortalApiUrl, + ipv6OnlyWaitTime, domainName, domainSearchList)); } else { mPacketReader.sendResponse(buildDhcpOfferPacket(packet, CLIENT_ADDR, - leaseTimeSec, (short) mtu, captivePortalApiUrl)); + leaseTimeSec, (short) mtu, captivePortalApiUrl, ipv6OnlyWaitTime, + domainName, domainSearchList)); } } else if (packet instanceof DhcpRequestPacket) { final ByteBuffer byteBuffer = isSuccessLease ? buildDhcpAckPacket(packet, CLIENT_ADDR, leaseTimeSec, (short) mtu, - false /* rapidCommit */, captivePortalApiUrl) + false /* rapidCommit */, captivePortalApiUrl, ipv6OnlyWaitTime, + domainName, domainSearchList) : buildDhcpNakPacket(packet, "duplicated request IP address"); mPacketReader.sendResponse(byteBuffer); } else { @@ -3317,7 +3347,7 @@ public abstract class IpClientIntegrationTestCommon { // Respond DHCPOFFER with IPv6-Only preferred option and offered address. mPacketReader.sendResponse(buildDhcpOfferPacket(packet, clientAddress, TEST_LEASE_DURATION_S, (short) TEST_DEFAULT_MTU, null /* captivePortalUrl */, - ipv6OnlyWaitTime)); + ipv6OnlyWaitTime, null /* domainName */, null /* domainSearchList */)); } private void doDiscoverIPv6OnlyPreferredOptionTest(final int optionSecs, @@ -3387,7 +3417,8 @@ public abstract class IpClientIntegrationTestCommon { // contain the IPv6-only Preferred option to the client, instead respond with // a DHCPOFFER. mPacketReader.sendResponse(buildDhcpOfferPacket(packet, CLIENT_ADDR, TEST_LEASE_DURATION_S, - (short) TEST_DEFAULT_MTU, null /* captivePortalUrl */, TEST_IPV6_ONLY_WAIT_S)); + (short) TEST_DEFAULT_MTU, null /* captivePortalUrl */, TEST_IPV6_ONLY_WAIT_S, + null /* domainName */, null /* domainSearchList */)); final OnAlarmListener alarm = expectAlarmSet(null /* inOrder */, "TIMEOUT", 1800, mDependencies.mDhcpClient.getHandler()); @@ -3436,7 +3467,8 @@ public abstract class IpClientIntegrationTestCommon { // Respond DHCPACK with IPv6-Only preferred option. mPacketReader.sendResponse(buildDhcpAckPacket(packet, CLIENT_ADDR, TEST_LEASE_DURATION_S, (short) TEST_DEFAULT_MTU, false /* rapidcommit */, - null /* captivePortalUrl */, ipv6OnlyWaitTime)); + null /* captivePortalUrl */, ipv6OnlyWaitTime, null /* domainName */, + null /* domainSearchList */)); if (ipv6OnlyWaitTime != null) { expectAlarmSet(null /* inOrder */, "TIMEOUT", expectedWaitSecs, @@ -5363,4 +5395,51 @@ public abstract class IpClientIntegrationTestCommon { mNetd.getProcSysNet(INetd.IPV6, INetd.CONF, mIfaceName, "accept_ra_defrtr")); assertEquals(1, acceptRaDefRtr); } + private void runDhcpDomainSearchListOptionTest(final String domainName, + final List<String> domainSearchList, final String expectedDomain) throws Exception { + when(mResources.getBoolean(R.bool.config_dhcp_client_domain_search_list)).thenReturn(true); + final ProvisioningConfiguration cfg = new ProvisioningConfiguration.Builder() + .withoutIpReachabilityMonitor() + .withoutIPv6() + .withCreatorUid(TEST_DEVICE_OWNER_APP_UID) + .build(); + + startIpClientProvisioning(cfg); + handleDhcpPackets(true /* isSuccessLease */, TEST_LEASE_DURATION_S, + false /* shouldReplyRapidCommitAck */, TEST_DEFAULT_MTU, + null /* captivePortalApiUrl */, null /* ipv6OnlyWaitTime */, + domainName, domainSearchList); + + final ArgumentCaptor<LinkProperties> captor = ArgumentCaptor.forClass(LinkProperties.class); + verify(mCb, timeout(TEST_TIMEOUT_MS)).onProvisioningSuccess(captor.capture()); + final LinkProperties lp = captor.getValue(); + assertNotNull(lp); + assertEquals(expectedDomain, lp.getDomains()); + } + + @Test + @SignatureRequiredTest(reason = "requires mocked DevicePolicyManager") + public void testDhcpDomainSearchListOption() throws Exception { + final String domainName = "google.com"; + final List<String> searchList = List.of("suffix1.google.com", "suffix2.google.com"); + final String expectedDomain = "google.com suffix1.google.com suffix2.google.com"; + runDhcpDomainSearchListOptionTest(domainName, searchList, expectedDomain); + } + + @Test + @SignatureRequiredTest(reason = "requires mocked DevicePolicyManager") + public void testDhcpDomainSearchListOption_invalidSuffix() throws Exception { + final String domainName = "google.com"; + final List<String> searchList = List.of("google com"); + runDhcpDomainSearchListOptionTest(domainName, searchList, domainName /* expectedDomain */); + } + + @Test + @SignatureRequiredTest(reason = "requires mocked DevicePolicyManager") + public void testDhcpDomainSearchListOption_onlySearchList() throws Exception { + final List<String> searchList = List.of("google.com", "example.com"); + final String expectedDomain = "google.com example.com"; + runDhcpDomainSearchListOptionTest(null /* domainName */, searchList, + expectedDomain); + } } diff --git a/tests/unit/src/android/net/apf/ApfV5Test.kt b/tests/unit/src/android/net/apf/ApfV5Test.kt index 447495c8..1b74c3ee 100644 --- a/tests/unit/src/android/net/apf/ApfV5Test.kt +++ b/tests/unit/src/android/net/apf/ApfV5Test.kt @@ -18,6 +18,7 @@ package android.net.apf import android.net.apf.ApfGenerator.IllegalInstructionException import androidx.test.filters.SmallTest import androidx.test.runner.AndroidJUnit4 +import java.lang.IllegalArgumentException import kotlin.test.assertContentEquals import kotlin.test.assertFailsWith import org.junit.Test @@ -34,6 +35,17 @@ class ApfV5Test { fun testApfInstructionVersionCheck() { var gen = ApfGenerator(ApfGenerator.MIN_APF_VERSION) assertFailsWith<IllegalInstructionException> { gen.addDrop() } + assertFailsWith<IllegalInstructionException> { gen.addCountAndDrop(12) } + assertFailsWith<IllegalInstructionException> { gen.addCountAndPass(1000) } + assertFailsWith<IllegalInstructionException> { gen.addTransmit() } + assertFailsWith<IllegalInstructionException> { gen.addDiscard() } + } + + @Test + fun testApfInstructionArgumentCheck() { + var gen = ApfGenerator(ApfGenerator.MIN_APF_VERSION_IN_DEV) + assertFailsWith<IllegalArgumentException> { gen.addCountAndPass(0) } + assertFailsWith<IllegalArgumentException> { gen.addCountAndDrop(0) } } @Test @@ -42,81 +54,109 @@ class ApfV5Test { gen.addPass() var program = gen.generate() // encoding PASS opcode: opcode=0, imm_len=0, R=0 - assertContentEquals(byteArrayOf(encodeInstruction(0, 0, 0)), program) + assertContentEquals( + byteArrayOf(encodeInstruction(opcode = 0, immLength = 0, register = 0)), program) gen = ApfGenerator(ApfGenerator.MIN_APF_VERSION_IN_DEV) gen.addDrop() program = gen.generate() // encoding DROP opcode: opcode=0, imm_len=0, R=1 - assertContentEquals(byteArrayOf(encodeInstruction(0, 0, 1)), program) + assertContentEquals( + byteArrayOf(encodeInstruction(opcode = 0, immLength = 0, register = 1)), program) gen = ApfGenerator(ApfGenerator.MIN_APF_VERSION_IN_DEV) - gen.addAlloc(ApfGenerator.Register.R0) + gen.addCountAndPass(129) program = gen.generate() - assertContentEquals(byteArrayOf(encodeInstruction(21, 1, 0), 36), program) - assertContentEquals(arrayOf(" 0: alloc r0"), ApfJniUtils.disassembleApf(program)) + // encoding COUNT(PASS) opcode: opcode=0, imm_len=size_of(imm), R=0, imm=counterNumber + assertContentEquals( + byteArrayOf(encodeInstruction(opcode = 0, immLength = 1, register = 0), + 0x81.toByte()), program) gen = ApfGenerator(ApfGenerator.MIN_APF_VERSION_IN_DEV) - gen.addTrans(ApfGenerator.Register.R1) + gen.addCountAndDrop(1000) program = gen.generate() - assertContentEquals(byteArrayOf(encodeInstruction(21, 1, 1), 37), program) - assertContentEquals(arrayOf(" 0: trans r1"), ApfJniUtils.disassembleApf(program)) + // encoding COUNT(DROP) opcode: opcode=0, imm_len=size_of(imm), R=1, imm=counterNumber + assertContentEquals( + byteArrayOf(encodeInstruction(opcode = 0, immLength = 2, register = 1), + 0x03, 0xe8.toByte()), program) gen = ApfGenerator(ApfGenerator.MIN_APF_VERSION_IN_DEV) - gen.addWrite(0x01, 1) - gen.addWrite(0x0102, 2) - gen.addWrite(0x01020304, 4) + gen.addAlloc(ApfGenerator.Register.R0) program = gen.generate() - assertContentEquals(byteArrayOf( - encodeInstruction(24, 1, 0), 0x01, - encodeInstruction(24, 2, 0), 0x01, 0x02, - encodeInstruction(24, 4, 0), 0x01, 0x02, 0x03, 0x04 - ), program) - assertContentEquals(arrayOf( - " 0: write 0x01", - " 2: write 0x0102", - " 5: write 0x01020304"), ApfJniUtils.disassembleApf(program)) + assertContentEquals(byteArrayOf(encodeInstruction(21, 1, 0), 36), program) + assertContentEquals(arrayOf(" 0: alloc r0"), ApfJniUtils.disassembleApf(program)) gen = ApfGenerator(ApfGenerator.MIN_APF_VERSION_IN_DEV) - gen.addWrite(ApfGenerator.Register.R0, 1) - gen.addWrite(ApfGenerator.Register.R0, 2) - gen.addWrite(ApfGenerator.Register.R0, 4) + gen.addTransmit() + gen.addDiscard() program = gen.generate() + // encoding TRANSMIT/DISCARD opcode: opcode=21(EXT opcode number), + // imm=37(TRANSMIT/DISCARD opcode number), + // R=0 means discard the buffer. R=1 means transmit the buffer. assertContentEquals(byteArrayOf( - encodeInstruction(21, 1, 0), 38, - encodeInstruction(21, 1, 0), 39, - encodeInstruction(21, 1, 0), 40 + encodeInstruction(opcode = 21, immLength = 1, register = 0), 37, + encodeInstruction(opcode = 21, immLength = 1, register = 1), 37, ), program) - assertContentEquals(arrayOf( - " 0: write r0, 1", - " 2: write r0, 2", - " 4: write r0, 4"), ApfJniUtils.disassembleApf(program)) + // TODO: add back disassembling test check after we update the apf_disassembler + // assertContentEquals(arrayOf(" 0: trans"), ApfJniUtils.disassembleApf(program)) - gen = ApfGenerator(ApfGenerator.MIN_APF_VERSION_IN_DEV) - gen.addDataCopy(1, 5) - gen.addPacketCopy(1000, 255) - program = gen.generate() - assertContentEquals(byteArrayOf( - encodeInstruction(25, 1, 1), 1, 5, - encodeInstruction(25, 2, 0), - 0x03.toByte(), 0xe8.toByte(), 0xff.toByte(), - ), program) - assertContentEquals(arrayOf( - " 0: dcopy 1, 5", - " 3: pcopy 1000, 255"), ApfJniUtils.disassembleApf(program)) + // TODO: add back when support write opcode +// gen = ApfGenerator(ApfGenerator.MIN_APF_VERSION_IN_DEV) +// gen.addWrite(0x01, 1) +// gen.addWrite(0x0102, 2) +// gen.addWrite(0x01020304, 4) +// program = gen.generate() +// assertContentEquals(byteArrayOf( +// encodeInstruction(24, 1, 0), 0x01, +// encodeInstruction(24, 2, 0), 0x01, 0x02, +// encodeInstruction(24, 4, 0), 0x01, 0x02, 0x03, 0x04 +// ), program) +// assertContentEquals(arrayOf( +// " 0: write 0x01", +// " 2: write 0x0102", +// " 5: write 0x01020304"), ApfJniUtils.disassembleApf(program)) +// +// gen = ApfGenerator(ApfGenerator.MIN_APF_VERSION_IN_DEV) +// gen.addWrite(ApfGenerator.Register.R0, 1) +// gen.addWrite(ApfGenerator.Register.R0, 2) +// gen.addWrite(ApfGenerator.Register.R0, 4) +// program = gen.generate() +// assertContentEquals(byteArrayOf( +// encodeInstruction(21, 1, 0), 38, +// encodeInstruction(21, 1, 0), 39, +// encodeInstruction(21, 1, 0), 40 +// ), program) +// assertContentEquals(arrayOf( +// " 0: write r0, 1", +// " 2: write r0, 2", +// " 4: write r0, 4"), ApfJniUtils.disassembleApf(program)) - gen = ApfGenerator(ApfGenerator.MIN_APF_VERSION_IN_DEV) - gen.addDataCopy(ApfGenerator.Register.R1, 0, 5) - gen.addPacketCopy(ApfGenerator.Register.R0, 1000, 255) - program = gen.generate() - assertContentEquals(byteArrayOf( - encodeInstruction(21, 1, 1), 42, 0, 5, - encodeInstruction(21, 2, 0), - 0, 41, 0x03.toByte(), 0xe8.toByte(), 0xff.toByte() - ), program) - assertContentEquals(arrayOf( - " 0: dcopy [r1+0], 5", - " 4: pcopy [r0+1000], 255"), ApfJniUtils.disassembleApf(program)) + // TODO: add back when we properly support copy opcode +// gen = ApfGenerator(ApfGenerator.MIN_APF_VERSION_IN_DEV) +// gen.addDataCopy(1, 5) +// gen.addPacketCopy(1000, 255) +// program = gen.generate() +// assertContentEquals(byteArrayOf( +// encodeInstruction(25, 1, 1), 1, 5, +// encodeInstruction(25, 2, 0), +// 0x03.toByte(), 0xe8.toByte(), 0xff.toByte(), +// ), program) +// assertContentEquals(arrayOf( +// " 0: dcopy 1, 5", +// " 3: pcopy 1000, 255"), ApfJniUtils.disassembleApf(program)) +// +// gen = ApfGenerator(ApfGenerator.MIN_APF_VERSION_IN_DEV) +// gen.addDataCopy(ApfGenerator.Register.R1, 0, 5) +// gen.addPacketCopy(ApfGenerator.Register.R0, 1000, 255) +// program = gen.generate() +// assertContentEquals(byteArrayOf( +// encodeInstruction(21, 1, 1), 42, 0, 5, +// encodeInstruction(21, 2, 0), +// 0, 41, 0x03.toByte(), 0xe8.toByte(), 0xff.toByte() +// ), program) +// assertContentEquals(arrayOf( +// " 0: dcopy [r1+0], 5", +// " 4: pcopy [r0+1000], 255"), ApfJniUtils.disassembleApf(program)) } private fun encodeInstruction(opcode: Int, immLength: Int, register: Int): Byte { diff --git a/tests/unit/src/android/net/dhcp/DhcpResultsParcelableUtilTest.java b/tests/unit/src/android/net/dhcp/DhcpResultsParcelableUtilTest.java index 28103010..2d0916f7 100644 --- a/tests/unit/src/android/net/dhcp/DhcpResultsParcelableUtilTest.java +++ b/tests/unit/src/android/net/dhcp/DhcpResultsParcelableUtilTest.java @@ -40,6 +40,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import java.net.Inet4Address; +import java.util.Arrays; /** * Tests for {@link IpConfigurationParcelableUtil}. @@ -63,8 +64,9 @@ public class DhcpResultsParcelableUtilTest { mDhcpResults.serverHostName = "dhcp.example.com"; mDhcpResults.mtu = 1450; mDhcpResults.captivePortalApiUrl = "https://example.com/testapi"; + mDhcpResults.dmnsrchList.addAll(Arrays.asList("google.com", "example.com")); // Any added DhcpResults field must be included in equals() to be tested properly - assertFieldCountEquals(10, DhcpResults.class); + assertFieldCountEquals(11, DhcpResults.class); } @Test @@ -126,10 +128,16 @@ public class DhcpResultsParcelableUtilTest { assertEquals(mDhcpResults, unparceled); } - private static void setFieldsLostWhileParceling(@NonNull DhcpResults unparceledResults) { + private void setFieldsLostWhileParceling(@NonNull DhcpResults unparceledResults) { // TODO: add other fields that are not part of DhcpResultsParcelable here // e.g. if the dmnsrchList field is added, - // parceledResults.dmnsrchList.addAll(mDhcpResults.dmnSrchList); + unparceledResults.dmnsrchList.clear(); + unparceledResults.dnsServers.clear(); + unparceledResults.dmnsrchList.addAll(mDhcpResults.dmnsrchList); + unparceledResults.domains = mDhcpResults.domains; + unparceledResults.dnsServers.addAll(mDhcpResults.dnsServers); + unparceledResults.gateway = mDhcpResults.gateway; + unparceledResults.ipAddress = mDhcpResults.ipAddress; } /** diff --git a/tests/unit/src/android/net/shared/ProvisioningConfigurationTest.java b/tests/unit/src/android/net/shared/ProvisioningConfigurationTest.java index 033cdbc6..29ddf211 100644 --- a/tests/unit/src/android/net/shared/ProvisioningConfigurationTest.java +++ b/tests/unit/src/android/net/shared/ProvisioningConfigurationTest.java @@ -112,6 +112,7 @@ public class ProvisioningConfigurationTest { config.mIPv4ProvisioningMode = PROV_IPV4_DHCP; config.mIPv6ProvisioningMode = PROV_IPV6_SLAAC; config.mUniqueEui64AddressesOnly = false; + config.mCreatorUid = 10136; return config; } @@ -142,6 +143,7 @@ public class ProvisioningConfigurationTest { MacAddress.fromString("00:01:02:03:04:05")); p.layer2Info = layer2Info.toStableParcelable(); p.options = makeCustomizedDhcpOptions((byte) 60, new String("android-dhcp-11").getBytes()); + p.creatorUid = 10136; return p; } @@ -149,7 +151,7 @@ public class ProvisioningConfigurationTest { public void setUp() { mConfig = makeTestProvisioningConfiguration(); // Any added field must be included in equals() to be tested properly - assertFieldCountEquals(17, ProvisioningConfiguration.class); + assertFieldCountEquals(18, ProvisioningConfiguration.class); } @Test @@ -281,7 +283,8 @@ public class ProvisioningConfigurationTest { assertNotEqualsAfterChange(c -> c.mIPv6ProvisioningMode = PROV_IPV6_DISABLED); assertNotEqualsAfterChange(c -> c.mIPv6ProvisioningMode = PROV_IPV6_LINKLOCAL); assertNotEqualsAfterChange(c -> c.mUniqueEui64AddressesOnly = true); - assertFieldCountEquals(17, ProvisioningConfiguration.class); + assertNotEqualsAfterChange(c -> c.mCreatorUid = 10138); + assertFieldCountEquals(18, ProvisioningConfiguration.class); } private void assertNotEqualsAfterChange(Consumer<ProvisioningConfiguration> mutator) { |