1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 17:05:10 +00:00

Kernel+LibC+Userland: Yet more networking bringup hacking.

All ICMP sockets now receive all ICMP packets. All this buffering is gonna
need some limits and such.
This commit is contained in:
Andreas Kling 2019-03-12 17:27:07 +01:00
parent a017a77442
commit a7d5e9781a
14 changed files with 178 additions and 2 deletions

View file

@ -3,6 +3,7 @@
#include <Kernel/ARP.h>
#include <Kernel/ICMP.h>
#include <Kernel/IPv4.h>
#include <Kernel/IPv4Socket.h>
#include <Kernel/Process.h>
#include <Kernel/EtherType.h>
#include <AK/Lock.h>
@ -165,6 +166,16 @@ void handle_icmp(const EthernetFrameHeader& eth, int frame_size)
);
#endif
{
LOCKER(IPv4Socket::all_sockets().lock());
for (RetainPtr<IPv4Socket> socket : IPv4Socket::all_sockets().resource()) {
LOCKER(socket->lock());
if (socket->protocol() != (unsigned)IPv4Protocol::ICMP)
continue;
socket->did_receive(ByteBuffer::copy((const byte*)&ipv4_packet, sizeof(IPv4Packet) + ipv4_packet.payload_size()));
}
}
auto* adapter = NetworkAdapter::from_ipv4_address(ipv4_packet.destination());
if (!adapter)
return;