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