Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: webrtc/p2p/base/turnport.h

Issue 1247573002: Fix a Turn TCP port issue. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/asynctcpsocket.cc ('k') | webrtc/p2p/base/turnport.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 } 26 }
27 27
28 namespace cricket { 28 namespace cricket {
29 29
30 extern const char TURN_PORT_TYPE[]; 30 extern const char TURN_PORT_TYPE[];
31 class TurnAllocateRequest; 31 class TurnAllocateRequest;
32 class TurnEntry; 32 class TurnEntry;
33 33
34 class TurnPort : public Port { 34 class TurnPort : public Port {
35 public: 35 public:
36 enum PortState {
37 STATE_CONNECTING, // Initial state, cannot send any packets.
38 STATE_CONNECTED, // Socket connected, ready to send stun requests.
39 STATE_READY, // Received allocate success, can send any packets.
40 STATE_DISCONNECTED, // TCP connection died, cannot send any packets.
41 };
36 static TurnPort* Create(rtc::Thread* thread, 42 static TurnPort* Create(rtc::Thread* thread,
37 rtc::PacketSocketFactory* factory, 43 rtc::PacketSocketFactory* factory,
38 rtc::Network* network, 44 rtc::Network* network,
39 rtc::AsyncPacketSocket* socket, 45 rtc::AsyncPacketSocket* socket,
40 const std::string& username, // ice username. 46 const std::string& username, // ice username.
41 const std::string& password, // ice password. 47 const std::string& password, // ice password.
42 const ProtocolAddress& server_address, 48 const ProtocolAddress& server_address,
43 const RelayCredentials& credentials, 49 const RelayCredentials& credentials,
44 int server_priority, 50 int server_priority,
45 const std::string& origin) { 51 const std::string& origin) {
(...skipping 17 matching lines...) Expand all
63 username, password, server_address, credentials, 69 username, password, server_address, credentials,
64 server_priority, origin); 70 server_priority, origin);
65 } 71 }
66 72
67 virtual ~TurnPort(); 73 virtual ~TurnPort();
68 74
69 const ProtocolAddress& server_address() const { return server_address_; } 75 const ProtocolAddress& server_address() const { return server_address_; }
70 // Returns an empty address if the local address has not been assigned. 76 // Returns an empty address if the local address has not been assigned.
71 rtc::SocketAddress GetLocalAddress() const; 77 rtc::SocketAddress GetLocalAddress() const;
72 78
73 bool connected() const { return connected_; } 79 bool ready() const { return state_ == STATE_READY; }
80 bool connected() const {
81 return state_ == STATE_READY || state_ == STATE_CONNECTED;
82 }
74 const RelayCredentials& credentials() const { return credentials_; } 83 const RelayCredentials& credentials() const { return credentials_; }
75 84
76 virtual void PrepareAddress(); 85 virtual void PrepareAddress();
77 virtual Connection* CreateConnection( 86 virtual Connection* CreateConnection(
78 const Candidate& c, PortInterface::CandidateOrigin origin); 87 const Candidate& c, PortInterface::CandidateOrigin origin);
79 virtual int SendTo(const void* data, size_t size, 88 virtual int SendTo(const void* data, size_t size,
80 const rtc::SocketAddress& addr, 89 const rtc::SocketAddress& addr,
81 const rtc::PacketOptions& options, 90 const rtc::PacketOptions& options,
82 bool payload); 91 bool payload);
83 virtual int SetOption(rtc::Socket::Option opt, int value); 92 virtual int SetOption(rtc::Socket::Option opt, int value);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 int error_; 227 int error_;
219 228
220 StunRequestManager request_manager_; 229 StunRequestManager request_manager_;
221 std::string realm_; // From 401/438 response message. 230 std::string realm_; // From 401/438 response message.
222 std::string nonce_; // From 401/438 response message. 231 std::string nonce_; // From 401/438 response message.
223 std::string hash_; // Digest of username:realm:password 232 std::string hash_; // Digest of username:realm:password
224 233
225 int next_channel_number_; 234 int next_channel_number_;
226 EntryList entries_; 235 EntryList entries_;
227 236
228 bool connected_; 237 PortState state_;
229 // By default the value will be set to 0. This value will be used in 238 // By default the value will be set to 0. This value will be used in
230 // calculating the candidate priority. 239 // calculating the candidate priority.
231 int server_priority_; 240 int server_priority_;
232 241
233 // The number of retries made due to allocate mismatch error. 242 // The number of retries made due to allocate mismatch error.
234 size_t allocate_mismatch_retries_; 243 size_t allocate_mismatch_retries_;
235 244
236 friend class TurnEntry; 245 friend class TurnEntry;
237 friend class TurnAllocateRequest; 246 friend class TurnAllocateRequest;
238 friend class TurnRefreshRequest; 247 friend class TurnRefreshRequest;
239 friend class TurnCreatePermissionRequest; 248 friend class TurnCreatePermissionRequest;
240 friend class TurnChannelBindRequest; 249 friend class TurnChannelBindRequest;
241 }; 250 };
242 251
243 } // namespace cricket 252 } // namespace cricket
244 253
245 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ 254 #endif // WEBRTC_P2P_BASE_TURNPORT_H_
OLDNEW
« no previous file with comments | « webrtc/base/asynctcpsocket.cc ('k') | webrtc/p2p/base/turnport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698