From 01a602cb5198b06e95925195e3bc4e61aaeff6e2 Mon Sep 17 00:00:00 2001 From: Thitat Auareesuksakul Date: Fri, 15 Apr 2022 00:48:43 +0700 Subject: [PATCH] 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. --- Userland/Services/DHCPClient/DHCPv4Client.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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(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