/* * Copyright (c) 2021, Liav A. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include namespace Kernel { class NetworkAdapter; class NetworkingManagement { friend class NetworkAdapter; AK_MAKE_ETERNAL public: static NetworkingManagement& the(); static bool is_initialized(); bool initialize(); static ErrorOr> generate_interface_name_from_pci_address(PCI::DeviceIdentifier const&); NetworkingManagement(); void for_each(Function); RefPtr from_ipv4_address(const IPv4Address&) const; RefPtr lookup_by_name(StringView) const; NonnullRefPtr loopback_adapter() const; private: RefPtr determine_network_device(PCI::DeviceIdentifier const&) const; NonnullRefPtrVector m_adapters; RefPtr m_loopback_adapter; mutable Mutex m_lock { "Networking" }; }; }