chromium/third_party/webrtc/p2p/client/basic_port_allocator.cc

/*
 *  Copyright 2004 The WebRTC Project Authors. All rights reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "p2p/client/basic_port_allocator.h"

#include <algorithm>
#include <functional>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
#include "absl/strings/string_view.h"
#include "api/task_queue/pending_task_safety_flag.h"
#include "api/transport/field_trial_based_config.h"
#include "api/units/time_delta.h"
#include "p2p/base/basic_packet_socket_factory.h"
#include "p2p/base/port.h"
#include "p2p/base/stun_port.h"
#include "p2p/base/tcp_port.h"
#include "p2p/base/turn_port.h"
#include "p2p/base/udp_port.h"
#include "rtc_base/checks.h"
#include "rtc_base/crypto_random.h"
#include "rtc_base/experiments/field_trial_parser.h"
#include "rtc_base/logging.h"
#include "rtc_base/network_constants.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/trace_event.h"
#include "system_wrappers/include/metrics.h"

namespace cricket {
namespace {
CreateRandomId;
IceCandidateType;
SafeTask;
TimeDelta;

const int PHASE_UDP =;
const int PHASE_RELAY =;
const int PHASE_TCP =;

const int kNumPhases =;

// Gets protocol priority: UDP > TCP > SSLTCP == TLS.
int GetProtocolPriority(cricket::ProtocolType protocol) {}
// Gets address family priority:  IPv6 > IPv4 > Unspecified.
int GetAddressFamilyPriority(int ip_family) {}

// Returns positive if a is better, negative if b is better, and 0 otherwise.
int ComparePort(const cricket::Port* a, const cricket::Port* b) {}

struct NetworkFilter {};

void FilterNetworks(std::vector<const rtc::Network*>* networks,
                    NetworkFilter filter) {}

bool IsAllowedByCandidateFilter(const Candidate& c, uint32_t filter) {}

std::string NetworksToString(const std::vector<const rtc::Network*>& networks) {}

}  // namespace

const uint32_t DISABLE_ALL_PHASES =;

// BasicPortAllocator
BasicPortAllocator::BasicPortAllocator(
    rtc::NetworkManager* network_manager,
    rtc::PacketSocketFactory* socket_factory,
    webrtc::TurnCustomizer* customizer,
    RelayPortFactoryInterface* relay_port_factory,
    const webrtc::FieldTrialsView* field_trials)
    :{}

BasicPortAllocator::BasicPortAllocator(
    rtc::NetworkManager* network_manager,
    rtc::PacketSocketFactory* socket_factory,
    const ServerAddresses& stun_servers,
    const webrtc::FieldTrialsView* field_trials)
    :{}

BasicPortAllocator::~BasicPortAllocator() {}

void BasicPortAllocator::SetNetworkIgnoreMask(int network_ignore_mask) {}

int BasicPortAllocator::GetNetworkIgnoreMask() const {}

PortAllocatorSession* BasicPortAllocator::CreateSessionInternal(
    absl::string_view content_name,
    int component,
    absl::string_view ice_ufrag,
    absl::string_view ice_pwd) {}

void BasicPortAllocator::AddTurnServerForTesting(
    const RelayServerConfig& turn_server) {}

// BasicPortAllocatorSession
BasicPortAllocatorSession::BasicPortAllocatorSession(
    BasicPortAllocator* allocator,
    absl::string_view content_name,
    int component,
    absl::string_view ice_ufrag,
    absl::string_view ice_pwd)
    :{}

BasicPortAllocatorSession::~BasicPortAllocatorSession() {}

BasicPortAllocator* BasicPortAllocatorSession::allocator() {}

void BasicPortAllocatorSession::SetCandidateFilter(uint32_t filter) {}

void BasicPortAllocatorSession::StartGettingPorts() {}

void BasicPortAllocatorSession::StopGettingPorts() {}

void BasicPortAllocatorSession::ClearGettingPorts() {}

bool BasicPortAllocatorSession::IsGettingPorts() {}

bool BasicPortAllocatorSession::IsCleared() const {}

bool BasicPortAllocatorSession::IsStopped() const {}

std::vector<const rtc::Network*>
BasicPortAllocatorSession::GetFailedNetworks() {}

void BasicPortAllocatorSession::RegatherOnFailedNetworks() {}

void BasicPortAllocatorSession::Regather(
    const std::vector<const rtc::Network*>& networks,
    bool disable_equivalent_phases,
    IceRegatheringReason reason) {}

void BasicPortAllocatorSession::GetCandidateStatsFromReadyPorts(
    CandidateStatsList* candidate_stats_list) const {}

void BasicPortAllocatorSession::SetStunKeepaliveIntervalForReadyPorts(
    const absl::optional<int>& stun_keepalive_interval) {}

std::vector<PortInterface*> BasicPortAllocatorSession::ReadyPorts() const {}

std::vector<Candidate> BasicPortAllocatorSession::ReadyCandidates() const {}

void BasicPortAllocatorSession::GetCandidatesFromPort(
    const PortData& data,
    std::vector<Candidate>* candidates) const {}

bool BasicPortAllocator::MdnsObfuscationEnabled() const {}

bool BasicPortAllocatorSession::CandidatesAllocationDone() const {}

void BasicPortAllocatorSession::UpdateIceParametersInternal() {}

void BasicPortAllocatorSession::GetPortConfigurations() {}

void BasicPortAllocatorSession::ConfigReady(PortConfiguration* config) {}

void BasicPortAllocatorSession::ConfigReady(
    std::unique_ptr<PortConfiguration> config) {}

// Adds a configuration to the list.
void BasicPortAllocatorSession::OnConfigReady(
    std::unique_ptr<PortConfiguration> config) {}

void BasicPortAllocatorSession::OnConfigStop() {}

void BasicPortAllocatorSession::AllocatePorts() {}

void BasicPortAllocatorSession::OnAllocate(int allocation_epoch) {}

std::vector<const rtc::Network*> BasicPortAllocatorSession::GetNetworks() {}

std::vector<const rtc::Network*> BasicPortAllocatorSession::SelectIPv6Networks(
    std::vector<const rtc::Network*>& all_ipv6_networks,
    int max_ipv6_networks) {}

// For each network, see if we have a sequence that covers it already.  If not,
// create a new sequence to create the appropriate ports.
void BasicPortAllocatorSession::DoAllocate(bool disable_equivalent) {}

void BasicPortAllocatorSession::OnNetworksChanged() {}

void BasicPortAllocatorSession::DisableEquivalentPhases(
    const rtc::Network* network,
    PortConfiguration* config,
    uint32_t* flags) {}

void BasicPortAllocatorSession::AddAllocatedPort(Port* port,
                                                 AllocationSequence* seq) {}

void BasicPortAllocatorSession::OnAllocationSequenceObjectsCreated() {}

void BasicPortAllocatorSession::OnCandidateReady(Port* port,
                                                 const Candidate& c) {}

void BasicPortAllocatorSession::OnCandidateError(
    Port* port,
    const IceCandidateErrorEvent& event) {}

Port* BasicPortAllocatorSession::GetBestTurnPortForNetwork(
    absl::string_view network_name) const {}

bool BasicPortAllocatorSession::PruneNewlyPairableTurnPort(
    PortData* newly_pairable_port_data) {}

bool BasicPortAllocatorSession::PruneTurnPorts(Port* newly_pairable_turn_port) {}

void BasicPortAllocatorSession::PruneAllPorts() {}

void BasicPortAllocatorSession::OnPortComplete(Port* port) {}

void BasicPortAllocatorSession::OnPortError(Port* port) {}

bool BasicPortAllocatorSession::CheckCandidateFilter(const Candidate& c) const {}

bool BasicPortAllocatorSession::CandidatePairable(const Candidate& c,
                                                  const Port* port) const {}

void BasicPortAllocatorSession::OnPortAllocationComplete() {}

void BasicPortAllocatorSession::MaybeSignalCandidatesAllocationDone() {}

void BasicPortAllocatorSession::OnPortDestroyed(PortInterface* port) {}

BasicPortAllocatorSession::PortData* BasicPortAllocatorSession::FindPort(
    Port* port) {}

std::vector<BasicPortAllocatorSession::PortData*>
BasicPortAllocatorSession::GetUnprunedPorts(
    const std::vector<const rtc::Network*>& networks) {}

void BasicPortAllocatorSession::PrunePortsAndRemoveCandidates(
    const std::vector<PortData*>& port_data_list) {}

void BasicPortAllocator::SetVpnList(
    const std::vector<rtc::NetworkMask>& vpn_list) {}

// AllocationSequence

AllocationSequence::AllocationSequence(
    BasicPortAllocatorSession* session,
    const rtc::Network* network,
    PortConfiguration* config,
    uint32_t flags,
    std::function<void()> port_allocation_complete_callback)
    :{}

void AllocationSequence::Init() {}

void AllocationSequence::Clear() {}

void AllocationSequence::OnNetworkFailed() {}

void AllocationSequence::DisableEquivalentPhases(const rtc::Network* network,
                                                 PortConfiguration* config,
                                                 uint32_t* flags) {}

void AllocationSequence::Start() {}

void AllocationSequence::Stop() {}

void AllocationSequence::Process(int epoch) {}

void AllocationSequence::CreateUDPPorts() {}

void AllocationSequence::CreateTCPPorts() {}

void AllocationSequence::CreateStunPorts() {}

void AllocationSequence::CreateRelayPorts() {}

void AllocationSequence::CreateTurnPort(const RelayServerConfig& config,
                                        int relative_priority) {}

void AllocationSequence::OnReadPacket(rtc::AsyncPacketSocket* socket,
                                      const rtc::ReceivedPacket& packet) {}

void AllocationSequence::OnPortDestroyed(PortInterface* port) {}

PortConfiguration::PortConfiguration(
    const ServerAddresses& stun_servers,
    absl::string_view username,
    absl::string_view password,
    const webrtc::FieldTrialsView* field_trials)
    :{}

ServerAddresses PortConfiguration::StunServers() {}

void PortConfiguration::AddRelay(const RelayServerConfig& config) {}

bool PortConfiguration::SupportsProtocol(const RelayServerConfig& relay,
                                         ProtocolType type) const {}

bool PortConfiguration::SupportsProtocol(ProtocolType type) const {}

ServerAddresses PortConfiguration::GetRelayServerAddresses(
    ProtocolType type) const {}

}  // namespace cricket