summaryrefslogtreecommitdiffstats
path: root/services/net
Commit message (Collapse)AuthorAgeFilesLines
* Connect the DHCP UDP socket to the server.Lorenzo Colitti2015-10-111-7/+19
| | | | | | | | | | | This makes it so that the socket cannot receive datagrams from anybody except the DHCP server. This does not improve security, because we never read from the UDP socket anyway, but it does make ListeningPortsTest pass. Bug: 23906864 Bug: 23933386 Change-Id: Ib090273a417f7eb2ac1ee3309260249b72fb8345
* Support DHCP replies with multiple default gateways.Lorenzo Colitti2015-10-083-15/+20
| | | | | | | Just use the first one for compatibility with the legacy client. Bug: 23975855 Change-Id: Id6a0b0de32e8947c12c02eb9a3be417e2f82c99a
* Accept DHCP responses from non-67 server source portsErik Kline2015-10-081-2/+14
| | | | | Bug: 24687559 Change-Id: I5f03b8b2780c558281d8a50d0893fd64f2812add
* Improve logging of DHCP parse errors using exceptions.Erik Kline2015-10-082-28/+49
| | | | | Bug: 23975855 Change-Id: I62464b92f0bb568e57bf5e1a63bc75f22c75aac1
* Give the DhcpClient alarm broadcasts foreground priority.Lorenzo Colitti2015-09-251-2/+3
| | | | | | Bug: 24265658 Bug: 24224067 Change-Id: I375097e7957643efb4bc0bb81318b13d9b9c82c1
* am 0a76afb9: Merge "Don\'t crash on (invalid) hardware address lengths > ↵Ian Pedowitz2015-09-031-2/+13
|\ | | | | | | | | | | | | 127." into mnc-dev * commit '0a76afb93e6f303921ab84e2f26747c3ebf19b62': Don't crash on (invalid) hardware address lengths > 127.
| * Don't crash on (invalid) hardware address lengths > 127.Lorenzo Colitti2015-09-031-2/+13
| | | | | | | | | | | | | | | | | | | | | | 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
* | am e022cb08: Merge "Don\'t attempt to stop the receive thread if we never ↵Lorenzo Colitti2015-08-121-1/+4
|\ \ | |/ | | | | | | | | | | started it." into mnc-dev * commit 'e022cb085f6ebc2801f843bb47c9fd23f6daa3ea': Don't attempt to stop the receive thread if we never started it.
| * Don't attempt to stop the receive thread if we never started it.Lorenzo Colitti2015-08-111-1/+4
| | | | | | | | | | | | | | | | | | | | If socket initialization fails, DhcpState#exit will call mReceiveThread#stop and crash the system with an NPE. Make sure we don't do that if mReceiveThread is null, and properly null it out when exiting. Bug: 23088314 Change-Id: I4378d8280f9d8588f5eaa8bd7ade61beab1c3ce2
* | ConnectivityManager API for for packet keepalives.Lorenzo Colitti2015-07-181-0/+151
|/ | | | | Bug: 21405946 Change-Id: Ie1f8f8bee684fe2bb1092a9f1bc9f5dc29b1defc
* Fix two parsing bugs in new DHCP client.Lorenzo Colitti2015-07-061-2/+28
| | | | | | | | | | | | | | | 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
* Correctly time out CMD_START_DHCP.Lorenzo Colitti2015-06-081-18/+60
| | | | | | | | | | | | | | | | | WifiStateMachine expects CMD_START_DHCP to time out after 30-40 seconds. Currently, DhcpClient imposes timeouts on DhcpInitState and on DhcpRequestState, but not on the time it takes to get to from CMD_START_DHCP to DhcpBoundState. So in theory the client could oscillate between DhcpInitState and DhcpRequestState and never time out. Fix this by introducing a new oneshot timer that is set when DHCP starts and is cancelled when it succeeds. CMD_RENEW_DHCP does not need this because it's implemented using only one state, so the oneshot timeout can be implemented using the state timeout. Bug: 19704592 Change-Id: I6a5847a3dee23a2692237b8f3b3b0f8049da5140
* Actually close sockets when stopping the receive thread.Lorenzo Colitti2015-06-041-5/+13
| | | | | | | | | | | | | | | | | | Contrary to the expectations of the code, IoUtils.closeQuietly() does not unblock system calls. So mReceiveThread.halt() was not actually stopping the receive thread. This wasn't actually a problem, because after "stopping" the receive thread, either the interface would go down (interrupting the previous receive thread with ENETDOWN), or a packet would arrive to both the old and new receive threads, stopping the old one. But the lack of a "stopping receive thread" message at the expected time was confusing. While I'm at it, also add the string for CMD_TIMEOUT. Bug: 19704592 Change-Id: I74732429118af780453028898148519b294fa9d3
* Actually fall back from yiaddr to ciaddr.Lorenzo Colitti2015-06-043-10/+10
| | | | | | | | | | | | | | | 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
* Make RenewingState time out as well.Lorenzo Colitti2015-06-031-15/+21
| | | | | Bug: 19704592 Change-Id: I0759a98911a8c0059936916db8db459b7d66bc00
* Remove the IPv4 address from the interface when DHCP fails.Lorenzo Colitti2015-06-031-12/+25
| | | | | Bug: 19704592 Change-Id: I9b96cdcfc7c9442b3f8d6797aca63559ed4bdb9b
* Merge "Fix DHCP lease time parsing." into mnc-devLorenzo Colitti2015-06-022-12/+38
|\
| * Fix DHCP lease time parsing.Lorenzo Colitti2015-06-022-12/+38
| | | | | | | | | | | | | | | | | | | | | | 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
* | pass a defensive copy of DhcpResultsErik Kline2015-06-021-6/+7
| | | | | | | | | | | | | | Also: correct state transition handling in DhcpBoundState#enter(). Bug: 20451261 Change-Id: I3be50f6b1b3fae179d6fff7ca8ae1d687caa3221
* | Specify more information in DhcpClient PendingIntents.Lorenzo Colitti2015-05-261-4/+5
|/ | | | | | | | | | | - Specify the package name. This provides a bit of security, but not much since the package is "android". - Specify the interface name so we can run more than one client at a time. Bug: 21395858 Bug: 19704592 Change-Id: I91c9ea15285b36628b6aef0b975c16a0b08d061e
* Merge commit '4cb5d80' into merge2Etan Cohen2015-04-249-36/+50
|\
| * Set the secs field in the BOOTP header.Lorenzo Colitti2015-04-219-36/+50
| | | | | | | | | | | | | | | | | | | | | | 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
| * Deal with null characters in string options.Lorenzo Colitti2015-04-011-6/+18
| | | | | | | | | | | | | | | | This currently truncates all strings at the first NULL character, except for vendorInfo, which is an opaque string. Bug: 19985674 Change-Id: Ie53b2c55eb8a5204d7b2c7e2d8587743d923647a
* | Always send the DHCP client identifier.Lorenzo Colitti2015-04-225-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Log DHCP replies that we can't parse.Lorenzo Colitti2015-04-221-0/+4
| | | | | | | | | | | | Bug: 19704592 Bug: 20335221 Change-Id: I73def02a08345bd96f45cb970f9f251e6d5df2db
* | Merge commit 'b2ff415' into merge_workPrerepa Viswanadham2015-04-101-2/+4
|\ \ | |/ | | | | Change-Id: I4f9c662112fc49e4f94315d3c69860607be3bc1e
| * Don't log errors if the receive thread is stopped.Lorenzo Colitti2015-03-311-2/+4
| | | | | | | | Change-Id: I75ddc9b68f0a61a9a7a78026ed97a8a7c5109cc3
| * DHCP: Don't write options longer than 255 bytes.Lorenzo Colitti2015-03-171-14/+23
| | | | | | | | Change-Id: Iddc971c7ac97253af3063850cde3dee10c3829ff
| * DHCP: parsing robustness fixes.Lorenzo Colitti2015-03-171-105/+123
| | | | | | | | | | | | | | 1. Check the length of the fixed-length portions of the packet. 2. Catch BufferUnderflowException while parsing options. Change-Id: If907f49f02a04a4a3360f46a3192e94ab099af0e
| * DHCP: Add a Java DHCP client.Lorenzo Colitti2015-03-171-0/+807
| | | | | | | | | | | | | | | | | | 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
| * DHCP: protocol changes.Lorenzo Colitti2015-03-173-18/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * DHCP: glue code.Lorenzo Colitti2015-03-161-3/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * DHCP: Ethernet/IP packet header changes.Lorenzo Colitti2015-03-161-7/+31
| | | | | | | | | | | | | | | | 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
| * DHCP: Minor cleanups to the packet code.Lorenzo Colitti2015-03-169-234/+83
| | | | | | | | | | | | | | | | | | | | | | 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
| * DHCP: Move the packet code to frameworks/base/services.Lorenzo Colitti2015-03-1610-0/+1559
| | | | | | | | 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
* Deal with null characters in string options.Lorenzo Colitti2015-04-011-6/+18
| | | | | | | | This currently truncates all strings at the first NULL character, except for vendorInfo, which is an opaque string. Bug: 19985674 Change-Id: Ie53b2c55eb8a5204d7b2c7e2d8587743d923647a
* DHCP: Don't write options longer than 255 bytes.Lorenzo Colitti2015-03-201-14/+23
| | | | Change-Id: Iddc971c7ac97253af3063850cde3dee10c3829ff
* DHCP: parsing robustness fixes.Lorenzo Colitti2015-03-201-105/+123
| | | | | | | 1. Check the length of the fixed-length portions of the packet. 2. Catch BufferUnderflowException while parsing options. Change-Id: If907f49f02a04a4a3360f46a3192e94ab099af0e
* DHCP: Add a Java DHCP client.Lorenzo Colitti2015-03-201-0/+807
| | | | | | | | | 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
* DHCP: protocol changes.Lorenzo Colitti2015-03-203-18/+91
| | | | | | | | | | | | | | 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
* DHCP: glue code.Lorenzo Colitti2015-03-201-3/+58
| | | | | | | | | | | | | 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
* DHCP: Ethernet/IP packet header changes.Lorenzo Colitti2015-03-201-7/+31
| | | | | | | | 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
* DHCP: Minor cleanups to the packet code.Lorenzo Colitti2015-03-209-234/+83
| | | | | | | | | | | 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
* DHCP: Move the packet code to frameworks/base/services.Lorenzo Colitti2015-03-2010-0/+1559
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