History log of /frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
2677b1957b444e2dae5737feee989109b811547c 18-Apr-2016 Hugo Benichi <hugobenichi@google.com> Fix spurious DHCP parse error logging.

This patch moves the event logging of DHCP response packet parse errors
to DHCPClient in a single place. It also logs receive IO errors as
DHCPErrors instead of DHCPClientEvents.

BUG=28197345

Change-Id: I7ad666cff4d8b97915880477347fbb3f588fdb2a
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
6241874355c0e0d9ff04e993ad1d522c66b8c50b 13-Apr-2016 Hugo Benichi <hugobenichi@google.com> Add DHCP error event class and record DHCP errors.

This patch adds an event class derived from IpConnectivityEvent that
records parsing errors of DHCP response packets.

Change-Id: I19516cf05e3419c4262e3236899e52987e5f2264
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
77fdf23d6f7831c09fc43d206b346e273ebe266a 31-Mar-2016 Lorenzo Colitti <lorenzo@google.com> Honour the DHCP MTU option.

Bug: 25590369
Bug: 27719279
Change-Id: I473b5ec9c13f0d74e1ddd55e9d4abcff374a83ef
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
f55c9c1781d1bf24360bc1cb3d2c41fb8a9d6107 02-Mar-2016 Lorenzo Colitti <lorenzo@google.com> Don't crash if we get a DHCP packet with the wrong port.

This should only happen if we get a packet in the small time
window between binding the packet socket and programming the
BPF filter on it.

Bug: 26696823
Change-Id: I481f1bc74bbaeb9646d96e1841d2a69acdb47d62
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
6c7acb6ec7494235dd80d972fb3db0f7b48fb4fc 29-Jun-2015 Lorenzo Colitti <lorenzo@google.com> Add a test that checks the contents of DISCOVER packets.

Change-Id: I571d560cf7032babf7b7867ad748e2a896116ce7
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
025f4a5aae1660eda6406703771995010d9de990 17-Sep-2015 Lorenzo Colitti <lorenzo@google.com> Support DHCP replies with multiple default gateways.

Just use the first one for compatibility with the legacy client.

Bug: 23975855
Change-Id: Id6a0b0de32e8947c12c02eb9a3be417e2f82c99a
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
b19238c48814c5a1438b1238794e121876ae89ab 06-Oct-2015 Erik Kline <ek@google.com> Accept DHCP responses from non-67 server source ports

Bug: 24687559
Change-Id: I5f03b8b2780c558281d8a50d0893fd64f2812add
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
496906ee7008b72619f230c65f103533d4d2d68a 16-Sep-2015 Erik Kline <ek@google.com> Improve logging of DHCP parse errors using exceptions.

Bug: 23975855
Change-Id: I62464b92f0bb568e57bf5e1a63bc75f22c75aac1
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
d64144a37ca0a6f341c0092cc04271831ff5f90d 03-Sep-2015 Lorenzo Colitti <lorenzo@google.com> Don't crash on (invalid) hardware address lengths > 127.

These would cause us to crash with a NegativeArraySizeException
when trying to create the clientMac array. Instead, if the length
is > 16 (invalid, because the field is only 16 bytes long), fudge
it to 6 (Ethernet / wifi). This is a bit less liberal than the
legacy client, which doesn't check the length at all.

Bug: 23725795
Change-Id: I83f47bfc400ffa8ce85dd9d1b8eb96be5afe51a5
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
b0b3d0bcfb0af678d4c85bec63722f976ffb01cf 05-Jul-2015 Lorenzo Colitti <lorenzo@google.com> Fix two parsing bugs in new DHCP client.

1. We don't parse PAD options properly, leading in failure to
parse packets sent by DHCP servers that put the end of options
marker after pad options and at an odd offset.
2. We get the DhcpResults vendorInfo from the wrong option type
(60 instead of 43).

Fix these and add unit tests for the offer packets sent by a few
different DHCP servers.

Bug: 21955617
Bug: 22281295
Change-Id: I5d13f1a6a3ff0b53112f18f3db8792fa32ad2da3
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
f68edb16116307553059a889ef456227a9697918 02-Jun-2015 Lorenzo Colitti <lorenzo@google.com> Actually fall back from yiaddr to ciaddr.

The initial implementation of toDhcpResults attempted to get the
leased IP address from ciaddr if yiaddr was 0.0.0.0, but it never
actually did so because a) it used == instead of equals(), and b)
the parsing code never populated mClientIp for a DhcpOfferPacket
or DhcpAckPacket.

Fix this and add a test for it.. Technically DHCP does not use
ciaddr (only bootp uses it), but in 5.0 we would use ciaddr if
yiaddr was 0.0.0.0 and a bit more compatibility shouldn't hurt.

Bug: 19704592
Change-Id: I1f58555f0c10b9c576995a6edb759a83d8938ea0
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
d973537ee1bd013b4233d3369d66821e124a2e65 02-Jun-2015 Lorenzo Colitti <lorenzo@google.com> Fix DHCP lease time parsing.

Currently we treat a lease time larger than 2**31-1 as a negative
value, which causes DhcpClient to attempt to renew its IP address
constantly. Fix this by properly handling large and infinite
lifetimes, and while we're at it, impose a minimum lease time of
60 seconds.

Bug: 21352084
Change-Id: If62c9efeffad6222e2fe0c110f77d0e4c70de96d
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
644f41368f9eddd475fa9c5dddc7ceac5722a3a8 24-Apr-2015 Etan Cohen <etancohen@google.com> Merge commit '4cb5d80' into merge2
f443bfc25e80ef46aedd616d4ecb4c95abd7be7a 22-Apr-2015 Lorenzo Colitti <lorenzo@google.com> Always send the DHCP client identifier.

Currently we send it only in request packets, but not in discover
packets. This might confuse servers because they might think that
the discover and the request come from different clients.

Also reorder the options in the request packet to match the order
used by the legacy DHCP client.

While I'm at it, fix the generation code for inform and decline
packets, which we do not use.

Bug: 19704592
Bug: 20335221
Change-Id: I1d45306e76dbd5da9cc4611e6df84a9f67346b2c
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
3e979321a5d96b9e2688f67ef0f936602c0f7e5a 21-Apr-2015 Lorenzo Colitti <lorenzo@google.com> Set the secs field in the BOOTP header.

We mostly follow RFC 2131, which says that secs is the number of
seconds "since client began address acquisition or renewal
process", and thus set secs to zero on renew. This is different
from our current behaviour, which keeps on counting without
resetting secs to zero on renew.

Bug: 19704592
Change-Id: Ifbb7644094c579be626ffb698eee87047425dbf0
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
a12bde35672c45af7bca8170ee1a3b3370bec30e 31-Mar-2015 Lorenzo Colitti <lorenzo@google.com> Deal with null characters in string options.

This currently truncates all strings at the first NULL character,
except for vendorInfo, which is an opaque string.

Bug: 19985674
Change-Id: Ie53b2c55eb8a5204d7b2c7e2d8587743d923647a
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
c2abb2bf5efa901d747fe1dc020ba3361c60b45e 31-Mar-2015 Lorenzo Colitti <lorenzo@google.com> Deal with null characters in string options.

This currently truncates all strings at the first NULL character,
except for vendorInfo, which is an opaque string.

Bug: 19985674
Change-Id: Ie53b2c55eb8a5204d7b2c7e2d8587743d923647a
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
06ac4b8dd1877d8a82103f11c236f1527b692f94 17-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: Don't write options longer than 255 bytes.

Change-Id: Iddc971c7ac97253af3063850cde3dee10c3829ff
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
b05c9234e644b9648ff21c991ef010df10783b0c 17-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: parsing robustness fixes.

1. Check the length of the fixed-length portions of the packet.
2. Catch BufferUnderflowException while parsing options.

Change-Id: If907f49f02a04a4a3360f46a3192e94ab099af0e
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
fe5ffce09c4a163ee9a190aedc9fd7cea38a576f 10-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: protocol changes.

1. Define and add parsing code for MTU, max message size, T1, T2.
2. Add common TLVs (message size, hostname, vendor ID) to all
packets sent by the client.
3. Don't include requested IP and server ID in renew messages,
since the RFC says MUST NOT.
4. Don't hardcode the broadcast flag to true in DISCOVER packets,
use what the caller passed in.
5. Make some methods static.

Bug: 19704592
Change-Id: I42a0997e468b12e19cad9b403b98fe266e6cea73
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
86bff86778d006d59a36bb10c7a577d982934402 10-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: glue code.

1. Add a method to make a DhcpResults object from a DHCP packet.
2. Add a method to fetch the client MAC from the packet. This is
needed to check that the message is for us (lots of DHCP
messages are broadcast).
3. Add a length argument to the method that parses DHCP packets,
so the caller can use the same MTU-sized array all the time
instead of having to pass in a new array for every packet.

Bug: 19704592
Change-Id: I58223f5ec90fb5c762bc2934649e02f9122018b2
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
7f7cc6115914b4a0ebd99c5d77db8f571195a1fb 12-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: Ethernet/IP packet header changes.

1. Support L2_ENCAP when building packets as well as when parsing.
2. Skip IP options when parsing DHCP packets.

Bug: 19704592
Change-Id: Ic27a45790ed1cf7cf5b82d63b6c0b64c909a570f
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
51697effe9567a144532190ad534370a00c15996 14-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: Minor cleanups to the packet code.

1. Delete the DhcpStateMachine, since we don't plan to use it.
2. Make all InetAddresses Inet4Addresses, since that's what they
are. In order to do this, define INADDR_ANY and
INADDR_BROADCAST, constants, since Inet4Address.{ANY,ALL} are
not Inet4Addresses but InetAddresses.

Bug: 19704592
Change-Id: I5a0499be889076992a60aaad0bd8be5ea66bd560
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
eca9b9bd8b9a4d0a2de8af8edc20834dd46b98b3 09-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: Move the packet code to frameworks/base/services.

There's no need for it to be in frameworks/base/core, since it
will only be used by services.

Bug: 19704592
Change-Id: I2f5277eca848b7000ca46db575e8602eacb5c8bd
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
3698af5f644fa5d34a1619886c66617ed2eab5a5 17-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: Don't write options longer than 255 bytes.

Change-Id: Iddc971c7ac97253af3063850cde3dee10c3829ff
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
2ed489f4100e058eb8713280c06a5a5e15cb1f3d 17-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: parsing robustness fixes.

1. Check the length of the fixed-length portions of the packet.
2. Catch BufferUnderflowException while parsing options.

Change-Id: If907f49f02a04a4a3360f46a3192e94ab099af0e
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
04b8d3aab6acdf382c74d12a89b5fc50fd8d0158 10-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: protocol changes.

1. Define and add parsing code for MTU, max message size, T1, T2.
2. Add common TLVs (message size, hostname, vendor ID) to all
packets sent by the client.
3. Don't include requested IP and server ID in renew messages,
since the RFC says MUST NOT.
4. Don't hardcode the broadcast flag to true in DISCOVER packets,
use what the caller passed in.
5. Make some methods static.

Bug: 19704592
Change-Id: I42a0997e468b12e19cad9b403b98fe266e6cea73
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
29cb944bef7b56ef4b657cd7f2d0c2be96d670d6 10-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: glue code.

1. Add a method to make a DhcpResults object from a DHCP packet.
2. Add a method to fetch the client MAC from the packet. This is
needed to check that the message is for us (lots of DHCP
messages are broadcast).
3. Add a length argument to the method that parses DHCP packets,
so the caller can use the same MTU-sized array all the time
instead of having to pass in a new array for every packet.

Bug: 19704592
Change-Id: I58223f5ec90fb5c762bc2934649e02f9122018b2
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
15204d50b4220f98e4144567a9cfa4418cc9763a 12-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: Ethernet/IP packet header changes.

1. Support L2_ENCAP when building packets as well as when parsing.
2. Skip IP options when parsing DHCP packets.

Bug: 19704592
Change-Id: Ic27a45790ed1cf7cf5b82d63b6c0b64c909a570f
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
c8a0f49feecaf231e3f5972bd247dfbc586ccb34 14-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: Minor cleanups to the packet code.

1. Delete the DhcpStateMachine, since we don't plan to use it.
2. Make all InetAddresses Inet4Addresses, since that's what they
are. In order to do this, define INADDR_ANY and
INADDR_BROADCAST, constants, since Inet4Address.{ANY,ALL} are
not Inet4Addresses but InetAddresses.

Bug: 19704592
Change-Id: I5a0499be889076992a60aaad0bd8be5ea66bd560
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java
c95a87f30d069472302f90a206e229b82bb2316a 09-Mar-2015 Lorenzo Colitti <lorenzo@google.com> DHCP: Move the packet code to frameworks/base/services.

There's no need for it to be in frameworks/base/core, since it
will only be used by services.

Bug: 19704592
Change-Id: I2f5277eca848b7000ca46db575e8602eacb5c8bd
/frameworks/base/services/net/java/android/net/dhcp/DhcpPacket.java