1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:58:12 +00:00

Kernel: Bring up enough networking code that we can respond to ARP requests.

This is all pretty rickety but we can now respond to "arping" from the host
while running inside QEMU. Very cool. :^)
This commit is contained in:
Andreas Kling 2019-03-11 23:21:38 +01:00
parent 10dcd3a47f
commit 318b01e055
12 changed files with 229 additions and 40 deletions

View file

@ -2,6 +2,7 @@
#include <Kernel/StdLib.h>
#include <Kernel/EthernetFrameHeader.h>
#include <Kernel/kmalloc.h>
#include <Kernel/EtherType.h>
NetworkAdapter::NetworkAdapter()
{
@ -17,6 +18,7 @@ void NetworkAdapter::send(const MACAddress& destination, const ARPPacket& packet
auto* eth = (EthernetFrameHeader*)kmalloc(size_in_bytes);
eth->set_source(mac_address());
eth->set_destination(destination);
eth->set_ether_type(EtherType::ARP);
memcpy(eth->payload(), &packet, sizeof(ARPPacket));
send_raw((byte*)eth, size_in_bytes);
kfree(eth);
@ -35,3 +37,8 @@ ByteBuffer NetworkAdapter::dequeue_packet()
return { };
return m_packet_queue.take_first();
}
void NetworkAdapter::set_ipv4_address(const IPv4Address& address)
{
m_ipv4_address = address;
}