/* * 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; 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); ErrorOr try_for_each(Function(NetworkAdapter&)>); RefPtr from_ipv4_address(IPv4Address const&) const; RefPtr lookup_by_name(StringView) const; NonnullRefPtr loopback_adapter() const; private: RefPtr determine_network_device(PCI::DeviceIdentifier const&) const; SpinlockProtected> m_adapters; RefPtr m_loopback_adapter; }; }