OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 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 20 matching lines...) Expand all Loading... |
31 extern const char TURN_PORT_TYPE[]; | 31 extern const char TURN_PORT_TYPE[]; |
32 class TurnAllocateRequest; | 32 class TurnAllocateRequest; |
33 class TurnEntry; | 33 class TurnEntry; |
34 | 34 |
35 class TurnPort : public Port { | 35 class TurnPort : public Port { |
36 public: | 36 public: |
37 enum PortState { | 37 enum PortState { |
38 STATE_CONNECTING, // Initial state, cannot send any packets. | 38 STATE_CONNECTING, // Initial state, cannot send any packets. |
39 STATE_CONNECTED, // Socket connected, ready to send stun requests. | 39 STATE_CONNECTED, // Socket connected, ready to send stun requests. |
40 STATE_READY, // Received allocate success, can send any packets. | 40 STATE_READY, // Received allocate success, can send any packets. |
41 STATE_DISCONNECTED, // TCP connection died, cannot send any packets. | 41 STATE_RECEIVEONLY, // Had REFRESH_REQUEST error, cannot send any packets. |
| 42 STATE_DISCONNECTED, // TCP connection died, cannot send/receive any |
| 43 // packets. |
42 }; | 44 }; |
43 static TurnPort* Create(rtc::Thread* thread, | 45 static TurnPort* Create(rtc::Thread* thread, |
44 rtc::PacketSocketFactory* factory, | 46 rtc::PacketSocketFactory* factory, |
45 rtc::Network* network, | 47 rtc::Network* network, |
46 rtc::AsyncPacketSocket* socket, | 48 rtc::AsyncPacketSocket* socket, |
47 const std::string& username, // ice username. | 49 const std::string& username, // ice username. |
48 const std::string& password, // ice password. | 50 const std::string& password, // ice password. |
49 const ProtocolAddress& server_address, | 51 const ProtocolAddress& server_address, |
50 const RelayCredentials& credentials, | 52 const RelayCredentials& credentials, |
51 int server_priority, | 53 int server_priority, |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 bool CreateTurnClientSocket(); | 197 bool CreateTurnClientSocket(); |
196 | 198 |
197 void set_nonce(const std::string& nonce) { nonce_ = nonce; } | 199 void set_nonce(const std::string& nonce) { nonce_ = nonce; } |
198 void set_realm(const std::string& realm) { | 200 void set_realm(const std::string& realm) { |
199 if (realm != realm_) { | 201 if (realm != realm_) { |
200 realm_ = realm; | 202 realm_ = realm; |
201 UpdateHash(); | 203 UpdateHash(); |
202 } | 204 } |
203 } | 205 } |
204 | 206 |
205 void OnTurnRefreshError(); | 207 void OnRefreshError(); |
| 208 void HandleRefreshError(); |
206 bool SetAlternateServer(const rtc::SocketAddress& address); | 209 bool SetAlternateServer(const rtc::SocketAddress& address); |
207 void ResolveTurnAddress(const rtc::SocketAddress& address); | 210 void ResolveTurnAddress(const rtc::SocketAddress& address); |
208 void OnResolveResult(rtc::AsyncResolverInterface* resolver); | 211 void OnResolveResult(rtc::AsyncResolverInterface* resolver); |
209 | 212 |
210 void AddRequestAuthInfo(StunMessage* msg); | 213 void AddRequestAuthInfo(StunMessage* msg); |
211 void OnSendStunPacket(const void* data, size_t size, StunRequest* request); | 214 void OnSendStunPacket(const void* data, size_t size, StunRequest* request); |
212 // Stun address from allocate success response. | 215 // Stun address from allocate success response. |
213 // Currently used only for testing. | 216 // Currently used only for testing. |
214 void OnStunAddress(const rtc::SocketAddress& address); | 217 void OnStunAddress(const rtc::SocketAddress& address); |
215 void OnAllocateSuccess(const rtc::SocketAddress& address, | 218 void OnAllocateSuccess(const rtc::SocketAddress& address, |
(...skipping 22 matching lines...) Expand all Loading... |
238 TurnEntry* FindEntry(int channel_id) const; | 241 TurnEntry* FindEntry(int channel_id) const; |
239 bool EntryExists(TurnEntry* e); | 242 bool EntryExists(TurnEntry* e); |
240 void CreateOrRefreshEntry(const rtc::SocketAddress& address); | 243 void CreateOrRefreshEntry(const rtc::SocketAddress& address); |
241 void DestroyEntry(TurnEntry* entry); | 244 void DestroyEntry(TurnEntry* entry); |
242 // Destroys the entry only if |timestamp| matches the destruction timestamp | 245 // Destroys the entry only if |timestamp| matches the destruction timestamp |
243 // in |entry|. | 246 // in |entry|. |
244 void DestroyEntryIfNotCancelled(TurnEntry* entry, int64_t timestamp); | 247 void DestroyEntryIfNotCancelled(TurnEntry* entry, int64_t timestamp); |
245 void ScheduleEntryDestruction(TurnEntry* entry); | 248 void ScheduleEntryDestruction(TurnEntry* entry); |
246 void CancelEntryDestruction(TurnEntry* entry); | 249 void CancelEntryDestruction(TurnEntry* entry); |
247 | 250 |
248 // Destroys the connection with remote address |address|. Returns true if | 251 // Marks the connection with remote address |address| failed and |
249 // a connection is found and destroyed. | 252 // pruned (a.k.a. write-timed-out). Returns true if a connection is found. |
250 bool DestroyConnection(const rtc::SocketAddress& address); | 253 bool FailAndPruneConnection(const rtc::SocketAddress& address); |
251 | 254 |
252 ProtocolAddress server_address_; | 255 ProtocolAddress server_address_; |
253 RelayCredentials credentials_; | 256 RelayCredentials credentials_; |
254 AttemptedServerSet attempted_server_addresses_; | 257 AttemptedServerSet attempted_server_addresses_; |
255 | 258 |
256 rtc::AsyncPacketSocket* socket_; | 259 rtc::AsyncPacketSocket* socket_; |
257 SocketOptionsMap socket_options_; | 260 SocketOptionsMap socket_options_; |
258 rtc::AsyncResolverInterface* resolver_; | 261 rtc::AsyncResolverInterface* resolver_; |
259 int error_; | 262 int error_; |
260 | 263 |
(...skipping 18 matching lines...) Expand all Loading... |
279 friend class TurnEntry; | 282 friend class TurnEntry; |
280 friend class TurnAllocateRequest; | 283 friend class TurnAllocateRequest; |
281 friend class TurnRefreshRequest; | 284 friend class TurnRefreshRequest; |
282 friend class TurnCreatePermissionRequest; | 285 friend class TurnCreatePermissionRequest; |
283 friend class TurnChannelBindRequest; | 286 friend class TurnChannelBindRequest; |
284 }; | 287 }; |
285 | 288 |
286 } // namespace cricket | 289 } // namespace cricket |
287 | 290 |
288 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ | 291 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ |
OLD | NEW |