chromium/components/openscreen_platform/udp_socket.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/openscreen_platform/udp_socket.h"

#include <utility>

#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "components/openscreen_platform/network_context.h"
#include "components/openscreen_platform/network_util.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/base/address_family.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "third_party/openscreen/src/platform/base/udp_packet.h"

// Open Screen expects us to provide linked implementations of some of its
// static create methods, which have to be in their namespace.
namespace openscreen {

// static
ErrorOr<std::unique_ptr<UdpSocket>> UdpSocket::Create(
    TaskRunner& task_runner,
    Client* client,
    const IPEndpoint& local_endpoint) {}

}  // namespace openscreen

namespace openscreen_platform {

namespace {

ByteView;
Error;
IPAddress;
IPEndpoint;
UdpPacket;

constexpr net::NetworkTrafficAnnotationTag kTrafficAnnotation =;

}  // namespace

UdpSocket::UdpSocket(
    Client* client,
    const IPEndpoint& local_endpoint,
    mojo::Remote<network::mojom::UDPSocket> udp_socket,
    mojo::PendingReceiver<network::mojom::UDPSocketListener> pending_listener)
    :{}

UdpSocket::~UdpSocket() = default;

bool UdpSocket::IsIPv4() const {}

bool UdpSocket::IsIPv6() const {}

IPEndpoint UdpSocket::GetLocalEndpoint() const {}

void UdpSocket::Bind() {}

// mojom::UDPSocket doesn't have a concept of network interface indices, so
// this is a noop.
void UdpSocket::SetMulticastOutboundInterface(
    openscreen::NetworkInterfaceIndex ifindex) {}

// mojom::UDPSocket doesn't have a concept of network interface indices, so
// the ifindex argument is ignored here.
void UdpSocket::JoinMulticastGroup(const IPAddress& address,
                                   openscreen::NetworkInterfaceIndex ifindex) {}

void UdpSocket::SendMessage(ByteView data, const IPEndpoint& dest) {}

// mojom::UDPSocket doesn't have a concept of DSCP, so this is a noop.
void UdpSocket::SetDscp(openscreen::UdpSocket::DscpMode state) {}

void UdpSocket::OnReceived(
    int32_t net_result,
    const std::optional<net::IPEndPoint>& source_endpoint,
    std::optional<base::span<const uint8_t>> data) {}

void UdpSocket::BindCallback(int32_t result,
                             const std::optional<net::IPEndPoint>& address) {}

void UdpSocket::JoinGroupCallback(int32_t result) {}

void UdpSocket::SendCallback(int32_t result) {}

}  // namespace openscreen_platform