henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | // P2PTransportChannel wraps up the state management of the connection between |
| 12 | // two P2P clients. Clients have candidate ports for connecting, and |
| 13 | // connections which are combinations of candidates from each end (Alice and |
| 14 | // Bob each have candidates, one candidate from Alice and one candidate from |
| 15 | // Bob are used to make a connection, repeat to make many connections). |
| 16 | // |
| 17 | // When all of the available connections become invalid (non-writable), we |
| 18 | // kick off a process of determining more candidates and more connections. |
| 19 | // |
| 20 | #ifndef WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
| 21 | #define WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
| 22 | |
| 23 | #include <map> |
guoweis | 36f0137 | 2016-03-02 18:02:40 -0800 | [diff] [blame] | 24 | #include <set> |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 25 | #include <string> |
| 26 | #include <vector> |
| 27 | #include "webrtc/p2p/base/candidate.h" |
| 28 | #include "webrtc/p2p/base/p2ptransport.h" |
| 29 | #include "webrtc/p2p/base/portallocator.h" |
| 30 | #include "webrtc/p2p/base/portinterface.h" |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 31 | #include "webrtc/p2p/base/transportchannelimpl.h" |
| 32 | #include "webrtc/base/asyncpacketsocket.h" |
| 33 | #include "webrtc/base/sigslot.h" |
| 34 | |
| 35 | namespace cricket { |
| 36 | |
Honghai Zhang | 049fbb1 | 2016-03-07 11:13:07 -0800 | [diff] [blame^] | 37 | extern const int WEAK_PING_INTERVAL; |
guoweis | b0bb77f | 2015-10-26 15:10:01 -0700 | [diff] [blame] | 38 | |
honghaiz | a54a080 | 2015-12-16 18:37:23 -0800 | [diff] [blame] | 39 | struct IceParameters { |
| 40 | std::string ufrag; |
| 41 | std::string pwd; |
| 42 | IceParameters(const std::string& ice_ufrag, const std::string& ice_pwd) |
| 43 | : ufrag(ice_ufrag), pwd(ice_pwd) {} |
| 44 | |
| 45 | bool operator==(const IceParameters& other) { |
| 46 | return ufrag == other.ufrag && pwd == other.pwd; |
| 47 | } |
| 48 | bool operator!=(const IceParameters& other) { return !(*this == other); } |
| 49 | }; |
| 50 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 51 | // Adds the port on which the candidate originated. |
| 52 | class RemoteCandidate : public Candidate { |
| 53 | public: |
| 54 | RemoteCandidate(const Candidate& c, PortInterface* origin_port) |
| 55 | : Candidate(c), origin_port_(origin_port) {} |
| 56 | |
| 57 | PortInterface* origin_port() { return origin_port_; } |
| 58 | |
| 59 | private: |
| 60 | PortInterface* origin_port_; |
| 61 | }; |
| 62 | |
| 63 | // P2PTransportChannel manages the candidates and connection process to keep |
| 64 | // two P2P clients connected to each other. |
| 65 | class P2PTransportChannel : public TransportChannelImpl, |
| 66 | public rtc::MessageHandler { |
| 67 | public: |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 68 | P2PTransportChannel(const std::string& transport_name, |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 69 | int component, |
mikescarlett | b9dd7c5 | 2016-02-19 20:43:45 -0800 | [diff] [blame] | 70 | PortAllocator* allocator); |
| 71 | // TODO(mikescarlett): Deprecated. Remove when Chromium's |
| 72 | // IceTransportChannel does not depend on this. |
| 73 | P2PTransportChannel(const std::string& transport_name, |
| 74 | int component, |
guidou | 74db777 | 2016-02-18 01:57:49 -0800 | [diff] [blame] | 75 | P2PTransport* transport, |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 76 | PortAllocator* allocator); |
| 77 | virtual ~P2PTransportChannel(); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 78 | |
| 79 | // From TransportChannelImpl: |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 80 | TransportChannelState GetState() const override; |
| 81 | void SetIceRole(IceRole role) override; |
| 82 | IceRole GetIceRole() const override { return ice_role_; } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 83 | void SetIceTiebreaker(uint64_t tiebreaker) override; |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 84 | void SetIceCredentials(const std::string& ice_ufrag, |
| 85 | const std::string& ice_pwd) override; |
| 86 | void SetRemoteIceCredentials(const std::string& ice_ufrag, |
| 87 | const std::string& ice_pwd) override; |
| 88 | void SetRemoteIceMode(IceMode mode) override; |
| 89 | void Connect() override; |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 90 | void MaybeStartGathering() override; |
| 91 | IceGatheringState gathering_state() const override { |
| 92 | return gathering_state_; |
| 93 | } |
| 94 | void AddRemoteCandidate(const Candidate& candidate) override; |
Honghai Zhang | 049fbb1 | 2016-03-07 11:13:07 -0800 | [diff] [blame^] | 95 | // Sets the parameters in IceConfig. We do not set them blindly. Instead, we |
| 96 | // only update the parameter if it is considered set in |config|. For example, |
| 97 | // a negative value of receiving_timeout will be considered "not set" and we |
| 98 | // will not use it to update the respective parameter in |config_|. |
honghaiz | 1f429e3 | 2015-09-28 07:57:34 -0700 | [diff] [blame] | 99 | void SetIceConfig(const IceConfig& config) override; |
guoweis | 36f0137 | 2016-03-02 18:02:40 -0800 | [diff] [blame] | 100 | const IceConfig& config() const; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 101 | |
| 102 | // From TransportChannel: |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 103 | int SendPacket(const char* data, |
| 104 | size_t len, |
| 105 | const rtc::PacketOptions& options, |
| 106 | int flags) override; |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 107 | int SetOption(rtc::Socket::Option opt, int value) override; |
| 108 | bool GetOption(rtc::Socket::Option opt, int* value) override; |
| 109 | int GetError() override { return error_; } |
| 110 | bool GetStats(std::vector<ConnectionInfo>* stats) override; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 111 | |
| 112 | const Connection* best_connection() const { return best_connection_; } |
| 113 | void set_incoming_only(bool value) { incoming_only_ = value; } |
| 114 | |
| 115 | // Note: This is only for testing purpose. |
| 116 | // |ports_| should not be changed from outside. |
Peter Thatcher | 1fe120a | 2015-06-10 11:33:17 -0700 | [diff] [blame] | 117 | const std::vector<PortInterface*>& ports() { return ports_; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 118 | |
| 119 | IceMode remote_ice_mode() const { return remote_ice_mode_; } |
| 120 | |
| 121 | // DTLS methods. |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 122 | bool IsDtlsActive() const override { return false; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 123 | |
| 124 | // Default implementation. |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 125 | bool GetSslRole(rtc::SSLRole* role) const override { return false; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 126 | |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 127 | bool SetSslRole(rtc::SSLRole role) override { return false; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 128 | |
| 129 | // Set up the ciphers to use for DTLS-SRTP. |
Guo-wei Shieh | 521ed7b | 2015-11-18 19:41:53 -0800 | [diff] [blame] | 130 | bool SetSrtpCryptoSuites(const std::vector<int>& ciphers) override { |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 131 | return false; |
| 132 | } |
| 133 | |
pthatcher@webrtc.org | 3ee4fe5 | 2015-02-11 22:34:36 +0000 | [diff] [blame] | 134 | // Find out which DTLS-SRTP cipher was negotiated. |
Guo-wei Shieh | 521ed7b | 2015-11-18 19:41:53 -0800 | [diff] [blame] | 135 | bool GetSrtpCryptoSuite(int* cipher) override { return false; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 136 | |
pthatcher@webrtc.org | 3ee4fe5 | 2015-02-11 22:34:36 +0000 | [diff] [blame] | 137 | // Find out which DTLS cipher was negotiated. |
Guo-wei Shieh | 6caafbe | 2015-10-05 12:43:27 -0700 | [diff] [blame] | 138 | bool GetSslCipherSuite(int* cipher) override { return false; } |
pthatcher@webrtc.org | 3ee4fe5 | 2015-02-11 22:34:36 +0000 | [diff] [blame] | 139 | |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 140 | // Returns null because the channel is not encrypted by default. |
| 141 | rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const override { |
| 142 | return nullptr; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 145 | bool GetRemoteSSLCertificate(rtc::SSLCertificate** cert) const override { |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 146 | return false; |
| 147 | } |
| 148 | |
| 149 | // Allows key material to be extracted for external encryption. |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 150 | bool ExportKeyingMaterial(const std::string& label, |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 151 | const uint8_t* context, |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 152 | size_t context_len, |
| 153 | bool use_context, |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 154 | uint8_t* result, |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 155 | size_t result_len) override { |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 156 | return false; |
| 157 | } |
| 158 | |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 159 | bool SetLocalCertificate( |
| 160 | const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override { |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 161 | return false; |
| 162 | } |
| 163 | |
| 164 | // Set DTLS Remote fingerprint. Must be after local identity set. |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 165 | bool SetRemoteFingerprint(const std::string& digest_alg, |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 166 | const uint8_t* digest, |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 167 | size_t digest_len) override { |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 168 | return false; |
| 169 | } |
| 170 | |
Honghai Zhang | 049fbb1 | 2016-03-07 11:13:07 -0800 | [diff] [blame^] | 171 | int receiving_timeout() const { return config_.receiving_timeout; } |
| 172 | int check_receiving_interval() const { return check_receiving_interval_; } |
Peter Thatcher | 5436051 | 2015-07-08 11:08:35 -0700 | [diff] [blame] | 173 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 174 | // Helper method used only in unittest. |
| 175 | rtc::DiffServCodePoint DefaultDscpValue() const; |
| 176 | |
Peter Thatcher | 7351f46 | 2015-04-02 16:39:16 -0700 | [diff] [blame] | 177 | // Public for unit tests. |
| 178 | Connection* FindNextPingableConnection(); |
guoweis | 36f0137 | 2016-03-02 18:02:40 -0800 | [diff] [blame] | 179 | void MarkConnectionPinged(Connection* conn); |
Peter Thatcher | 7351f46 | 2015-04-02 16:39:16 -0700 | [diff] [blame] | 180 | |
honghaiz | 77d0d6e | 2015-10-27 11:34:45 -0700 | [diff] [blame] | 181 | // Public for unit tests. |
| 182 | const std::vector<Connection*>& connections() const { return connections_; } |
| 183 | |
honghaiz | 9b66957 | 2015-11-04 12:07:44 -0800 | [diff] [blame] | 184 | // Public for unit tests. |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 185 | PortAllocatorSession* allocator_session() { |
| 186 | return allocator_sessions_.back(); |
| 187 | } |
| 188 | |
honghaiz | 112fe43 | 2015-12-30 13:32:47 -0800 | [diff] [blame] | 189 | // Public for unit tests. |
| 190 | const std::vector<RemoteCandidate>& remote_candidates() const { |
| 191 | return remote_candidates_; |
| 192 | } |
| 193 | |
honghaiz | 9b66957 | 2015-11-04 12:07:44 -0800 | [diff] [blame] | 194 | private: |
| 195 | rtc::Thread* thread() { return worker_thread_; } |
| 196 | bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); } |
| 197 | |
honghaiz | a58ea78 | 2015-09-24 08:13:36 -0700 | [diff] [blame] | 198 | // A transport channel is weak if the current best connection is either |
| 199 | // not receiving or not writable, or if there is no best connection at all. |
Honghai Zhang | 2b342bf | 2015-09-30 09:51:58 -0700 | [diff] [blame] | 200 | bool weak() const; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 201 | void UpdateConnectionStates(); |
| 202 | void RequestSort(); |
| 203 | void SortConnections(); |
| 204 | void SwitchBestConnectionTo(Connection* conn); |
Honghai Zhang | 381b421 | 2015-12-04 12:24:03 -0800 | [diff] [blame] | 205 | void UpdateState(); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 206 | void HandleAllTimedOut(); |
honghaiz | 9b66957 | 2015-11-04 12:07:44 -0800 | [diff] [blame] | 207 | void MaybeStopPortAllocatorSessions(); |
Honghai Zhang | 381b421 | 2015-12-04 12:24:03 -0800 | [diff] [blame] | 208 | TransportChannelState ComputeState() const; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 209 | |
guoweis@webrtc.org | 8c9ff20 | 2014-12-04 07:56:02 +0000 | [diff] [blame] | 210 | Connection* GetBestConnectionOnNetwork(rtc::Network* network) const; |
Peter Thatcher | 04ac81f | 2015-09-21 11:48:28 -0700 | [diff] [blame] | 211 | bool CreateConnections(const Candidate& remote_candidate, |
| 212 | PortInterface* origin_port); |
| 213 | bool CreateConnection(PortInterface* port, |
| 214 | const Candidate& remote_candidate, |
| 215 | PortInterface* origin_port); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 216 | bool FindConnection(cricket::Connection* connection) const; |
| 217 | |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 218 | uint32_t GetRemoteCandidateGeneration(const Candidate& candidate); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 219 | bool IsDuplicateRemoteCandidate(const Candidate& candidate); |
| 220 | void RememberRemoteCandidate(const Candidate& remote_candidate, |
| 221 | PortInterface* origin_port); |
Honghai Zhang | 381b421 | 2015-12-04 12:24:03 -0800 | [diff] [blame] | 222 | bool IsPingable(Connection* conn, uint32_t now); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 223 | void PingConnection(Connection* conn); |
| 224 | void AddAllocatorSession(PortAllocatorSession* session); |
| 225 | void AddConnection(Connection* connection); |
| 226 | |
| 227 | void OnPortReady(PortAllocatorSession *session, PortInterface* port); |
| 228 | void OnCandidatesReady(PortAllocatorSession *session, |
| 229 | const std::vector<Candidate>& candidates); |
| 230 | void OnCandidatesAllocationDone(PortAllocatorSession* session); |
| 231 | void OnUnknownAddress(PortInterface* port, |
| 232 | const rtc::SocketAddress& addr, |
| 233 | ProtocolType proto, |
| 234 | IceMessage* stun_msg, |
| 235 | const std::string& remote_username, |
| 236 | bool port_muxed); |
| 237 | void OnPortDestroyed(PortInterface* port); |
honghaiz | e3c6c82 | 2016-02-17 13:00:28 -0800 | [diff] [blame] | 238 | void OnPortNetworkInactive(PortInterface* port); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 239 | void OnRoleConflict(PortInterface* port); |
| 240 | |
| 241 | void OnConnectionStateChange(Connection* connection); |
| 242 | void OnReadPacket(Connection *connection, const char *data, size_t len, |
| 243 | const rtc::PacketTime& packet_time); |
Stefan Holmer | 55674ff | 2016-01-14 15:49:16 +0100 | [diff] [blame] | 244 | void OnSentPacket(const rtc::SentPacket& sent_packet); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 245 | void OnReadyToSend(Connection* connection); |
| 246 | void OnConnectionDestroyed(Connection *connection); |
| 247 | |
honghaiz | 5a3acd8 | 2015-08-20 15:53:17 -0700 | [diff] [blame] | 248 | void OnNominated(Connection* conn); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 249 | |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 250 | void OnMessage(rtc::Message* pmsg) override; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 251 | void OnSort(); |
honghaiz | a58ea78 | 2015-09-24 08:13:36 -0700 | [diff] [blame] | 252 | void OnCheckAndPing(); |
Peter Thatcher | 5436051 | 2015-07-08 11:08:35 -0700 | [diff] [blame] | 253 | |
honghaiz | 5a3acd8 | 2015-08-20 15:53:17 -0700 | [diff] [blame] | 254 | void PruneConnections(); |
| 255 | Connection* best_nominated_connection() const; |
Honghai Zhang | 381b421 | 2015-12-04 12:24:03 -0800 | [diff] [blame] | 256 | bool IsBackupConnection(Connection* conn) const; |
honghaiz | 5a3acd8 | 2015-08-20 15:53:17 -0700 | [diff] [blame] | 257 | |
guoweis | 36f0137 | 2016-03-02 18:02:40 -0800 | [diff] [blame] | 258 | Connection* FindConnectionToPing(uint32_t now); |
| 259 | Connection* FindOldestConnectionNeedingTriggeredCheck(uint32_t now); |
| 260 | // Between |conn1| and |conn2|, this function returns the one which should |
| 261 | // be pinged first. |
| 262 | Connection* SelectMostPingableConnection(Connection* conn1, |
| 263 | Connection* conn2); |
| 264 | // Select the connection which is Relay/Relay. If both of them are, |
| 265 | // UDP relay protocol takes precedence. |
| 266 | Connection* MostLikelyToWork(Connection* conn1, Connection* conn2); |
| 267 | // Compare the last_ping_sent time and return the one least recently pinged. |
| 268 | Connection* LeastRecentlyPinged(Connection* conn1, Connection* conn2); |
| 269 | |
honghaiz | a54a080 | 2015-12-16 18:37:23 -0800 | [diff] [blame] | 270 | // Returns the latest remote ICE parameters or nullptr if there are no remote |
| 271 | // ICE parameters yet. |
| 272 | IceParameters* remote_ice() { |
| 273 | return remote_ice_parameters_.empty() ? nullptr |
| 274 | : &remote_ice_parameters_.back(); |
| 275 | } |
honghaiz | 112fe43 | 2015-12-30 13:32:47 -0800 | [diff] [blame] | 276 | // Returns the remote IceParameters and generation that match |ufrag| |
| 277 | // if found, and returns nullptr otherwise. |
| 278 | const IceParameters* FindRemoteIceFromUfrag(const std::string& ufrag, |
| 279 | uint32_t* generation); |
honghaiz | a54a080 | 2015-12-16 18:37:23 -0800 | [diff] [blame] | 280 | // Returns the index of the latest remote ICE parameters, or 0 if no remote |
| 281 | // ICE parameters have been received. |
| 282 | uint32_t remote_ice_generation() { |
| 283 | return remote_ice_parameters_.empty() |
| 284 | ? 0 |
| 285 | : static_cast<uint32_t>(remote_ice_parameters_.size() - 1); |
| 286 | } |
| 287 | |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 288 | PortAllocator* allocator_; |
| 289 | rtc::Thread* worker_thread_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 290 | bool incoming_only_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 291 | int error_; |
| 292 | std::vector<PortAllocatorSession*> allocator_sessions_; |
| 293 | std::vector<PortInterface *> ports_; |
guoweis | 36f0137 | 2016-03-02 18:02:40 -0800 | [diff] [blame] | 294 | |
| 295 | // |connections_| is a sorted list with the first one always be the |
| 296 | // |best_connection_| when it's not nullptr. The combination of |
| 297 | // |pinged_connections_| and |unpinged_connections_| has the same |
| 298 | // connections as |connections_|. These 2 sets maintain whether a |
| 299 | // connection should be pinged next or not. |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 300 | std::vector<Connection *> connections_; |
guoweis | 36f0137 | 2016-03-02 18:02:40 -0800 | [diff] [blame] | 301 | std::set<Connection*> pinged_connections_; |
| 302 | std::set<Connection*> unpinged_connections_; |
| 303 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 304 | Connection* best_connection_; |
guoweis | 36f0137 | 2016-03-02 18:02:40 -0800 | [diff] [blame] | 305 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 306 | // Connection selected by the controlling agent. This should be used only |
| 307 | // at controlled side when protocol type is RFC5245. |
| 308 | Connection* pending_best_connection_; |
| 309 | std::vector<RemoteCandidate> remote_candidates_; |
| 310 | bool sort_dirty_; // indicates whether another sort is needed right now |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 311 | bool had_connection_ = false; // if connections_ has ever been nonempty |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 312 | typedef std::map<rtc::Socket::Option, int> OptionMap; |
| 313 | OptionMap options_; |
| 314 | std::string ice_ufrag_; |
| 315 | std::string ice_pwd_; |
honghaiz | a54a080 | 2015-12-16 18:37:23 -0800 | [diff] [blame] | 316 | std::vector<IceParameters> remote_ice_parameters_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 317 | IceMode remote_ice_mode_; |
| 318 | IceRole ice_role_; |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 319 | uint64_t tiebreaker_; |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 320 | IceGatheringState gathering_state_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 321 | |
Honghai Zhang | 049fbb1 | 2016-03-07 11:13:07 -0800 | [diff] [blame^] | 322 | int check_receiving_interval_; |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 323 | uint32_t last_ping_sent_ms_ = 0; |
Honghai Zhang | 049fbb1 | 2016-03-07 11:13:07 -0800 | [diff] [blame^] | 324 | int weak_ping_interval_ = WEAK_PING_INTERVAL; |
Honghai Zhang | 381b421 | 2015-12-04 12:24:03 -0800 | [diff] [blame] | 325 | TransportChannelState state_ = TransportChannelState::STATE_INIT; |
guoweis | 36f0137 | 2016-03-02 18:02:40 -0800 | [diff] [blame] | 326 | IceConfig config_; |
Peter Thatcher | 5436051 | 2015-07-08 11:08:35 -0700 | [diff] [blame] | 327 | |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 328 | RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 329 | }; |
| 330 | |
| 331 | } // namespace cricket |
| 332 | |
| 333 | #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |