summaryrefslogtreecommitdiff
path: root/src/android/net/dhcp/DhcpLeaseRepository.java
diff options
context:
space:
mode:
authorXiao Ma <xiaom@google.com>2019-07-24 16:27:50 +0900
committerXiao Ma <xiaom@google.com>2019-12-11 11:26:49 +0900
commit859ceabd04daece392d42d37dbc2092cb88996f1 (patch)
tree2a2adec6473fee85f7aff6971238eb58beaff56e /src/android/net/dhcp/DhcpLeaseRepository.java
parent762f239387423bf2250139f49972d2afa14c7428 (diff)
Add Rapid Commit option support in DHCP Server side.
Bug:136216415 Test: atest FrameworksNetTests NetworkStackTests Test: atest NetworkStackIntegrationTests Test: manual tethering Change-Id: I0f9483c72374bab271eb18549a1a41812f32f2dd
Diffstat (limited to 'src/android/net/dhcp/DhcpLeaseRepository.java')
-rw-r--r--src/android/net/dhcp/DhcpLeaseRepository.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/android/net/dhcp/DhcpLeaseRepository.java b/src/android/net/dhcp/DhcpLeaseRepository.java
index d22193b..4e74dc8 100644
--- a/src/android/net/dhcp/DhcpLeaseRepository.java
+++ b/src/android/net/dhcp/DhcpLeaseRepository.java
@@ -190,6 +190,25 @@ class DhcpLeaseRepository {
return newLease;
}
+ /**
+ * Get a rapid committed DHCP Lease, to reply to a DHCPDISCOVER w/ Rapid Commit option.
+ *
+ * @param clientId Client identifier option if specified, or {@link #CLIENTID_UNSPEC}
+ * @param relayAddr Internet address of the relay (giaddr), can be {@link Inet4Address#ANY}
+ * @param hostname Client-provided hostname, or {@link DhcpLease#HOSTNAME_NONE}
+ * @throws OutOfAddressesException The server does not have any available address
+ * @throws InvalidSubnetException The lease was requested from an unsupported subnet
+ */
+ @NonNull
+ public DhcpLease getCommittedLease(@Nullable byte[] clientId, @NonNull MacAddress hwAddr,
+ @NonNull Inet4Address relayAddr, @Nullable String hostname)
+ throws OutOfAddressesException, InvalidSubnetException {
+ final DhcpLease newLease = getOffer(clientId, hwAddr, relayAddr, null /* reqAddr */,
+ hostname);
+ commitLease(newLease);
+ return newLease;
+ }
+
private void checkValidRelayAddr(@Nullable Inet4Address relayAddr)
throws InvalidSubnetException {
// As per #4.3.1, addresses are assigned based on the relay address if present. This