mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 13:45:06 +00:00
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.
This commit is contained in:
parent
8e79bde2b7
commit
8cc81c2953
6 changed files with 10 additions and 10 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue