diff options
author | Xiao Ma <xiaom@google.com> | 2019-07-05 07:46:34 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-07-05 07:46:34 -0700 |
commit | f093022d6c8186c9bb3e02cba10f76ca3f848d1e (patch) | |
tree | 6da997056111b477a3a564d93a6d8862acdfbbd0 /src/android/net/dhcp/DhcpPacket.java | |
parent | fff7b07d00fbe0cacaf61dec80f5e28cec982c81 (diff) | |
parent | d53f5498850e2371843dfbba2bcaad7dd5cd74a3 (diff) |
Merge "Add DHCP Rapid Commit option(RFC4039) support in client side."
am: d53f549885
Change-Id: I4a868d673f6263a5ad2d5acb475e99aac80b750c
Diffstat (limited to 'src/android/net/dhcp/DhcpPacket.java')
-rw-r--r-- | src/android/net/dhcp/DhcpPacket.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/android/net/dhcp/DhcpPacket.java b/src/android/net/dhcp/DhcpPacket.java index d5c3efb..79e1c4f 100644 --- a/src/android/net/dhcp/DhcpPacket.java +++ b/src/android/net/dhcp/DhcpPacket.java @@ -281,6 +281,13 @@ public abstract class DhcpPacket { protected byte[] mClientId; /** + * DHCP zero-length Optional Type: Rapid Commit. Per RFC4039, both DHCPDISCOVER and DHCPACK + * packet may include this option. + */ + protected static final byte DHCP_RAPID_COMMIT = 80; + protected boolean mRapidCommit; + + /** * DHCP zero-length option code: pad */ protected static final byte DHCP_OPTION_PAD = 0x00; @@ -605,6 +612,14 @@ public abstract class DhcpPacket { } /** + * Adds an optional parameter containing zero-length value. + */ + protected static void addTlv(ByteBuffer buf, byte type) { + buf.put(type); + buf.put((byte) 0); + } + + /** * Adds an optional parameter containing an array of bytes. * * <p>This method is a no-op if the payload argument is null. @@ -858,6 +873,7 @@ public abstract class DhcpPacket { String message = null; String vendorId = null; String vendorInfo = null; + boolean rapidCommit = false; byte[] expectedParams = null; String hostName = null; String domainName = null; @@ -1126,6 +1142,10 @@ public abstract class DhcpPacket { optionOverload = packet.get(); optionOverload &= OPTION_OVERLOAD_BOTH; break; + case DHCP_RAPID_COMMIT: + expectedLen = 0; + rapidCommit = true; + break; default: // ignore any other parameters for (int i = 0; i < optionLen; i++) { @@ -1216,6 +1236,7 @@ public abstract class DhcpPacket { newPacket.mT2 = T2; newPacket.mVendorId = vendorId; newPacket.mVendorInfo = vendorInfo; + newPacket.mRapidCommit = rapidCommit; if ((optionOverload & OPTION_OVERLOAD_SNAME) == 0) { newPacket.mServerHostName = serverHostName; } else { @@ -1304,10 +1325,12 @@ public abstract class DhcpPacket { * parameters. */ public static ByteBuffer buildDiscoverPacket(int encap, int transactionId, - short secs, byte[] clientMac, boolean broadcast, byte[] expectedParams) { + short secs, byte[] clientMac, boolean broadcast, byte[] expectedParams, + boolean rapidCommit) { DhcpPacket pkt = new DhcpDiscoverPacket(transactionId, secs, INADDR_ANY /* relayIp */, clientMac, broadcast, INADDR_ANY /* srcIp */); pkt.mRequestedParams = expectedParams; + pkt.mRapidCommit = rapidCommit; return pkt.buildPacket(encap, DHCP_SERVER, DHCP_CLIENT); } |