summaryrefslogtreecommitdiff
path: root/Kernel/Net
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-10-31 11:32:33 +0100
committerAndreas Kling <kling@serenityos.org>2020-10-31 13:56:21 +0100
commite06d8d94dad9ab34910f69cc406791e4958b21af (patch)
tree69f4a22dfccb2eaadddb3f990adede4269cf7574 /Kernel/Net
parent982e066100c187a7565c43103572a987ae3766bc (diff)
downloadserenity-e06d8d94dad9ab34910f69cc406791e4958b21af.zip
IPv4: Include IP headers when receiving from a raw socket
We were stripping the L3 headers from packets received on raw sockets. This didn't match what other systems do, so let's adjust our behavior. Thanks to @SpencerCDixon for noticing this! :^)
Diffstat (limited to 'Kernel/Net')
-rw-r--r--Kernel/Net/IPv4Socket.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index 98d400456e..a6011acc71 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -331,7 +331,6 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
#endif
}
ASSERT(packet.data.has_value());
- auto& ipv4_packet = *(const IPv4Packet*)(packet.data.value().data());
packet_timestamp = packet.timestamp;
@@ -355,8 +354,8 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
}
if (type() == SOCK_RAW) {
- size_t bytes_written = min((size_t)ipv4_packet.payload_size(), buffer_length);
- if (!buffer.write(ipv4_packet.payload(), bytes_written))
+ size_t bytes_written = min(packet.data.value().size(), buffer_length);
+ if (!buffer.write(packet.data.value().data(), bytes_written))
return KResult(-EFAULT);
return bytes_written;
}