mirror of
https://github.com/RGBCube/serenity
synced 2025-05-29 13:55:07 +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
|
@ -79,10 +79,10 @@ NonnullRefPtr<UDPSocket> UDPSocket::create(int protocol)
|
|||
return adopt(*new UDPSocket(protocol));
|
||||
}
|
||||
|
||||
KResultOr<size_t> UDPSocket::protocol_receive(const KBuffer& packet_buffer, UserOrKernelBuffer& buffer, size_t buffer_size, int flags)
|
||||
KResultOr<size_t> UDPSocket::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 = *(const IPv4Packet*)(raw_ipv4_packet.data());
|
||||
auto& udp_packet = *static_cast<const UDPPacket*>(ipv4_packet.payload());
|
||||
ASSERT(udp_packet.length() >= sizeof(UDPPacket)); // FIXME: This should be rejected earlier.
|
||||
ASSERT(buffer_size >= (udp_packet.length() - sizeof(UDPPacket)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue