| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 static TurnPort* Create(rtc::Thread* thread, | 62 static TurnPort* Create(rtc::Thread* thread, |
| 63 rtc::PacketSocketFactory* factory, | 63 rtc::PacketSocketFactory* factory, |
| 64 rtc::Network* network, | 64 rtc::Network* network, |
| 65 uint16_t min_port, | 65 uint16_t min_port, |
| 66 uint16_t max_port, | 66 uint16_t max_port, |
| 67 const std::string& username, // ice username. | 67 const std::string& username, // ice username. |
| 68 const std::string& password, // ice password. | 68 const std::string& password, // ice password. |
| 69 const ProtocolAddress& server_address, | 69 const ProtocolAddress& server_address, |
| 70 const RelayCredentials& credentials, | 70 const RelayCredentials& credentials, |
| 71 int server_priority, | 71 int server_priority, |
| 72 const std::string& origin) { | 72 const std::string& origin, |
| 73 const std::vector<std::string>& tls_alpn_protocols) { |
| 73 return new TurnPort(thread, factory, network, min_port, max_port, username, | 74 return new TurnPort(thread, factory, network, min_port, max_port, username, |
| 74 password, server_address, credentials, server_priority, | 75 password, server_address, credentials, server_priority, |
| 75 origin); | 76 origin, tls_alpn_protocols); |
| 76 } | 77 } |
| 77 | 78 |
| 78 virtual ~TurnPort(); | 79 virtual ~TurnPort(); |
| 79 | 80 |
| 80 const ProtocolAddress& server_address() const { return server_address_; } | 81 const ProtocolAddress& server_address() const { return server_address_; } |
| 81 // Returns an empty address if the local address has not been assigned. | 82 // Returns an empty address if the local address has not been assigned. |
| 82 rtc::SocketAddress GetLocalAddress() const; | 83 rtc::SocketAddress GetLocalAddress() const; |
| 83 | 84 |
| 84 bool ready() const { return state_ == STATE_READY; } | 85 bool ready() const { return state_ == STATE_READY; } |
| 85 bool connected() const { | 86 bool connected() const { |
| 86 return state_ == STATE_READY || state_ == STATE_CONNECTED; | 87 return state_ == STATE_READY || state_ == STATE_CONNECTED; |
| 87 } | 88 } |
| 88 const RelayCredentials& credentials() const { return credentials_; } | 89 const RelayCredentials& credentials() const { return credentials_; } |
| 89 | 90 |
| 90 virtual ProtocolType GetProtocol() const { return server_address_.proto; } | 91 virtual ProtocolType GetProtocol() const { return server_address_.proto; } |
| 91 | 92 |
| 92 virtual TlsCertPolicy GetTlsCertPolicy() const { return tls_cert_policy_; } | 93 virtual TlsCertPolicy GetTlsCertPolicy() const { return tls_cert_policy_; } |
| 93 | 94 |
| 94 virtual void SetTlsCertPolicy(TlsCertPolicy tls_cert_policy) { | 95 virtual void SetTlsCertPolicy(TlsCertPolicy tls_cert_policy) { |
| 95 tls_cert_policy_ = tls_cert_policy; | 96 tls_cert_policy_ = tls_cert_policy; |
| 96 } | 97 } |
| 97 | 98 |
| 99 virtual std::vector<std::string> GetTlsAlpnProtocols() const { |
| 100 return tls_alpn_protocols_; |
| 101 } |
| 102 |
| 98 virtual void PrepareAddress(); | 103 virtual void PrepareAddress(); |
| 99 virtual Connection* CreateConnection( | 104 virtual Connection* CreateConnection( |
| 100 const Candidate& c, PortInterface::CandidateOrigin origin); | 105 const Candidate& c, PortInterface::CandidateOrigin origin); |
| 101 virtual int SendTo(const void* data, size_t size, | 106 virtual int SendTo(const void* data, size_t size, |
| 102 const rtc::SocketAddress& addr, | 107 const rtc::SocketAddress& addr, |
| 103 const rtc::PacketOptions& options, | 108 const rtc::PacketOptions& options, |
| 104 bool payload); | 109 bool payload); |
| 105 virtual int SetOption(rtc::Socket::Option opt, int value); | 110 virtual int SetOption(rtc::Socket::Option opt, int value); |
| 106 virtual int GetOption(rtc::Socket::Option opt, int* value); | 111 virtual int GetOption(rtc::Socket::Option opt, int* value); |
| 107 virtual int GetError(); | 112 virtual int GetError(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 TurnPort(rtc::Thread* thread, | 184 TurnPort(rtc::Thread* thread, |
| 180 rtc::PacketSocketFactory* factory, | 185 rtc::PacketSocketFactory* factory, |
| 181 rtc::Network* network, | 186 rtc::Network* network, |
| 182 uint16_t min_port, | 187 uint16_t min_port, |
| 183 uint16_t max_port, | 188 uint16_t max_port, |
| 184 const std::string& username, | 189 const std::string& username, |
| 185 const std::string& password, | 190 const std::string& password, |
| 186 const ProtocolAddress& server_address, | 191 const ProtocolAddress& server_address, |
| 187 const RelayCredentials& credentials, | 192 const RelayCredentials& credentials, |
| 188 int server_priority, | 193 int server_priority, |
| 189 const std::string& origin); | 194 const std::string& origin, |
| 195 const std::vector<std::string>& alpn_protocols); |
| 190 | 196 |
| 191 private: | 197 private: |
| 192 enum { | 198 enum { |
| 193 MSG_ALLOCATE_ERROR = MSG_FIRST_AVAILABLE, | 199 MSG_ALLOCATE_ERROR = MSG_FIRST_AVAILABLE, |
| 194 MSG_ALLOCATE_MISMATCH, | 200 MSG_ALLOCATE_MISMATCH, |
| 195 MSG_TRY_ALTERNATE_SERVER, | 201 MSG_TRY_ALTERNATE_SERVER, |
| 196 MSG_REFRESH_ERROR | 202 MSG_REFRESH_ERROR |
| 197 }; | 203 }; |
| 198 | 204 |
| 199 typedef std::list<TurnEntry*> EntryList; | 205 typedef std::list<TurnEntry*> EntryList; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 265 |
| 260 // Marks the connection with remote address |address| failed and | 266 // Marks the connection with remote address |address| failed and |
| 261 // pruned (a.k.a. write-timed-out). Returns true if a connection is found. | 267 // pruned (a.k.a. write-timed-out). Returns true if a connection is found. |
| 262 bool FailAndPruneConnection(const rtc::SocketAddress& address); | 268 bool FailAndPruneConnection(const rtc::SocketAddress& address); |
| 263 | 269 |
| 264 // Reconstruct the URL of the server which the candidate is gathered from. | 270 // Reconstruct the URL of the server which the candidate is gathered from. |
| 265 std::string ReconstructedServerUrl(); | 271 std::string ReconstructedServerUrl(); |
| 266 | 272 |
| 267 ProtocolAddress server_address_; | 273 ProtocolAddress server_address_; |
| 268 TlsCertPolicy tls_cert_policy_ = TlsCertPolicy::TLS_CERT_POLICY_SECURE; | 274 TlsCertPolicy tls_cert_policy_ = TlsCertPolicy::TLS_CERT_POLICY_SECURE; |
| 275 std::vector<std::string> tls_alpn_protocols_; |
| 269 RelayCredentials credentials_; | 276 RelayCredentials credentials_; |
| 270 AttemptedServerSet attempted_server_addresses_; | 277 AttemptedServerSet attempted_server_addresses_; |
| 271 | 278 |
| 272 rtc::AsyncPacketSocket* socket_; | 279 rtc::AsyncPacketSocket* socket_; |
| 273 SocketOptionsMap socket_options_; | 280 SocketOptionsMap socket_options_; |
| 274 rtc::AsyncResolverInterface* resolver_; | 281 rtc::AsyncResolverInterface* resolver_; |
| 275 int error_; | 282 int error_; |
| 276 | 283 |
| 277 StunRequestManager request_manager_; | 284 StunRequestManager request_manager_; |
| 278 std::string realm_; // From 401/438 response message. | 285 std::string realm_; // From 401/438 response message. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 295 friend class TurnEntry; | 302 friend class TurnEntry; |
| 296 friend class TurnAllocateRequest; | 303 friend class TurnAllocateRequest; |
| 297 friend class TurnRefreshRequest; | 304 friend class TurnRefreshRequest; |
| 298 friend class TurnCreatePermissionRequest; | 305 friend class TurnCreatePermissionRequest; |
| 299 friend class TurnChannelBindRequest; | 306 friend class TurnChannelBindRequest; |
| 300 }; | 307 }; |
| 301 | 308 |
| 302 } // namespace cricket | 309 } // namespace cricket |
| 303 | 310 |
| 304 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ | 311 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ |
| OLD | NEW |