Kernel: Cleanup network code and implement basic ARP request

This commit is contained in:
2024-02-03 02:39:26 +02:00
parent a0138955cd
commit 5cfe249945
8 changed files with 162 additions and 33 deletions

View File

@@ -1,9 +1,8 @@
#pragma once
#include <BAN/HashMap.h>
#include <BAN/IPv4.h>
#include <BAN/MAC.h>
#include <BAN/UniqPtr.h>
#include <kernel/Networking/NetworkInterface.h>
namespace Kernel
{
@@ -16,14 +15,28 @@ namespace Kernel
public:
static BAN::ErrorOr<BAN::UniqPtr<ARPTable>> create();
BAN::ErrorOr<BAN::MACAddress> get_mac_from_ipv4(BAN::IPv4Address);
BAN::ErrorOr<BAN::MACAddress> get_mac_from_ipv4(NetworkInterface&, BAN::IPv4Address);
void handle_arp_packet(BAN::ConstByteSpan);
private:
ARPTable();
private:
struct ARPReply
{
BAN::IPv4Address ipv4_address { 0 };
BAN::MACAddress mac_address;
};
private:
SpinLock m_lock;
BAN::HashMap<BAN::IPv4Address, BAN::MACAddress> m_arp_table;
BAN::Atomic<bool> m_has_got_reply;
ARPReply m_reply;
friend class BAN::UniqPtr<ARPTable>;
};