mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25: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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user