summaryrefslogtreecommitdiff
path: root/src/android/net/dhcp/DhcpPacket.java
diff options
context:
space:
mode:
authoryuanyunli <yuanyunli@vivo.corp-partner.google.com>2019-01-09 16:59:37 +0800
committerLorenzo Colitti <lorenzo@google.com>2019-04-26 22:59:52 +0900
commitb945b7982b2dc83dd63ada4e4947b2a41e7c1f53 (patch)
tree26279eb2a68a2f06a78a9219b9cdd7215e148ae5 /src/android/net/dhcp/DhcpPacket.java
parente64317d08784679031b2d62ba827e49468cffbe3 (diff)
Parse the server host name field of the dhcp package
Some hotspot devices will fill in the server host name field of the DHCP package, such as iphone. Parsing the server host name of the DHCP package can help identify ios hotspots. Bug: 120584519 Test: 127423755 Test: builds, boots, wifi works Change-Id: Idbe10c36332ce421f1bba93eb87e9e1e12463088
Diffstat (limited to 'src/android/net/dhcp/DhcpPacket.java')
-rw-r--r--src/android/net/dhcp/DhcpPacket.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/android/net/dhcp/DhcpPacket.java b/src/android/net/dhcp/DhcpPacket.java
index d7ff98b..c5b75f8 100644
--- a/src/android/net/dhcp/DhcpPacket.java
+++ b/src/android/net/dhcp/DhcpPacket.java
@@ -309,6 +309,11 @@ public abstract class DhcpPacket {
protected final byte[] mClientMac;
/**
+ * The server host name from server.
+ */
+ protected String mServerHostName;
+
+ /**
* Asks the packet object to create a ByteBuffer serialization of
* the packet for transmission.
*/
@@ -848,6 +853,7 @@ public abstract class DhcpPacket {
Inet4Address ipDst = null;
Inet4Address bcAddr = null;
Inet4Address requestedIp = null;
+ String serverHostName = null;
// The following are all unsigned integers. Internally we store them as signed integers of
// the same length because that way we're guaranteed that they can't be out of the range of
@@ -989,9 +995,9 @@ public abstract class DhcpPacket {
packet.get(clientMac);
// skip over address padding (16 octets allocated)
- packet.position(packet.position() + (16 - addrLen)
- + 64 // skip server host name (64 chars)
- + 128); // skip boot file name (128 chars)
+ packet.position(packet.position() + (16 - addrLen));
+ serverHostName = readAsciiString(packet, 64, false);
+ packet.position(packet.position() + 128);
// Ensure this is a DHCP packet with a magic cookie, and not BOOTP. http://b/31850211
if (packet.remaining() < 4) {
@@ -1192,6 +1198,7 @@ public abstract class DhcpPacket {
newPacket.mT2 = T2;
newPacket.mVendorId = vendorId;
newPacket.mVendorInfo = vendorInfo;
+ newPacket.mServerHostName = serverHostName;
return newPacket;
}
@@ -1251,6 +1258,7 @@ public abstract class DhcpPacket {
results.vendorInfo = mVendorInfo;
results.leaseDuration = (mLeaseTime != null) ? mLeaseTime : INFINITE_LEASE;
results.mtu = (mMtu != null && MIN_MTU <= mMtu && mMtu <= MAX_MTU) ? mMtu : 0;
+ results.serverHostName = mServerHostName;
return results;
}