diff options
Diffstat (limited to 'Kernel/Net')
-rw-r--r-- | Kernel/Net/IPv4Socket.cpp | 20 | ||||
-rw-r--r-- | Kernel/Net/IPv4Socket.h | 20 | ||||
-rw-r--r-- | Kernel/Net/LocalSocket.cpp | 22 | ||||
-rw-r--r-- | Kernel/Net/LocalSocket.h | 24 | ||||
-rw-r--r-- | Kernel/Net/Socket.cpp | 4 | ||||
-rw-r--r-- | Kernel/Net/Socket.h | 14 | ||||
-rw-r--r-- | Kernel/Net/TCPSocket.cpp | 2 | ||||
-rw-r--r-- | Kernel/Net/TCPSocket.h | 2 | ||||
-rw-r--r-- | Kernel/Net/UDPSocket.h | 2 |
9 files changed, 55 insertions, 55 deletions
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 681674ba61..b09e320409 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -11,7 +11,7 @@ #include <Kernel/Net/ARP.h> #include <Kernel/Net/Routing.h> #include <LibC/errno_numbers.h> -#include <Kernel/FileSystem/FileDescriptor.h> +#include <Kernel/FileSystem/FileDescription.h> #define IPV4_SOCKET_DEBUG @@ -89,7 +89,7 @@ KResult IPv4Socket::bind(const sockaddr* address, socklen_t address_size) return protocol_bind(); } -KResult IPv4Socket::connect(FileDescriptor& descriptor, const sockaddr* address, socklen_t address_size, ShouldBlock should_block) +KResult IPv4Socket::connect(FileDescription& descriptor, const sockaddr* address, socklen_t address_size, ShouldBlock should_block) { ASSERT(!m_bound); if (address_size != sizeof(sockaddr_in)) @@ -104,17 +104,17 @@ KResult IPv4Socket::connect(FileDescriptor& descriptor, const sockaddr* address, return protocol_connect(descriptor, should_block); } -void IPv4Socket::attach(FileDescriptor&) +void IPv4Socket::attach(FileDescription&) { ++m_attached_fds; } -void IPv4Socket::detach(FileDescriptor&) +void IPv4Socket::detach(FileDescription&) { --m_attached_fds; } -bool IPv4Socket::can_read(FileDescriptor& descriptor) const +bool IPv4Socket::can_read(FileDescription& descriptor) const { if (descriptor.socket_role() == SocketRole::Listener) return can_accept(); @@ -123,17 +123,17 @@ bool IPv4Socket::can_read(FileDescriptor& descriptor) const return m_can_read; } -ssize_t IPv4Socket::read(FileDescriptor& descriptor, byte* buffer, ssize_t size) +ssize_t IPv4Socket::read(FileDescription& descriptor, byte* buffer, ssize_t size) { return recvfrom(descriptor, buffer, size, 0, nullptr, 0); } -ssize_t IPv4Socket::write(FileDescriptor& descriptor, const byte* data, ssize_t size) +ssize_t IPv4Socket::write(FileDescription& descriptor, const byte* data, ssize_t size) { return sendto(descriptor, data, size, 0, nullptr, 0); } -bool IPv4Socket::can_write(FileDescriptor&) const +bool IPv4Socket::can_write(FileDescription&) const { return is_connected(); } @@ -149,7 +149,7 @@ int IPv4Socket::allocate_local_port_if_needed() return port; } -ssize_t IPv4Socket::sendto(FileDescriptor&, const void* data, size_t data_length, int flags, const sockaddr* addr, socklen_t addr_length) +ssize_t IPv4Socket::sendto(FileDescription&, const void* data, size_t data_length, int flags, const sockaddr* addr, socklen_t addr_length) { (void)flags; if (addr && addr_length != sizeof(sockaddr_in)) @@ -184,7 +184,7 @@ ssize_t IPv4Socket::sendto(FileDescriptor&, const void* data, size_t data_length return protocol_send(data, data_length); } -ssize_t IPv4Socket::recvfrom(FileDescriptor& descriptor, void* buffer, size_t buffer_length, int flags, sockaddr* addr, socklen_t* addr_length) +ssize_t IPv4Socket::recvfrom(FileDescription& descriptor, void* buffer, size_t buffer_length, int flags, sockaddr* addr, socklen_t* addr_length) { (void)flags; if (addr_length && *addr_length < sizeof(sockaddr_in)) diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h index 4f18d63113..dea6b5c171 100644 --- a/Kernel/Net/IPv4Socket.h +++ b/Kernel/Net/IPv4Socket.h @@ -21,17 +21,17 @@ public: static Lockable<HashTable<IPv4Socket*>>& all_sockets(); virtual KResult bind(const sockaddr*, socklen_t) override; - virtual KResult connect(FileDescriptor&, const sockaddr*, socklen_t, ShouldBlock = ShouldBlock::Yes) override; + virtual KResult connect(FileDescription&, const sockaddr*, socklen_t, ShouldBlock = ShouldBlock::Yes) override; virtual bool get_local_address(sockaddr*, socklen_t*) override; virtual bool get_peer_address(sockaddr*, socklen_t*) override; - virtual void attach(FileDescriptor&) override; - virtual void detach(FileDescriptor&) override; - virtual bool can_read(FileDescriptor&) const override; - virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override; - virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override; - virtual bool can_write(FileDescriptor&) const override; - virtual ssize_t sendto(FileDescriptor&, const void*, size_t, int, const sockaddr*, socklen_t) override; - virtual ssize_t recvfrom(FileDescriptor&, void*, size_t, int flags, sockaddr*, socklen_t*) override; + virtual void attach(FileDescription&) override; + virtual void detach(FileDescription&) override; + virtual bool can_read(FileDescription&) const override; + virtual ssize_t read(FileDescription&, byte*, ssize_t) override; + virtual ssize_t write(FileDescription&, const byte*, ssize_t) override; + virtual bool can_write(FileDescription&) const override; + virtual ssize_t sendto(FileDescription&, const void*, size_t, int, const sockaddr*, socklen_t) override; + virtual ssize_t recvfrom(FileDescription&, void*, size_t, int flags, sockaddr*, socklen_t*) override; void did_receive(const IPv4Address& peer_address, word peer_port, ByteBuffer&&); @@ -52,7 +52,7 @@ protected: virtual KResult protocol_bind() { return KSuccess; } virtual int protocol_receive(const ByteBuffer&, void*, size_t, int, sockaddr*, socklen_t*) { return -ENOTIMPL; } virtual int protocol_send(const void*, int) { return -ENOTIMPL; } - virtual KResult protocol_connect(FileDescriptor&, ShouldBlock) { return KSuccess; } + virtual KResult protocol_connect(FileDescription&, ShouldBlock) { return KSuccess; } virtual int protocol_allocate_local_port() { return 0; } virtual bool protocol_is_disconnected() const { return false; } diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index 99457e2cc4..208348847a 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -1,7 +1,7 @@ #include <Kernel/Net/LocalSocket.h> #include <Kernel/UnixTypes.h> #include <Kernel/Process.h> -#include <Kernel/FileSystem/FileDescriptor.h> +#include <Kernel/FileSystem/FileDescription.h> #include <Kernel/FileSystem/VirtualFileSystem.h> #include <LibC/errno_numbers.h> @@ -71,7 +71,7 @@ KResult LocalSocket::bind(const sockaddr* address, socklen_t address_size) return KSuccess; } -KResult LocalSocket::connect(FileDescriptor& descriptor, const sockaddr* address, socklen_t address_size, ShouldBlock) +KResult LocalSocket::connect(FileDescription& descriptor, const sockaddr* address, socklen_t address_size, ShouldBlock) { ASSERT(!m_bound); if (address_size != sizeof(sockaddr_un)) @@ -106,7 +106,7 @@ KResult LocalSocket::connect(FileDescriptor& descriptor, const sockaddr* address return current->wait_for_connect(descriptor); } -void LocalSocket::attach(FileDescriptor& descriptor) +void LocalSocket::attach(FileDescription& descriptor) { switch (descriptor.socket_role()) { case SocketRole::Accepted: @@ -123,7 +123,7 @@ void LocalSocket::attach(FileDescriptor& descriptor) } } -void LocalSocket::detach(FileDescriptor& descriptor) +void LocalSocket::detach(FileDescription& descriptor) { switch (descriptor.socket_role()) { case SocketRole::Accepted: @@ -143,7 +143,7 @@ void LocalSocket::detach(FileDescriptor& descriptor) } } -bool LocalSocket::can_read(FileDescriptor& descriptor) const +bool LocalSocket::can_read(FileDescription& descriptor) const { auto role = descriptor.socket_role(); if (role == SocketRole::Listener) @@ -155,7 +155,7 @@ bool LocalSocket::can_read(FileDescriptor& descriptor) const ASSERT_NOT_REACHED(); } -ssize_t LocalSocket::read(FileDescriptor& descriptor, byte* buffer, ssize_t size) +ssize_t LocalSocket::read(FileDescription& descriptor, byte* buffer, ssize_t size) { auto role = descriptor.socket_role(); if (role == SocketRole::Accepted) { @@ -175,7 +175,7 @@ ssize_t LocalSocket::read(FileDescriptor& descriptor, byte* buffer, ssize_t size ASSERT_NOT_REACHED(); } -bool LocalSocket::has_attached_peer(const FileDescriptor& descriptor) const +bool LocalSocket::has_attached_peer(const FileDescription& descriptor) const { if (descriptor.socket_role() == SocketRole::Accepted) return m_connected_fds_open || m_connecting_fds_open; @@ -184,7 +184,7 @@ bool LocalSocket::has_attached_peer(const FileDescriptor& descriptor) const ASSERT_NOT_REACHED(); } -ssize_t LocalSocket::write(FileDescriptor& descriptor, const byte* data, ssize_t size) +ssize_t LocalSocket::write(FileDescription& descriptor, const byte* data, ssize_t size) { if (!has_attached_peer(descriptor)) return -EPIPE; @@ -195,7 +195,7 @@ ssize_t LocalSocket::write(FileDescriptor& descriptor, const byte* data, ssize_t ASSERT_NOT_REACHED(); } -bool LocalSocket::can_write(FileDescriptor& descriptor) const +bool LocalSocket::can_write(FileDescription& descriptor) const { if (descriptor.socket_role() == SocketRole::Accepted) return !has_attached_peer(descriptor) || m_for_client.bytes_in_write_buffer() < 16384; @@ -204,12 +204,12 @@ bool LocalSocket::can_write(FileDescriptor& descriptor) const ASSERT_NOT_REACHED(); } -ssize_t LocalSocket::sendto(FileDescriptor& descriptor, const void* data, size_t data_size, int, const sockaddr*, socklen_t) +ssize_t LocalSocket::sendto(FileDescription& descriptor, const void* data, size_t data_size, int, const sockaddr*, socklen_t) { return write(descriptor, (const byte*)data, data_size); } -ssize_t LocalSocket::recvfrom(FileDescriptor& descriptor, void* buffer, size_t buffer_size, int, sockaddr*, socklen_t*) +ssize_t LocalSocket::recvfrom(FileDescription& descriptor, void* buffer, size_t buffer_size, int, sockaddr*, socklen_t*) { return read(descriptor, (byte*)buffer, buffer_size); } diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h index 3328fd4eba..f1ac23719b 100644 --- a/Kernel/Net/LocalSocket.h +++ b/Kernel/Net/LocalSocket.h @@ -3,7 +3,7 @@ #include <Kernel/DoubleBuffer.h> #include <Kernel/Net/Socket.h> -class FileDescriptor; +class FileDescription; class LocalSocket final : public Socket { public: @@ -11,24 +11,24 @@ public: virtual ~LocalSocket() override; virtual KResult bind(const sockaddr*, socklen_t) override; - virtual KResult connect(FileDescriptor&, const sockaddr*, socklen_t, ShouldBlock = ShouldBlock::Yes) override; + virtual KResult connect(FileDescription&, const sockaddr*, socklen_t, ShouldBlock = ShouldBlock::Yes) override; virtual bool get_local_address(sockaddr*, socklen_t*) override; virtual bool get_peer_address(sockaddr*, socklen_t*) override; - virtual void attach(FileDescriptor&) override; - virtual void detach(FileDescriptor&) override; - virtual bool can_read(FileDescriptor&) const override; - virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override; - virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override; - virtual bool can_write(FileDescriptor&) const override; - virtual ssize_t sendto(FileDescriptor&, const void*, size_t, int, const sockaddr*, socklen_t) override; - virtual ssize_t recvfrom(FileDescriptor&, void*, size_t, int flags, sockaddr*, socklen_t*) override; + virtual void attach(FileDescription&) override; + virtual void detach(FileDescription&) override; + virtual bool can_read(FileDescription&) const override; + virtual ssize_t read(FileDescription&, byte*, ssize_t) override; + virtual ssize_t write(FileDescription&, const byte*, ssize_t) override; + virtual bool can_write(FileDescription&) const override; + virtual ssize_t sendto(FileDescription&, const void*, size_t, int, const sockaddr*, socklen_t) override; + virtual ssize_t recvfrom(FileDescription&, void*, size_t, int flags, sockaddr*, socklen_t*) override; private: explicit LocalSocket(int type); virtual bool is_local() const override { return true; } - bool has_attached_peer(const FileDescriptor&) const; + bool has_attached_peer(const FileDescription&) const; - RetainPtr<FileDescriptor> m_file; + RetainPtr<FileDescription> m_file; bool m_bound { false }; int m_accepted_fds_open { 0 }; diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp index 8c800f8eba..ee4a78c473 100644 --- a/Kernel/Net/Socket.cpp +++ b/Kernel/Net/Socket.cpp @@ -1,4 +1,4 @@ -#include <Kernel/FileSystem/FileDescriptor.h> +#include <Kernel/FileSystem/FileDescription.h> #include <Kernel/Net/Socket.h> #include <Kernel/Net/LocalSocket.h> #include <Kernel/Net/IPv4Socket.h> @@ -142,7 +142,7 @@ static const char* to_string(SocketRole role) } } -String Socket::absolute_path(const FileDescriptor& descriptor) const +String Socket::absolute_path(const FileDescription& descriptor) const { return String::format("socket:%x (role: %s)", this, to_string(descriptor.socket_role())); } diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h index f11f3e768b..336dc8623b 100644 --- a/Kernel/Net/Socket.h +++ b/Kernel/Net/Socket.h @@ -23,7 +23,7 @@ enum class ShouldBlock Yes = 1 }; -class FileDescriptor; +class FileDescription; class Socket : public File { public: @@ -40,15 +40,15 @@ public: KResult listen(int backlog); virtual KResult bind(const sockaddr*, socklen_t) = 0; - virtual KResult connect(FileDescriptor&, const sockaddr*, socklen_t, ShouldBlock) = 0; + virtual KResult connect(FileDescription&, const sockaddr*, socklen_t, ShouldBlock) = 0; virtual bool get_local_address(sockaddr*, socklen_t*) = 0; virtual bool get_peer_address(sockaddr*, socklen_t*) = 0; virtual bool is_local() const { return false; } virtual bool is_ipv4() const { return false; } - virtual void attach(FileDescriptor&) = 0; - virtual void detach(FileDescriptor&) = 0; - virtual ssize_t sendto(FileDescriptor&, const void*, size_t, int flags, const sockaddr*, socklen_t) = 0; - virtual ssize_t recvfrom(FileDescriptor&, void*, size_t, int flags, sockaddr*, socklen_t*) = 0; + virtual void attach(FileDescription&) = 0; + virtual void detach(FileDescription&) = 0; + virtual ssize_t sendto(FileDescription&, const void*, size_t, int flags, const sockaddr*, socklen_t) = 0; + virtual ssize_t recvfrom(FileDescription&, void*, size_t, int flags, sockaddr*, socklen_t*) = 0; KResult setsockopt(int level, int option, const void*, socklen_t); KResult getsockopt(int level, int option, void*, socklen_t*); @@ -62,7 +62,7 @@ public: Lock& lock() { return m_lock; } - virtual String absolute_path(const FileDescriptor&) const override; + virtual String absolute_path(const FileDescription&) const override; protected: Socket(int domain, int type, int protocol); diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index acb3c47569..fe60425fd3 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -148,7 +148,7 @@ NetworkOrdered<word> TCPSocket::compute_tcp_checksum(const IPv4Address& source, return ~(checksum & 0xffff); } -KResult TCPSocket::protocol_connect(FileDescriptor& descriptor, ShouldBlock should_block) +KResult TCPSocket::protocol_connect(FileDescription& descriptor, ShouldBlock should_block) { auto* adapter = adapter_for_route_to(peer_address()); if (!adapter) diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h index 35856d7ae8..7ced06f56f 100644 --- a/Kernel/Net/TCPSocket.h +++ b/Kernel/Net/TCPSocket.h @@ -36,7 +36,7 @@ private: virtual int protocol_receive(const ByteBuffer&, void* buffer, size_t buffer_size, int flags, sockaddr* addr, socklen_t* addr_length) override; virtual int protocol_send(const void*, int) override; - virtual KResult protocol_connect(FileDescriptor&, ShouldBlock) override; + virtual KResult protocol_connect(FileDescription&, ShouldBlock) override; virtual int protocol_allocate_local_port() override; virtual bool protocol_is_disconnected() const override; virtual KResult protocol_bind() override; diff --git a/Kernel/Net/UDPSocket.h b/Kernel/Net/UDPSocket.h index a76eaa7fe7..80ef09b7bf 100644 --- a/Kernel/Net/UDPSocket.h +++ b/Kernel/Net/UDPSocket.h @@ -18,7 +18,7 @@ private: virtual int protocol_receive(const ByteBuffer&, void* buffer, size_t buffer_size, int flags, sockaddr* addr, socklen_t* addr_length) override; virtual int protocol_send(const void*, int) override; - virtual KResult protocol_connect(FileDescriptor&, ShouldBlock) override { return KSuccess; } + virtual KResult protocol_connect(FileDescription&, ShouldBlock) override { return KSuccess; } virtual int protocol_allocate_local_port() override; virtual KResult protocol_bind() override; }; |