diff --git a/repos/os/src/server/nic_router/interface.cc b/repos/os/src/server/nic_router/interface.cc index e6c69218c9..6f1427dad9 100644 --- a/repos/os/src/server/nic_router/interface.cc +++ b/repos/os/src/server/nic_router/interface.cc @@ -451,6 +451,7 @@ void Interface::_nat_link_and_pass(Ethernet_frame ð, void Interface::_send_dhcp_reply(Dhcp_server const &dhcp_srv, + Mac_address const ð_dst, Mac_address const &client_mac, Ipv4_address const &client_ip, Dhcp_packet::Message_type msg_type, @@ -462,7 +463,10 @@ void Interface::_send_dhcp_reply(Dhcp_server const &dhcp_srv, /* create ETH header of the reply */ Ethernet_frame ð = Ethernet_frame::construct_at(pkt_base, size_guard); - eth.dst(client_mac); + if (msg_type == Dhcp_packet::Message_type::OFFER) { + eth.dst(Ethernet_frame::broadcast()); } + else { + eth.dst(eth_dst); } eth.src(_router_mac); eth.type(Ethernet_frame::Type::IPV4); @@ -543,7 +547,7 @@ void Interface::_new_dhcp_allocation(Ethernet_frame ð, log("Offer DHCP allocation: ", allocation, " at ", local_domain); } - _send_dhcp_reply(dhcp_srv, eth.src(), + _send_dhcp_reply(dhcp_srv, eth.src(), dhcp.client_mac(), allocation.ip(), Dhcp_packet::Message_type::OFFER, dhcp.xid(), @@ -584,7 +588,7 @@ void Interface::_handle_dhcp_request(Ethernet_frame ð, } else { allocation.lifetime(_config().dhcp_offer_timeout()); - _send_dhcp_reply(dhcp_srv, eth.src(), + _send_dhcp_reply(dhcp_srv, eth.src(), dhcp.client_mac(), allocation.ip(), Dhcp_packet::Message_type::OFFER, dhcp.xid(), local_intf); @@ -594,7 +598,7 @@ void Interface::_handle_dhcp_request(Ethernet_frame ð, if (allocation.bound()) { allocation.lifetime(dhcp_srv.ip_lease_time()); - _send_dhcp_reply(dhcp_srv, eth.src(), + _send_dhcp_reply(dhcp_srv, eth.src(), dhcp.client_mac(), allocation.ip(), Dhcp_packet::Message_type::ACK, dhcp.xid(), local_intf); @@ -612,7 +616,7 @@ void Interface::_handle_dhcp_request(Ethernet_frame ð, log("Bind DHCP allocation: ", allocation, " at ", local_domain); } - _send_dhcp_reply(dhcp_srv, eth.src(), + _send_dhcp_reply(dhcp_srv, eth.src(), dhcp.client_mac(), allocation.ip(), Dhcp_packet::Message_type::ACK, dhcp.xid(), local_intf); @@ -627,7 +631,7 @@ void Interface::_handle_dhcp_request(Ethernet_frame ð, } case Dhcp_packet::Message_type::INFORM: - _send_dhcp_reply(dhcp_srv, eth.src(), + _send_dhcp_reply(dhcp_srv, eth.src(), dhcp.client_mac(), allocation.ip(), Dhcp_packet::Message_type::ACK, dhcp.xid(), local_intf); diff --git a/repos/os/src/server/nic_router/interface.h b/repos/os/src/server/nic_router/interface.h index 506829ae3a..0aa91543de 100644 --- a/repos/os/src/server/nic_router/interface.h +++ b/repos/os/src/server/nic_router/interface.h @@ -120,6 +120,7 @@ class Net::Interface : private Interface_list::Element Domain &local_domain); void _send_dhcp_reply(Dhcp_server const &dhcp_srv, + Mac_address const ð_dst, Mac_address const &client_mac, Ipv4_address const &client_ip, Dhcp_packet::Message_type msg_type,