diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 9e31baff49..32704cae17 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -51,13 +51,15 @@ Lockable>& IPv4Socket::all_sockets() return *s_table; } -NonnullRefPtr IPv4Socket::create(int type, int protocol) +KResultOr> IPv4Socket::create(int type, int protocol) { if (type == SOCK_STREAM) return TCPSocket::create(protocol); if (type == SOCK_DGRAM) return UDPSocket::create(protocol); - return adopt(*new IPv4Socket(type, protocol)); + if (type == SOCK_RAW) + return adopt(*new IPv4Socket(type, protocol)); + return KResult(-EINVAL); } IPv4Socket::IPv4Socket(int type, int protocol) diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h index 6c603793b4..15676e347d 100644 --- a/Kernel/Net/IPv4Socket.h +++ b/Kernel/Net/IPv4Socket.h @@ -41,7 +41,7 @@ class TCPSocket; class IPv4Socket : public Socket { public: - static NonnullRefPtr create(int type, int protocol); + static KResultOr> create(int type, int protocol); virtual ~IPv4Socket() override; static Lockable>& all_sockets(); diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index 0c59ba14f8..e334f41c8f 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -50,7 +50,7 @@ void LocalSocket::for_each(Function callback) callback(socket); } -NonnullRefPtr LocalSocket::create(int type) +KResultOr> LocalSocket::create(int type) { return adopt(*new LocalSocket(type)); } diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h index 74153d4042..439cf1998f 100644 --- a/Kernel/Net/LocalSocket.h +++ b/Kernel/Net/LocalSocket.h @@ -35,7 +35,7 @@ class FileDescription; class LocalSocket final : public Socket, public InlineLinkedListNode { friend class InlineLinkedListNode; public: - static NonnullRefPtr create(int type); + static KResultOr> create(int type); virtual ~LocalSocket() override; static void for_each(Function); diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp index 5c1c47e0bd..4e8346ce42 100644 --- a/Kernel/Net/Socket.cpp +++ b/Kernel/Net/Socket.cpp @@ -37,7 +37,6 @@ KResultOr> Socket::create(int domain, int type, int protocol) { - (void)protocol; switch (domain) { case AF_LOCAL: return LocalSocket::create(type & SOCK_TYPE_MASK);