19 Commits

Author SHA1 Message Date
Prerepa Viswanadham
220951a6d0 Merge commit 'b2ff415' into merge_work
Change-Id: I4f9c662112fc49e4f94315d3c69860607be3bc1e
2015-04-10 15:54:48 -07:00
Lorenzo Colitti
a12bde3567 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
2015-04-01 17:53:14 +09:00
Lorenzo Colitti
f5c17221d4 Don't log errors if the receive thread is stopped.
Change-Id: I75ddc9b68f0a61a9a7a78026ed97a8a7c5109cc3
2015-03-31 07:07:03 +09:00
Lorenzo Colitti
06ac4b8dd1 DHCP: Don't write options longer than 255 bytes.
Change-Id: Iddc971c7ac97253af3063850cde3dee10c3829ff
2015-03-20 16:32:44 +09:00
Lorenzo Colitti
b05c9234e6 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
2015-03-20 16:32:43 +09:00
Lorenzo Colitti
e7d4243be9 DHCP: Add a Java DHCP client.
The behaviour of the client is intended to mirror the behaviour
of the current DhcpStateMachine + dhcpcd combination, except it
does not store leases across network changes.

Bug: 19704592
Change-Id: I110b58003da2d8293059d48a0181e16f7f7f145c
2015-03-20 16:32:41 +09:00
Lorenzo Colitti
fe5ffce09c 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
2015-03-20 16:32:39 +09:00
Lorenzo Colitti
86bff86778 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
2015-03-20 16:32:39 +09:00
Lorenzo Colitti
7f7cc61159 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
2015-03-20 16:32:38 +09:00
Lorenzo Colitti
51697effe9 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
2015-03-20 16:32:37 +09:00
Lorenzo Colitti
eca9b9bd8b 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
2015-03-20 16:32:36 +09:00
Lorenzo Colitti
3698af5f64 DHCP: Don't write options longer than 255 bytes.
Change-Id: Iddc971c7ac97253af3063850cde3dee10c3829ff
2015-03-17 19:56:34 +09:00
Lorenzo Colitti
2ed489f410 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
2015-03-17 19:46:14 +09:00
Lorenzo Colitti
a071edce46 DHCP: Add a Java DHCP client.
The behaviour of the client is intended to mirror the behaviour
of the current DhcpStateMachine + dhcpcd combination, except it
does not store leases across network changes.

Bug: 19704592
Change-Id: I110b58003da2d8293059d48a0181e16f7f7f145c
2015-03-17 19:46:13 +09:00
Lorenzo Colitti
04b8d3aab6 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
2015-03-17 13:21:21 +09:00
Lorenzo Colitti
29cb944bef 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
2015-03-16 22:35:19 +09:00
Lorenzo Colitti
15204d50b4 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
2015-03-16 21:57:00 +09:00
Lorenzo Colitti
c8a0f49fee 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
2015-03-16 20:08:47 +09:00
Lorenzo Colitti
c95a87f30d 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
2015-03-16 20:08:46 +09:00