summaryrefslogtreecommitdiff
path: root/Userland/Services/DHCPClient/DHCPv4Client.cpp
AgeCommit message (Collapse)Author
2023-02-13LibCore: Rename `File` to `DeprecatedFile`Tim Schumacher
As usual, this removes many unused includes and moves used includes further down the chain.
2023-01-27Services: Replace uses of JsonObject::get_deprecated()/get_ptr()Sam Atkins
2023-01-17AK+Everywhere: Rename JsonObject::get() to ::get_deprecated()Sam Atkins
This is a preparatory step to making `get()` return `ErrorOr`.
2023-01-12LibCore+Userland: Make Core::Timer::create_single_shot() return ErrorOrSam Atkins
clang-format sure has some interesting opinions about where to put a method call that comes after a lambda. :thonk:
2023-01-12LibCore+Userland: Make Core::Timer::create_repeating() return ErrorOrSam Atkins
The FIXMEs must flow!
2022-12-20LibCore: Make UDPServer::receive() return ErrorOr<ByteBuffer>Alexander Narsudinov
This is a first step towards handling OOM errors instead of just crashing the program. Now UDPServer's method `receive()` return memory allocation errors explicitly with help of ErrorOr. This removes one FIXME and make a bunch of new ones. :(
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-10-25Services: Use new global variables at /sys/kernel/ directoryLiav A
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-07-12Everywhere: Split Error::from_string_literal and Error::from_string_viewsin-ack
Error::from_string_literal now takes direct char const*s, while Error::from_string_view does what Error::from_string_literal used to do: taking StringViews. This change will remove the need to insert `sv` after error strings when returning string literal errors once StringView(char const*) is removed. No functional changes.
2022-05-31DHCPClient: Don't reset the interface if its already configuredTim Schumacher
Resetting the interface just based on the fact that it already has an IP assigned doesn't make much sense, considering that we frequently end up here after having configured an interface via DHCP already. Instead, just keep the part that prevents us from sending DHCP discoveries to interfaces that shouldn't be using DHCP. While we are at it, place some of the logging behind a debug flag, as this function is apparently meant to be run frequently. This partially reverts commit e14d4482a18f250787cbf64bae596de1f7278d8d.
2022-05-26DHCPClient: Don't discover interfaces other than given by defaultMaciej
Now, the caller needs to give interface names in command-line arguments. The DHCPClient will perform DHCP discovery only on these adapters. The service now immediately closes when no interfaces were given. We don't check if interface has already IP address assigned; we just reset it to zero so that DHCP resolution will not fail.
2022-05-03DHCPClient: Don't crash if DHCP options contain no gatewayPatrick Meyer
Fixes #13879
2022-04-17DHCPClient: Send ParameterRequestList option with DHCPRequest packetThitat Auareesuksakul
We'll need SubnetMask and Router options to be returned with the ACK packet. So, it's a good idea to request them explicitly in this packet.
2022-04-17DHCPClient: Send ServerIdentifier option with DHCPRequest packetThitat Auareesuksakul
Some DHCP servers (including Mikrotik ones) will NAK the request if the ServerIdentifier option is not sent with the DHCPRequest packet.
2022-04-11DHCPClient: Close outgoing sockets after useTim Schumacher
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-24Services: Use default constructors/destructorsLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2021-12-05DHCP4Client: Cast unused Timer return values to voidSam Atkins
Timers attach themselves to the provided parent, so they are safely kept alive.
2021-11-17AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)Andreas Kling
Also add slightly richer parse errors now that we can include a string literal with returned errors. This will allow us to use TRY() when working with JSON data.
2021-11-08DHCPClient: Replace Result<T, E> use with ErrorOr<T>Andreas Kling
2021-05-27DHCPClient: Rename struct members for InterfaceDescriptorGunnar Beutner
Public members shouldn't have an "m_" prefix.
2021-05-27DHCPClient: Remove unused #includesGunnar Beutner
2021-05-27DHCPClient: Resend DHCP packets when we don't receive an answerGunnar Beutner
Previously we'd only only send one DHCP request for network interfaces which were up when DHCPClient started. If that packet was lost we'd never send another request for those interfaces. Also, if an interface were to appear after DHCPClient started (not that that is possible at the moment) we wouldn't send requests for that interface either.
2021-05-12LibCore+Everywhere: Move OpenMode out of IODeviceAli Mohammad Pur
...and make it an enum class so people don't omit "OpenMode".
2021-05-06DHCPClient: Handle invalid DHCP responses more gracefullyGunnar Beutner
2021-04-29Everywhere: Use "the SerenityOS developers." in copyright headersLinus Groh
We had some inconsistencies before: - Sometimes "The", sometimes "the" - Sometimes trailing ".", sometimes no trailing "." I picked the most common one (lowecase "the", trailing ".") and applied it to all copyright headers. By using the exact same string everywhere we can ensure nothing gets missed during a global search (and replace), and that these inconsistencies are not spread any further (as copyright headers are commonly copied to new files).
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-06DHCPClient: Retry DISCOVER for interfaces that failAnotherTest
Attempts are spaced out with exponential backoff, cut at 10 minutes per attempt. Also avoid trying to acquire an IP on interfaces that aren't up. Fixes #6126. Fixes #6125.
2021-04-04DHCPClient: Store current IP address instead of relaying on the yiaddrIdan Horowitz
Real DHCP servers might decide to send the DHCPAck directly to the specified ciaddr instead of as a unicast or multicast, resulting in the ack being ignored by the network adapter when we are requesting a new IPv4 address instead of renewing an existing lease, as the yiaddr (and as a result the ciaddr) is set to the offered address in that case instead of the current ip address.
2021-04-04DHCPClient: Dont set DHCPOption::ServerIdentifier on DHCPRequestIdan Horowitz
Some real DHCP servers dont set the siaddr field in the DHCPOffer to their IPv4 (and instead leave it blank - 0.0.0.0), which results in the server assuming the DHCPRequest is not directed at him when it has the ServerIdentifier option attached that specifies 0.0.0.0 as the targeted server. So instead we just omit the option and let the DHCP servers decipher the target themselves based on the requested IP.
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-21DHCPClient: Actually randomize transaction ID's (XID)Andreas Kling
We were using unseeded rand() for the XID, which meant that our DHCP XID's were 100% predictable. Switch to using AK::get_random<u32>() instead. :^)
2021-02-21DHCPClient: Silence a debug messageAndreas Kling
2021-02-17DHCPClient: Set ServerIdentifier and RequestedAddress in DHCP REQUESTsAnotherTest
Some dhcp servers require these to be there - otherwise, the ack gets dropped somewhere.
2021-02-17DHCPClient: Set the client IP field of the DHCP DISCOVER messageAnotherTest
This is the field that tells the DHCP server which IP we want, not setting it is quite silly :P
2021-02-17DHCPClient: Don't reject packets smaller than the max sizeAnotherTest
It's acceptable to have less padding in a packet, the only requirement is to have a single byte of 'END' in the DHCP fields.
2021-02-08Everywhere: Replace dbgln<flag>(...) with dbgln_if(flag, ...)AnotherTest
Replacement made by `find Kernel Userland -name '*.h' -o -name '*.cpp' | sed -i -Ee 's/dbgln\b<(\w+)>\(/dbgln_if(\1, /g'`
2021-01-25Everywhere: Debug macros instead of constexpr.asynts
This was done with the following script: find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/dbgln<debug_([a-z_]+)>/dbgln<\U\1_DEBUG>/' {} \; find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/if constexpr \(debug_([a-z0-9_]+)/if constexpr \(\U\1_DEBUG/' {} \;
2021-01-22Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
2021-01-12Services: Move to Userland/Services/Andreas Kling