Assign specific client address to dhcp server
Bug: 141256482
Test: manual
atest TetheringTests
Merged-In: Ief76c98c843ba5420224cbf0f34464f366c891b7
Change-Id: Ief76c98c843ba5420224cbf0f34464f366c891b7
This commit is contained in:
committed by
Mark Chien
parent
d20078112b
commit
5da1070d8f
@@ -18,10 +18,12 @@ package android.net.dhcp;
|
||||
|
||||
import static android.net.shared.Inet4AddressUtils.inet4AddressToIntHTH;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.net.LinkAddress;
|
||||
import android.util.ArraySet;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -160,6 +162,17 @@ public class DhcpServingParamsParcelExt extends DhcpServingParamsParcel {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the client address to tell DHCP server only offer this address.
|
||||
* The client's prefix length is the same as server's.
|
||||
*
|
||||
* <p>If not set, the default value is null.
|
||||
*/
|
||||
public DhcpServingParamsParcelExt setSingleClientAddr(@Nullable Inet4Address clientAddr) {
|
||||
this.clientAddr = clientAddr == null ? 0 : inet4AddressToIntHTH(clientAddr);
|
||||
return this;
|
||||
}
|
||||
|
||||
private static int[] toIntArray(@NonNull Collection<Inet4Address> addrs) {
|
||||
int[] res = new int[addrs.size()];
|
||||
int i = 0;
|
||||
|
||||
Reference in New Issue
Block a user