mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 02:03:06 -05:00
1c94b5e8eb
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.
38 lines
770 B
C++
38 lines
770 B
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/Singleton.h>
|
|
#include <Kernel/Net/LoopbackAdapter.h>
|
|
|
|
namespace Kernel {
|
|
|
|
static bool s_loopback_initialized = false;
|
|
|
|
NonnullRefPtr<LoopbackAdapter> LoopbackAdapter::create()
|
|
{
|
|
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 });
|
|
}
|
|
|
|
LoopbackAdapter::~LoopbackAdapter()
|
|
{
|
|
}
|
|
|
|
void LoopbackAdapter::send_raw(ReadonlyBytes payload)
|
|
{
|
|
dbgln("LoopbackAdapter: Sending {} byte(s) to myself.", payload.size());
|
|
did_receive(payload);
|
|
}
|
|
|
|
}
|