mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:57:35 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
0376c127f6
commit
086969277e
1665 changed files with 8479 additions and 8479 deletions
|
@ -11,7 +11,7 @@ ParsedDHCPv4Options DHCPv4Packet::parse_options() const
|
|||
{
|
||||
ParsedDHCPv4Options options;
|
||||
for (size_t index = 4; index < DHCPV4_OPTION_FIELD_MAX_LENGTH; ++index) {
|
||||
auto opt_name = *(const DHCPOption*)&m_options[index];
|
||||
auto opt_name = *(DHCPOption const*)&m_options[index];
|
||||
switch (opt_name) {
|
||||
case DHCPOption::Pad:
|
||||
continue;
|
||||
|
|
|
@ -159,7 +159,7 @@ struct ParsedDHCPv4Options {
|
|||
for (auto& opt : options) {
|
||||
builder.appendff("\toption {} ({} bytes):", (u8)opt.key, (u8)opt.value.length);
|
||||
for (auto i = 0; i < opt.value.length; ++i)
|
||||
builder.appendff(" {} ", ((const u8*)opt.value.value)[i]);
|
||||
builder.appendff(" {} ", ((u8 const*)opt.value.value)[i]);
|
||||
builder.append('\n');
|
||||
}
|
||||
return builder.build();
|
||||
|
@ -167,7 +167,7 @@ struct ParsedDHCPv4Options {
|
|||
|
||||
struct DHCPOptionValue {
|
||||
u8 length;
|
||||
const void* value;
|
||||
void const* value;
|
||||
};
|
||||
|
||||
HashMap<DHCPOption, DHCPOptionValue> options;
|
||||
|
@ -198,10 +198,10 @@ public:
|
|||
u16 flags() const { return m_flags; }
|
||||
void set_flags(DHCPv4Flags flags) { m_flags = (u16)flags; }
|
||||
|
||||
const IPv4Address& ciaddr() const { return m_ciaddr; }
|
||||
const IPv4Address& yiaddr() const { return m_yiaddr; }
|
||||
const IPv4Address& siaddr() const { return m_siaddr; }
|
||||
const IPv4Address& giaddr() const { return m_giaddr; }
|
||||
IPv4Address const& ciaddr() const { return m_ciaddr; }
|
||||
IPv4Address const& yiaddr() const { return m_yiaddr; }
|
||||
IPv4Address const& siaddr() const { return m_siaddr; }
|
||||
IPv4Address const& giaddr() const { return m_giaddr; }
|
||||
|
||||
IPv4Address& ciaddr() { return m_ciaddr; }
|
||||
IPv4Address& yiaddr() { return m_yiaddr; }
|
||||
|
@ -211,11 +211,11 @@ public:
|
|||
u8* options() { return m_options; }
|
||||
ParsedDHCPv4Options parse_options() const;
|
||||
|
||||
const MACAddress& chaddr() const { return *(const MACAddress*)&m_chaddr[0]; }
|
||||
void set_chaddr(const MACAddress& mac) { *(MACAddress*)&m_chaddr[0] = mac; }
|
||||
MACAddress const& chaddr() const { return *(MACAddress const*)&m_chaddr[0]; }
|
||||
void set_chaddr(MACAddress const& mac) { *(MACAddress*)&m_chaddr[0] = mac; }
|
||||
|
||||
StringView sname() const { return { (const char*)&m_sname[0] }; }
|
||||
StringView file() const { return { (const char*)&m_file[0] }; }
|
||||
StringView sname() const { return { (char const*)&m_sname[0] }; }
|
||||
StringView file() const { return { (char const*)&m_file[0] }; }
|
||||
|
||||
private:
|
||||
NetworkOrdered<u8> m_op;
|
||||
|
@ -247,7 +247,7 @@ public:
|
|||
options[3] = 99;
|
||||
}
|
||||
|
||||
void add_option(DHCPOption option, u8 length, const void* data)
|
||||
void add_option(DHCPOption option, u8 length, void const* data)
|
||||
{
|
||||
VERIFY(m_can_add);
|
||||
// we need enough space to fit the option value, its length, and its data
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
#include <LibCore/Timer.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static u8 mac_part(const Vector<String>& parts, size_t index)
|
||||
static u8 mac_part(Vector<String> const& parts, size_t index)
|
||||
{
|
||||
auto result = AK::StringUtils::convert_to_uint_from_hex(parts.at(index));
|
||||
VERIFY(result.has_value());
|
||||
return result.value();
|
||||
}
|
||||
|
||||
static MACAddress mac_from_string(const String& str)
|
||||
static MACAddress mac_from_string(String const& str)
|
||||
{
|
||||
auto chunks = str.split(':');
|
||||
VERIFY(chunks.size() == 6); // should we...worry about this?
|
||||
|
@ -32,7 +32,7 @@ static MACAddress mac_from_string(const String& str)
|
|||
};
|
||||
}
|
||||
|
||||
static bool send(const InterfaceDescriptor& iface, const DHCPv4Packet& packet, Core::Object*)
|
||||
static bool send(InterfaceDescriptor const& iface, DHCPv4Packet const& packet, Core::Object*)
|
||||
{
|
||||
int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (fd < 0) {
|
||||
|
@ -63,7 +63,7 @@ static bool send(const InterfaceDescriptor& iface, const DHCPv4Packet& packet, C
|
|||
return true;
|
||||
}
|
||||
|
||||
static void set_params(const InterfaceDescriptor& iface, const IPv4Address& ipv4_addr, const IPv4Address& netmask, const IPv4Address& gateway)
|
||||
static void set_params(InterfaceDescriptor const& iface, IPv4Address const& ipv4_addr, IPv4Address const& netmask, IPv4Address const& gateway)
|
||||
{
|
||||
int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
|
||||
if (fd < 0) {
|
||||
|
@ -201,7 +201,7 @@ ErrorOr<DHCPv4Client::Interfaces> DHCPv4Client::get_discoverable_interfaces()
|
|||
};
|
||||
}
|
||||
|
||||
void DHCPv4Client::handle_offer(const DHCPv4Packet& packet, const ParsedDHCPv4Options& options)
|
||||
void DHCPv4Client::handle_offer(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options)
|
||||
{
|
||||
dbgln("We were offered {} for {}", packet.yiaddr().to_string(), options.get<u32>(DHCPOption::IPAddressLeaseTime).value_or(0));
|
||||
auto* transaction = const_cast<DHCPv4Transaction*>(m_ongoing_transactions.get(packet.xid()).value_or(nullptr));
|
||||
|
@ -221,7 +221,7 @@ void DHCPv4Client::handle_offer(const DHCPv4Packet& packet, const ParsedDHCPv4Op
|
|||
dhcp_request(*transaction, packet);
|
||||
}
|
||||
|
||||
void DHCPv4Client::handle_ack(const DHCPv4Packet& packet, const ParsedDHCPv4Options& options)
|
||||
void DHCPv4Client::handle_ack(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options)
|
||||
{
|
||||
if constexpr (DHCPV4CLIENT_DEBUG) {
|
||||
dbgln("The DHCP server handed us {}", packet.yiaddr().to_string());
|
||||
|
@ -250,7 +250,7 @@ void DHCPv4Client::handle_ack(const DHCPv4Packet& packet, const ParsedDHCPv4Opti
|
|||
set_params(transaction->interface, new_ip, options.get<IPv4Address>(DHCPOption::SubnetMask).value(), options.get_many<IPv4Address>(DHCPOption::Router, 1).first());
|
||||
}
|
||||
|
||||
void DHCPv4Client::handle_nak(const DHCPv4Packet& packet, const ParsedDHCPv4Options& options)
|
||||
void DHCPv4Client::handle_nak(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options)
|
||||
{
|
||||
dbgln("The DHCP server told us to go chase our own tail about {}", packet.yiaddr().to_string());
|
||||
dbgln("Here are the options: {}", options.to_string());
|
||||
|
@ -271,7 +271,7 @@ void DHCPv4Client::handle_nak(const DHCPv4Packet& packet, const ParsedDHCPv4Opti
|
|||
this);
|
||||
}
|
||||
|
||||
void DHCPv4Client::process_incoming(const DHCPv4Packet& packet)
|
||||
void DHCPv4Client::process_incoming(DHCPv4Packet const& packet)
|
||||
{
|
||||
auto options = packet.parse_options();
|
||||
|
||||
|
@ -307,7 +307,7 @@ void DHCPv4Client::process_incoming(const DHCPv4Packet& packet)
|
|||
}
|
||||
}
|
||||
|
||||
void DHCPv4Client::dhcp_discover(const InterfaceDescriptor& iface)
|
||||
void DHCPv4Client::dhcp_discover(InterfaceDescriptor const& iface)
|
||||
{
|
||||
auto transaction_id = get_random<u32>();
|
||||
|
||||
|
@ -339,7 +339,7 @@ void DHCPv4Client::dhcp_discover(const InterfaceDescriptor& iface)
|
|||
m_ongoing_transactions.set(transaction_id, make<DHCPv4Transaction>(iface));
|
||||
}
|
||||
|
||||
void DHCPv4Client::dhcp_request(DHCPv4Transaction& transaction, const DHCPv4Packet& offer)
|
||||
void DHCPv4Client::dhcp_request(DHCPv4Transaction& transaction, DHCPv4Packet const& offer)
|
||||
{
|
||||
auto& iface = transaction.interface;
|
||||
dbgln("Leasing the IP {} for adapter {}", offer.yiaddr().to_string(), iface.ifname);
|
||||
|
|
|
@ -42,10 +42,10 @@ class DHCPv4Client final : public Core::Object {
|
|||
public:
|
||||
virtual ~DHCPv4Client() override = default;
|
||||
|
||||
void dhcp_discover(const InterfaceDescriptor& ifname);
|
||||
void dhcp_request(DHCPv4Transaction& transaction, const DHCPv4Packet& packet);
|
||||
void dhcp_discover(InterfaceDescriptor const& ifname);
|
||||
void dhcp_request(DHCPv4Transaction& transaction, DHCPv4Packet const& packet);
|
||||
|
||||
void process_incoming(const DHCPv4Packet& packet);
|
||||
void process_incoming(DHCPv4Packet const& packet);
|
||||
|
||||
bool id_is_registered(u32 id) { return m_ongoing_transactions.contains(id); }
|
||||
|
||||
|
@ -65,7 +65,7 @@ private:
|
|||
RefPtr<Core::Timer> m_check_timer;
|
||||
int m_max_timer_backoff_interval { 600000 }; // 10 minutes
|
||||
|
||||
void handle_offer(const DHCPv4Packet&, const ParsedDHCPv4Options&);
|
||||
void handle_ack(const DHCPv4Packet&, const ParsedDHCPv4Options&);
|
||||
void handle_nak(const DHCPv4Packet&, const ParsedDHCPv4Options&);
|
||||
void handle_offer(DHCPv4Packet const&, ParsedDHCPv4Options const&);
|
||||
void handle_ack(DHCPv4Packet const&, ParsedDHCPv4Options const&);
|
||||
void handle_nak(DHCPv4Packet const&, ParsedDHCPv4Options const&);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue