chromium/net/dns/mdns_client_impl.cc

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

#include "net/dns/mdns_client_impl.h"

#include <algorithm>
#include <cstdint>
#include <memory>
#include <optional>
#include <utility>
#include <vector>

#include "base/containers/fixed_flat_set.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/metrics/histogram_functions.h"
#include "base/not_fatal_until.h"
#include "base/observer_list.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/clock.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "net/base/net_errors.h"
#include "net/base/rand_callback.h"
#include "net/dns/dns_names_util.h"
#include "net/dns/public/dns_protocol.h"
#include "net/dns/public/util.h"
#include "net/dns/record_rdata.h"
#include "net/socket/datagram_socket.h"

// TODO(gene): Remove this temporary method of disabling NSEC support once it
// becomes clear whether this feature should be
// supported. http://crbug.com/255232
#define ENABLE_NSEC

namespace net {

namespace {

// The fractions of the record's original TTL after which an active listener
// (one that had |SetActiveRefresh(true)| called) will send a query to refresh
// its cache. This happens both at 85% of the original TTL and again at 95% of
// the original TTL.
const double kListenerRefreshRatio1 =;
const double kListenerRefreshRatio2 =;

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class mdnsQueryType {};

void RecordQueryMetric(mdnsQueryType query_type, std::string_view host) {}

}  // namespace

void MDnsSocketFactoryImpl::CreateSockets(
    std::vector<std::unique_ptr<DatagramServerSocket>>* sockets) {}

MDnsConnection::SocketHandler::SocketHandler(
    std::unique_ptr<DatagramServerSocket> socket,
    MDnsConnection* connection)
    :{}

MDnsConnection::SocketHandler::~SocketHandler() = default;

int MDnsConnection::SocketHandler::Start() {}

int MDnsConnection::SocketHandler::DoLoop(int rv) {}

void MDnsConnection::SocketHandler::OnDatagramReceived(int rv) {}

void MDnsConnection::SocketHandler::Send(const scoped_refptr<IOBuffer>& buffer,
                                         unsigned size) {}

void MDnsConnection::SocketHandler::SendDone(int rv) {}

MDnsConnection::MDnsConnection(MDnsConnection::Delegate* delegate)
    :{}

MDnsConnection::~MDnsConnection() = default;

int MDnsConnection::Init(MDnsSocketFactory* socket_factory) {}

void MDnsConnection::Send(const scoped_refptr<IOBuffer>& buffer,
                          unsigned size) {}

void MDnsConnection::PostOnError(SocketHandler* loop, int rv) {}

void MDnsConnection::OnError(int rv) {}

void MDnsConnection::OnDatagramReceived(
    DnsResponse* response,
    const IPEndPoint& recv_addr,
    int bytes_read) {}

MDnsClientImpl::Core::Core(base::Clock* clock, base::OneShotTimer* timer)
    :{}

MDnsClientImpl::Core::~Core() {}

int MDnsClientImpl::Core::Init(MDnsSocketFactory* socket_factory) {}

bool MDnsClientImpl::Core::SendQuery(uint16_t rrtype, const std::string& name) {}

void MDnsClientImpl::Core::HandlePacket(DnsResponse* response,
                                        int bytes_read) {}

void MDnsClientImpl::Core::NotifyNsecRecord(const RecordParsed* record) {}

void MDnsClientImpl::Core::OnConnectionError(int error) {}

MDnsClientImpl::Core::ListenerKey::ListenerKey(const std::string& name,
                                               uint16_t type)
    :{}

bool MDnsClientImpl::Core::ListenerKey::operator<(
    const MDnsClientImpl::Core::ListenerKey& key) const {}

void MDnsClientImpl::Core::AlertListeners(
    MDnsCache::UpdateType update_type,
    const ListenerKey& key,
    const RecordParsed* record) {}

void MDnsClientImpl::Core::AddListener(
    MDnsListenerImpl* listener) {}

void MDnsClientImpl::Core::RemoveListener(MDnsListenerImpl* listener) {}

void MDnsClientImpl::Core::CleanupObserverList(const ListenerKey& key) {}

void MDnsClientImpl::Core::ScheduleCleanup(base::Time cleanup) {}

void MDnsClientImpl::Core::DoCleanup() {}

void MDnsClientImpl::Core::OnRecordRemoved(
    const RecordParsed* record) {}

void MDnsClientImpl::Core::QueryCache(
    uint16_t rrtype,
    const std::string& name,
    std::vector<const RecordParsed*>* records) const {}

MDnsClientImpl::MDnsClientImpl()
    :{}

MDnsClientImpl::MDnsClientImpl(base::Clock* clock,
                               std::unique_ptr<base::OneShotTimer> timer)
    :{}

MDnsClientImpl::~MDnsClientImpl() {}

int MDnsClientImpl::StartListening(MDnsSocketFactory* socket_factory) {}

void MDnsClientImpl::StopListening() {}

bool MDnsClientImpl::IsListening() const {}

std::unique_ptr<MDnsListener> MDnsClientImpl::CreateListener(
    uint16_t rrtype,
    const std::string& name,
    MDnsListener::Delegate* delegate) {}

std::unique_ptr<MDnsTransaction> MDnsClientImpl::CreateTransaction(
    uint16_t rrtype,
    const std::string& name,
    int flags,
    const MDnsTransaction::ResultCallback& callback) {}

MDnsListenerImpl::MDnsListenerImpl(uint16_t rrtype,
                                   const std::string& name,
                                   base::Clock* clock,
                                   MDnsListener::Delegate* delegate,
                                   MDnsClientImpl* client)
    :{}

MDnsListenerImpl::~MDnsListenerImpl() {}

bool MDnsListenerImpl::Start() {}

void MDnsListenerImpl::SetActiveRefresh(bool active_refresh) {}

const std::string& MDnsListenerImpl::GetName() const {}

uint16_t MDnsListenerImpl::GetType() const {}

void MDnsListenerImpl::HandleRecordUpdate(MDnsCache::UpdateType update_type,
                                          const RecordParsed* record) {}

void MDnsListenerImpl::AlertNsecRecord() {}

void MDnsListenerImpl::ScheduleNextRefresh() {}

void MDnsListenerImpl::DoRefresh() {}

MDnsTransactionImpl::MDnsTransactionImpl(
    uint16_t rrtype,
    const std::string& name,
    int flags,
    const MDnsTransaction::ResultCallback& callback,
    MDnsClientImpl* client)
    :{}

MDnsTransactionImpl::~MDnsTransactionImpl() {}

bool MDnsTransactionImpl::Start() {}

const std::string& MDnsTransactionImpl::GetName() const {}

uint16_t MDnsTransactionImpl::GetType() const {}

void MDnsTransactionImpl::CacheRecordFound(const RecordParsed* record) {}

void MDnsTransactionImpl::TriggerCallback(MDnsTransaction::Result result,
                                          const RecordParsed* record) {}

void MDnsTransactionImpl::Reset() {}

void MDnsTransactionImpl::OnRecordUpdate(MDnsListener::UpdateType update,
                                         const RecordParsed* record) {}

void MDnsTransactionImpl::SignalTransactionOver() {}

void MDnsTransactionImpl::ServeRecordsFromCache() {}

bool MDnsTransactionImpl::QueryAndListen() {}

void MDnsTransactionImpl::OnNsecRecord(const std::string& name, unsigned type) {}

void MDnsTransactionImpl::OnCachePurged() {}

}  // namespace net