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

Skip to content
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
7DD3
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