8000 DHCP custom option by mcspr · Pull Request #8582 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

DHCP custom option #8582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jun 8, 2022
Merged
Prev Previous commit
Next Next commit
might as well keep using initlist
/to d-a-v it has automatic storage, here it's the same stack based one
(just one less line for us)
  • Loading branch information
mcspr committed May 31, 2022
commit 76a0f7ef79d813c17bbd51994c07d18801ffdaaf
17 changes: 7 additions & 10 deletions cores/esp8266/LwipDhcpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,21 @@ class DhcpServer

OptionsBuffer& add(uint8_t code, uint8_t value)
{
uint8_t buffer[] { value };
return add(code, buffer, sizeof(buffer));
return add(code, { value });
}

OptionsBuffer& add(uint8_t code, uint16_t value)
{
uint8_t buffer[2] { static_cast<uint8_t>((value >> 8) & 0xff),
static_cast<uint8_t>(value & 0xff) };
return add(code, buffer, sizeof(buffer));
return add(code, { static_cast<uint8_t>((value >> 8) & 0xff),
static_cast<uint8_t>(value & 0xff) });
}

OptionsBuffer& add(uint8_t code, uint32_t value)
{
uint8_t buffer[4] { static_cast<uint8_t>((value >> 24) & 0xff),
static_cast<uint8_t>((value >> 16) & 0xff),
static_cast<uint8_t>((value >> 8) & 0xff),
static_cast<uint8_t>((value & 0xff)) };
return add(code, buffer, sizeof(buffer));
return add(code, { static_cast<uint8_t>((value >> 24) & 0xff),
static_cast<uint8_t>((value >> 16) & 0xff),
static_cast<uint8_t>((value >> 8) & 0xff),
static_cast<uint8_t>((value & 0xff)) });
}

OptionsBuffer& add(uint8_t code)
Expand Down
0