From d6d0bcd960540e7a113f33e703a03962568227f0 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 18 Dec 2017 14:54:02 +0100 Subject: [PATCH] nic_router: no Arp_packet constructor when sending When composing an ARP packet for sending, it's pointless to use the Arp_packet constructor as the constructor only checks whether the packet is malformed. Issue #2618 --- repos/os/src/server/nic_router/interface.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/repos/os/src/server/nic_router/interface.cc b/repos/os/src/server/nic_router/interface.cc index c028eee54c..83cc6ba234 100644 --- a/repos/os/src/server/nic_router/interface.cc +++ b/repos/os/src/server/nic_router/interface.cc @@ -675,11 +675,9 @@ void Interface::_handle_ip(Ethernet_frame ð, void Interface::_broadcast_arp_request(Ipv4_address const &ip) { - using Ethernet_arp = Ethernet_frame_sized; - Ethernet_arp eth_arp(Mac_address(0xff), _router_mac, Ethernet_frame::Type::ARP); - void *const eth_data = eth_arp.data(); - size_t const arp_size = sizeof(eth_arp) - sizeof(Ethernet_frame); - Arp_packet &arp = *new (eth_data) Arp_packet(arp_size); + Ethernet_frame_sized + eth(Mac_address(0xff), _router_mac, Ethernet_frame::Type::ARP); + Arp_packet &arp = *eth.data(); arp.hardware_address_type(Arp_packet::ETHERNET); arp.protocol_address_type(Arp_packet::IPV4); arp.hardware_address_size(sizeof(Mac_address)); @@ -689,7 +687,7 @@ void Interface::_broadcast_arp_request(Ipv4_address const &ip) arp.src_ip(_router_ip()); arp.dst_mac(Mac_address(0xff)); arp.dst_ip(ip); - send(eth_arp, sizeof(eth_arp)); + send(eth, sizeof(eth)); }