mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:28:10 +00:00
IPv4: Save the source address/port together with incoming packet payloads.
We need the address/port to fill in the out-params in recvfrom(). It should now be more or less possible to create a UDP server. :^)
This commit is contained in:
parent
c4bb9a3ccb
commit
780d2a08c4
6 changed files with 29 additions and 21 deletions
|
@ -54,10 +54,6 @@ int TCPSocket::protocol_receive(const ByteBuffer& packet_buffer, void* buffer, s
|
|||
size_t payload_size = packet_buffer.size() - sizeof(IPv4Packet) - tcp_packet.header_size();
|
||||
kprintf("payload_size %u, will it fit in %u?\n", payload_size, buffer_size);
|
||||
ASSERT(buffer_size >= payload_size);
|
||||
if (addr) {
|
||||
auto& ia = *(sockaddr_in*)addr;
|
||||
ia.sin_port = htons(tcp_packet.destination_port());
|
||||
}
|
||||
memcpy(buffer, tcp_packet.payload(), payload_size);
|
||||
return payload_size;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue