summaryrefslogtreecommitdiff
path: root/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
diff options
context:
space:
mode:
authormarkchien <markchien@google.com>2022-02-25 23:14:58 +0800
committermarkchien <markchien@google.com>2022-03-31 16:32:55 +0800
commitfb65dfeb8da0c0ce4ec8ac63099ede54195e4da2 (patch)
tree38b9b09286e53b73f7d7fdb1dd2befb583024331 /Tethering/tests/unit/src/android/net/ip/IpServerTest.java
parent3d4de57752ef58e0fb58d6cd14e71bff8646c37e (diff)
Add config_p2p_leases_subnet_prefix_length configuration
Add new rro configuration which can be used to make the p2p dhcp prefix length larger to reserve the address range outside of leases subnet prefix length for EAPOL-Key feature. This configuration only valid if its value larger than dhcp server address prefix length and config_tether_enable_legacy_wifi_p2p_dedicated_ip is true. E.g.:leaseSubnetPrefixLength = 25, p2p static address = 192.168.49.1/24 dhcp range: 192.168.49.0 ~ 192.168.49.127 (192.168.49.1/25), reserved 192.168.49.128 ~ 192.168.49.255 for EAPOL-Key feature. Bug: 170056953 Test: atest TetheringTests Change-Id: I1319efd871796da7234383a29ab64a1623101ae7
Diffstat (limited to 'Tethering/tests/unit/src/android/net/ip/IpServerTest.java')
-rw-r--r--Tethering/tests/unit/src/android/net/ip/IpServerTest.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/Tethering/tests/unit/src/android/net/ip/IpServerTest.java b/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
index 6488421464..43f1eaa7d7 100644
--- a/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
+++ b/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
@@ -156,6 +156,8 @@ public class IpServerTest {
private static final int BLUETOOTH_DHCP_PREFIX_LENGTH = 24;
private static final int DHCP_LEASE_TIME_SECS = 3600;
private static final boolean DEFAULT_USING_BPF_OFFLOAD = true;
+ private static final int DEFAULT_SUBNET_PREFIX_LENGTH = 0;
+ private static final int P2P_SUBNET_PREFIX_LENGTH = 25;
private static final InterfaceParams TEST_IFACE_PARAMS = new InterfaceParams(
IFACE_NAME, 42 /* index */, MacAddress.ALL_ZEROS_ADDRESS, 1500 /* defaultMtu */);
@@ -230,6 +232,7 @@ public class IpServerTest {
when(mTetherConfig.isBpfOffloadEnabled()).thenReturn(usingBpfOffload);
when(mTetherConfig.useLegacyDhcpServer()).thenReturn(usingLegacyDhcp);
+ when(mTetherConfig.getP2pLeasesSubnetPrefixLength()).thenReturn(P2P_SUBNET_PREFIX_LENGTH);
mIpServer = new IpServer(
IFACE_NAME, mLooper.getLooper(), interfaceType, mSharedLog, mNetd, mBpfCoordinator,
mCallback, mTetherConfig, mAddressCoordinator, mDependencies);
@@ -1312,6 +1315,12 @@ public class IpServerTest {
if (mIpServer.interfaceType() == TETHERING_NCM) {
assertTrue(params.changePrefixOnDecline);
}
+
+ if (mIpServer.interfaceType() == TETHERING_WIFI_P2P) {
+ assertEquals(P2P_SUBNET_PREFIX_LENGTH, params.leasesSubnetPrefixLength);
+ } else {
+ assertEquals(DEFAULT_SUBNET_PREFIX_LENGTH, params.leasesSubnetPrefixLength);
+ }
}
private void assertDhcpStarted(IpPrefix expectedPrefix) throws Exception {