Merge "Assign specific client address to dhcp server" am: 037becbf64 am: 815ab636c3

Change-Id: Ia0e4a913faa5eac5d5ccba837eb7774d59670d27
This commit is contained in:
Treehugger Robot
2020-03-30 04:23:55 +00:00
committed by Automerger Merge Worker
5 changed files with 76 additions and 22 deletions

View File

@@ -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");
}
@@ -656,6 +652,19 @@ public class TetheringManager {
return mRequestParcel.showProvisioningUi;
}
/**
* 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