summaryrefslogtreecommitdiff
path: root/Kernel/Net/TCPSocket.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-18 16:13:23 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-18 19:22:26 +0100
commit8cc81c2953d247eaa7c13227ed5d78f471cc21b4 (patch)
treecac5120b327b69e37b09af683d72cf3017ee349a /Kernel/Net/TCPSocket.cpp
parent8e79bde2b73d18f31e4dcc1b33c61cd5ec73c83d (diff)
downloadserenity-8cc81c2953d247eaa7c13227ed5d78f471cc21b4.zip
Kernel/Net: Make IPv4Socket::protocol_receive() take a ReadonlyBytes
The overrides of this function don't need to know how the original packet was stored, so let's just give them a ReadonlyBytes view of the raw packet data.
Diffstat (limited to 'Kernel/Net/TCPSocket.cpp')
-rw-r--r--Kernel/Net/TCPSocket.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp
index 91b5252207..de8b1fff16 100644
--- a/Kernel/Net/TCPSocket.cpp
+++ b/Kernel/Net/TCPSocket.cpp
@@ -167,12 +167,12 @@ NonnullRefPtr<TCPSocket> TCPSocket::create(int protocol)
return adopt(*new TCPSocket(protocol));
}
-KResultOr<size_t> TCPSocket::protocol_receive(const KBuffer& packet_buffer, UserOrKernelBuffer& buffer, size_t buffer_size, int flags)
+KResultOr<size_t> TCPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, int flags)
{
(void)flags;
- auto& ipv4_packet = *(const IPv4Packet*)(packet_buffer.data());
+ auto& ipv4_packet = *reinterpret_cast<const IPv4Packet*>(raw_ipv4_packet.data());
auto& tcp_packet = *static_cast<const TCPPacket*>(ipv4_packet.payload());
- size_t payload_size = packet_buffer.size() - sizeof(IPv4Packet) - tcp_packet.header_size();
+ size_t payload_size = raw_ipv4_packet.size() - sizeof(IPv4Packet) - tcp_packet.header_size();
#ifdef TCP_SOCKET_DEBUG
klog() << "payload_size " << payload_size << ", will it fit in " << buffer_size << "?";
#endif