mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
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! :^)
This commit is contained in:
parent
982e066100
commit
e06d8d94da
Notes:
sideshowbarker
2024-07-19 01:37:19 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e06d8d94dad
1 changed files with 2 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue