diff options
Diffstat (limited to 'Kernel/Net')
-rw-r--r-- | Kernel/Net/NetworkAdapter.cpp | 9 | ||||
-rw-r--r-- | Kernel/Net/NetworkAdapter.h | 11 |
2 files changed, 11 insertions, 9 deletions
diff --git a/Kernel/Net/NetworkAdapter.cpp b/Kernel/Net/NetworkAdapter.cpp index 379a740cc8..e050fcc581 100644 --- a/Kernel/Net/NetworkAdapter.cpp +++ b/Kernel/Net/NetworkAdapter.cpp @@ -21,18 +21,11 @@ namespace Kernel { static AK::Singleton<Lockable<HashTable<NetworkAdapter*>>> s_table; -static Lockable<HashTable<NetworkAdapter*>>& all_adapters() +Lockable<HashTable<NetworkAdapter*>>& NetworkAdapter::all_adapters() { return *s_table; } -void NetworkAdapter::for_each(Function<void(NetworkAdapter&)> callback) -{ - Locker locker(all_adapters().lock()); - for (auto& it : all_adapters().resource()) - callback(*it); -} - RefPtr<NetworkAdapter> NetworkAdapter::from_ipv4_address(const IPv4Address& address) { Locker locker(all_adapters().lock()); diff --git a/Kernel/Net/NetworkAdapter.h b/Kernel/Net/NetworkAdapter.h index 6e6dcf32b0..d25d3a2c30 100644 --- a/Kernel/Net/NetworkAdapter.h +++ b/Kernel/Net/NetworkAdapter.h @@ -25,7 +25,14 @@ class NetworkAdapter; class NetworkAdapter : public RefCounted<NetworkAdapter> { public: - static void for_each(Function<void(NetworkAdapter&)>); + template<typename Callback> + static inline void for_each(Callback callback) + { + Locker locker(all_adapters().lock()); + for (auto& it : all_adapters().resource()) + callback(*it); + } + static RefPtr<NetworkAdapter> from_ipv4_address(const IPv4Address&); static RefPtr<NetworkAdapter> lookup_by_name(const StringView&); virtual ~NetworkAdapter(); @@ -70,6 +77,8 @@ protected: void did_receive(ReadonlyBytes); private: + static Lockable<HashTable<NetworkAdapter*>>& all_adapters(); + MACAddress m_mac_address; IPv4Address m_ipv4_address; IPv4Address m_ipv4_netmask; |