summaryrefslogtreecommitdiff
path: root/Kernel/Net/NetworkAdapter.cpp
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-05-15 22:45:22 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-16 17:49:42 +0200
commit006f11f23d75a751351a0c18a903e169c6a4d492 (patch)
tree7295058f16da14559f03e7a5eb2d0126edf50f89 /Kernel/Net/NetworkAdapter.cpp
parent53d015082749b9bf43a2160d5553bc0e9e1086ef (diff)
downloadserenity-006f11f23d75a751351a0c18a903e169c6a4d492.zip
Kernel: Avoid allocations when handling network packets
Diffstat (limited to 'Kernel/Net/NetworkAdapter.cpp')
-rw-r--r--Kernel/Net/NetworkAdapter.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Kernel/Net/NetworkAdapter.cpp b/Kernel/Net/NetworkAdapter.cpp
index e050fcc581..e1b3a999a4 100644
--- a/Kernel/Net/NetworkAdapter.cpp
+++ b/Kernel/Net/NetworkAdapter.cpp
@@ -65,7 +65,7 @@ NetworkAdapter::~NetworkAdapter()
void NetworkAdapter::send(const MACAddress& destination, const ARPPacket& packet)
{
size_t size_in_bytes = sizeof(EthernetFrameHeader) + sizeof(ARPPacket);
- auto buffer = ByteBuffer::create_zeroed(size_in_bytes);
+ auto buffer = NetworkByteBuffer::create_zeroed(size_in_bytes);
auto* eth = (EthernetFrameHeader*)buffer.data();
eth->set_source(mac_address());
eth->set_destination(destination);
@@ -83,7 +83,7 @@ KResult NetworkAdapter::send_ipv4(const IPv4Address& source_ipv4, const MACAddre
return send_ipv4_fragmented(source_ipv4, destination_mac, destination_ipv4, protocol, payload, payload_size, ttl);
size_t ethernet_frame_size = sizeof(EthernetFrameHeader) + sizeof(IPv4Packet) + payload_size;
- auto buffer = ByteBuffer::create_zeroed(ethernet_frame_size);
+ auto buffer = NetworkByteBuffer::create_zeroed(ethernet_frame_size);
auto& eth = *(EthernetFrameHeader*)buffer.data();
eth.set_source(mac_address());
eth.set_destination(destination_mac);
@@ -121,7 +121,7 @@ KResult NetworkAdapter::send_ipv4_fragmented(const IPv4Address& source_ipv4, con
for (size_t packet_index = 0; packet_index < fragment_block_count; ++packet_index) {
auto is_last_block = packet_index + 1 == fragment_block_count;
auto packet_payload_size = is_last_block ? last_block_size : packet_boundary_size;
- auto buffer = ByteBuffer::create_zeroed(ethernet_frame_size);
+ auto buffer = NetworkByteBuffer::create_zeroed(ethernet_frame_size);
auto& eth = *(EthernetFrameHeader*)buffer.data();
eth.set_source(mac_address());
eth.set_destination(destination_mac);