diff options
| author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-03-30 04:06:29 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-03-30 04:06:29 +0000 |
| commit | 815ab636c3795db55bbba22a886bc77e8052467d (patch) | |
| tree | 4de7b7eeed3685a14916df3805b497f2e49544cb /Tethering/common/TetheringLib/src/android/net/TetheringManager.java | |
| parent | 2692eab096fdfbe19bd4adf3ca4c7befa715f18d (diff) | |
| parent | 037becbf643ad9e72ce19ba7fbb4b4fa59fba63b (diff) | |
Merge "Assign specific client address to dhcp server" am: 037becbf64
Change-Id: Ic5b645bb62a1b62ab010a9fa50427e1a1fc8ff01
Diffstat (limited to 'Tethering/common/TetheringLib/src/android/net/TetheringManager.java')
| -rw-r--r-- | Tethering/common/TetheringLib/src/android/net/TetheringManager.java | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Tethering/common/TetheringLib/src/android/net/TetheringManager.java b/Tethering/common/TetheringLib/src/android/net/TetheringManager.java index 096f4fefa8..0107a7ef5b 100644 --- a/Tethering/common/TetheringLib/src/android/net/TetheringManager.java +++ b/Tethering/common/TetheringLib/src/android/net/TetheringManager.java @@ -571,9 +571,8 @@ public class TetheringManager { /** * Configure tethering with static IPv4 assignment. * - * The clientAddress must be in the localIPv4Address prefix. A DHCP server will be - * started, but will only be able to offer the client address. The two addresses must - * be in the same prefix. + * A DHCP server will be started, but will only be able to offer the client address. + * The two addresses must be in the same prefix. * * @param localIPv4Address The preferred local IPv4 link address to use. * @param clientAddress The static client address. @@ -584,10 +583,7 @@ public class TetheringManager { @NonNull final LinkAddress clientAddress) { Objects.requireNonNull(localIPv4Address); Objects.requireNonNull(clientAddress); - if (localIPv4Address.getPrefixLength() != clientAddress.getPrefixLength() - || !localIPv4Address.isIpv4() || !clientAddress.isIpv4() - || !new IpPrefix(localIPv4Address.toString()).equals( - new IpPrefix(clientAddress.toString()))) { + if (!checkStaticAddressConfiguration(localIPv4Address, clientAddress)) { throw new IllegalArgumentException("Invalid server or client addresses"); } @@ -657,6 +653,19 @@ public class TetheringManager { } /** + * Check whether the two addresses are ipv4 and in the same prefix. + * @hide + */ + public static boolean checkStaticAddressConfiguration( + @NonNull final LinkAddress localIPv4Address, + @NonNull final LinkAddress clientAddress) { + return localIPv4Address.getPrefixLength() == clientAddress.getPrefixLength() + && localIPv4Address.isIpv4() && clientAddress.isIpv4() + && new IpPrefix(localIPv4Address.toString()).equals( + new IpPrefix(clientAddress.toString())); + } + + /** * Get a TetheringRequestParcel from the configuration * @hide */ |
