mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:07:34 +00:00
parent
527c8047fe
commit
f48feae0b2
44 changed files with 184 additions and 146 deletions
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <Kernel/Singleton.h>
|
||||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
#include <Kernel/Net/ARP.h>
|
||||
#include <Kernel/Net/ICMP.h>
|
||||
|
@ -45,11 +46,10 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
static auto s_table = make_singleton<Lockable<HashTable<IPv4Socket*>>>();
|
||||
|
||||
Lockable<HashTable<IPv4Socket*>>& IPv4Socket::all_sockets()
|
||||
{
|
||||
static Lockable<HashTable<IPv4Socket*>>* s_table;
|
||||
if (!s_table)
|
||||
s_table = new Lockable<HashTable<IPv4Socket*>>;
|
||||
return *s_table;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/Net/LocalSocket.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/Singleton.h>
|
||||
#include <Kernel/StdLib.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
|
@ -37,11 +38,10 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
static auto s_list = make_singleton<Lockable<InlineLinkedList<LocalSocket>>>();
|
||||
|
||||
Lockable<InlineLinkedList<LocalSocket>>& LocalSocket::all_sockets()
|
||||
{
|
||||
static Lockable<InlineLinkedList<LocalSocket>>* s_list;
|
||||
if (!s_list)
|
||||
s_list = new Lockable<InlineLinkedList<LocalSocket>>();
|
||||
return *s_list;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,15 +25,15 @@
|
|||
*/
|
||||
|
||||
#include <Kernel/Net/LoopbackAdapter.h>
|
||||
#include <Kernel/Singleton.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
static auto s_loopback = make_singleton<LoopbackAdapter>();
|
||||
|
||||
LoopbackAdapter& LoopbackAdapter::the()
|
||||
{
|
||||
static LoopbackAdapter* the;
|
||||
if (!the)
|
||||
the = new LoopbackAdapter;
|
||||
return *the;
|
||||
return *s_loopback;
|
||||
}
|
||||
|
||||
LoopbackAdapter::LoopbackAdapter()
|
||||
|
|
|
@ -33,15 +33,13 @@ namespace Kernel {
|
|||
class LoopbackAdapter final : public NetworkAdapter {
|
||||
AK_MAKE_ETERNAL
|
||||
public:
|
||||
LoopbackAdapter();
|
||||
static LoopbackAdapter& the();
|
||||
|
||||
virtual ~LoopbackAdapter() override;
|
||||
|
||||
virtual void send_raw(ReadonlyBytes) override;
|
||||
virtual const char* class_name() const override { return "LoopbackAdapter"; }
|
||||
|
||||
private:
|
||||
LoopbackAdapter();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -33,16 +33,16 @@
|
|||
#include <Kernel/Net/LoopbackAdapter.h>
|
||||
#include <Kernel/Net/NetworkAdapter.h>
|
||||
#include <Kernel/Random.h>
|
||||
#include <Kernel/Singleton.h>
|
||||
#include <Kernel/StdLib.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
static auto s_table = make_singleton<Lockable<HashTable<NetworkAdapter*>>>();
|
||||
|
||||
static Lockable<HashTable<NetworkAdapter*>>& all_adapters()
|
||||
{
|
||||
static Lockable<HashTable<NetworkAdapter*>>* table;
|
||||
if (!table)
|
||||
table = new Lockable<HashTable<NetworkAdapter*>>;
|
||||
return *table;
|
||||
return *s_table;
|
||||
}
|
||||
|
||||
void NetworkAdapter::for_each(Function<void(NetworkAdapter&)> callback)
|
||||
|
|
|
@ -28,17 +28,17 @@
|
|||
#include <Kernel/Net/LoopbackAdapter.h>
|
||||
#include <Kernel/Net/Routing.h>
|
||||
#include <Kernel/Thread.h>
|
||||
#include <Kernel/Singleton.h>
|
||||
|
||||
//#define ROUTING_DEBUG
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
static auto s_arp_table = make_singleton<Lockable<HashMap<IPv4Address, MACAddress>>>();
|
||||
|
||||
Lockable<HashMap<IPv4Address, MACAddress>>& arp_table()
|
||||
{
|
||||
static Lockable<HashMap<IPv4Address, MACAddress>>* the;
|
||||
if (!the)
|
||||
the = new Lockable<HashMap<IPv4Address, MACAddress>>;
|
||||
return *the;
|
||||
return *s_arp_table;
|
||||
}
|
||||
|
||||
bool RoutingDecision::is_zero() const
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <Kernel/Net/TCPSocket.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/Random.h>
|
||||
#include <Kernel/Singleton.h>
|
||||
|
||||
//#define TCP_SOCKET_DEBUG
|
||||
|
||||
|
@ -70,11 +71,10 @@ Lockable<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>& TCPSocket::closing_socket
|
|||
return *s_map;
|
||||
}
|
||||
|
||||
static auto s_map = make_singleton<Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>>();
|
||||
|
||||
Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>& TCPSocket::sockets_by_tuple()
|
||||
{
|
||||
static Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>* s_map;
|
||||
if (!s_map)
|
||||
s_map = new Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>;
|
||||
return *s_map;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <Kernel/Net/UDPSocket.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/Random.h>
|
||||
#include <Kernel/Singleton.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -41,11 +42,10 @@ void UDPSocket::for_each(Function<void(const UDPSocket&)> callback)
|
|||
callback(*it.value);
|
||||
}
|
||||
|
||||
static auto s_map = make_singleton<Lockable<HashMap<u16, UDPSocket*>>>();
|
||||
|
||||
Lockable<HashMap<u16, UDPSocket*>>& UDPSocket::sockets_by_port()
|
||||
{
|
||||
static Lockable<HashMap<u16, UDPSocket*>>* s_map;
|
||||
if (!s_map)
|
||||
s_map = new Lockable<HashMap<u16, UDPSocket*>>;
|
||||
return *s_map;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue