diff options
Diffstat (limited to 'third_party/libwebrtc/p2p/base/port.h')
-rw-r--r-- | third_party/libwebrtc/p2p/base/port.h | 81 |
1 files changed, 40 insertions, 41 deletions
diff --git a/third_party/libwebrtc/p2p/base/port.h b/third_party/libwebrtc/p2p/base/port.h index 7b44e534de..a3214af1b8 100644 --- a/third_party/libwebrtc/p2p/base/port.h +++ b/third_party/libwebrtc/p2p/base/port.h @@ -11,10 +11,15 @@ #ifndef P2P_BASE_PORT_H_ #define P2P_BASE_PORT_H_ +#include <stddef.h> +#include <stdint.h> + +#include <functional> #include <map> #include <memory> #include <set> #include <string> +#include <type_traits> #include <utility> #include <vector> @@ -25,6 +30,7 @@ #include "api/field_trials_view.h" #include "api/packet_socket_factory.h" #include "api/rtc_error.h" +#include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" #include "api/transport/field_trial_based_config.h" #include "api/transport/stun.h" @@ -37,18 +43,22 @@ #include "p2p/base/p2p_constants.h" #include "p2p/base/port_interface.h" #include "p2p/base/stun_request.h" +#include "p2p/base/transport_description.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/callback_list.h" #include "rtc_base/checks.h" +#include "rtc_base/dscp.h" #include "rtc_base/memory/always_valid_pointer.h" #include "rtc_base/net_helper.h" #include "rtc_base/network.h" #include "rtc_base/network/received_packet.h" +#include "rtc_base/network/sent_packet.h" #include "rtc_base/proxy_info.h" #include "rtc_base/rate_tracker.h" #include "rtc_base/socket_address.h" #include "rtc_base/system/rtc_export.h" #include "rtc_base/third_party/sigslot/sigslot.h" +#include "rtc_base/thread_annotations.h" #include "rtc_base/weak_ptr.h" namespace cricket { @@ -59,19 +69,6 @@ extern const char TCPTYPE_ACTIVE_STR[]; extern const char TCPTYPE_PASSIVE_STR[]; extern const char TCPTYPE_SIMOPEN_STR[]; -// The type preference MUST be an integer from 0 to 126 inclusive. -// https://datatracker.ietf.org/doc/html/rfc5245#section-4.1.2.1 -enum IcePriorityValue : uint8_t { - ICE_TYPE_PREFERENCE_RELAY_TLS = 0, - ICE_TYPE_PREFERENCE_RELAY_TCP = 1, - ICE_TYPE_PREFERENCE_RELAY_UDP = 2, - ICE_TYPE_PREFERENCE_PRFLX_TCP = 80, - ICE_TYPE_PREFERENCE_HOST_TCP = 90, - ICE_TYPE_PREFERENCE_SRFLX = 100, - ICE_TYPE_PREFERENCE_PRFLX = 110, - ICE_TYPE_PREFERENCE_HOST = 126 -}; - enum class MdnsNameRegistrationStatus { // IP concealment with mDNS is not enabled or the name registration process is // not started yet. @@ -202,8 +199,8 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { // Note that the port type does NOT uniquely identify different subclasses of // Port. Use the 2-tuple of the port type AND the protocol (GetProtocol()) to // uniquely identify subclasses. Whenever a new subclass of Port introduces a - // conflit in the value of the 2-tuple, make sure that the implementation that - // relies on this 2-tuple for RTTI is properly changed. + // conflict in the value of the 2-tuple, make sure that the implementation + // that relies on this 2-tuple for RTTI is properly changed. const absl::string_view Type() const override; const rtc::Network* Network() const override; @@ -227,13 +224,13 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { void CancelPendingTasks(); // The thread on which this port performs its I/O. - webrtc::TaskQueueBase* thread() { return thread_; } + webrtc::TaskQueueBase* thread() override { return thread_; } // The factory used to create the sockets of this port. - rtc::PacketSocketFactory* socket_factory() const { return factory_; } + rtc::PacketSocketFactory* socket_factory() const override { return factory_; } // For debugging purposes. - const std::string& content_name() const { return content_name_; } + const std::string& content_name() const override { return content_name_; } void set_content_name(absl::string_view content_name) { content_name_ = std::string(content_name); } @@ -241,7 +238,7 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { int component() const { return component_; } void set_component(int component) { component_ = component; } - bool send_retransmit_count_attribute() const { + bool send_retransmit_count_attribute() const override { return send_retransmit_count_attribute_; } void set_send_retransmit_count_attribute(bool enable) { @@ -249,8 +246,10 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { } // Identifies the generation that this port was created in. - uint32_t generation() const { return generation_; } - void set_generation(uint32_t generation) { generation_ = generation; } + uint32_t generation() const override { return generation_; } + void set_generation(uint32_t generation) override { + generation_ = generation; + } const std::string& username_fragment() const; const std::string& password() const { return password_; } @@ -296,11 +295,11 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { // defers the `delete` operation to when the call stack has been unwound. // Async may be needed when deleting a connection object from within a // callback. - void DestroyConnection(Connection* conn) { + void DestroyConnection(Connection* conn) override { DestroyConnectionInternal(conn, false); } - void DestroyConnectionAsync(Connection* conn) { + void DestroyConnectionAsync(Connection* conn) override { DestroyConnectionInternal(conn, true); } @@ -330,8 +329,8 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { user_agent_ = std::string(user_agent); proxy_ = proxy; } - const std::string& user_agent() { return user_agent_; } - const rtc::ProxyInfo& proxy() { return proxy_; } + const std::string& user_agent() override { return user_agent_; } + const rtc::ProxyInfo& proxy() override { return proxy_; } void EnablePortPackets() override; @@ -350,12 +349,13 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { // stun username attribute if present. bool ParseStunUsername(const StunMessage* stun_msg, std::string* local_username, - std::string* remote_username) const; - std::string CreateStunUsername(absl::string_view remote_username) const; + std::string* remote_username) const override; + std::string CreateStunUsername( + absl::string_view remote_username) const override; bool MaybeIceRoleConflict(const rtc::SocketAddress& addr, IceMessage* stun_msg, - absl::string_view remote_ufrag); + absl::string_view remote_ufrag) override; // Called when a packet has been sent to the socket. // This is made pure virtual to notify subclasses of Port that they MUST @@ -368,9 +368,9 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { void OnReadyToSend(); // Called when the Connection discovers a local peer reflexive candidate. - void AddPrflxCandidate(const Candidate& local); + void AddPrflxCandidate(const Candidate& local) override; - int16_t network_cost() const { return network_cost_; } + int16_t network_cost() const override { return network_cost_; } void GetStunStats(absl::optional<StunStats>* stats) override {} @@ -380,13 +380,14 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { // then the foundation will be different. Two candidate pairs with // the same foundation pairs are likely to have similar network // characteristics. Foundations are used in the frozen algorithm. - std::string ComputeFoundation(absl::string_view type, - absl::string_view protocol, - absl::string_view relay_protocol, - const rtc::SocketAddress& base_address); + std::string ComputeFoundation( + absl::string_view type, + absl::string_view protocol, + absl::string_view relay_protocol, + const rtc::SocketAddress& base_address) override; protected: - virtual void UpdateNetworkCost(); + void UpdateNetworkCost() override; rtc::WeakPtr<Port> NewWeakPtr() { return weak_factory_.GetWeakPtr(); } @@ -438,13 +439,13 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { size_t size, const rtc::SocketAddress& addr, std::unique_ptr<IceMessage>* out_msg, - std::string* out_username); + std::string* out_username) override; // Checks if the address in addr is compatible with the port's ip. bool IsCompatibleAddress(const rtc::SocketAddress& addr); // Returns DSCP value packets generated by the port itself should use. - virtual rtc::DiffServCodePoint StunDscpValue() const; + rtc::DiffServCodePoint StunDscpValue() const override; // Extra work to be done in subclasses when a connection is destroyed. virtual void HandleConnectionDestroyed(Connection* conn) {} @@ -524,11 +525,9 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { webrtc::FieldTrialBasedConfig> field_trials_; - bool MaybeObfuscateAddress(Candidate* c, - absl::string_view type, - bool is_final) RTC_RUN_ON(thread_); + bool MaybeObfuscateAddress(const Candidate& c, bool is_final) + RTC_RUN_ON(thread_); - friend class Connection; webrtc::CallbackList<PortInterface*> port_destroyed_callback_list_; }; |