#include "p2p/base/port.h"
#include <cstddef>
#include <cstdint>
#include <memory>
#include <utility>
#include <vector>
#include "absl/memory/memory.h"
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "api/array_view.h"
#include "api/rtc_error.h"
#include "api/units/time_delta.h"
#include "p2p/base/p2p_constants.h"
#include "p2p/base/stun_request.h"
#include "rtc_base/byte_buffer.h"
#include "rtc_base/checks.h"
#include "rtc_base/crypto_random.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/mdns_responder_interface.h"
#include "rtc_base/net_helper.h"
#include "rtc_base/network.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/string_encode.h"
#include "rtc_base/string_utils.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/time_utils.h"
#include "rtc_base/trace_event.h"
IceCandidateType;
namespace cricket {
namespace {
IceCandidateType;
RTCError;
RTCErrorType;
TaskQueueBase;
TimeDelta;
rtc::PacketInfoProtocolType ConvertProtocolTypeToPacketInfoProtocolType(
cricket::ProtocolType type) { … }
const int kPortTimeoutDelay = …;
}
static const char* const PROTO_NAMES[] = …;
const char* ProtoToString(ProtocolType proto) { … }
absl::optional<ProtocolType> StringToProto(absl::string_view proto_name) { … }
const int DISCARD_PORT = …;
const char TCPTYPE_ACTIVE_STR[] = …;
const char TCPTYPE_PASSIVE_STR[] = …;
const char TCPTYPE_SIMOPEN_STR[] = …;
Port::Port(const PortParametersRef& args, webrtc::IceCandidateType type)
: … { … }
Port::Port(const PortParametersRef& args,
webrtc::IceCandidateType type,
uint16_t min_port,
uint16_t max_port,
bool shared_socket )
: … { … }
Port::~Port() { … }
IceCandidateType Port::Type() const { … }
const rtc::Network* Port::Network() const { … }
IceRole Port::GetIceRole() const { … }
void Port::SetIceRole(IceRole role) { … }
void Port::SetIceTiebreaker(uint64_t tiebreaker) { … }
uint64_t Port::IceTiebreaker() const { … }
bool Port::SharedSocket() const { … }
void Port::SetIceParameters(int component,
absl::string_view username_fragment,
absl::string_view password) { … }
const std::vector<Candidate>& Port::Candidates() const { … }
Connection* Port::GetConnection(const rtc::SocketAddress& remote_addr) { … }
void Port::AddAddress(const rtc::SocketAddress& address,
const rtc::SocketAddress& base_address,
const rtc::SocketAddress& related_address,
absl::string_view protocol,
absl::string_view relay_protocol,
absl::string_view tcptype,
IceCandidateType type,
uint32_t type_preference,
uint32_t relay_preference,
absl::string_view url,
bool is_final) { … }
bool Port::MaybeObfuscateAddress(const Candidate& c, bool is_final) { … }
void Port::FinishAddingAddress(const Candidate& c, bool is_final) { … }
void Port::PostAddAddress(bool is_final) { … }
void Port::AddOrReplaceConnection(Connection* conn) { … }
void Port::OnReadPacket(const rtc::ReceivedPacket& packet, ProtocolType proto) { … }
void Port::OnReadyToSend() { … }
void Port::AddPrflxCandidate(const Candidate& local) { … }
bool Port::GetStunMessage(const char* data,
size_t size,
const rtc::SocketAddress& addr,
std::unique_ptr<IceMessage>* out_msg,
std::string* out_username) { … }
bool Port::IsCompatibleAddress(const rtc::SocketAddress& addr) { … }
rtc::DiffServCodePoint Port::StunDscpValue() const { … }
void Port::DestroyAllConnections() { … }
void Port::set_timeout_delay(int delay) { … }
bool Port::ParseStunUsername(const StunMessage* stun_msg,
std::string* local_ufrag,
std::string* remote_ufrag) const { … }
bool Port::MaybeIceRoleConflict(const rtc::SocketAddress& addr,
IceMessage* stun_msg,
absl::string_view remote_ufrag) { … }
std::string Port::CreateStunUsername(absl::string_view remote_username) const { … }
bool Port::HandleIncomingPacket(rtc::AsyncPacketSocket* socket,
const rtc::ReceivedPacket& packet) { … }
bool Port::CanHandleIncomingPacketsFrom(const rtc::SocketAddress&) const { … }
void Port::SendBindingErrorResponse(StunMessage* message,
const rtc::SocketAddress& addr,
int error_code,
absl::string_view reason) { … }
void Port::SendUnknownAttributesErrorResponse(
StunMessage* message,
const rtc::SocketAddress& addr,
const std::vector<uint16_t>& unknown_types) { … }
void Port::KeepAliveUntilPruned() { … }
void Port::Prune() { … }
void Port::CancelPendingTasks() { … }
void Port::PostDestroyIfDead(bool delayed) { … }
void Port::DestroyIfDead() { … }
void Port::SubscribePortDestroyed(
std::function<void(PortInterface*)> callback) { … }
void Port::SendPortDestroyed(Port* port) { … }
void Port::OnNetworkTypeChanged(const rtc::Network* network) { … }
std::string Port::ToString() const { … }
void Port::UpdateNetworkCost() { … }
void Port::EnablePortPackets() { … }
bool Port::OnConnectionDestroyed(Connection* conn) { … }
void Port::DestroyConnectionInternal(Connection* conn, bool async) { … }
void Port::Destroy() { … }
const std::string& Port::username_fragment() const { … }
void Port::CopyPortInformationToPacketInfo(rtc::PacketInfo* info) const { … }
}