OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 // Set to kDefaultNetworkIgnoreMask by default. | 40 // Set to kDefaultNetworkIgnoreMask by default. |
41 void SetNetworkIgnoreMask(int network_ignore_mask) override { | 41 void SetNetworkIgnoreMask(int network_ignore_mask) override { |
42 // TODO(phoglund): implement support for other types than loopback. | 42 // TODO(phoglund): implement support for other types than loopback. |
43 // See https://code.google.com/p/webrtc/issues/detail?id=4288. | 43 // See https://code.google.com/p/webrtc/issues/detail?id=4288. |
44 // Then remove set_network_ignore_list from NetworkManager. | 44 // Then remove set_network_ignore_list from NetworkManager. |
45 network_ignore_mask_ = network_ignore_mask; | 45 network_ignore_mask_ = network_ignore_mask; |
46 } | 46 } |
47 | 47 |
48 int network_ignore_mask() const { return network_ignore_mask_; } | 48 int network_ignore_mask() const { return network_ignore_mask_; } |
49 | 49 |
50 rtc::NetworkManager* network_manager() { return network_manager_; } | 50 rtc::NetworkManager* network_manager() const { return network_manager_; } |
51 | 51 |
52 // If socket_factory() is set to NULL each PortAllocatorSession | 52 // If socket_factory() is set to NULL each PortAllocatorSession |
53 // creates its own socket factory. | 53 // creates its own socket factory. |
54 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } | 54 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } |
55 | 55 |
56 PortAllocatorSession* CreateSessionInternal( | 56 PortAllocatorSession* CreateSessionInternal( |
57 const std::string& content_name, | 57 const std::string& content_name, |
58 int component, | 58 int component, |
59 const std::string& ice_ufrag, | 59 const std::string& ice_ufrag, |
60 const std::string& ice_pwd) override; | 60 const std::string& ice_pwd) override; |
(...skipping 29 matching lines...) Expand all Loading... |
90 | 90 |
91 void SetCandidateFilter(uint32_t filter) override; | 91 void SetCandidateFilter(uint32_t filter) override; |
92 void StartGettingPorts() override; | 92 void StartGettingPorts() override; |
93 void StopGettingPorts() override; | 93 void StopGettingPorts() override; |
94 void ClearGettingPorts() override; | 94 void ClearGettingPorts() override; |
95 bool IsGettingPorts() override { return running_; } | 95 bool IsGettingPorts() override { return running_; } |
96 // These will all be cricket::Ports. | 96 // These will all be cricket::Ports. |
97 std::vector<PortInterface*> ReadyPorts() const override; | 97 std::vector<PortInterface*> ReadyPorts() const override; |
98 std::vector<Candidate> ReadyCandidates() const override; | 98 std::vector<Candidate> ReadyCandidates() const override; |
99 bool CandidatesAllocationDone() const override; | 99 bool CandidatesAllocationDone() const override; |
| 100 void RegatherOnFailedNetworks() override; |
100 | 101 |
101 protected: | 102 protected: |
102 void UpdateIceParametersInternal() override; | 103 void UpdateIceParametersInternal() override; |
103 | 104 |
104 // Starts the process of getting the port configurations. | 105 // Starts the process of getting the port configurations. |
105 virtual void GetPortConfigurations(); | 106 virtual void GetPortConfigurations(); |
106 | 107 |
107 // Adds a port configuration that is now ready. Once we have one for each | 108 // Adds a port configuration that is now ready. Once we have one for each |
108 // network (or a timeout occurs), we will start allocating ports. | 109 // network (or a timeout occurs), we will start allocating ports. |
109 virtual void ConfigReady(PortConfiguration* config); | 110 virtual void ConfigReady(PortConfiguration* config); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 void AddAllocatedPort(Port* port, AllocationSequence* seq, | 164 void AddAllocatedPort(Port* port, AllocationSequence* seq, |
164 bool prepare_address); | 165 bool prepare_address); |
165 void OnCandidateReady(Port* port, const Candidate& c); | 166 void OnCandidateReady(Port* port, const Candidate& c); |
166 void OnPortComplete(Port* port); | 167 void OnPortComplete(Port* port); |
167 void OnPortError(Port* port); | 168 void OnPortError(Port* port); |
168 void OnProtocolEnabled(AllocationSequence* seq, ProtocolType proto); | 169 void OnProtocolEnabled(AllocationSequence* seq, ProtocolType proto); |
169 void OnPortDestroyed(PortInterface* port); | 170 void OnPortDestroyed(PortInterface* port); |
170 void MaybeSignalCandidatesAllocationDone(); | 171 void MaybeSignalCandidatesAllocationDone(); |
171 void OnPortAllocationComplete(AllocationSequence* seq); | 172 void OnPortAllocationComplete(AllocationSequence* seq); |
172 PortData* FindPort(Port* port); | 173 PortData* FindPort(Port* port); |
173 void GetNetworks(std::vector<rtc::Network*>* networks); | 174 std::vector<rtc::Network*> GetNetworks(); |
| 175 std::vector<rtc::Network*> GetFailedNetworks(); |
174 | 176 |
175 bool CheckCandidateFilter(const Candidate& c) const; | 177 bool CheckCandidateFilter(const Candidate& c) const; |
176 bool CandidatePairable(const Candidate& c, const Port* port) const; | 178 bool CandidatePairable(const Candidate& c, const Port* port) const; |
177 // Clear the related address according to the flags and candidate filter | 179 // Clear the related address according to the flags and candidate filter |
178 // in order to avoid leaking any information. | 180 // in order to avoid leaking any information. |
179 Candidate SanitizeRelatedAddress(const Candidate& c) const; | 181 Candidate SanitizeRelatedAddress(const Candidate& c) const; |
180 | 182 |
| 183 // Removes the ports and candidates on given networks. |
| 184 void RemovePortsAndCandidates(const std::vector<rtc::Network*>& networks); |
| 185 // Gets filtered and sanitized candidates generated from a port and |
| 186 // append to |candidates|. |
| 187 void GetCandidatesFromPort(const PortData& data, |
| 188 std::vector<Candidate>* candidates) const; |
| 189 |
181 BasicPortAllocator* allocator_; | 190 BasicPortAllocator* allocator_; |
182 rtc::Thread* network_thread_; | 191 rtc::Thread* network_thread_; |
183 std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_; | 192 std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_; |
184 rtc::PacketSocketFactory* socket_factory_; | 193 rtc::PacketSocketFactory* socket_factory_; |
185 bool allocation_started_; | 194 bool allocation_started_; |
186 bool network_manager_started_; | 195 bool network_manager_started_; |
187 bool running_; // set when StartGetAllPorts is called | 196 bool running_; // set when StartGetAllPorts is called |
188 bool allocation_sequences_created_; | 197 bool allocation_sequences_created_; |
189 std::vector<PortConfiguration*> configs_; | 198 std::vector<PortConfiguration*> configs_; |
190 std::vector<AllocationSequence*> sequences_; | 199 std::vector<AllocationSequence*> sequences_; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 257 |
249 // kInit --> kRunning --> {kCompleted|kStopped} | 258 // kInit --> kRunning --> {kCompleted|kStopped} |
250 }; | 259 }; |
251 AllocationSequence(BasicPortAllocatorSession* session, | 260 AllocationSequence(BasicPortAllocatorSession* session, |
252 rtc::Network* network, | 261 rtc::Network* network, |
253 PortConfiguration* config, | 262 PortConfiguration* config, |
254 uint32_t flags); | 263 uint32_t flags); |
255 ~AllocationSequence(); | 264 ~AllocationSequence(); |
256 bool Init(); | 265 bool Init(); |
257 void Clear(); | 266 void Clear(); |
258 void OnNetworkRemoved(); | 267 void OnNetworkFailed(); |
259 | 268 |
260 State state() const { return state_; } | 269 State state() const { return state_; } |
261 const rtc::Network* network() const { return network_; } | 270 rtc::Network* network() const { return network_; } |
262 bool network_removed() const { return network_removed_; } | 271 |
| 272 bool network_failed() const { return network_failed_; } |
| 273 void set_network_failed() { network_failed_ = true; } |
263 | 274 |
264 // Disables the phases for a new sequence that this one already covers for an | 275 // Disables the phases for a new sequence that this one already covers for an |
265 // equivalent network setup. | 276 // equivalent network setup. |
266 void DisableEquivalentPhases(rtc::Network* network, | 277 void DisableEquivalentPhases(rtc::Network* network, |
267 PortConfiguration* config, | 278 PortConfiguration* config, |
268 uint32_t* flags); | 279 uint32_t* flags); |
269 | 280 |
270 // Starts and stops the sequence. When started, it will continue allocating | 281 // Starts and stops the sequence. When started, it will continue allocating |
271 // new ports on its own timed schedule. | 282 // new ports on its own timed schedule. |
272 void Start(); | 283 void Start(); |
(...skipping 29 matching lines...) Expand all Loading... |
302 | 313 |
303 void OnReadPacket(rtc::AsyncPacketSocket* socket, | 314 void OnReadPacket(rtc::AsyncPacketSocket* socket, |
304 const char* data, | 315 const char* data, |
305 size_t size, | 316 size_t size, |
306 const rtc::SocketAddress& remote_addr, | 317 const rtc::SocketAddress& remote_addr, |
307 const rtc::PacketTime& packet_time); | 318 const rtc::PacketTime& packet_time); |
308 | 319 |
309 void OnPortDestroyed(PortInterface* port); | 320 void OnPortDestroyed(PortInterface* port); |
310 | 321 |
311 BasicPortAllocatorSession* session_; | 322 BasicPortAllocatorSession* session_; |
312 bool network_removed_ = false; | 323 bool network_failed_ = false; |
313 rtc::Network* network_; | 324 rtc::Network* network_; |
314 rtc::IPAddress ip_; | 325 rtc::IPAddress ip_; |
315 PortConfiguration* config_; | 326 PortConfiguration* config_; |
316 State state_; | 327 State state_; |
317 uint32_t flags_; | 328 uint32_t flags_; |
318 ProtocolList protocols_; | 329 ProtocolList protocols_; |
319 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_; | 330 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_; |
320 // There will be only one udp port per AllocationSequence. | 331 // There will be only one udp port per AllocationSequence. |
321 UDPPort* udp_port_; | 332 UDPPort* udp_port_; |
322 std::vector<TurnPort*> turn_ports_; | 333 std::vector<TurnPort*> turn_ports_; |
323 int phase_; | 334 int phase_; |
324 }; | 335 }; |
325 | 336 |
326 } // namespace cricket | 337 } // namespace cricket |
327 | 338 |
328 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ | 339 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ |
OLD | NEW |