From c949a4db2dbde23bcc30d69ebcd6c7de2b1a23ac Mon Sep 17 00:00:00 2001 From: Thitat Auareesuksakul Date: Fri, 15 Apr 2022 01:11:27 +0700 Subject: [PATCH] DHCPClient: Send ParameterRequestList option with DHCPRequest packet We'll need SubnetMask and Router options to be returned with the ACK packet. So, it's a good idea to request them explicitly in this packet. --- Userland/Services/DHCPClient/DHCPv4Client.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Userland/Services/DHCPClient/DHCPv4Client.cpp b/Userland/Services/DHCPClient/DHCPv4Client.cpp index 6c64386983..c579663fde 100644 --- a/Userland/Services/DHCPClient/DHCPv4Client.cpp +++ b/Userland/Services/DHCPClient/DHCPv4Client.cpp @@ -5,6 +5,7 @@ */ #include "DHCPv4Client.h" +#include #include #include #include @@ -366,6 +367,12 @@ void DHCPv4Client::dhcp_request(DHCPv4Transaction& transaction, DHCPv4Packet con if (maybe_dhcp_server_ip.has_value()) builder.add_option(DHCPOption::ServerIdentifier, sizeof(IPv4Address), &maybe_dhcp_server_ip.value()); + AK::Array parameter_request_list = { + DHCPOption::SubnetMask, + DHCPOption::Router, + }; + builder.add_option(DHCPOption::ParameterRequestList, parameter_request_list.size(), ¶meter_request_list); + auto& dhcp_packet = builder.build(); // broadcast the "request" request