diff options
author | Thitat Auareesuksakul <thitat@flux.ci> | 2022-04-15 00:48:43 +0700 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-04-17 10:25:01 +0430 |
commit | 01a602cb5198b06e95925195e3bc4e61aaeff6e2 (patch) | |
tree | 0affa7fd76cc84f829d32cb1db9c8bb2a2875ebc /Userland | |
parent | fa18c283dc4fbbf27f82caa97fc90156c521099e (diff) | |
download | serenity-01a602cb5198b06e95925195e3bc4e61aaeff6e2.zip |
DHCPClient: Send ServerIdentifier option with DHCPRequest packet
Some DHCP servers (including Mikrotik ones) will NAK the request if the
ServerIdentifier option is not sent with the DHCPRequest packet.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Services/DHCPClient/DHCPv4Client.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Services/DHCPClient/DHCPv4Client.cpp b/Userland/Services/DHCPClient/DHCPv4Client.cpp index 5b366db8dc..6c64386983 100644 --- a/Userland/Services/DHCPClient/DHCPv4Client.cpp +++ b/Userland/Services/DHCPClient/DHCPv4Client.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, the SerenityOS developers. + * Copyright (c) 2020-2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -361,6 +361,11 @@ void DHCPv4Client::dhcp_request(DHCPv4Transaction& transaction, DHCPv4Packet con // set packet options builder.set_message_type(DHCPMessageType::DHCPRequest); builder.add_option(DHCPOption::RequestedIPAddress, sizeof(IPv4Address), &offer.yiaddr()); + + auto maybe_dhcp_server_ip = offer.parse_options().get<IPv4Address>(DHCPOption::ServerIdentifier); + if (maybe_dhcp_server_ip.has_value()) + builder.add_option(DHCPOption::ServerIdentifier, sizeof(IPv4Address), &maybe_dhcp_server_ip.value()); + auto& dhcp_packet = builder.build(); // broadcast the "request" request |