1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-21 23:15:08 +00:00
serenity/Userland/Services/DHCPClient/DHCPv4.cpp
Linus Groh 649d2faeab Everywhere: Use "the SerenityOS developers." in copyright headers
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-29 00:59:26 +02:00

36 lines
1 KiB
C++

/*
* Copyright (c) 2020, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "DHCPv4.h"
#include <AK/Debug.h>
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];
switch (opt_name) {
case DHCPOption::Pad:
continue;
case DHCPOption::End:
goto escape;
default:
++index;
auto length = m_options[index];
if ((size_t)length > DHCPV4_OPTION_FIELD_MAX_LENGTH - index) {
dbgln("Bogus option length {} assuming forgotten END", length);
break;
}
dbgln_if(DHCPV4_DEBUG, "DHCP Option {} with length {}", (u8)opt_name, length);
++index;
options.options.set(opt_name, { length, &m_options[index] });
index += length - 1;
break;
}
}
escape:;
return options;
}