mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
AK: Add Endian.h header to replace NetworkOrdered.h.
This commit is contained in:
parent
ecf6cbbd02
commit
10c6f062b3
20 changed files with 195 additions and 106 deletions
|
@ -28,10 +28,10 @@
|
|||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Endian.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/IPv4Address.h>
|
||||
#include <AK/MACAddress.h>
|
||||
#include <AK/NetworkOrdered.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Traits.h>
|
||||
|
@ -126,14 +126,14 @@ enum class DHCPMessageType : u8 {
|
|||
DHCPRelease,
|
||||
};
|
||||
|
||||
template <>
|
||||
template<>
|
||||
struct AK::Traits<DHCPOption> : public AK::GenericTraits<DHCPOption> {
|
||||
static constexpr bool is_trivial() { return true; }
|
||||
static unsigned hash(DHCPOption u) { return int_hash((u8)u); }
|
||||
};
|
||||
|
||||
struct ParsedDHCPv4Options {
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
Optional<const T> get(DHCPOption option_name) const
|
||||
{
|
||||
auto option = options.get(option_name);
|
||||
|
@ -146,7 +146,7 @@ struct ParsedDHCPv4Options {
|
|||
return *(const T*)value.value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
Vector<T> get_many(DHCPOption option_name, size_t max_number) const
|
||||
{
|
||||
Vector<T> values;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "DHCPv4Client.h"
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Endian.h>
|
||||
#include <AK/Function.h>
|
||||
#include <LibCore/SocketAddress.h>
|
||||
#include <LibCore/Timer.h>
|
||||
|
@ -163,7 +164,7 @@ void DHCPv4Client::handle_ack(const DHCPv4Packet& packet, const ParsedDHCPv4Opti
|
|||
transaction->has_ip = true;
|
||||
auto& interface = transaction->interface;
|
||||
auto new_ip = packet.yiaddr();
|
||||
auto lease_time = convert_between_host_and_network(options.get<u32>(DHCPOption::IPAddressLeaseTime).value_or(transaction->offered_lease_time));
|
||||
auto lease_time = AK::convert_between_host_and_network_endian(options.get<u32>(DHCPOption::IPAddressLeaseTime).value_or(transaction->offered_lease_time));
|
||||
// set a timer for the duration of the lease, we shall renew if needed
|
||||
Core::Timer::create_single_shot(
|
||||
lease_time * 1000,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue