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 14 matching lines...) Expand all Loading... | |
25 class AsyncResolver; | 25 class AsyncResolver; |
26 class SignalThread; | 26 class SignalThread; |
27 } | 27 } |
28 | 28 |
29 namespace cricket { | 29 namespace cricket { |
30 | 30 |
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 { |
andresp
2016/06/21 11:36:10
I noticed every caller of Port::IsCompatibleAddres
honghaiz3
2016/06/21 18:36:06
I think IsCompatibleAddress is useful in matching
pthatcher1
2016/06/21 18:50:18
We'd have to duplicate the following logic between
honghaiz3
2016/06/21 20:06:49
For turn port, the generated candidate family is a
pthatcher1
2016/06/21 20:55:08
StunPort and TcpPort both use IsCompatibleAddress
| |
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_DISCONNECTED, // TCP connection died, cannot send any packets. |
42 }; | 42 }; |
43 static TurnPort* Create(rtc::Thread* thread, | 43 static TurnPort* Create(rtc::Thread* thread, |
44 rtc::PacketSocketFactory* factory, | 44 rtc::PacketSocketFactory* factory, |
45 rtc::Network* network, | 45 rtc::Network* network, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 | 79 |
80 bool ready() const { return state_ == STATE_READY; } | 80 bool ready() const { return state_ == STATE_READY; } |
81 bool connected() const { | 81 bool connected() const { |
82 return state_ == STATE_READY || state_ == STATE_CONNECTED; | 82 return state_ == STATE_READY || state_ == STATE_CONNECTED; |
83 } | 83 } |
84 const RelayCredentials& credentials() const { return credentials_; } | 84 const RelayCredentials& credentials() const { return credentials_; } |
85 | 85 |
86 virtual void PrepareAddress(); | 86 virtual void PrepareAddress(); |
87 virtual Connection* CreateConnection( | 87 virtual Connection* CreateConnection( |
88 const Candidate& c, PortInterface::CandidateOrigin origin); | 88 const Candidate& c, PortInterface::CandidateOrigin origin); |
89 | |
89 virtual int SendTo(const void* data, size_t size, | 90 virtual int SendTo(const void* data, size_t size, |
90 const rtc::SocketAddress& addr, | 91 const rtc::SocketAddress& addr, |
91 const rtc::PacketOptions& options, | 92 const rtc::PacketOptions& options, |
92 bool payload); | 93 bool payload); |
93 virtual int SetOption(rtc::Socket::Option opt, int value); | 94 virtual int SetOption(rtc::Socket::Option opt, int value); |
94 virtual int GetOption(rtc::Socket::Option opt, int* value); | 95 virtual int GetOption(rtc::Socket::Option opt, int* value); |
95 virtual int GetError(); | 96 virtual int GetError(); |
96 | 97 |
97 virtual bool HandleIncomingPacket(rtc::AsyncPacketSocket* socket, | 98 virtual bool HandleIncomingPacket(rtc::AsyncPacketSocket* socket, |
98 const char* data, size_t size, | 99 const char* data, size_t size, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 | 195 |
195 bool CreateTurnClientSocket(); | 196 bool CreateTurnClientSocket(); |
196 | 197 |
197 void set_nonce(const std::string& nonce) { nonce_ = nonce; } | 198 void set_nonce(const std::string& nonce) { nonce_ = nonce; } |
198 void set_realm(const std::string& realm) { | 199 void set_realm(const std::string& realm) { |
199 if (realm != realm_) { | 200 if (realm != realm_) { |
200 realm_ = realm; | 201 realm_ = realm; |
201 UpdateHash(); | 202 UpdateHash(); |
202 } | 203 } |
203 } | 204 } |
205 bool AddressFamilyMatch(const Candidate& local_candidate, | |
206 const Candidate& remote_candidate) const; | |
204 | 207 |
205 void OnTurnRefreshError(); | 208 void OnTurnRefreshError(); |
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. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |