/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include namespace Kernel { class UDPSocket final : public IPv4Socket { public: static KResultOr> create(int protocol, NonnullOwnPtr receive_buffer); virtual ~UDPSocket() override; static SocketHandle from_port(u16); static void for_each(Function); private: explicit UDPSocket(int protocol, NonnullOwnPtr receive_buffer); virtual StringView class_name() const override { return "UDPSocket"; } static Lockable>& sockets_by_port(); virtual KResultOr protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, int flags) override; virtual KResultOr protocol_send(const UserOrKernelBuffer&, size_t) override; virtual KResult protocol_connect(FileDescription&, ShouldBlock) override; virtual KResultOr protocol_allocate_local_port() override; virtual KResult protocol_bind() override; }; }