summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-13 13:12:13 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-13 13:12:29 +0100
commit7bcd3863382c4151e322a01a8ba573817879bd42 (patch)
treee3207ca3a695c2c10bee97578c2fe5501f3a6a2e
parent60db082fdd8f72bb68923d3f407f2968acb3d358 (diff)
downloadserenity-7bcd3863382c4151e322a01a8ba573817879bd42.zip
NetworkAdapter: Use a ByteBuffer instead of kmalloc/kfree in send().
-rw-r--r--Kernel/NetworkAdapter.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Kernel/NetworkAdapter.cpp b/Kernel/NetworkAdapter.cpp
index 663614d111..001d32b59c 100644
--- a/Kernel/NetworkAdapter.cpp
+++ b/Kernel/NetworkAdapter.cpp
@@ -41,13 +41,13 @@ NetworkAdapter::~NetworkAdapter()
void NetworkAdapter::send(const MACAddress& destination, const ARPPacket& packet)
{
int size_in_bytes = sizeof(EthernetFrameHeader) + sizeof(ARPPacket);
- auto* eth = (EthernetFrameHeader*)kmalloc(size_in_bytes);
+ auto buffer = ByteBuffer::create_zeroed(size_in_bytes);
+ auto* eth = (EthernetFrameHeader*)buffer.pointer();
eth->set_source(mac_address());
eth->set_destination(destination);
eth->set_ether_type(EtherType::ARP);
memcpy(eth->payload(), &packet, sizeof(ARPPacket));
send_raw((byte*)eth, size_in_bytes);
- kfree(eth);
}
void NetworkAdapter::send_ipv4(const MACAddress& destination_mac, const IPv4Address& destination_ipv4, IPv4Protocol protocol, ByteBuffer&& payload)