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

Kernel: Introduce the NetworkingManagement singleton

Instead of initializing network adapters in init.cpp, let's move that
logic into a separate class to handle this.
Also, it seems like a good idea to shift responsiblity on enumeration
of network adapters after the boot process, so this singleton will take
care of finding the appropriate network adapter when asked to with an
IPv4 address or interface name.

With this change being merged, we simplify the creation logic of
NetworkAdapter derived classes, so we enumerate the PCI bus only once,
searching for driver candidates when doing so, and we let each driver
to test if it is resposible for the specified PCI device.
This commit is contained in:
Liav A 2021-06-04 07:43:16 +03:00 committed by Ali Mohammad Pur
parent 8b1d4d1b8e
commit 1c94b5e8eb
20 changed files with 212 additions and 117 deletions

View file

@ -9,15 +9,17 @@
namespace Kernel {
static AK::Singleton<LoopbackAdapter> s_loopback;
static bool s_loopback_initialized = false;
LoopbackAdapter& LoopbackAdapter::the()
NonnullRefPtr<LoopbackAdapter> LoopbackAdapter::create()
{
return *s_loopback;
return adopt_ref(*new LoopbackAdapter());
}
LoopbackAdapter::LoopbackAdapter()
{
VERIFY(!s_loopback_initialized);
s_loopback_initialized = true;
set_loopback_name();
set_mtu(65536);
set_mac_address({ 19, 85, 2, 9, 0x55, 0xaa });